summaryrefslogtreecommitdiffstats
path: root/SConstruct
diff options
context:
space:
mode:
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct23
1 files changed, 20 insertions, 3 deletions
diff --git a/SConstruct b/SConstruct
index 753cea40e3..73ef420a0d 100644
--- a/SConstruct
+++ b/SConstruct
@@ -203,6 +203,7 @@ opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursi
opts.Add(BoolVariable("dev_mode", "Alias for dev options: verbose=yes warnings=extra werror=yes tests=yes", False))
opts.Add(BoolVariable("tests", "Build the unit tests", False))
opts.Add(BoolVariable("fast_unsafe", "Enable unsafe options for faster rebuilds", False))
+opts.Add(BoolVariable("ninja", "Use the ninja backend for faster rebuilds", False))
opts.Add(BoolVariable("compiledb", "Generate compilation DB (`compile_commands.json`) for external tools", False))
opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))
opts.Add(BoolVariable("progress", "Show a progress indicator during compilation", True))
@@ -956,7 +957,8 @@ if selected_platform in platform_list:
env.vs_incs = []
env.vs_srcs = []
- # CompileDB
+ # CompileDB and Ninja are only available with certain SCons versions which
+ # not everybody might have yet, so we have to check.
from SCons import __version__ as scons_raw_version
scons_ver = env._get_major_minor_revision(scons_raw_version)
@@ -968,6 +970,20 @@ if selected_platform in platform_list:
env.Tool("compilation_db")
env.Alias("compiledb", env.CompilationDatabase())
+ if env["ninja"]:
+ if scons_ver < (4, 2, 0):
+ print("The `ninja=yes` option requires SCons 4.2 or later, but your version is %s." % scons_raw_version)
+ Exit(255)
+
+ SetOption("experimental", "ninja")
+
+ # By setting this we allow the user to run ninja by themselves with all
+ # the flags they need, as apparently automatically running from scons
+ # is way slower.
+ SetOption("disable_execute_ninja", True)
+
+ env.Tool("ninja")
+
# Threads
if env["threads"]:
env.Append(CPPDEFINES=["THREADS_ENABLED"])
@@ -1041,9 +1057,10 @@ atexit.register(print_elapsed_time)
def purge_flaky_files():
+ paths_to_keep = ["ninja.build"]
for build_failure in GetBuildFailures():
- path = build_failure.node.abspath
- if os.path.isfile(path):
+ path = build_failure.node.path
+ if os.path.isfile(path) and path not in paths_to_keep:
os.remove(path)