Skip to content

Commit e9db0e8

Browse files
committed
Create build_distrib.py tool (cztomczak#317)...
Add --no-run-examples flag to build.py.
1 parent 36c0560 commit e9db0e8

File tree

6 files changed

+571
-66
lines changed

6 files changed

+571
-66
lines changed

docs/Build-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Before you can build CEF Python or CEF you must satisfy
4747

4848
## Quick build instructions for Windows
4949

50-
Complete steps for building CEF Python v50+ using prebuilt binaries
51-
and libraries from GitHub Releases:
50+
Complete steps for building CEF Python v50+ with Python 2.7 using
51+
prebuilt binaries and libraries from GitHub Releases:
5252

5353
1) Tested and works fine on Windows 7 64-bit
5454

tools/build.py

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
build.py VERSION [--rebuild-cpp] [--fast] [--clean] [--kivy]
2222
2323
Options:
24-
VERSION Version number eg. 50.0
25-
--rebuild-cpp Force rebuild of C++ projects
26-
--fast Fast mode
27-
--clean Clean C++ projects build files (.o .a etc)
28-
--kivy Run only Kivy example
24+
VERSION Version number eg. 50.0
25+
--no-run-examples Do not run examples after build, only unit tests
26+
--rebuild-cpp Force rebuild of .vcproj C++ projects (DISABLED)
27+
--fast Fast mode
28+
--clean Clean C++ projects build files on Linux/Mac
29+
--kivy Run only Kivy example
2930
"""
3031

3132
# How to debug on Linux:
@@ -59,12 +60,13 @@
5960
pass
6061

6162
# Command line args variables
63+
VERSION = ""
64+
NO_RUN_EXAMPLES = False
6265
DEBUG_FLAG = False
6366
FAST_FLAG = False
6467
CLEAN_FLAG = False
6568
KIVY_FLAG = False
6669
REBUILD_CPP = False
67-
VERSION = ""
6870

6971
# First run
7072
FIRST_RUN = False
@@ -102,39 +104,44 @@ def main():
102104

103105
def command_line_args():
104106
global DEBUG_FLAG, FAST_FLAG, CLEAN_FLAG, KIVY_FLAG,\
105-
REBUILD_CPP, VERSION
107+
REBUILD_CPP, VERSION, NO_RUN_EXAMPLES
106108

107-
VERSION = get_version_from_command_line_args()
109+
VERSION = get_version_from_command_line_args(__file__)
108110
if not VERSION:
109111
print(__doc__)
110112
sys.exit(1)
111113

112114
print("[build.py] Parse command line arguments")
113115

114-
# -- debug flag
115-
if len(sys.argv) > 1 and "--debug" in sys.argv:
116+
# --no-run-examples
117+
if "--no-run-examples" in sys.argv:
118+
NO_RUN_EXAMPLES = True
119+
print("[build.py] Running examples disabled (--no-run-examples)")
120+
121+
# -- debug
122+
if "--debug" in sys.argv:
116123
DEBUG_FLAG = True
117124
print("[build.py] DEBUG mode On")
118125

119-
# --fast flag
120-
if len(sys.argv) > 1 and "--fast" in sys.argv:
126+
# --fast
127+
if "--fast" in sys.argv:
121128
# Fast mode doesn't delete C++ .o .a files.
122129
# Fast mode also disables optimization flags in setup/setup.py .
123130
FAST_FLAG = True
124131
print("[build.py] FAST mode On")
125132

126-
# --clean flag
127-
if len(sys.argv) > 1 and "--clean" in sys.argv:
133+
# --clean
134+
if "--clean" in sys.argv:
128135
CLEAN_FLAG = True
129136

130-
# --kivy flag
131-
if len(sys.argv) > 1 and "--kivy" in sys.argv:
137+
# --kivy
138+
if "--kivy" in sys.argv:
132139
KIVY_FLAG = True
133140
print("[build.py] KIVY mode enabled")
134141

135-
# --rebuild-cpp flag
142+
# --rebuild-cpp
136143
# Rebuild c++ projects
137-
if len(sys.argv) > 1 and "--rebuild-cpp" in sys.argv:
144+
if "--rebuild-cpp" in sys.argv:
138145
REBUILD_CPP = True
139146
print("[build.py] REBUILD_CPP mode enabled")
140147

@@ -825,17 +832,18 @@ def install_and_run():
825832
sys.exit(ret)
826833

827834
# Run examples
828-
print("[build.py] Run examples")
829-
os.chdir(EXAMPLES_DIR)
830-
kivy_flag = "--kivy" if KIVY_FLAG else ""
831-
run_examples = os.path.join(TOOLS_DIR, "run_examples.py")
832-
ret = os.system("\"{python}\" {run_examples} {kivy_flag}"
833-
.format(python=sys.executable,
834-
run_examples=run_examples,
835-
kivy_flag=kivy_flag))
836-
if ret != 0:
837-
print("[build.py] ERROR while running examples")
838-
sys.exit(1)
835+
if not NO_RUN_EXAMPLES:
836+
print("[build.py] Run examples")
837+
os.chdir(EXAMPLES_DIR)
838+
kivy_flag = "--kivy" if KIVY_FLAG else ""
839+
run_examples = os.path.join(TOOLS_DIR, "run_examples.py")
840+
ret = os.system("\"{python}\" {run_examples} {kivy_flag}"
841+
.format(python=sys.executable,
842+
run_examples=run_examples,
843+
kivy_flag=kivy_flag))
844+
if ret != 0:
845+
print("[build.py] ERROR while running examples")
846+
sys.exit(1)
839847

840848
print("[build.py] Everything OK")
841849

tools/build_cpp_projects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ def smart_compile(compiler, macros, extra_args, sources, output_dir):
221221
obj_time = os.path.getmtime(obj_file)
222222
source_time = os.path.getmtime(source_file)
223223
header_time = os.path.getmtime(header_file) if header_file else 0
224-
cefpython_h_fixed_time = os.path.getmtime(CEFPYTHON_API_HFILE_FIXED)
224+
cefpython_h_fixed_time = os.path.getmtime(
225+
CEFPYTHON_API_HFILE_FIXED)
225226
common_files_time = get_directory_mtime(os.path.join(SRC_DIR,
226227
"common"))
227228
changed = ((source_time > obj_time)

0 commit comments

Comments
 (0)