author | Tom Henderson <tomh@tomh.org> |
Tue, 04 Nov 2014 10:54:48 -0800 | |
changeset 11048 | 8a2ae153d4aa |
parent 11047 | 259a56c15a37 |
child 11077 | 5c8dea49a671 |
permissions | -rw-r--r-- |
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
1 |
.. include:: replace.txt |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
2 |
.. highlight:: bash |
6754 | 3 |
|
4 |
Getting Started |
|
5 |
--------------- |
|
6 |
||
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
7 |
This section is aimed at getting a user to a working state starting |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
8 |
with a machine that may never have had |ns3| installed. It covers |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
9 |
supported platforms, prerequisites, ways to obtain |ns3|, ways to |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
10 |
build |ns3|, and ways to verify your build and run simple programs. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
11 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
12 |
Overview |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
13 |
******** |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
14 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
15 |
|ns3| is built as a system of software libraries that work together. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
16 |
User programs can be written that links with (or imports from) these |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
17 |
libraries. User programs are written in either the C++ or Python |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
18 |
programming languages. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
19 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
20 |
|ns3| is distributed as source code, meaning that the target system |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
21 |
needs to have a software development environment to build the libraries |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
22 |
first, then build the user program. |ns3| could in principle be |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
23 |
distributed as pre-built libraries for selected systems, and in the |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
24 |
future it may be distributed that way, but at present, many users |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
25 |
actually do their work by editing |ns3| itself, so having the source |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
26 |
code around to rebuild the libraries is useful. If someone would like |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
27 |
to undertake the job of making pre-built libraries and packages for |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
28 |
operating systems, please contact the ns-developers mailing list. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
29 |
|
9749 | 30 |
In the following, we'll look at two ways of downloading and building |
31 |
|ns3|. The first is to download and build an official release |
|
32 |
from the main web site. The second is to fetch and build development |
|
33 |
copies of |ns3|. We'll walk through both examples since the tools |
|
34 |
involved are slightly different. |
|
35 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
36 |
Downloading |ns3| |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
37 |
***************** |
6754 | 38 |
|
39 |
The |ns3| system as a whole is a fairly complex system and has a |
|
40 |
number of dependencies on other components. Along with the systems you will |
|
8837 | 41 |
most likely deal with every day (the GNU toolchain, Mercurial, a text |
6754 | 42 |
editor) you will need to ensure that a number of additional libraries are |
43 |
present on your system before proceeding. |ns3| provides a wiki |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
44 |
page that includes pages with many useful hints and tips. |
6754 | 45 |
One such page is the "Installation" page, |
10401
6e9d4ceb880b
Update ns-3 wiki URL
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
9960
diff
changeset
|
46 |
http://www.nsnam.org/wiki/Installation. |
6754 | 47 |
|
48 |
The "Prerequisites" section of this wiki page explains which packages are |
|
49 |
required to support common |ns3| options, and also provides the |
|
50 |
commands used to install them for common Linux variants. Cygwin users will |
|
51 |
have to use the Cygwin installer (if you are a Cygwin user, you used it to |
|
52 |
install Cygwin). |
|
53 |
||
54 |
You may want to take this opportunity to explore the |ns3| wiki |
|
55 |
a bit since there really is a wealth of information there. |
|
56 |
||
57 |
From this point forward, we are going to assume that the reader is working in |
|
58 |
Linux or a Linux emulation environment (Linux, Cygwin, etc.) and has the GNU |
|
59 |
toolchain installed and verified along with the prerequisites mentioned |
|
60 |
above. We are also going to assume that you have Mercurial and Waf installed |
|
7314
7162e24118ea
Miscellaneous fixes to Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents:
7275
diff
changeset
|
61 |
and running on the target system. |
6754 | 62 |
|
63 |
The |ns3| code is available in Mercurial repositories on the server |
|
64 |
http://code.nsnam.org. You can also download a tarball release at |
|
65 |
http://www.nsnam.org/releases/, or you can work with repositories |
|
66 |
using Mercurial. We recommend using Mercurial unless there's a good reason |
|
67 |
not to. See the end of this section for instructions on how to get a tarball |
|
68 |
release. |
|
69 |
||
70 |
The simplest way to get started using Mercurial repositories is to use the |
|
71 |
``ns-3-allinone`` environment. This is a set of scripts that manages the |
|
72 |
downloading and building of various subsystems of |ns3| for you. We |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
73 |
recommend that you begin your |ns3| work in this environment. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
74 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
75 |
Downloading |ns3| Using a Tarball |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
76 |
+++++++++++++++++++++++++++++++++ |
9749 | 77 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
78 |
A tarball is a particular format of software archive where multiple |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
79 |
files are bundled together and the archive possibly compressed. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
80 |
|ns3| software releases are provided via a downloadable tarball. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
81 |
The process for downloading |ns3| via tarball is simple; you just |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
82 |
have to pick a release, download it and decompress it. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
83 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
84 |
Let's assume that you, as a user, wish to build |ns3| in a local |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
85 |
directory called ``workspace``. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
86 |
If you adopt the ``workspace`` directory approach, you can |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
87 |
get a copy of a release by typing the following into your Linux shell |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
88 |
(substitute the appropriate version numbers, of course):: |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
89 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
90 |
$ cd |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
91 |
$ mkdir workspace |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
92 |
$ cd workspace |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
93 |
$ wget http://www.nsnam.org/releases/ns-allinone-3.20.tar.bz2 |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
94 |
$ tar xjf ns-allinone-3.20.tar.bz2 |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
95 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
96 |
If you change into the directory ``ns-allinone-3.20`` you should see a |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
97 |
number of files:: |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
98 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
99 |
$ ls |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
100 |
bake constants.py ns-3.20 README |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
101 |
build.py netanim-3.103 pybindgen-0.16.0.825 util.py |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
102 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
103 |
You are now ready to build the |ns3| distribution. |
6754 | 104 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
105 |
Downloading |ns3| Using Bake |
9749 | 106 |
++++++++++++++++++++++++++++ |
107 |
||
108 |
Bake is a tool for distributed integration and building, |
|
109 |
developed for the |ns3| project. Â First of all, Bake is |
|
110 |
developed in Python, and should be fetched from the project's |
|
111 |
master code repositories using a tool called Mercurial, so to |
|
112 |
run Bake one must have Python and mercurial on one's machine. |
|
113 |
||
114 |
One practice is to create a directory called ``workspace`` in one's home |
|
6754 | 115 |
directory under which one can keep local Mercurial repositories. |
9749 | 116 |
Any directory name will do, but we'll assume that ``workspace`` is used |
117 |
herein (note: ``repos`` may also be used in some documentation as |
|
118 |
an example directory name). You can get a copy of ``bake`` by typing the |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
119 |
following into your Linux shell (assuming you have installed Mercurial):: |
9163
950db74a6484
Minor fixes and corrections to tutorial formatting.
Vedran Miletić <rivanvx@gmail.com>
parents:
9107
diff
changeset
|
120 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
121 |
$ cd |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
122 |
$ mkdir workspace |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
123 |
$ cd workspace |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
124 |
$ hg clone http://code.nsnam.org/bake |
6754 | 125 |
|
126 |
As the hg (Mercurial) command executes, you should see something like the |
|
127 |
following displayed, |
|
128 |
||
129 |
:: |
|
130 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
131 |
... |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
132 |
destination directory: bake |
6754 | 133 |
requesting all changes |
134 |
adding changesets |
|
135 |
adding manifests |
|
136 |
adding file changes |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
137 |
added 252 changesets with 661 changes to 62 files |
7654 | 138 |
updating to branch default |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
139 |
45 files updated, 0 files merged, 0 files removed, 0 files unresolved |
6754 | 140 |
|
141 |
After the clone command completes, you should have a directory called |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
142 |
``bake``, the contents of which should look something like the following:: |
6754 | 143 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
144 |
$ ls |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
145 |
bake bakeconf.xml doc generate-binary.py TODO |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
146 |
bake.py examples test |
6754 | 147 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
148 |
Notice that you really just downloaded some Python scripts and a Python |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
149 |
module called ``bake``. The next step |
6754 | 150 |
will be to use those scripts to download and build the |ns3| |
151 |
distribution of your choice. |
|
152 |
||
9749 | 153 |
There are a few configuration targets available: |
154 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
155 |
1. ``ns-3.20``: the module corresponding to the release; it will download |
9749 | 156 |
components similar to the release tarball. |
157 |
2. ``ns-3-dev``: a similar module but using the development code tree |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
158 |
3. ``ns-allinone-3.20``: the module that includes other optional features |
9749 | 159 |
such as click routing, openflow for |ns3|, and the Network Simulation |
160 |
Cradle |
|
161 |
4. ``ns-3-allinone``: similar to the released version of the allinone |
|
162 |
module, but for development code. |
|
6754 | 163 |
|
164 |
The current development snapshot (unreleased) of |ns3| may be found |
|
165 |
at http://code.nsnam.org/ns-3-dev/. The |
|
166 |
developers attempt to keep these repository in consistent, working states but |
|
167 |
they are in a development area with unreleased code present, so you may want |
|
168 |
to consider staying with an official release if you do not need newly- |
|
169 |
introduced features. |
|
170 |
||
9749 | 171 |
You can find the latest version of the |
6754 | 172 |
code either by inspection of the repository list or by going to the |
7314
7162e24118ea
Miscellaneous fixes to Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents:
7275
diff
changeset
|
173 |
`"ns-3 Releases" |
7162e24118ea
Miscellaneous fixes to Tutorial
Mitch Watrous <watrous@u.washington.edu>
parents:
7275
diff
changeset
|
174 |
<http://www.nsnam.org/releases>`_ |
9749 | 175 |
web page and clicking on the latest release link. We'll proceed in |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
176 |
this tutorial example with ``ns-3.20``. |
9749 | 177 |
|
178 |
We are now going to use the bake tool to pull down the various pieces of |
|
179 |
|ns3| you will be using. First, we'll say a word about running bake. |
|
6754 | 180 |
|
9749 | 181 |
bake works by downloading source packages into a source directory, |
182 |
and installing libraries into a build directory. bake can be run |
|
183 |
by referencing the binary, but if one chooses to run bake from |
|
184 |
outside of the directory it was downloaded into, it is advisable |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
185 |
to put bake into your path, such as follows (Linux bash shell example):: |
6754 | 186 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
187 |
$ export BAKE_HOME=`pwd`/bake |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
188 |
$ export PATH=$PATH:$BAKE_HOME |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
189 |
$ export PYTHONPATH=$PYTHONPATH:$BAKE_HOME |
9749 | 190 |
|
191 |
However, setting environment variables is not strictly necessary to |
|
192 |
complete this tutorial, so we'll call bake directly by specifying the path |
|
193 |
to it in our shell commands. |
|
194 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
195 |
Step into the workspace directory and type the following into your shell:: |
9749 | 196 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
197 |
$ ./bake.py configure -e ns-3.20 |
6754 | 198 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
199 |
Next, we'l ask bake to check whether we have enough tools to download |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
200 |
various components. Type:: |
6754 | 201 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
202 |
$ ./bake.py check |
6754 | 203 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
204 |
You should see something like the following, |
6754 | 205 |
|
206 |
:: |
|
207 |
||
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
208 |
> Python - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
209 |
> GNU C++ compiler - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
210 |
> Mercurial - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
211 |
> CVS - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
212 |
> GIT - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
213 |
> Bazaar - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
214 |
> Tar tool - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
215 |
> Unzip tool - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
216 |
> Unrar tool - is missing |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
217 |
> 7z data compression utility - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
218 |
> XZ data compression utility - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
219 |
> Make - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
220 |
> cMake - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
221 |
> patch tool - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
222 |
> autoreconf tool - OK |
6754 | 223 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
224 |
> Path searched for tools: /usr/lib64/qt-3.3/bin /usr/lib64/ccache |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
225 |
/usr/local/bin /bin /usr/bin /usr/local/sbin /usr/sbin /sbin |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
226 |
/home/tomh/bin bin |
6754 | 227 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
228 |
In particular, download tools such as Mercurial, CVS, GIT, and Bazaar |
9749 | 229 |
are our principal concerns at this point, since they allow us to fetch |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
230 |
the code. Please install missing tools at this stage if you are able to. |
6754 | 231 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
232 |
Next, try to download the software:: |
6754 | 233 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
234 |
$ ./bake.py download |
6754 | 235 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
236 |
should yield something like:: |
6754 | 237 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
238 |
>> Searching for system dependency pygoocanvas - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
239 |
>> Searching for system dependency python-dev - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
240 |
>> Searching for system dependency pygraphviz - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
241 |
>> Downloading pybindgen-0.16.0.825 - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
242 |
>> Searching for system dependency g++ - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
243 |
>> Searching for system dependency qt4 - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
244 |
>> Downloading netanim-3.103 - OK |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
245 |
>> Downloading ns-3.20 - OK |
6754 | 246 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
247 |
The above suggests that three sources have been downloaded. Check the |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
248 |
``source`` directory now and type ``ls``; one should see:: |
6754 | 249 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
250 |
$ ls |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
251 |
netanim-3.103 ns-3.20 pybindgen-0.16.0.825 |
6754 | 252 |
|
253 |
You are now ready to build the |ns3| distribution. |
|
254 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
255 |
Building |ns3| |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
256 |
************** |
6754 | 257 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
258 |
Building with ``build.py`` |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
259 |
++++++++++++++++++++++++++ |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
260 |
When working from a released tarball, the first time you build the |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
261 |
|ns3| project you can build using a convenience program found in the |
7661
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
262 |
``allinone`` directory. This program is called ``build.py``. This |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
263 |
program will get the project configured for you |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
264 |
in the most commonly useful way. However, please note that more advanced |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
265 |
configuration and work with |ns3| will typically involve using the |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
266 |
native |ns3| build system, Waf, to be introduced later in this tutorial. |
6754 | 267 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
268 |
If you downloaded |
6754 | 269 |
using a tarball you should have a directory called something like |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
270 |
``ns-allinone-3.20`` under your ``~/workspace`` directory. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
271 |
Type the following:: |
6754 | 272 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
273 |
$ ./build.py --enable-examples --enable-tests |
6998
1c2b8cfb71d2
Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6754
diff
changeset
|
274 |
|
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
275 |
Because we are working with examples and tests in this tutorial, and |
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
276 |
because they are not built by default in |ns3|, the arguments for |
7661
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
277 |
build.py tells it to build them for us. The program also defaults to |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
278 |
building all available modules. Later, you can build |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
279 |
|ns3| without examples and tests, or eliminate the modules that |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
280 |
are not necessary for your work, if you wish. |
6754 | 281 |
|
282 |
You will see lots of typical compiler output messages displayed as the build |
|
283 |
script builds the various pieces you downloaded. Eventually you should see the |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
284 |
following magic words:: |
6754 | 285 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
286 |
Waf: Leaving directory `/path/to/workspace/ns-allinone-3.20/ns-3.20/build' |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
287 |
'build' finished successfully (6m25.032s) |
7071 | 288 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
289 |
Modules built: |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
290 |
antenna aodv applications |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
291 |
bridge buildings config-store |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
292 |
core csma csma-layout |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
293 |
dsdv dsr emu |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
294 |
energy fd-net-device flow-monitor |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
295 |
internet lte mesh |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
296 |
mobility mpi netanim (no Python) |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
297 |
network nix-vector-routing olsr |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
298 |
point-to-point point-to-point-layout propagation |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
299 |
spectrum stats tap-bridge |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
300 |
test (no Python) tools topology-read |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
301 |
uan virtual-net-device wifi |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
302 |
wimax |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
303 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
304 |
Modules not built (see ns-3 tutorial for explanation): |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
305 |
brite click openflow |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
306 |
visualizer |
6754 | 307 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
308 |
Leaving directory `./ns-3.20' |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
309 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
310 |
Regarding the portion about modules not built:: |
9169
f8bff624db3c
clarify 'Modules not built' waf report
Tom Henderson <tomh@tomh.org>
parents:
9163
diff
changeset
|
311 |
|
f8bff624db3c
clarify 'Modules not built' waf report
Tom Henderson <tomh@tomh.org>
parents:
9163
diff
changeset
|
312 |
Modules not built (see ns-3 tutorial for explanation): |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
313 |
brite click openflow |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
314 |
visualizer |
9169
f8bff624db3c
clarify 'Modules not built' waf report
Tom Henderson <tomh@tomh.org>
parents:
9163
diff
changeset
|
315 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
316 |
This just means that some |ns3| modules that have dependencies on |
9169
f8bff624db3c
clarify 'Modules not built' waf report
Tom Henderson <tomh@tomh.org>
parents:
9163
diff
changeset
|
317 |
outside libraries may not have been built, or that the configuration |
f8bff624db3c
clarify 'Modules not built' waf report
Tom Henderson <tomh@tomh.org>
parents:
9163
diff
changeset
|
318 |
specifically asked not to build them. It does not mean that the |
f8bff624db3c
clarify 'Modules not built' waf report
Tom Henderson <tomh@tomh.org>
parents:
9163
diff
changeset
|
319 |
simulator did not build successfully or that it will provide wrong |
f8bff624db3c
clarify 'Modules not built' waf report
Tom Henderson <tomh@tomh.org>
parents:
9163
diff
changeset
|
320 |
results for the modules listed as being built. |
f8bff624db3c
clarify 'Modules not built' waf report
Tom Henderson <tomh@tomh.org>
parents:
9163
diff
changeset
|
321 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
322 |
Building with bake |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
323 |
++++++++++++++++++ |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
324 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
325 |
If you used bake above to fetch source code from project repositories, you |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
326 |
may continue to use it to build |ns3|. Type |
6754 | 327 |
|
328 |
:: |
|
329 |
||
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
330 |
$ ./bake.py build |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
331 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
332 |
and you should see something like:: |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
333 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
334 |
>> Building pybindgen-0.16.0.825 - OK |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
335 |
>> Building netanim-3.103 - OK |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
336 |
>> Building ns-3.20 - OK |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
337 |
|
9749 | 338 |
*Hint: you can also perform both steps, download and build by calling 'bake.py deploy'.* |
339 |
||
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
340 |
If there happens to be a failure, please have a look at what the following |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
341 |
command tells you; it may give a hint as to a missing dependency:: |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
342 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
343 |
$ ./bake.py show |
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
344 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
345 |
This will list out the various dependencies of the packages you are |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
346 |
trying to build. |
6754 | 347 |
|
348 |
Building with Waf |
|
349 |
+++++++++++++++++ |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
350 |
|
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
351 |
Up to this point, we have used either the `build.py` script, or the |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
352 |
`bake` tool, to get started with building |ns3|. These tools are useful |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
353 |
for building |ns3| and supporting libraries, and they call into |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
354 |
the |ns3| directory to call the Waf build tool to do the actual building. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
355 |
Most users quickly transition to using Waf directly to configure and |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
356 |
build |ns3|. So, to proceed, please change your working directory to |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
357 |
the |ns3| directory that you have initially built. |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
358 |
|
7661
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
359 |
It's not |
6754 | 360 |
strictly required at this point, but it will be valuable to take a slight |
361 |
detour and look at how to make changes to the configuration of the project. |
|
362 |
Probably the most useful configuration change you can make will be to |
|
363 |
build the optimized version of the code. By default you have configured |
|
6998
1c2b8cfb71d2
Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6754
diff
changeset
|
364 |
your project to build the debug version. Let's tell the project to |
6754 | 365 |
make an optimized build. To explain to Waf that it should do optimized |
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
366 |
builds that include the examples and tests, you will need to execute the |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
367 |
following commands:: |
6754 | 368 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
369 |
$ ./waf clean |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
370 |
$ ./waf --build-profile=optimized --enable-examples --enable-tests configure |
6754 | 371 |
|
372 |
This runs Waf out of the local directory (which is provided as a convenience |
|
7661
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
373 |
for you). The first command to clean out the previous build is not |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
374 |
typically strictly necessary but is good practice (but see `Build Profiles`_, |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
375 |
below); it will remove the |
7661
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
376 |
previously built libraries and object files found in directory ``build/``. |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
377 |
When the project is reconfigured and the build system checks for various |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
378 |
dependencies, you should see |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
379 |
output that looks similar to the following:: |
6754 | 380 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
381 |
Setting top to : . |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
382 |
Setting out to : build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
383 |
Checking for 'gcc' (c compiler) : /usr/bin/gcc |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
384 |
Checking for cc version : 4.2.1 |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
385 |
Checking for 'g++' (c++ compiler) : /usr/bin/g++ |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
386 |
Checking boost includes : 1_46_1 |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
387 |
Checking boost libs : ok |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
388 |
Checking for boost linkage : ok |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
389 |
Checking for click location : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
390 |
Checking for program pkg-config : /sw/bin/pkg-config |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
391 |
Checking for 'gtk+-2.0' >= 2.12 : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
392 |
Checking for 'libxml-2.0' >= 2.7 : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
393 |
Checking for type uint128_t : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
394 |
Checking for type __uint128_t : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
395 |
Checking high precision implementation : 128-bit integer (default) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
396 |
Checking for header stdint.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
397 |
Checking for header inttypes.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
398 |
Checking for header sys/inttypes.h : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
399 |
Checking for header sys/types.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
400 |
Checking for header sys/stat.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
401 |
Checking for header dirent.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
402 |
Checking for header stdlib.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
403 |
Checking for header signal.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
404 |
Checking for header pthread.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
405 |
Checking for header stdint.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
406 |
Checking for header inttypes.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
407 |
Checking for header sys/inttypes.h : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
408 |
Checking for library rt : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
409 |
Checking for header netpacket/packet.h : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
410 |
Checking for header sys/ioctl.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
411 |
Checking for header net/if.h : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
412 |
Checking for header net/ethernet.h : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
413 |
Checking for header linux/if_tun.h : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
414 |
Checking for header netpacket/packet.h : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
415 |
Checking for NSC location : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
416 |
Checking for 'mpic++' : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
417 |
Checking for 'sqlite3' : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
418 |
Checking for header linux/if_tun.h : not found |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
419 |
Checking for program sudo : /usr/bin/sudo |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
420 |
Checking for program valgrind : /sw/bin/valgrind |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
421 |
Checking for 'gsl' : yes |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
422 |
Checking for compilation flag -Wno-error=deprecated-d... support : ok |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
423 |
Checking for compilation flag -Wno-error=deprecated-d... support : ok |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
424 |
Checking for compilation flag -fstrict-aliasing... support : ok |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
425 |
Checking for compilation flag -fstrict-aliasing... support : ok |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
426 |
Checking for compilation flag -Wstrict-aliasing... support : ok |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
427 |
Checking for compilation flag -Wstrict-aliasing... support : ok |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
428 |
Checking for program doxygen : /usr/local/bin/doxygen |
6754 | 429 |
---- Summary of optional NS-3 features: |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
430 |
Build profile : debug |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
431 |
Build directory : build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
432 |
Python Bindings : enabled |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
433 |
BRITE Integration : not enabled (BRITE not enabled (see option --with-brite)) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
434 |
NS-3 Click Integration : not enabled (nsclick not enabled (see option --with-nsclick)) |
6754 | 435 |
GtkConfigStore : enabled |
436 |
XmlIo : enabled |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
437 |
Threading Primitives : enabled |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
438 |
Real Time Simulator : enabled (librt is not available) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
439 |
Emulated Net Device : enabled (<netpacket/packet.h> include not detected) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
440 |
File descriptor NetDevice : enabled |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
441 |
Tap FdNetDevice : not enabled (needs linux/if_tun.h) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
442 |
Emulation FdNetDevice : not enabled (needs netpacket/packet.h) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
443 |
PlanetLab FdNetDevice : not enabled (PlanetLab operating system not detected (see option --force-planetlab)) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
444 |
Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc)) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
445 |
MPI Support : enabled |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
446 |
NS-3 OpenFlow Integration : not enabled (Required boost libraries not found, missing: system, signals, filesystem) |
6754 | 447 |
SQlite stats data output : enabled |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
448 |
Tap Bridge : not enabled (<linux/if_tun.h> include not detected) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
449 |
PyViz visualizer : enabled |
6754 | 450 |
Use sudo to set suid bit : not enabled (option --enable-sudo not selected) |
7071 | 451 |
Build tests : enabled |
7025
32212c736ab4
Move examples out of samples directory and remove it
Mitch Watrous <watrous@u.washington.edu>
parents:
7024
diff
changeset
|
452 |
Build examples : enabled |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
453 |
GNU Scientific Library (GSL) : enabled |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
454 |
'configure' finished successfully (1.944s) |
6754 | 455 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
456 |
Note the last part of the above output. Some |ns3| options are not enabled by |
6754 | 457 |
default or require support from the underlying system to work properly. |
458 |
For instance, to enable XmlTo, the library libxml-2.0 must be found on the |
|
459 |
system. If this library were not found, the corresponding |ns3| feature |
|
460 |
would not be enabled and a message would be displayed. Note further that there is |
|
461 |
a feature to use the program ``sudo`` to set the suid bit of certain programs. |
|
462 |
This is not enabled by default and so this feature is reported as "not enabled." |
|
463 |
||
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
464 |
Now go ahead and switch back to the debug build that includes the examples and tests. |
6754 | 465 |
|
466 |
:: |
|
467 |
||
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
468 |
$ ./waf clean |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
469 |
$ ./waf --build-profile=debug --enable-examples --enable-tests configure |
6754 | 470 |
|
471 |
The build system is now configured and you can build the debug versions of |
|
7654 | 472 |
the |ns3| programs by simply typing |
6754 | 473 |
|
474 |
:: |
|
475 |
||
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
476 |
$ ./waf |
6754 | 477 |
|
7661
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
478 |
Okay, sorry, I made you build the |ns3| part of the system twice, |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
479 |
but now you know how to change the configuration and build optimized code. |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
480 |
|
11047
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
481 |
The build.py script discussed above supports also the ``--enable-examples`` |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
482 |
and ``enable-tests`` arguments, but in general, does not directly support |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
483 |
other waf options; for example, this will not work: |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
484 |
|
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
485 |
:: |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
486 |
|
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
487 |
$ ./build.py --disable-python |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
488 |
|
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
489 |
will result in |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
490 |
|
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
491 |
:: |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
492 |
|
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
493 |
build.py: error: no such option: --disable-python |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
494 |
|
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
495 |
However, the special operator ``--`` can be used to pass additional |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
496 |
options through to waf, so instead of the above, the following will work: |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
497 |
|
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
498 |
:: |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
499 |
|
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
500 |
$ ./build.py -- --disable-python |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
501 |
|
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
502 |
as it generates the underlying command ``./waf configure --disable-python``. |
259a56c15a37
bug 1326: document the -- operator to build.py
Tom Henderson <tomh@tomh.org>
parents:
10609
diff
changeset
|
503 |
|
7661
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
504 |
Here are a few more introductory tips about Waf. |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
505 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
506 |
Configure vs. Build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
507 |
=================== |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
508 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
509 |
Some Waf commands are only meaningful during the configure phase and some commands are valid |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
510 |
in the build phase. For example, if you wanted to use the emulation |
6998
1c2b8cfb71d2
Make tests not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6754
diff
changeset
|
511 |
features of |ns3|, you might want to enable setting the suid bit using |
6754 | 512 |
sudo as described above. This turns out to be a configuration-time command, and so |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
513 |
you could reconfigure using the following command that also includes the examples and tests. |
6754 | 514 |
|
515 |
:: |
|
516 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
517 |
$ ./waf configure --enable-sudo --enable-examples --enable-tests |
6754 | 518 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
519 |
If you do this, Waf will have run sudo to change the socket creator programs of the |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
520 |
emulation code to run as root. |
6754 | 521 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
522 |
There are many other configure- and build-time options |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
523 |
available in Waf. To explore these options, type:: |
6754 | 524 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
525 |
$ ./waf --help |
6754 | 526 |
|
527 |
We'll use some of the testing-related commands in the next section. |
|
528 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
529 |
Build Profiles |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
530 |
============== |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
531 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
532 |
We already saw how you can configure Waf for ``debug`` or ``optimized`` builds:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
533 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
534 |
$ ./waf --build-profile=debug |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
535 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
536 |
There is also an intermediate build profile, ``release``. ``-d`` is a |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
537 |
synonym for ``--build-profile``. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
538 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
539 |
By default Waf puts the build artifacts in the ``build`` directory. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
540 |
You can specify a different output directory with the ``--out`` |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
541 |
option, e.g. |
7661
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
542 |
|
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
543 |
:: |
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
544 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
545 |
$ ./waf configure --out=foo |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
546 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
547 |
Combining this with build profiles lets you switch between the different |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
548 |
compile options in a clean way:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
549 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
550 |
$ ./waf configure --build-profile=debug --out=build/debug |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
551 |
$ ./waf build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
552 |
... |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
553 |
$ ./waf configure --build-profile=optimized --out=build/optimized |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
554 |
$ ./waf build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
555 |
... |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
556 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
557 |
This allows you to work with multiple builds rather than always |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
558 |
overwriting the last build. When you switch, Waf will only compile |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
559 |
what it has to, instead of recompiling everything. |
7661
9ef562047d3e
some clarifications to the use of build.py in the tutorial
Tom Henderson <tomh@tomh.org>
parents:
7654
diff
changeset
|
560 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
561 |
When you do switch build profiles like this, you have to be careful |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
562 |
to give the same configuration parameters each time. It may be convenient |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
563 |
to define some environment variables to help you avoid mistakes:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
564 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
565 |
$ export NS3CONFIG="--enable-examples --enable-tests" |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
566 |
$ export NS3DEBUG="--build-profile=debug --out=build/debug" |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
567 |
$ export NS3OPT=="--build-profile=optimized --out=build/optimized" |
6754 | 568 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
569 |
$ ./waf configure $NS3CONFIG $NS3DEBUG |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
570 |
$ ./waf build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
571 |
... |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
572 |
$ ./waf configure $NS3CONFIG $NS3OPT |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
573 |
$ ./waf build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
574 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
575 |
Compilers |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
576 |
========= |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
577 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
578 |
In the examples above, Waf uses the GCC C++ compiler, ``g++``, for |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
579 |
building |ns3|. However, it's possible to change the C++ compiler used by Waf |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
580 |
by defining the ``CXX`` environment variable. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
581 |
For example, to use the Clang C++ compiler, ``clang++``, |
9189
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
582 |
|
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
583 |
:: |
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
584 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
585 |
$ CXX="clang++" ./waf configure |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
586 |
$ ./waf build |
9189
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
587 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
588 |
One can also set up Waf to do distributed compilation with ``distcc`` in |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
589 |
a similar way:: |
9189
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
590 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
591 |
$ CXX="distcc g++" ./waf configure |
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
592 |
$ ./waf build |
9189
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
593 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
594 |
More info on ``distcc`` and distributed compilation can be found on it's |
9189
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
595 |
`project page |
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
596 |
<http://code.google.com/p/distcc/>`_ |
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
597 |
under Documentation section. |
b6e9f47c260b
Document building with distcc in tutorial, add it to RELEASE_NOTES and CHANGES.html.
Vedran Miletić <rivanvx@gmail.com>
parents:
9169
diff
changeset
|
598 |
|
11048
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
599 |
Install |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
600 |
======= |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
601 |
|
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
602 |
Waf may be used to install libraries in various places on the system. |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
603 |
The default location where libraries and executables are built is |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
604 |
in the ``build`` directory, and because Waf knows the location of these |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
605 |
libraries and executables, it is not necessary to install the libraries |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
606 |
elsewhere. |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
607 |
|
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
608 |
If users choose to install things outside of the build directory, users |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
609 |
may issue the ``./waf install`` command. By default, the prefix for |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
610 |
installation is ``/usr/local``, so ``./waf install`` will install programs |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
611 |
into ``/usr/local/bin``, libraries into ``/usr/local/lib``, and headers |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
612 |
into ``/usr/local/include``. Superuser privileges are typically needed |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
613 |
to install to the default prefix, so the typical command would be |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
614 |
``sudo ./waf install``. When running programs with Waf, Waf will |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
615 |
first prefer to use shared libraries in the build directory, then |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
616 |
will look for libraries in the library path configured in the local |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
617 |
environment. So when installing libraries to the system, it is good |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
618 |
practice to check that the intended libraries are being used. |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
619 |
|
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
620 |
Users may choose to install to a different prefix by passing the ``--prefix`` |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
621 |
option at configure time, such as: |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
622 |
|
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
623 |
:: |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
624 |
|
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
625 |
./waf configure --prefix=/opt/local |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
626 |
|
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
627 |
If later after the build the user issues the ``./waf install`` command, the |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
628 |
prefix ``/opt/local`` will be used. |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
629 |
|
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
630 |
The ``./waf clean`` command should be used prior to reconfiguring |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
631 |
the project if Waf will be used to install things at a different prefix. |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
632 |
|
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
633 |
In summary, it is not necessary to call ``./waf install`` to use |ns3|. |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
634 |
Most users will not need this command since Waf will pick up the |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
635 |
current libraries from the ``build`` directory, but some users may find |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
636 |
it useful if their use case involves working with programs outside |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
637 |
of the |ns3| directory. |
8a2ae153d4aa
add coverage of ./waf install to tutorial
Tom Henderson <tomh@tomh.org>
parents:
11047
diff
changeset
|
638 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
639 |
One Waf |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
640 |
======= |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
641 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
642 |
There is only one Waf script, at the top level of the |ns3| source tree. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
643 |
As you work, you may find yourself spending a lot of time in ``scratch/``, |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
644 |
or deep in ``src/...``, and needing to invoke Waf. You could just |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
645 |
remember where you are, and invoke Waf like this:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
646 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
647 |
$ ../../../waf ... |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
648 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
649 |
but that get's tedious, and error prone, and there are better solutions. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
650 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
651 |
If you have the full |ns3| repository this little gem is a start:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
652 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
653 |
$ cd $(hg root) && ./waf ... |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
654 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
655 |
Even better is to define this as a shell function:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
656 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
657 |
$ function waff { cd $(hg root) && ./waf $* ; } |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
658 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
659 |
$ waff build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
660 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
661 |
If you only have the tarball, an environment variable can help:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
662 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
663 |
$ export NS3DIR="$PWD" |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
664 |
$ function waff { cd $NS3DIR && ./waf $* ; } |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
665 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
666 |
$ cd scratch |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
667 |
$ waff build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
668 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
669 |
It might be tempting in a module directory to add a trivial ``waf`` |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
670 |
script along the lines of ``exec ../../waf``. Please don't. It's |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
671 |
confusing to new-comers, and when done poorly it leads to subtle build |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
672 |
errors. The solutions above are the way to go. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
673 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
674 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
675 |
Testing |ns3| |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
676 |
************* |
6754 | 677 |
|
678 |
You can run the unit tests of the |ns3| distribution by running the |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
679 |
``./test.py -c core`` script:: |
6754 | 680 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
681 |
$ ./test.py -c core |
6754 | 682 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
683 |
These tests are run in parallel by Waf. You should eventually |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
684 |
see a report saying that |
6754 | 685 |
|
686 |
:: |
|
687 |
||
7654 | 688 |
92 of 92 tests passed (92 passed, 0 failed, 0 crashed, 0 valgrind errors) |
6754 | 689 |
|
690 |
This is the important message. |
|
691 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
692 |
You will also see the summary output from Waf and the test runner |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
693 |
executing each test, which will actually look something like:: |
6754 | 694 |
|
9742
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
695 |
Waf: Entering directory `/path/to/workspace/ns-3-allinone/ns-3-dev/build' |
b24738ffa84b
update tutorial for bake usage
Tom Henderson <tomh@tomh.org>
parents:
9189
diff
changeset
|
696 |
Waf: Leaving directory `/path/to/workspace/ns-3-allinone/ns-3-dev/build' |
6754 | 697 |
'build' finished successfully (1.799s) |
7071 | 698 |
|
699 |
Modules built: |
|
7275 | 700 |
aodv applications bridge |
701 |
click config-store core |
|
702 |
csma csma-layout dsdv |
|
703 |
emu energy flow-monitor |
|
704 |
internet lte mesh |
|
705 |
mobility mpi netanim |
|
706 |
network nix-vector-routing ns3tcp |
|
707 |
ns3wifi olsr openflow |
|
708 |
point-to-point point-to-point-layout propagation |
|
709 |
spectrum stats tap-bridge |
|
710 |
template test tools |
|
711 |
topology-read uan virtual-net-device |
|
712 |
visualizer wifi wimax |
|
7071 | 713 |
|
6754 | 714 |
PASS: TestSuite ns3-wifi-interference |
715 |
PASS: TestSuite histogram |
|
716 |
||
717 |
... |
|
718 |
||
719 |
PASS: TestSuite object |
|
720 |
PASS: TestSuite random-number-generators |
|
7654 | 721 |
92 of 92 tests passed (92 passed, 0 failed, 0 crashed, 0 valgrind errors) |
6754 | 722 |
|
7654 | 723 |
This command is typically run by users to quickly verify that an |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
724 |
|ns3| distribution has built correctly. (Note the order of the ``PASS: ...`` |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
725 |
lines can vary, which is okay. What's important is that the summary line at |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
726 |
the end report that all tests passed; none failed or crashed.) |
6754 | 727 |
|
728 |
Running a Script |
|
729 |
**************** |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
730 |
|
6754 | 731 |
We typically run scripts under the control of Waf. This allows the build |
732 |
system to ensure that the shared library paths are set correctly and that |
|
733 |
the libraries are available at run time. To run a program, simply use the |
|
734 |
``--run`` option in Waf. Let's run the |ns3| equivalent of the |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
735 |
ubiquitous hello world program by typing the following:: |
6754 | 736 |
|
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
737 |
$ ./waf --run hello-simulator |
6754 | 738 |
|
739 |
Waf first checks to make sure that the program is built correctly and |
|
740 |
executes a build if required. Waf then executes the program, which |
|
741 |
produces the following output. |
|
742 |
||
743 |
:: |
|
744 |
||
745 |
Hello Simulator |
|
746 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
747 |
Congratulations! You are now an ns-3 user! |
6754 | 748 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
749 |
**What do I do if I don't see the output?** |
6754 | 750 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
751 |
If you see Waf messages indicating that the build was |
6754 | 752 |
completed successfully, but do not see the "Hello Simulator" output, |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
753 |
chances are that you have switched your build mode to ``optimized`` in |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
754 |
the `Building with Waf`_ section, but have missed the change back to |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
755 |
``debug`` mode. All of the console output used in this tutorial uses a |
6754 | 756 |
special |ns3| logging component that is useful for printing |
757 |
user messages to the console. Output from this component is |
|
758 |
automatically disabled when you compile optimized code -- it is |
|
759 |
"optimized out." If you don't see the "Hello Simulator" output, |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
760 |
type the following:: |
6754 | 761 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
762 |
$ ./waf configure --build-profile=debug --enable-examples --enable-tests |
6754 | 763 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
764 |
to tell Waf to build the debug versions of the |ns3| |
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
765 |
programs that includes the examples and tests. You must still build |
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
766 |
the actual debug version of the code by typing |
6754 | 767 |
|
768 |
:: |
|
769 |
||
9957
1a4d84a85bad
Manual and Tutorial syntax coloring
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9749
diff
changeset
|
770 |
$ ./waf |
6754 | 771 |
|
772 |
Now, if you run the ``hello-simulator`` program, you should see the |
|
773 |
expected output. |
|
774 |
||
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
775 |
Program Arguments |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
776 |
+++++++++++++++++ |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
777 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
778 |
To feed command line arguments to an |ns3| program use this pattern:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
779 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
780 |
$ ./waf --run <ns3-program> --command-template="%s <args>" |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
781 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
782 |
Substitute your program name for ``<ns3-program>``, and the arguments |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
783 |
for ``<args>``. The ``--command-template`` argument to Waf is |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
784 |
basically a recipe for constructing the actual command line Waf should use |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
785 |
to execute the program. Waf checks that the build is complete, |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
786 |
sets the shared library paths, then invokes the executable |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
787 |
using the provided command line template, |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
788 |
inserting the program name for the ``%s`` placeholder. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
789 |
(I admit this is a bit awkward, but that's the way it is. Patches welcome!) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
790 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
791 |
Another particularly useful example is to run the ``mytest`` test suite |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
792 |
by itself. Above, we used the ``./test.py`` script to run a whole slew of |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
793 |
tests in parallel, by repeatedly invoking the real testing program, |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
794 |
``test-runner``. To invoke ``test-runner`` directly for a single test:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
795 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
796 |
$ ./waf --run test-runner --command-template="% --suite=mytest --verbose" |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
797 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
798 |
This passes the arguments to the ``test-runner`` program. To print the |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
799 |
available ``test-runner`` options:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
800 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
801 |
$ ./waf --run test-runner --command-template="% --help" |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
802 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
803 |
Debugging |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
804 |
+++++++++ |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
805 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
806 |
To run |ns3| programs under the control of another utility, such as |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
807 |
a debugger (*e.g.* ``gdb``) or memory checker (*e.g.* ``valgrind``), |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
808 |
you use a similar ``--command-template="..."`` form. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
809 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
810 |
For example, to run your |ns3| program ``mysim`` with the arguments |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
811 |
``<args>`` under the ``gdb`` debugger:: |
6754 | 812 |
|
10609
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
813 |
$ ./waf --run=hello-simulator --command-template="gdb %s --args <args>" |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
814 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
815 |
Notice that the |ns3| program name goes with the ``--run`` argument, |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
816 |
and the control utility (here ``gdb``) is the first token |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
817 |
in the ``--commmand-template`` argument. The ``--args`` tells ``gdb`` |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
818 |
that the remainder of the command line belongs to the "inferior" program. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
819 |
(Some ``gdb``'s don't understand the ``--args`` feature. In this case, |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
820 |
omit the program arguments from the ``--command-template``, |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
821 |
and use the ``gdb`` command ``set args``.) |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
822 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
823 |
We can combine this recipe and the previous one to run a test under the |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
824 |
debugger:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
825 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
826 |
$ ./waf --run test-runner --command-template="gdb %s --args --suite=mytest --verbose" |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
827 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
828 |
Working Directory |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
829 |
+++++++++++++++++ |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
830 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
831 |
Waf needs to run from it's location at the top of the |ns3| tree. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
832 |
This becomes the working directory where output files will be written. |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
833 |
But what if you want to keep those ouf to the |ns3| source tree? Use |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
834 |
the ``--cwd`` argument:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
835 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
836 |
$ ./waf --cwd=... |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
837 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
838 |
It may be more convenient to start with your working directory where |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
839 |
you want the output files, in which case a little indirection can help:: |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
840 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
841 |
$ function waff { |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
842 |
CWD="$PWD" |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
843 |
cd $NS3DIR >/dev/null |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
844 |
./waf --cwd="$CWD" $* |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
845 |
cd - >/dev/null |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
846 |
} |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
847 |
|
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
848 |
This embellishment of the previous version saves the current working directory, |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
849 |
``cd``'s to the Waf directory, then instructs Waf to change the working |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
850 |
directory *back* to the saved current working directory before running the |
4fe4f5afb5f3
[tutorial] Introduce more waf options and best work practices.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10401
diff
changeset
|
851 |
program. |