Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2007-07-15 05:44:35


On Tuesday 03 July 2007 04:24:21 Chris Weed wrote:

[CC for convenience, please reply to list]

> I want to
> 1. call a glob command on the current directory
> 2. run an executable that outputs a text file
> 3. call a glob command on the current directory
> 4. get the list of new files (should be output text file name)
>
> Here is what I have so far.
>
> import testing ;
> import set ;
>
> project myproj : build-dir .bin ;
>
> # executable that outputs a text file
> exe main : main.cpp ;
>
> rule reg ( sources + : args * : input-files * : requirements * :
> target-name ? : default-build * : regression-dir + )
> {
> current_dir_files = [ glob * : .* ] ;
> run $(sources) : $(args) : $(input-files) : $(requirements) :
> $(target-name) : $(default-build) ;
> after_dir_files = [ glob * : .* ] ;
> ECHO $(current_dir_files) ;
> ECHO $(after_dir_files) ;
> before_after_diff = [ set.difference $(after_dir_files) :
> $(current_dir_files) ] ;
> ECHO $(before_after_diff) ;
>
> # regression_dir_files = [ glob $(regression-dir)/* ] ;
> # before_after_diff = [ set.difference $(after_dir_files) :
> $(current_dir_files) ] ;
> # ECHO $(diff) ;
> }
>
> alias regression :
> [ reg main : : : : m : : ../test2 ] ;
>
> This currently seems to skip the run target call. How do I get it to call run?

That's not so much 'skips' the run call. It's just 'run' call has no immediate
effect. First, Jamfiles are read, and your 'reg' rule is executed. The 'run'
rule only creates the target, it does not do anything yet. Then, all targets
are built. This is a constant source of confusion; I meant to document this
better but never finished the doc patch.

To achieve what you want you probably do this:

1. Define new target type RUN_OUTPUT_WITH_DIFF
2. Define new generator:

        generators.register-standard your-module.run-with-diff : EXE : RUN_OUTPUT_WITH_DIFF ;

3. Implement the 'your-module.run-with-diff' rule and action by copy-pasting
testing.capture-output and adding shell command to list files before and after
running the command itself.

Let me know if this works for you.

- Volodya


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk