example/bin/rubu_example in rubu-0.0.2 vs example/bin/rubu_example in rubu-0.0.3
- old
+ new
@@ -22,10 +22,11 @@
# Build specific definitions:
# Set trail related options.
Var[ :bin_dir ] = 'bin'
Var[ :source_dir ] = 'src'
+Var[ :gen_dir ] = 'gen_cee'
Var[ :build_dir ] = 'build'
Var[ :exe_name ] = 'build/hello'
# Default for :fast option.
Var[ :fast ] = false
@@ -33,20 +34,25 @@
# Change Rubu to verbose mode.
if Opt['verbose'].given
Order[ :verbose ] = true
end
+# Force serial execution.
+if Opt[ 'serial' ].given
+ Order[ :serial ] = true
+end
+
# Read setup files and apply Como command line arguments to Var space.
Trail.setup( :como => 'conf' )
# ------------------------------------------------------------
# Collect sources and create targets:
# Generator file and the target.
gen_file = Mark.path( "#{Var[:bin_dir]}/gen_world" )
-gen_cee_file = Mark.path( "#{Var[:build_dir]}/world.c" )
+gen_cee_file = Mark.path( "#{Var[:gen_dir]}/world.c" )
# Collect "normal" C files.
cee_files = Mark.glob( "#{Var[:source_dir]}/*.c" )
# Create complete list of all C files.
@@ -72,11 +78,18 @@
def step
shrun "bin/gen_world"
end
end
+# Code generator with generated file content dependency.
+class GenGreenWorld < StepMark
+ def step
+ shrun "bin/gen_world"
+ end
+end
+
# Typical C compilation with GCC, from source to object.
class GccCompileFile < StepAged
def setup
@cmd = "gcc -Wall -I #{Var[:source_dir]} -c #{source.rpath} -o #{target.rpath}"
@@ -133,27 +146,46 @@
Walk.form 'gen-cee' do
# Create GenWorld build and register it to 'gen-cee'.
GenWorld.use( gen_file, gen_cee_file )
end
+# Serial trail for code generation (with filtered updates).
+Walk.form 'gen-cee-green' do
+ # Create GenGreenWorld build and register it to 'gen-cee-green'.
+ GenGreenWorld.use( gen_file, gen_cee_file )
+end
+
# Parallel compilation of all C files.
Fork.form 'compile-cee' do
# Create set of GCC builds by joining 'all_cee_files' and
# 'obj_files' in pairs.
GccCompileFile.usezip( all_cee_files, obj_files )
end
+# Link executable.
+Walk.form 'link' do
+ GccLinkExe.use( obj_files, exe_file )
+end
+
# Default trail, i.e. generate, compile, link to executable.
Walk.form 'default' do
# Reference 'gen-cee' trail.
pick 'gen-cee'
# Reference 'compile-cee' trail.
pick 'compile-cee'
# Create GCC link build and register it.
- GccLinkExe.use( obj_files, exe_file )
+ pick 'link'
end
+# Trail for 'up-to-date' script (see: example dir).
+Walk.form 'up-to-date' do
+ # Reference 'gen-cee-green' trail.
+ pick 'gen-cee-green'
+ # Reference 'compile-cee' trail.
+ pick 'compile-cee'
+end
+
# Cleaner trail.
Walk.form 'clean' do
CleanObjects.use
end
@@ -165,12 +197,8 @@
trails = nil
if Opt[ nil ].given
trails = Opt[ nil ].value
else
trails = [ 'default' ]
-end
-
-if Opt[ 'serial' ].given
- Order[ :serial ] = true
end
Trail.run( trails )