Skip to content

Commit a88e4ce

Browse files
nodejs-github-botruyadorno
authored andcommitted
tools: update gyp-next to 0.19.0
PR-URL: #56158 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent bd0760e commit a88e4ce

11 files changed

+53
-36
lines changed

tools/gyp/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.19.0](https://github.com/nodejs/gyp-next/compare/v0.18.3...v0.19.0) (2024-12-03)
4+
5+
6+
### Features
7+
8+
* provide escaped version of `PRODUCT_DIR_ABS` ([#271](https://github.com/nodejs/gyp-next/issues/271)) ([3bf3b1c](https://github.com/nodejs/gyp-next/commit/3bf3b1cda26f16c645e0fdd5582ffbf49d9a2580))
9+
310
## [0.18.3](https://github.com/nodejs/gyp-next/compare/v0.18.2...v0.18.3) (2024-10-08)
411

512

tools/gyp/pylib/gyp/MSVSSettings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def ValidateMSBuild(self, value):
171171
int(value, self._msbuild_base)
172172

173173
def ConvertToMSBuild(self, value):
174-
msbuild_format = (self._msbuild_base == 10) and "%d" or "0x%04x"
174+
msbuild_format = ((self._msbuild_base == 10) and "%d") or "0x%04x"
175175
return msbuild_format % int(value)
176176

177177

tools/gyp/pylib/gyp/MSVSVersion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def UsesVcxproj(self):
6969

7070
def ProjectExtension(self):
7171
"""Returns the file extension for the project."""
72-
return self.uses_vcxproj and ".vcxproj" or ".vcproj"
72+
return (self.uses_vcxproj and ".vcxproj") or ".vcproj"
7373

7474
def Path(self):
7575
"""Returns the path to Visual Studio installation."""

tools/gyp/pylib/gyp/__init__.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -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.
66

7-
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"
2626

27+
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
2739

2840
def DebugOutput(mode, message, *args):
2941
if "all" in gyp.debug or mode in gyp.debug:
@@ -106,18 +118,19 @@ def Load(
106118

107119
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
)
120128

129+
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":

tools/gyp/pylib/gyp/generator/make.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ def __init__(self, generator_flags, flavor):
788788
self.suffix_rules_objdir2 = {}
789789

790790
# Generate suffix rules for all compilable extensions.
791-
for ext in COMPILABLE_EXTENSIONS:
791+
for ext, value in COMPILABLE_EXTENSIONS.items():
792792
# Suffix rules for source folder.
793793
self.suffix_rules_srcdir.update(
794794
{
@@ -797,7 +797,7 @@ def __init__(self, generator_flags, flavor):
797797
$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD
798798
\t@$(call do_cmd,%s,1)
799799
"""
800-
% (ext, COMPILABLE_EXTENSIONS[ext])
800+
% (ext, value)
801801
)
802802
}
803803
)
@@ -810,7 +810,7 @@ def __init__(self, generator_flags, flavor):
810810
$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD
811811
\t@$(call do_cmd,%s,1)
812812
"""
813-
% (ext, COMPILABLE_EXTENSIONS[ext])
813+
% (ext, value)
814814
)
815815
}
816816
)
@@ -821,7 +821,7 @@ def __init__(self, generator_flags, flavor):
821821
$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
822822
\t@$(call do_cmd,%s,1)
823823
"""
824-
% (ext, COMPILABLE_EXTENSIONS[ext])
824+
% (ext, value)
825825
)
826826
}
827827
)
@@ -1779,13 +1779,13 @@ def WriteTarget(
17791779
# using ":=".
17801780
self.WriteSortedXcodeEnv(self.output, self.GetSortedXcodePostbuildEnv())
17811781

1782-
for configname in target_postbuilds:
1782+
for configname, value in target_postbuilds.items():
17831783
self.WriteLn(
17841784
"%s: TARGET_POSTBUILDS_%s := %s"
17851785
% (
17861786
QuoteSpaces(self.output),
17871787
configname,
1788-
gyp.common.EncodePOSIXShellList(target_postbuilds[configname]),
1788+
gyp.common.EncodePOSIXShellList(value),
17891789
)
17901790
)
17911791

tools/gyp/pylib/gyp/input.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -2469,11 +2469,8 @@ def SetUpConfigurations(target, target_dict):
24692469
merged_configurations[configuration] = new_configuration_dict
24702470

24712471
# Put the new configurations back into the target dict as a configuration.
2472-
for configuration in merged_configurations:
2473-
target_dict["configurations"][configuration] = merged_configurations[
2474-
configuration
2475-
]
2476-
2472+
for configuration, value in merged_configurations.items():
2473+
target_dict["configurations"][configuration] = value
24772474
# Now drop all the abstract ones.
24782475
configs = target_dict["configurations"]
24792476
target_dict["configurations"] = {
@@ -3020,8 +3017,8 @@ def Load(
30203017
del target_dict[key]
30213018
ProcessListFiltersInDict(target_name, tmp_dict)
30223019
# Write the results back to |target_dict|.
3023-
for key in tmp_dict:
3024-
target_dict[key] = tmp_dict[key]
3020+
for key, value in tmp_dict.items():
3021+
target_dict[key] = value
30253022

30263023
# Make sure every dependency appears at most once.
30273024
RemoveDuplicateDependencies(targets)

tools/gyp/pylib/gyp/xcode_emulation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,8 @@ def _GetIOSPostbuilds(self, configname, output_binary):
11271127
be deployed to a device. This should be run as the very last step of the
11281128
build."""
11291129
if not (
1130-
self.isIOS
1131-
and (self.spec["type"] == "executable" or self._IsXCTest())
1130+
(self.isIOS
1131+
and (self.spec["type"] == "executable" or self._IsXCTest()))
11321132
or self.IsIosFramework()
11331133
):
11341134
return []

tools/gyp/pylib/gyp/xcodeproj_file.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3017,10 +3017,10 @@ def _AllSymrootsUnique(self, target, inherit_unique_symroot):
30173017
symroots = self._DefinedSymroots(target)
30183018
for s in self._DefinedSymroots(target):
30193019
if (
3020-
s is not None
3021-
and not self._IsUniqueSymrootForTarget(s)
3022-
or s is None
3023-
and not inherit_unique_symroot
3020+
(s is not None
3021+
and not self._IsUniqueSymrootForTarget(s))
3022+
or (s is None
3023+
and not inherit_unique_symroot)
30243024
):
30253025
return False
30263026
return True if symroots else inherit_unique_symroot

tools/gyp/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "gyp-next"
7-
version = "0.18.3"
7+
version = "0.19.0"
88
authors = [
99
{ name="Node.js contributors", email="[email protected]" },
1010
]

tools/gyp/tools/pretty_sln.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ def ParseSolution(solution_file):
9393
continue
9494

9595
# Change all dependencies clsid to name instead.
96-
for project in dependencies:
96+
for project, deps in dependencies.items():
9797
# For each dependencies in this project
9898
new_dep_array = []
99-
for dep in dependencies[project]:
99+
for dep in deps:
100100
# Look for the project name matching this cldis
101101
for project_info in projects:
102102
if projects[project_info][1] == dep:

tools/gyp/tools/pretty_vcproj.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ def FixFilenames(filenames, current_directory):
118118
new_list = []
119119
for filename in filenames:
120120
if filename:
121-
for key in REPLACEMENTS:
122-
filename = filename.replace(key, REPLACEMENTS[key])
121+
for key, value in REPLACEMENTS.items():
122+
filename = filename.replace(key, value)
123123
os.chdir(current_directory)
124124
filename = filename.strip("\"' ")
125125
if filename.startswith("$"):

0 commit comments

Comments
 (0)