Re: A few queries about Jam
Chris Molozian <chris <at> cmoz.me>
2011-05-31 12:02:27 GMT
Thank you to Alen and John for the great help. I'm using this:
DFILES = [ GLOB src/ob2c src/ob2c/gen : *.d ] ;
to handle gathering up the source files. I decided to keep the build
script nice and short and avoid defining RGLOB, just listing the
directories for GLOB is fine by me.
It's a good idea about using an external script (.bat, .sh) to feed jam
the correct C++FLAGS. I'll probably implement that eventually when I do
serious testing on windows.
As suggested I've tried:
MkDir build ;
ALL_LOCATE_TARGET = build ;
to relocate all build output to a dedicated build folder but it appears
to do nothing. The object files are still built alongside source files
and the libraries and executable build in the same directory as the
Jamfile. I'm not sure what I'm doing wrong.
On 29/05/11 23:00, Alen Ladavac wrote:
> One idea for your flags is to execute it on the command line that calls jam, and pass it through its input
using -s cmdline option. A bit clumsy, but might work.
>
> You can read from a file, if the file looks like:
>
> C++FLAGS =<something> ;
>
> Then you just Include the file. Been using that trick for some things and it works well. :)
>
> As for glob usage, it is something like:
>
> sourcefiles = [ GLOB $(SomeFolder) : *.cpp *.c ] ;
>
> Here is also a RGLOB rule I wrote a while ago. It is clumsy and suboptimal, but works on stock jam. (ListDir is
just a helper rule.)
>
> # list all files in a directory, except ., ..
> # [ ListDir dirname ]
> rule ListDir {
>
> # start with empty list
> local _result = ;
>
> # for each file in the directory
> local _dirlist = [ GLOB $(1) : * ] ;
> for _subdir in $(_dirlist) {
>
> # if it is not . or ..
> switch $(_subdir) {
> case */. : _dummy = "" ; # is there some no-op statement?
> case */.. : _dummy = "" ; # is there some no-op statement?
> case * :
> # add it to the list
> _result += $(_subdir) ;
> }
> }
>
> # return resulting list
> return $(_result) ;
> }
>
> # same as glob, but recurses into subdirs
> rule RGLOB {
>
> # initially use the files in the current directory
> local _files = [ GLOB $(1) : $(2) ] ;
>
> # filter so that only real files are included (skip current dir, parent dir and all other dirs)
> local _f = ;
> local _result = ;
> for _f in $(_files) {
> if $(_f:BS) != .&& $(_f:BS) != ..&& ! [ GLOB $(_f) : * ] {
> _result += $(_f) ;
> }
> }
>
>
> # list all subdirectories (and files, but it doesn't hurt)
> local _subdirlist = [ ListDir $(1) ] ;
>
> # for each subdir/file
> for _subdir in $(_subdirlist) {
> # recurse into it
> _result += [ RGLOB $(_subdir) : $(2) ] ;
> }
>
> # return the resulting list
> return $(_result) ;
> }
>
>
>
> Sunday, May 29, 2011, 6:01:02 PM, you wrote:
>
>
> Dear Alen,
>
> Thanks for the suggestions, I agree the stableness of the tool and it's cross-platform support are
wonderful. I think for the time being I'll hard-code the llvm-config flags, I thought about directing the
output to a file and reading that in to the C++FLAGS variable but wasn't sure how to do that either.
>
> Regarding redirecting the target output to a folder, I want to stay as compatible as possible with the
stock Jambase file. The less I have to modify the better. I was hoping there might be a simple trick to it I'd
missed, ah well.
>
> Would you happen to have an example of the GLOB rule that I could try to understand. I found the reference
rather unclear:
> Glob directories : patterns ; builtin
> Scans directories for files matching regex patterns, returning the list of matching files with
directory prepended. Useful with the [...] construct to change the Glob result into a list.
> I don't understand the [...] notation and where I'm supposed to use it, or how to recursively call itself to
descend directories.
>
> Kind Regards,
>
> Chris
>
>
> On 29/05/11 12:18, Alen Ladavac wrote:
> Chris wrote at 2011-05-28:
>
>
> I hope the mailing list is still active.
>
>
> Yes. Just that the damn thing is so stable there's nothing interesting to chatter about. ;)
>
>
>
>
> ° Can I call an external program (i.e. llvm-config) and store the stdout from it to the C++FLAGS variable?
>
>
> Not in vanilla jam. But IIRC there is a custom patch for that somewhere. Or at least one of the forks that can
do it (BJam, JamPlus, ...). Don't know the details from the top of my head.
>
>
>
>
> ° All of my source code is within a src folder, can I tell Jam to scan the directory and subdirectories for
source files and store them to the DFILES variable?
>
>
> Yes. There is this GLOB rule that scans files in a folder. It doesn't handle subdirectories, but you can
write a recursive rule based on it that does. Just watch out for . and .. , as usual.
>
>
>
>
> ° Is there a way for me to force all target output (e.g. object files, generated libraries, binaries...
etc) to be put within a build folder at the same directory level as the Jamfile?
>
>
> You can reconfigure everything, even rewrite your own Jambase from scratch. Depends on how compatible
with stock solution you want to be.
>
>
>
> HTH,
>
> Alen
>
>
>
>
>
>
>
>
_______________________________________________
jamming mailing list - jamming <at> maillist.perforce.com
http://maillist.perforce.com/mailman/listinfo/jamming