From dee0f733cdb3cab7714326574efc8a1ae4ec750f Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Tue, 3 Aug 2021 12:09:31 -0500 Subject: [PATCH] SERVER-58904 update ninja tool to support $ in scons command line args. --- site_scons/site_tools/next/ninja.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/site_scons/site_tools/next/ninja.py b/site_scons/site_tools/next/ninja.py index 67d27490c77..8961764d08b 100644 --- a/site_scons/site_tools/next/ninja.py +++ b/site_scons/site_tools/next/ninja.py @@ -423,9 +423,9 @@ class SConsToNinjaTranslator: class NinjaState: """Maintains state of Ninja build system as it's translated from SCons.""" - def __init__(self, env, writer_class): + def __init__(self, env, ninja_syntax): self.env = env - self.writer_class = writer_class + self.writer_class = ninja_syntax.Writer self.__generated = False self.translator = SConsToNinjaTranslator(env) self.generated_suffixes = env.get("NINJA_GENERATED_SOURCE_SUFFIXES", []) @@ -442,18 +442,18 @@ class NinjaState: # shell quoting on whatever platform it's run on. Here we use it # to make the SCONS_INVOCATION variable properly quoted for things # like CCFLAGS - escape = env.get("ESCAPE", lambda x: x) + scons_escape = env.get("ESCAPE", lambda x: x) self.variables = { "COPY": "cmd.exe /c 1>NUL copy" if sys.platform == "win32" else "cp", "SCONS_INVOCATION": "{} {} __NINJA_NO=1 $out".format( sys.executable, " ".join( - [escape(arg) for arg in sys.argv if arg not in COMMAND_LINE_TARGETS] + [ninja_syntax.escape(scons_escape(arg)) for arg in sys.argv if arg not in COMMAND_LINE_TARGETS] ), ), "SCONS_INVOCATION_W_TARGETS": "{} {}".format( - sys.executable, " ".join([escape(arg) for arg in sys.argv]) + sys.executable, " ".join([ninja_syntax.escape(scons_escape(arg)) for arg in sys.argv]) ), # This must be set to a global default per: # https://ninja-build.org/manual.html @@ -1612,7 +1612,7 @@ def generate(env): ninja_syntax = importlib.import_module(ninja_syntax_mod_name.replace(".py", "")) global NINJA_STATE - NINJA_STATE = NinjaState(env, ninja_syntax.Writer) + NINJA_STATE = NinjaState(env, ninja_syntax) # Here we will force every builder to use an emitter which makes the ninja # file depend on it's target. This forces the ninja file to the bottom of