aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build_scripts/main.py31
-rw-r--r--testing/runner.py34
2 files changed, 39 insertions, 26 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py
index ad6cc04ad..0fec51a6a 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -201,20 +201,16 @@ if not os.path.exists(OPTION_CMAKE):
print("'{}' does not exist.".format(OPTION_CMAKE))
sys.exit(1)
-if sys.platform == "win32":
- if OPTION_MAKESPEC is None:
- OPTION_MAKESPEC = "msvc"
- if not OPTION_MAKESPEC in ["msvc", "mingw"]:
- print("Invalid option --make-spec. Available values are {}".format(
- ["msvc", "mingw"]))
- sys.exit(1)
-else:
- if OPTION_MAKESPEC is None:
- OPTION_MAKESPEC = "make"
- if not OPTION_MAKESPEC in ["make"]:
- print("Invalid option --make-spec. Available values are {}".format(
- ["make"]))
- sys.exit(1)
+# First element is default
+available_mkspecs = ["msvc", "mingw", "ninja"] if sys.platform == "win32" else ["make", "ninja"]
+
+if OPTION_MAKESPEC is None:
+ OPTION_MAKESPEC = available_mkspecs[0]
+
+if not OPTION_MAKESPEC in available_mkspecs:
+ print('Invalid option --make-spec "{}". Available values are {}'.format(
+ OPTION_MAKESPEC, available_mkspecs))
+ sys.exit(1)
if OPTION_JOBS:
if sys.platform == 'win32' and OPTION_NO_JOM:
@@ -491,6 +487,9 @@ class PysideBuild(_build):
elif OPTION_MAKESPEC == "mingw":
make_name = "mingw32-make"
make_generator = "MinGW Makefiles"
+ elif OPTION_MAKESPEC == "ninja":
+ make_name = "ninja"
+ make_generator = "Ninja"
else:
raise DistutilsSetupError(
"Invalid option --make-spec.")
@@ -1107,7 +1106,9 @@ class PysideBuild(_build):
log.info("Waiting 1 second, to ensure installation is "
"successful...")
time.sleep(1)
- if run_process([self.make_path, "install/fast"]) != 0:
+ # ninja: error: unknown target 'install/fast'
+ target = 'install/fast' if self.make_generator != 'Ninja' else 'install'
+ if run_process([self.make_path, target]) != 0:
raise DistutilsSetupError("Error pseudo installing {}".format(
extension))
else:
diff --git a/testing/runner.py b/testing/runner.py
index 3c99df71c..baa29408c 100644
--- a/testing/runner.py
+++ b/testing/runner.py
@@ -88,21 +88,14 @@ class TestRunner(object):
os.environ['PATH'] = clang_bin_dir + os.pathsep + path
print("Adding %s as detected by %s to PATH" % (clang_bin_dir, clang_dir[1]))
- def _find_ctest(self):
+ def _find_ctest_in_file(self, file_name):
"""
- Find ctest in the Makefile
-
- We no longer use make, but the ctest command directly.
- It is convenient to look for the ctest program using the Makefile.
- This serves us two purposes:
-
- - there is no dependency of the PATH variable,
- - each project is checked whether ctest was configured.
+ Helper for _find_ctest() that finds the ctest binary in a build
+ system file (ninja, Makefile).
"""
- make_path = os.path.join(self.test_dir, "Makefile")
look_for = "--force-new-ctest-process"
line = None
- with open(make_path) as makefile:
+ with open(file_name) as makefile:
for line in makefile:
if look_for in line:
break
@@ -121,6 +114,25 @@ class TestRunner(object):
ctest = re.search(r'(\S+|"([^"]+)")\s+' + look_for, line).groups()
return ctest[1] or ctest[0]
+ def _find_ctest(self):
+ """
+ Find ctest in a build system file (ninja, Makefile)
+
+ We no longer use make, but the ctest command directly.
+ It is convenient to look for the ctest program using the Makefile.
+ This serves us two purposes:
+
+ - there is no dependency of the PATH variable,
+ - each project is checked whether ctest was configured.
+ """
+ candidate_files = ["Makefile", "build.ninja"]
+ for candidate in candidate_files:
+ path = os.path.join(self.test_dir, candidate)
+ if os.path.exists(path):
+ return self._find_ctest_in_file(path)
+ raise RuntimeError('Cannot find any of the build system files {}.'.format(
+ ', '.join(candidate_files)))
+
def _setup(self):
self.ctestCommand = self._find_ctest()