ruby - 我如何在我的 Rakefile 中声明这种依赖关系?

标签 ruby build rake

我正在尝试构建一个静态库,它的名称是在我处理一些文件后才得到的。我有这样的东西:

task :lib,:config do |t,args|
  # ... do some processing here, get a string representing the 
  # fullpath of the lib. Imaging libname contains a.lib
  file libname => object_files
end

但是,当然,因为在任务运行时我不知道依赖项的名称,所以应该构建 a.lib 的代码不会被执行。我试着这样做:

task :lib,:config do |t,args|
  # ... do some processing here, get a string representing the 
  # fullpath of the lib. Imaging libname contains a.lib
  file libname => object_files
  task :lib => [libname]
end

要将其添加为依赖项,但它不起作用。我现在拥有它,并且它有效:

task :lib,:config do |t,args|
  # ... do some processing here, get a string representing the 
  # fullpath of the lib. Imaging libname contains a.lib
  file libname => object_files
  Rake.application[libname].invoke
end

但是我觉得太丑了。有没有更好的方法来声明这种依赖关系?

最佳答案

我认为这个帖子已经有了最佳答案:How to run Rake tasks from within Rake tasks?

关于ruby - 我如何在我的 Rakefile 中声明这种依赖关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5474757/

相关文章:

ruby - 带有 block 的方法的包装器

c - 如何在 Alpine 上编译 time.c?

mysql - rake 数据库 :create generated "if you set the charset manually, make sure you have a matching collation" error

iphone构建错误让我想买钉枪

build - 适用于Windows XP的QtWebEngine目标

python - 为什么 Python 项目中没有用于自动化的 Makefile?

ruby-on-rails - #<Rails::Application::Configuration> 的未定义方法 `assets'

Ruby - 通过调用 require 'filename' 运行迭代

javascript - 同步服务器和客户端时间?

ruby - 多用户 RVM - 使用 sudo 执行 Ruby 脚本时 gem 路径不同