|
22 | 22 | [--hello-world] |
23 | 23 |
|
24 | 24 | Options: |
25 | | - VERSION Version number eg. 50.0 |
26 | | - --no-run-examples Do not run examples after build, only unit tests |
27 | | - --fast Fast mode |
28 | | - --clean Clean C++ projects build files on Linux/Mac |
29 | | - --kivy Run only Kivy example |
30 | | - --hello-world Run only Hello World example |
| 25 | + VERSION Version number eg. 50.0 |
| 26 | + --no-run-examples Do not run examples after build, only unit tests |
| 27 | + --fast Fast mode |
| 28 | + --clean Clean C++ projects build files on Linux/Mac |
| 29 | + --kivy Run only Kivy example |
| 30 | + --hello-world Run only Hello World example |
| 31 | + --enable-profiling Enable cProfile profiling |
| 32 | + --enable-line-tracing Enable cProfile line tracing |
31 | 33 | """ |
32 | 34 |
|
33 | 35 | # --rebuild-cpp Force rebuild of .vcproj C++ projects (DISABLED) |
|
82 | 84 | KIVY_FLAG = False |
83 | 85 | HELLO_WORLD_FLAG = False |
84 | 86 | REBUILD_CPP = False |
| 87 | +ENABLE_PROFILING = False |
| 88 | +ENABLE_LINE_TRACING = False |
85 | 89 |
|
86 | 90 | # First run |
87 | 91 | FIRST_RUN = False |
@@ -122,48 +126,72 @@ def command_line_args(): |
122 | 126 | REBUILD_CPP, VERSION, NO_RUN_EXAMPLES |
123 | 127 |
|
124 | 128 | VERSION = get_version_from_command_line_args(__file__) |
| 129 | + # Other scripts called by this script expect that version number |
| 130 | + # is available in sys.argv, so don't remove it like it's done |
| 131 | + # for all other args starting with "--". |
125 | 132 | if not VERSION: |
126 | 133 | print(__doc__) |
127 | 134 | sys.exit(1) |
128 | 135 |
|
129 | 136 | print("[build.py] Parse command line arguments") |
130 | 137 |
|
131 | | - # --no-run-examples |
132 | 138 | if "--no-run-examples" in sys.argv: |
133 | 139 | NO_RUN_EXAMPLES = True |
134 | 140 | print("[build.py] Running examples disabled (--no-run-examples)") |
| 141 | + sys.argv.remove("--no-run-examples") |
135 | 142 |
|
136 | | - # -- debug |
137 | 143 | if "--debug" in sys.argv: |
138 | 144 | DEBUG_FLAG = True |
139 | 145 | print("[build.py] DEBUG mode On") |
| 146 | + sys.argv.remove("--debug") |
140 | 147 |
|
141 | | - # --fast |
142 | 148 | if "--fast" in sys.argv: |
143 | 149 | # Fast mode doesn't delete C++ .o .a files. |
144 | 150 | # Fast mode also disables optimization flags in setup/setup.py . |
145 | 151 | FAST_FLAG = True |
146 | 152 | print("[build.py] FAST mode On") |
| 153 | + sys.argv.remove("--fast") |
147 | 154 |
|
148 | | - # --clean |
149 | 155 | if "--clean" in sys.argv: |
150 | 156 | CLEAN_FLAG = True |
| 157 | + sys.argv.remove("--clean") |
151 | 158 |
|
152 | | - # --kivy |
153 | 159 | if "--kivy" in sys.argv: |
154 | 160 | KIVY_FLAG = True |
155 | 161 | print("[build.py] KIVY example") |
| 162 | + sys.argv.remove("--kivy") |
156 | 163 |
|
157 | | - # --kivy |
158 | 164 | if "--hello-world" in sys.argv: |
159 | 165 | HELLO_WORLD_FLAG = True |
160 | 166 | print("[build.py] HELLO WORLD example") |
| 167 | + sys.argv.remove("--hello-world") |
161 | 168 |
|
162 | | - # --rebuild-cpp |
163 | 169 | # Rebuild c++ projects |
164 | 170 | if "--rebuild-cpp" in sys.argv: |
165 | 171 | REBUILD_CPP = True |
166 | 172 | print("[build.py] REBUILD_CPP mode enabled") |
| 173 | + sys.argv.remove("--rebuild-cpp") |
| 174 | + |
| 175 | + global ENABLE_PROFILING |
| 176 | + if "--enable-profiling" in sys.argv: |
| 177 | + print("[build.py] cProfile profiling enabled") |
| 178 | + ENABLE_PROFILING = True |
| 179 | + sys.argv.remove("--enable-profiling") |
| 180 | + |
| 181 | + global ENABLE_LINE_TRACING |
| 182 | + if "--enable-line-tracing" in sys.argv: |
| 183 | + print("[build.py] cProfile line tracing enabled") |
| 184 | + ENABLE_LINE_TRACING = True |
| 185 | + sys.argv.remove("--enable-line-tracing") |
| 186 | + |
| 187 | + for arg in sys.argv: |
| 188 | + if arg.startswith("--"): |
| 189 | + print("ERROR: invalid arg {0}".format(arg)) |
| 190 | + sys.exit(1) |
| 191 | + |
| 192 | + if len(sys.argv) <= 1: |
| 193 | + print(__doc__) |
| 194 | + sys.exit(1) |
167 | 195 |
|
168 | 196 | print("[build.py] VERSION=%s" % VERSION) |
169 | 197 |
|
@@ -726,8 +754,18 @@ def build_cefpython_module(): |
726 | 754 |
|
727 | 755 | os.chdir(BUILD_CEFPYTHON) |
728 | 756 |
|
| 757 | + enable_profiling = "" |
| 758 | + if ENABLE_PROFILING: |
| 759 | + enable_profiling = "--enable-profiling" |
| 760 | + enable_line_tracing = "" |
| 761 | + if ENABLE_LINE_TRACING: |
| 762 | + enable_line_tracing = "--enable-line-tracing" |
| 763 | + |
729 | 764 | command = ("\"{python}\" {tools_dir}/cython_setup.py build_ext" |
730 | | - .format(python=sys.executable, tools_dir=TOOLS_DIR)) |
| 765 | + " {enable_profiling} {enable_line_tracing}" |
| 766 | + .format(python=sys.executable, tools_dir=TOOLS_DIR, |
| 767 | + enable_profiling=enable_profiling, |
| 768 | + enable_line_tracing=enable_line_tracing)) |
731 | 769 | if FAST_FLAG: |
732 | 770 | command += " --fast" |
733 | 771 | ret = subprocess.call(command, shell=True) |
|
0 commit comments