◐ Shell
clean mode source ↗

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

88

import copy

99

import gyp.input

1010

import argparse

@@ -24,6 +24,18 @@

2424

DEBUG_VARIABLES = "variables"

2525

DEBUG_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

27392840

def DebugOutput(mode, message, *args):

2941

if "all" in gyp.debug or mode in gyp.debug:

@@ -106,18 +118,19 @@ def Load(

106118107119

output_dir = params["options"].generator_output or params["options"].toplevel_dir

108120

if 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

)

115124

else:

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.

123136

if getattr(generator, "CalculateVariables", None):

@@ -253,7 +266,7 @@ def Noop(value):

253266

for name, metadata in options._regeneration_metadata.items():

254267

opt = metadata["opt"]

255268

value = getattr(options, name)

256-

value_predicate = metadata["type"] == "path" and FixPath or Noop

269+

value_predicate = (metadata["type"] == "path" and FixPath) or Noop

257270

action = metadata["action"]

258271

env_name = metadata["env_name"]

259272

if action == "append":