Bug 1326 - Document how build.py allows passing configure options to waf
Document how build.py allows passing configure options to waf
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: documentation
pre-release
All All
: P5 normal
Assigned To: Tom Henderson
:
Depends on: 1325
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-28 16:20 EST by Mitch Watrous
Modified: 2014-11-04 14:07 EST (History)
4 users (show)

See Also:


Attachments
Patch to make build.py handle waf configure options (1.73 KB, application/octet-stream)
2011-12-28 16:20 EST, Mitch Watrous
Details
Patch for tutorial to show changes required if build.py handles waf configure options (5.02 KB, application/octet-stream)
2011-12-28 16:25 EST, Mitch Watrous
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mitch Watrous 2011-12-28 16:20:52 EST
Created attachment 1290 [details]
Patch to make build.py handle waf configure options

It is not currently possible in build.py to pass configure options to waf like these: 

    -d debug -o build/debug

So, build.py needs to be modified to support this API:

  ./build.py --configure-options="-d debug -o build/debug"

The first attached patch show changes that need to be made to build.py.

The second attached patch show changes that need to be made to the tutorial. It doesn't show changes that need to be made to the other ns-3 documents like the manual and model library document.
Comment 1 Mitch Watrous 2011-12-28 16:25:14 EST
Created attachment 1291 [details]
Patch for tutorial to show changes required if build.py handles waf configure options

This is the second attached patch for this bug. 

It show changes that need to be made to the tutorial. It doesn't show changes that need to be made to the other ns-3 documents like the manual and model library document.
Comment 2 Tom Henderson 2011-12-28 19:07:38 EST
Note, I had some discussion with Mitch about whether we want to be doing this.  I'm reluctant to start adding features to build.py and then having to maintain the build functions of both build.py and waf.

Presently, build.py is handled in the tutorial only as a way to quickly get up and running, but then it is abandoned in favor of using waf directly.  Do we want to encourage users to be always managing their builds via build.py?

Also, this suggested tutorial change:

-  ./build.py --enable-examples --enable-tests
+  ./build.py --enable-examples --enable-tests --configure-options="-d debug -o build/debug"

seems to just unnecessarily make things more complicated for the first-time user.

So, I would probably -1 on the tutorial patch, and am neutral on adding the --configure-options (that is, I would be OK with adding it or with not adding it and removing the --build-options while we are at it).

Other opinions?
Comment 3 Gustavo J. A. M. Carneiro 2011-12-29 05:47:32 EST
Hi, the bug report is not correct, build.py already supported passing configure options to waf for a long time.  All options after -- are passed verbatim to waf configure.  E.g.

./build.py -- --enable-nsc

Perhaps we need to document this better, that's all.
Comment 4 Gustavo J. A. M. Carneiro 2012-01-06 12:47:36 EST
The documentation should state something along these lines:
"""
The build.py script allows passing arbitrary options to ns-3's waf configure by preceding these options with a double dash token (--).  For example:

./build.py -- --enable-mpi
[...]
 =>  /usr/bin/python waf configure --enable-mpi
"""
Comment 5 Tom Henderson 2012-01-06 12:58:55 EST
(In reply to comment #4)
> The documentation should state something along these lines:
> """
> The build.py script allows passing arbitrary options to ns-3's waf configure by
> preceding these options with a double dash token (--).  For example:
> 
> ./build.py -- --enable-mpi
> [...]
>  =>  /usr/bin/python waf configure --enable-mpi
> """

I believe that we need to document that -- is greedy and needs to be the last option provided; e.g. this will work:
./build.py --disable-nsc --build-options="-j1" -- --disable-python

but other orderings will generally not work.  What do you think?
Comment 6 Gustavo J. A. M. Carneiro 2012-01-06 13:07:05 EST
(In reply to comment #5)
> (In reply to comment #4)
> > The documentation should state something along these lines:
> > """
> > The build.py script allows passing arbitrary options to ns-3's waf configure by
> > preceding these options with a double dash token (--).  For example:
> > 
> > ./build.py -- --enable-mpi
> > [...]
> >  =>  /usr/bin/python waf configure --enable-mpi
> > """
> 
> I believe that we need to document that -- is greedy and needs to be the last
> option provided; e.g. this will work:
> ./build.py --disable-nsc --build-options="-j1" -- --disable-python
> 
> but other orderings will generally not work.  What do you think?

What happens is that -- is a special token.  When it is found, the command-line option parser library stops interpreting argv elements starting with a dash as options and simply gives them to the application programmer in the end.  This is typically used to allow programs to support --xxx options but also support file names starting with --.  It is a standard feature of GNU programs to allow this interpretation of the '--' token.  I don't know yet where it is well explained, but if I find out I'll comment here.
Comment 7 Gustavo J. A. M. Carneiro 2012-01-06 13:11:40 EST
The getopt man page[1] says only this:

The special argument "--" forces an end of option-scanning regardless of the scanning mode.

[1] http://linux.die.net/man/3/getopt
Comment 8 Tom Henderson 2014-11-04 14:07:01 EST
I added documentation to the tutorial about this in changeset 11047:259a56c15a37