tools: update gyp-next to 0.19.0 · nodejs/node@e20eef6
@@ -4,7 +4,7 @@
44# Use of this source code is governed by a BSD-style license that can be
55# found in the LICENSE file.
667-7+from __future__ import annotations
88import copy
99import gyp.input
1010import argparse
@@ -24,6 +24,18 @@
2424DEBUG_VARIABLES = "variables"
2525DEBUG_INCLUDES = "includes"
262627+def EscapeForCString(string: bytes | str) -> str:
28+if isinstance(string, str):
29+string = string.encode(encoding='utf8')
30+31+backslash_or_double_quote = {ord('\\'), ord('"')}
32+result = []
33+for char in string:
34+if char in backslash_or_double_quote or not 32 <= char < 127:
35+result += '\\%03o' % char
36+else:
37+result += chr(char)
38+return result
27392840def DebugOutput(mode, message, *args):
2941if "all" in gyp.debug or mode in gyp.debug:
@@ -106,18 +118,19 @@ def Load(
106118107119output_dir = params["options"].generator_output or params["options"].toplevel_dir
108120if default_variables["GENERATOR"] == "ninja":
109-default_variables.setdefault(
110-"PRODUCT_DIR_ABS",
111-os.path.join(
112-output_dir, "out", default_variables.get("build_type", "default")
113- ),
121+product_dir_abs = os.path.join(
122+output_dir, "out", default_variables.get("build_type", "default")
114123 )
115124else:
116-default_variables.setdefault(
117-"PRODUCT_DIR_ABS",
118-os.path.join(output_dir, default_variables["CONFIGURATION_NAME"]),
125+product_dir_abs = os.path.join(
126+output_dir, default_variables["CONFIGURATION_NAME"]
119127 )
120128129+default_variables.setdefault("PRODUCT_DIR_ABS", product_dir_abs)
130+default_variables.setdefault(
131+"PRODUCT_DIR_ABS_CSTR", EscapeForCString(product_dir_abs)
132+ )
133+121134# Give the generator the opportunity to set additional variables based on
122135# the params it will receive in the output phase.
123136if getattr(generator, "CalculateVariables", None):
@@ -253,7 +266,7 @@ def Noop(value):
253266for name, metadata in options._regeneration_metadata.items():
254267opt = metadata["opt"]
255268value = getattr(options, name)
256-value_predicate = metadata["type"] == "path" and FixPath or Noop
269+value_predicate = (metadata["type"] == "path" and FixPath) or Noop
257270action = metadata["action"]
258271env_name = metadata["env_name"]
259272if action == "append":