List Info

Thread: Re: call run command in custom rule




Re: call run command in custom rule
country flaguser name
Russian Federation
2007-07-15 04: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
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: call run command in custom rule
user name
2007-07-15 10:53:52
>
> 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.


Actually, that is pretty much what I ended up doing.
Thanks,
Chris
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )