Skip to content

Commit 15967e2

Browse files
committed
perf(build): do not build SpiderMonkey if BUILD_TYPE is None
1 parent c8b0f61 commit 15967e2

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

build.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# Get number of CPU cores
1818
CPUS = os.getenv('CPUS') or os.cpu_count() or 1
1919

20+
BUILD_TYPE = os.environ["BUILD_TYPE"].title() if "BUILD_TYPE" in os.environ else "Release"
21+
BUILD_DOCS = "ON" if "BUILD_DOCS" in os.environ and os.environ["BUILD_DOCS"] in ("1", "ON", "on") else "OFF"
22+
2023

2124
def execute(cmd: str, cwd: Optional[str] = None):
2225
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
@@ -41,26 +44,18 @@ def ensure_spidermonkey():
4144
execute("bash ./setup.sh", cwd=TOP_DIR)
4245

4346

44-
def ensure_githooks():
45-
execute("ln -s -f ../../githooks/pre-commit .git/hooks/pre-commit", cwd=TOP_DIR)
46-
47-
4847
def run_cmake_build():
4948
os.makedirs(BUILD_DIR, exist_ok=True) # mkdir -p
50-
build_type = os.environ["BUILD_TYPE"].title() if "BUILD_TYPE" in os.environ else "Release"
51-
build_docs = "ON" if "BUILD_DOCS" in os.environ and os.environ["BUILD_DOCS"] in ("1", "ON", "on") else "OFF"
5249

5350
if platform.system() == "Windows":
5451
# use Clang/LLVM toolset for Visual Studio
55-
execute(f"cmake -DBUILD_DOCS={build_docs} -DPM_BUILD_TYPE={build_type} .. -T ClangCL", cwd=BUILD_DIR)
52+
execute(f"cmake -DBUILD_DOCS={BUILD_DOCS} -DPM_BUILD_TYPE={BUILD_TYPE} .. -T ClangCL", cwd=BUILD_DIR)
5653
else:
57-
execute(f"cmake -DBUILD_DOCS={build_docs} -DPM_BUILD_TYPE={build_type} ..", cwd=BUILD_DIR)
54+
execute(f"cmake -DBUILD_DOCS={BUILD_DOCS} -DPM_BUILD_TYPE={BUILD_TYPE} ..", cwd=BUILD_DIR)
5855
execute(f"cmake --build . -j{CPUS} --config Release", cwd=BUILD_DIR)
5956

6057

6158
def copy_artifacts():
62-
if "BUILD_TYPE" in os.environ and os.environ["BUILD_TYPE"].title() == "None":
63-
return # do not copy artifacts if we did not build them
6459

6560
if platform.system() == "Windows":
6661
execute("cp ./build/src/*/pythonmonkey.pyd ./python/pythonmonkey/", cwd=TOP_DIR) # Release or Debug build
@@ -71,10 +66,11 @@ def copy_artifacts():
7166

7267

7368
def build():
74-
ensure_spidermonkey()
75-
ensure_githooks()
69+
if BUILD_TYPE != "None": # do not build SpiderMonkey if we are not compiling
70+
ensure_spidermonkey()
7671
run_cmake_build()
77-
copy_artifacts()
72+
if BUILD_TYPE != "None": # do not copy artifacts if we did not build them
73+
copy_artifacts()
7874

7975

8076
if __name__ == "__main__":

0 commit comments

Comments
 (0)