Skip to content

Commit

Permalink
Create build_distrib.py tool (#317)...
Browse files Browse the repository at this point in the history
Add --no-run-examples flag to build.py.
  • Loading branch information
cztomczak committed Mar 11, 2017
1 parent 36c0560 commit e9db0e8
Show file tree
Hide file tree
Showing 6 changed files with 571 additions and 66 deletions.
4 changes: 2 additions & 2 deletions docs/Build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Before you can build CEF Python or CEF you must satisfy

## Quick build instructions for Windows

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

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

Expand Down
66 changes: 37 additions & 29 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
build.py VERSION [--rebuild-cpp] [--fast] [--clean] [--kivy]
Options:
VERSION Version number eg. 50.0
--rebuild-cpp Force rebuild of C++ projects
--fast Fast mode
--clean Clean C++ projects build files (.o .a etc)
--kivy Run only Kivy example
VERSION Version number eg. 50.0
--no-run-examples Do not run examples after build, only unit tests
--rebuild-cpp Force rebuild of .vcproj C++ projects (DISABLED)
--fast Fast mode
--clean Clean C++ projects build files on Linux/Mac
--kivy Run only Kivy example
"""

# How to debug on Linux:
Expand Down Expand Up @@ -59,12 +60,13 @@
pass

# Command line args variables
VERSION = ""
NO_RUN_EXAMPLES = False
DEBUG_FLAG = False
FAST_FLAG = False
CLEAN_FLAG = False
KIVY_FLAG = False
REBUILD_CPP = False
VERSION = ""

# First run
FIRST_RUN = False
Expand Down Expand Up @@ -102,39 +104,44 @@ def main():

def command_line_args():
global DEBUG_FLAG, FAST_FLAG, CLEAN_FLAG, KIVY_FLAG,\
REBUILD_CPP, VERSION
REBUILD_CPP, VERSION, NO_RUN_EXAMPLES

VERSION = get_version_from_command_line_args()
VERSION = get_version_from_command_line_args(__file__)
if not VERSION:
print(__doc__)
sys.exit(1)

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

# -- debug flag
if len(sys.argv) > 1 and "--debug" in sys.argv:
# --no-run-examples
if "--no-run-examples" in sys.argv:
NO_RUN_EXAMPLES = True
print("[build.py] Running examples disabled (--no-run-examples)")

# -- debug
if "--debug" in sys.argv:
DEBUG_FLAG = True
print("[build.py] DEBUG mode On")

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

# --clean flag
if len(sys.argv) > 1 and "--clean" in sys.argv:
# --clean
if "--clean" in sys.argv:
CLEAN_FLAG = True

# --kivy flag
if len(sys.argv) > 1 and "--kivy" in sys.argv:
# --kivy
if "--kivy" in sys.argv:
KIVY_FLAG = True
print("[build.py] KIVY mode enabled")

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

Expand Down Expand Up @@ -825,17 +832,18 @@ def install_and_run():
sys.exit(ret)

# Run examples
print("[build.py] Run examples")
os.chdir(EXAMPLES_DIR)
kivy_flag = "--kivy" if KIVY_FLAG else ""
run_examples = os.path.join(TOOLS_DIR, "run_examples.py")
ret = os.system("\"{python}\" {run_examples} {kivy_flag}"
.format(python=sys.executable,
run_examples=run_examples,
kivy_flag=kivy_flag))
if ret != 0:
print("[build.py] ERROR while running examples")
sys.exit(1)
if not NO_RUN_EXAMPLES:
print("[build.py] Run examples")
os.chdir(EXAMPLES_DIR)
kivy_flag = "--kivy" if KIVY_FLAG else ""
run_examples = os.path.join(TOOLS_DIR, "run_examples.py")
ret = os.system("\"{python}\" {run_examples} {kivy_flag}"
.format(python=sys.executable,
run_examples=run_examples,
kivy_flag=kivy_flag))
if ret != 0:
print("[build.py] ERROR while running examples")
sys.exit(1)

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

Expand Down
3 changes: 2 additions & 1 deletion tools/build_cpp_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ def smart_compile(compiler, macros, extra_args, sources, output_dir):
obj_time = os.path.getmtime(obj_file)
source_time = os.path.getmtime(source_file)
header_time = os.path.getmtime(header_file) if header_file else 0
cefpython_h_fixed_time = os.path.getmtime(CEFPYTHON_API_HFILE_FIXED)
cefpython_h_fixed_time = os.path.getmtime(
CEFPYTHON_API_HFILE_FIXED)
common_files_time = get_directory_mtime(os.path.join(SRC_DIR,
"common"))
changed = ((source_time > obj_time)
Expand Down
Loading

0 comments on commit e9db0e8

Please sign in to comment.