diff options
author | Mathew Robinson <mathew.robinson@mongodb.com> | 2019-12-08 01:59:50 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-12-08 01:59:50 +0000 |
commit | d8acb38f17c524621e4016b811041349669601f8 (patch) | |
tree | 26e9af0db74082033218ffd8f3566f2af1ae8660 | |
parent | 7c428b6fba15eb2058d52430b8d2c5f4df45d7ad (diff) | |
download | mongo-d8acb38f17c524621e4016b811041349669601f8.tar.gz |
SERVER-44767 Add depfile support to new Ninja generator
-rw-r--r-- | etc/evergreen.yml | 2 | ||||
-rw-r--r-- | site_scons/site_tools/ninja.py | 42 |
2 files changed, 42 insertions, 2 deletions
diff --git a/etc/evergreen.yml b/etc/evergreen.yml index 181c822e267..db27ac5281c 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -3955,7 +3955,7 @@ tasks: task_compile_flags: >- --ninja targets: - all.build.ninja + new.build.ninja - command: shell.exec params: working_dir: src diff --git a/site_scons/site_tools/ninja.py b/site_scons/site_tools/ninja.py index 6c342b1aa00..eb6317e8513 100644 --- a/site_scons/site_tools/ninja.py +++ b/site_scons/site_tools/ninja.py @@ -357,6 +357,12 @@ class NinjaState: sys.executable, " ".join([escape(arg) for arg in sys.argv]) ), + + # This must be set to a global default per: + # https://ninja-build.org/manual.html + # + # (The deps section) + "msvc_deps_prefix": "Note: including file:", } self.rules = { @@ -364,6 +370,13 @@ class NinjaState: "command": "cmd /c $cmd" if sys.platform == "win32" else "$cmd", "description": "Building $out", }, + + # We add the deps processing variables to this below. + "CMD_W_DEPS": { + "command": "cmd /c $cmd" if sys.platform == "win32" else "$cmd", + "description": "Building $out", + }, + "SYMLINK": { "command": ( "cmd /c mklink $out $in" @@ -416,6 +429,13 @@ class NinjaState: "restat": 1, }, } + + if env["PLATFORM"] == "win32": + self.rules["CMD_W_DEPS"]["deps"] = "msvc" + else: + self.rules["CMD_W_DEPS"]["deps"] = "gcc" + self.rules["CMD_W_DEPS"]["depfile"] = "$out.d" + self.rules.update(env.get(NINJA_RULES, {})) def generate_builds(self, node): @@ -702,10 +722,25 @@ def get_command(env, node, action): # pylint: disable=too-many-branches if cmd.endswith("&&"): cmd = cmd[0:-2].strip() + rule = "CMD" + + # Use NO COMPILER as the default value because the obvious choice + # ('') empty string always returns true with in. + # + # If you'd done something clever here like env['CC'] = + # my_generator_function this will break. In the interest of perf + # we aren't going to subst this again. Once Subst caching is done + # perhaps we should revisit this since the value will be + # pre-computed for CC by generating this command line. + CC = sub_env.get('CC', 'NO COMPILER') + CXX = sub_env.get('CXX', 'NO COMPILER') + if CC in cmd or CXX in cmd: + rule = "CMD_W_DEPS" + return { "outputs": get_outputs(node), "implicit": implicit, - "rule": "CMD", + "rule": rule, "variables": {"cmd": cmd}, } @@ -860,6 +895,11 @@ def generate(env): ninja_builder_obj = SCons.Builder.Builder(action=always_exec_ninja_action) env.Append(BUILDERS={"Ninja": ninja_builder_obj}) + if env["PLATFORM"] == "win32": + env.Append(CCFLAGS=["/showIncludes"]) + else: + env.Append(CCFLAGS=["-MMD", "-MF", "${TARGET}.d"]) + # Provides a way for users to handle custom FunctionActions they # want to translate to Ninja. env[NINJA_CUSTOM_HANDLERS] = {} |