From 0f64956336fac55852a89602e6d6878b6b92d445 Mon Sep 17 00:00:00 2001 From: Adam Simpkins Date: Fri, 20 Sep 2019 14:07:38 -0700 Subject: [PATCH] improve run_cmake.py on Windows Summary: Update the generated `run_cmake.py` script to use `subprocess.run()` instead of `os.execve()`. The `os.execve()` call doesn't really do what we want on Windows: this causes the script to exit while CMake is still running, resulting in confusing output. During the build step it also did not work correctly with `vcvarsall.bat`, and using `subprocess` also solves this. Reviewed By: wez Differential Revision: D17493897 fbshipit-source-id: e0477627fc1824b0efcb1fa5a782d207853bcae8 --- build/fbcode_builder/getdeps/builder.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/fbcode_builder/getdeps/builder.py b/build/fbcode_builder/getdeps/builder.py index 9007bc5ef..477564be2 100644 --- a/build/fbcode_builder/getdeps/builder.py +++ b/build/fbcode_builder/getdeps/builder.py @@ -202,7 +202,8 @@ class CMakeBuilder(BuilderBase): from __future__ import absolute_import, division, print_function, unicode_literals import argparse -import os +import subprocess +import sys CMAKE = {cmake!r} SRC_DIR = {src_dir!r} @@ -268,8 +269,8 @@ def main(): cmd_str = " ".join(full_cmd) print("Running: %r" % (cmd_str,)) - os.chdir(BUILD_DIR) - os.execve(CMAKE, full_cmd, env) + proc = subprocess.run(full_cmd, env=env, cwd=BUILD_DIR) + sys.exit(proc.returncode) if __name__ == "__main__":