author | John Abraham <john.abraham@gatech.edu> |
Sat, 21 Jan 2012 01:31:29 -0500 | |
changeset 52 | 56f02f06febc |
parent 51 | e903a1eda531 |
child 54 | 003887235ed3 |
permissions | -rwxr-xr-x |
0
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
1 |
#! /usr/bin/env python |
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
2 |
import sys |
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
3 |
from optparse import OptionParser |
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
4 |
import os |
18
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
5 |
from xml.dom import minidom as dom |
43
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
6 |
import shlex |
0
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
7 |
|
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
8 |
import constants |
28
6cbc3d534abc
If NSC build fails, just ignore it and build ns-3 without it.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
23
diff
changeset
|
9 |
from util import run_command, fatal, CommandError |
0
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
10 |
|
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
11 |
|
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
12 |
def build_nsc(): |
40
e17133ac5523
Use sys.executable to run python instead of hardcoded 'python'
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
37
diff
changeset
|
13 |
run_command([sys.executable, 'scons.py']) |
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
14 |
|
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
15 |
|
49 | 16 |
def build_netanim(qmakepath): |
17 |
qmake = 'qmake' |
|
51
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
18 |
qmakeFound = False |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
19 |
try: |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
20 |
run_command([qmake, '-v']) |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
21 |
print "qmake found" |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
22 |
qmakeFound = True |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
23 |
except: |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
24 |
print "Could not find qmake in the default path" |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
25 |
|
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
26 |
try: |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
27 |
if qmakeFound == False: |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
28 |
run_command(['qmake-qt4', '-v']) |
52
56f02f06febc
NetAnim: missing indent
John Abraham <john.abraham@gatech.edu>
parents:
51
diff
changeset
|
29 |
qmake = 'qmake-qt4' |
56f02f06febc
NetAnim: missing indent
John Abraham <john.abraham@gatech.edu>
parents:
51
diff
changeset
|
30 |
print "qmake-qt4 found" |
51
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
31 |
except: |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
32 |
print "Could not find qmake-qt4 in the default path" |
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
33 |
|
49 | 34 |
if qmakepath: |
51
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
35 |
print "Setting qmake to user provided path" |
49 | 36 |
qmake = qmakepath |
37 |
try: |
|
38 |
if sys.platform in ['darwin']: |
|
39 |
run_command([qmake, '-spec', 'macx-g++', 'NetAnim.pro']) |
|
40 |
else: |
|
41 |
run_command([qmake, 'NetAnim.pro']) |
|
42 |
run_command(['make']) |
|
43 |
except OSError: |
|
44 |
print "Error building NetAnim. Ensure the path to qmake is correct" |
|
45 |
print "Note: Some systems use qmake-qt4 instead of qmake" |
|
46 |
print "Skipping NetAnim ...." |
|
47 |
pass |
|
48 |
except: |
|
49 |
print "Error building NetAnim." |
|
50 |
print "Skipping NetAnim ...." |
|
51 |
pass |
|
52 |
||
43
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
53 |
def build_ns3(config, build_examples, build_tests, args, build_options): |
42
05ffdbe108d4
Pass build.py options after -- to ns-3 waf configure
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
40
diff
changeset
|
54 |
cmd = [sys.executable, "waf", "configure"] + args |
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
55 |
|
37
a03889bf55b1
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
36
diff
changeset
|
56 |
if build_examples: |
a03889bf55b1
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
36
diff
changeset
|
57 |
cmd.append("--enable-examples") |
36
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
58 |
|
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
59 |
if build_tests: |
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
60 |
cmd.append("--enable-tests") |
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
61 |
|
18
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
62 |
try: |
33
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
63 |
ns3_traces, = config.getElementsByTagName("ns-3-traces") |
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
64 |
except ValueError: |
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
65 |
# Don't print a warning message here since regression traces |
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
66 |
# are no longer used. |
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
67 |
pass |
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
68 |
else: |
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
69 |
cmd.extend([ |
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
70 |
"--with-regression-traces", os.path.join("..", ns3_traces.getAttribute("dir")), |
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
71 |
]) |
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
72 |
|
70764f72b46f
Fix Bug 1036: download.py doesn't let user specify regression traces
Mitch Watrous <watrous@u.washington.edu>
parents:
32
diff
changeset
|
73 |
try: |
18
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
74 |
pybindgen, = config.getElementsByTagName("pybindgen") |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
75 |
except ValueError: |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
76 |
print "Note: configuring ns-3 without pybindgen" |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
77 |
else: |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
78 |
cmd.extend([ |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
79 |
"--with-pybindgen", os.path.join("..", pybindgen.getAttribute("dir")), |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
80 |
]) |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
81 |
|
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
82 |
try: |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
83 |
nsc, = config.getElementsByTagName("nsc") |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
84 |
except ValueError: |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
85 |
print "Note: configuring ns-3 without NSC" |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
86 |
else: |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
87 |
# Build NSC if the architecture supports it |
23 | 88 |
if sys.platform not in ['linux2']: |
89 |
arch = None |
|
90 |
else: |
|
91 |
arch = os.uname()[4] |
|
18
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
92 |
if arch == 'x86_64' or arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386': |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
93 |
cmd.extend(["--with-nsc", os.path.join("..", nsc.getAttribute("dir"))]) |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
94 |
else: |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
95 |
print "Note: configuring ns-3 without NSC (architecture not supported)" |
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
96 |
|
43
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
97 |
run_command(cmd) # waf configure ... |
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
98 |
run_command([sys.executable, "waf", "build"] + build_options) |
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
99 |
|
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
100 |
|
0
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
101 |
def main(argv): |
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
102 |
parser = OptionParser() |
29
20922476c714
Add a --disable-nsc option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
28
diff
changeset
|
103 |
parser.add_option('--disable-nsc', |
50
bda5b48f0834
clarify NSC default build is on Linux
Tom Henderson <tomh@tomh.org>
parents:
49
diff
changeset
|
104 |
help=("Don't try to build NSC (built by default on Linux)"), action="store_true", default=False, |
29
20922476c714
Add a --disable-nsc option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
28
diff
changeset
|
105 |
dest='disable_nsc') |
49 | 106 |
parser.add_option('--disable-netanim', |
107 |
help=("Don't try to build NetAnim (built by default)"), action="store_true", default=False, |
|
108 |
dest='disable_netanim') |
|
109 |
parser.add_option('--qmake-path', |
|
51
e903a1eda531
NetAnim: build.py Try alternative qmake before giving up
John Abraham <john.abraham@gatech.edu>
parents:
50
diff
changeset
|
110 |
help=("Provide absolute path to qmake executable for NetAnim"), action="store", |
49 | 111 |
dest='qmake_path') |
37
a03889bf55b1
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
36
diff
changeset
|
112 |
parser.add_option('--enable-examples', |
a03889bf55b1
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
36
diff
changeset
|
113 |
help=("Do try to build examples (not built by default)"), action="store_true", default=False, |
a03889bf55b1
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
36
diff
changeset
|
114 |
dest='enable_examples') |
36
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
115 |
parser.add_option('--enable-tests', |
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
116 |
help=("Do try to build tests (not built by default)"), action="store_true", default=False, |
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
117 |
dest='enable_tests') |
43
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
118 |
parser.add_option('--build-options', |
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
119 |
help=("Add these options to ns-3's \"waf build\" command"), |
44
063172887f48
Fix build.py when --build-options default value
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
43
diff
changeset
|
120 |
default='', dest='build_options') |
0
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
121 |
(options, args) = parser.parse_args() |
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
122 |
|
23 | 123 |
cwd = os.getcwd() |
124 |
||
18
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
125 |
try: |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
126 |
dot_config = open(".config", "rt") |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
127 |
except IOError: |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
128 |
print >> sys.stderr, "** ERROR: missing .config file; you probably need to run the download.py script first." |
19
59bfecde0bb1
A couple of bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
18
diff
changeset
|
129 |
sys.exit(2) |
59bfecde0bb1
A couple of bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
18
diff
changeset
|
130 |
|
18
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
131 |
config = dom.parse(dot_config) |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
132 |
dot_config.close() |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
133 |
|
29
20922476c714
Add a --disable-nsc option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
28
diff
changeset
|
134 |
if options.disable_nsc: |
20922476c714
Add a --disable-nsc option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
28
diff
changeset
|
135 |
print "# Skip NSC (by user request)" |
20922476c714
Add a --disable-nsc option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
28
diff
changeset
|
136 |
for node in config.getElementsByTagName("nsc"): |
20922476c714
Add a --disable-nsc option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
28
diff
changeset
|
137 |
config.documentElement.removeChild(node) |
20922476c714
Add a --disable-nsc option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
28
diff
changeset
|
138 |
elif sys.platform in ['darwin', 'win32']: |
23 | 139 |
print "# Skip NSC (platform not supported)" |
140 |
else: |
|
141 |
nsc_config_elems = config.getElementsByTagName("nsc") |
|
142 |
if nsc_config_elems: |
|
143 |
nsc_config, = nsc_config_elems |
|
144 |
nsc_dir = nsc_config.getAttribute("dir") |
|
145 |
print "# Build NSC" |
|
146 |
os.chdir(nsc_dir) |
|
147 |
print "Entering directory `%s'" % nsc_dir |
|
148 |
try: |
|
30
a27797fe2367
bug 616: python problems with ns3.4 on RH family
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
29
diff
changeset
|
149 |
try: |
a27797fe2367
bug 616: python problems with ns3.4 on RH family
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
29
diff
changeset
|
150 |
build_nsc() |
a27797fe2367
bug 616: python problems with ns3.4 on RH family
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
29
diff
changeset
|
151 |
except CommandError: |
a27797fe2367
bug 616: python problems with ns3.4 on RH family
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
29
diff
changeset
|
152 |
print "# Build NSC: failure (ignoring NSC)" |
a27797fe2367
bug 616: python problems with ns3.4 on RH family
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
29
diff
changeset
|
153 |
config.documentElement.removeChild(nsc_config) |
23 | 154 |
finally: |
155 |
os.chdir(cwd) |
|
156 |
print "Leaving directory `%s'" % nsc_dir |
|
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
157 |
|
49 | 158 |
if options.disable_netanim: |
159 |
print "# Skip NetAnimC (by user request)" |
|
160 |
for node in config.getElementsByTagName("netanim"): |
|
161 |
config.documentElement.removeChild(node) |
|
162 |
elif sys.platform in ['cygwin', 'win32']: |
|
163 |
print "# Skip NetAnim (platform not supported)" |
|
164 |
else: |
|
165 |
netanim_config_elems = config.getElementsByTagName("netanim") |
|
166 |
if netanim_config_elems: |
|
167 |
netanim_config, = netanim_config_elems |
|
168 |
netanim_dir = netanim_config.getAttribute("dir") |
|
169 |
print "# Build NetAnim" |
|
170 |
os.chdir(netanim_dir) |
|
171 |
print "Entering directory `%s'" % netanim_dir |
|
172 |
try: |
|
173 |
try: |
|
174 |
build_netanim(options.qmake_path) |
|
175 |
except CommandError: |
|
176 |
print "# Build NetAnim: failure (ignoring NetAnim)" |
|
177 |
config.documentElement.removeChild(netanim_config) |
|
178 |
finally: |
|
179 |
os.chdir(cwd) |
|
180 |
print "Leaving directory `%s'" % netanim_dir |
|
181 |
||
37
a03889bf55b1
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
36
diff
changeset
|
182 |
if options.enable_examples: |
a03889bf55b1
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
36
diff
changeset
|
183 |
print "# Building examples (by user request)" |
a03889bf55b1
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
36
diff
changeset
|
184 |
build_examples = True |
a03889bf55b1
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
36
diff
changeset
|
185 |
else: |
36
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
186 |
build_examples = False |
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
187 |
|
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
188 |
if options.enable_tests: |
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
189 |
print "# Building tests (by user request)" |
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
190 |
build_tests = True |
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
191 |
else: |
456034b854e1
Make build.py allow tests to be enabled
Mitch Watrous <watrous@u.washington.edu>
parents:
35
diff
changeset
|
192 |
build_tests = False |
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
193 |
|
43
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
194 |
if options.build_options is None: |
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
195 |
build_options = None |
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
196 |
else: |
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
197 |
build_options = shlex.split(options.build_options) |
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
198 |
|
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
199 |
print "# Build NS-3" |
18
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
200 |
ns3_config, = config.getElementsByTagName("ns-3") |
32ed689ba78d
Switch to a single .config XML file, instead of BRANCH and REPO-BRANCH files. Save more state between download.py and build.py.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
17
diff
changeset
|
201 |
d = os.path.join(os.path.dirname(__file__), ns3_config.getAttribute("dir")) |
0
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
202 |
print "Entering directory `%s'" % d |
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
203 |
os.chdir(d) |
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
204 |
try: |
43
586b5fcd78b1
Add a --build-options option to build.py
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
42
diff
changeset
|
205 |
build_ns3(config, build_examples, build_tests, args, build_options) |
13
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
206 |
finally: |
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
207 |
os.chdir(cwd) |
0e5fbb71b791
Also build NSC if the architecture supports it
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
8
diff
changeset
|
208 |
print "Leaving directory `%s'" % d |
0
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
209 |
|
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
210 |
|
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
211 |
return 0 |
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
212 |
|
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
213 |
if __name__ == '__main__': |
b3cf4a666ff5
initial draft of the 'all-in-one' build system
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
214 |
sys.exit(main(sys.argv)) |