How to make a hierarchical assembly using rake?

I recently started using Rake to create some of my (non-ruble) packages. The rake is good, but what I found missing is a way to make hierarchical assemblies (aggregated Rakefiles in subdirectories). Since this is a common feature in most other build tools, I am wondering if anyone has a more familiar with Rake with a good solution.

+4
source share
4 answers

I would recommend Buildr for build tasks without Ruby. It is based on Rake (sits on top of it, allowing you to use all the features of Rake), but is better suited to the semantics of compiled languages. It also supports hierarchical assemblies.

+2
source

I also could not figure out how to do this. I finished:

SUBDIR = "subdir" task :subtask => SRC_FILES do |t| chdir(SUBDIR) do system("rake") end end task :subtaskclean do |t| chdir(SUBDIR) do system("rake clean") end end task :subtaskclean do |t| chdir(SUBDIR) do system("rake clobber") end end task :default => [:maintask, :subtask] task :clean => :subtaskclean task :clobber => :subtaskclobber 

A kind of sucks. In fact, really sucks. I looked through the documents and could not find the equivalent of <antcall>

I am sure that since all of this is Ruby, and I hardly know Ruby, there is some kind of super obvious way to require that it or something like that.

+1
source

Buildr uses the concept of areas in conjunction with the name of the projects.

Rake.application.current_scope must be an entry point to learn how to work with them. Hope this helps.

+1
source

The fix I used to get around this is:

 Dir.chdir(File.dirname(Rake.application.rakefile)) 

This statement must be executed at all levels of the hierarchy, except the root, at the beginning of each rake file. A short example of how this works in practice:

/ rakefile:

 task :default do sh "rake -f component/rakefile" end 

/ Component / rakefile

 Dir.chdir(File.dirname(Rake.application.rakefile)) task :binary => OBJECTS do sh "gcc #{SOURCES} -Iinclude -o #{TARGET}" end 

Since I'm new to the rake, I'm not convinced that this is the cleanest method to solve it, but that’s how I ended up getting it to work.

0
source

Source: https://habr.com/ru/post/1276850/


All Articles