List Info

Thread: Re: Executing shell command, save results to variable




Re: Executing shell command, save results to variable
country flaguser name
United States
2007-02-28 08:17:18
Chris,

I accomplished a similar thing by rewriting the action for
(in my case C++)
which performs the command at the native level in
preparation for the command.

rule C++ {
    EXTRAFLAGS=`wx_config --includes`
    $(C++) $EXTRAFLAGS <blah> <blah>
<blah>
}

You can get a bit more fancy and have the command(s) you wan
put into a file
during setup and sourcing that file in the proper rule.

It's not as elegant as having Jam be able to do a shell
`cmd` operation
directly, but I haven't had any luck when I asked for it.

That said, you can do a lot by wrapping the jam call in a
script to do a lot of
this nonsense up front outside of Jam.

BTW, I actually don't use this rule-replacement approach in
production, but it
worked in an experimental system.

Gary

Chris Stankevitz wrote:
> Hi group,
> 
> Is it possible to execute a shell command and save the
results as a jam 
> variable?  The command I want to execute and its output
is:
>    wx-config --libs
> 
> -pthread   -L/usr/X11R6/lib  -lwx_gtk2u_xrc-2.6
-lwx_gtk2u_qa-2.6 
> -lwx_gtk2u_htm l-2.6 -lwx_gtk2u_adv-2.6
-lwx_gtk2u_core-2.6 
> -lwx_baseu_xml-2.6 -lwx_baseu_net-2.6 -lwx_baseu-2.6
> 
> Thank you!
> 
> Chris
> _______________________________________________
> jamming mailing list  -  jammingperforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming


_______________________________________________
jamming mailing list  -  jammingperforce.com
http://maillist.perforce.com/mailman/listinfo/jamming

  
Re: Executing shell command, save results to variable
user name
2007-02-28 10:41:32
I've done both. I pass back-ticked pkg-config commands on my compile and link lines -- ie., I add them to the flags for each (from a new rule, though, not an override on Cc/C++/Link -- although I do have overrides for those rules, but for other reasons). And I also modified Jam to be able to run a shell command from a rule (it bugged me that there was something Make could do that Jam couldn';t

In your case, Chris, if all you need is to pass that wx-config in on the command line, adding it to the flags is the easiest way to go.

Diane
[1-2]

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