tools: update gyp-next to 0.20.4

PR-URL: https://github.com/nodejs/node/pull/59690
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
Node.js GitHub Bot 2025-09-02 02:08:00 +01:00 committed by GitHub
parent 255dd7b62c
commit ff533758df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
44 changed files with 1977 additions and 1997 deletions

View File

@ -1,5 +1,13 @@
# Changelog
## [0.20.4](https://github.com/nodejs/gyp-next/compare/v0.20.3...v0.20.4) (2025-08-25)
### Bug Fixes
* **cli:** remove duplicate usage ([#308](https://github.com/nodejs/gyp-next/issues/308)) ([0996f60](https://github.com/nodejs/gyp-next/commit/0996f60e9bc83ec9d7b31e39bebd23f8dc990130))
* **docs:** Add running gyp via uv ([#306](https://github.com/nodejs/gyp-next/issues/306)) ([0e43f61](https://github.com/nodejs/gyp-next/commit/0e43f61da8154f9b460ccba9ce4c0a25d2383ac4))
## [0.20.3](https://github.com/nodejs/gyp-next/compare/v0.20.2...v0.20.3) (2025-08-20)

View File

@ -6,8 +6,9 @@ Documents are available at [`./docs`](./docs).
__gyp-next__ is [released](https://github.com/nodejs/gyp-next/releases) to the [__Python Packaging Index__](https://pypi.org/project/gyp-next) (PyPI) and can be installed with the command:
* `python3 -m pip install gyp-next`
When used as a command line utility, __gyp-next__ can also be installed with [pipx](https://pypa.github.io/pipx):
* `pipx install gyp-next`
When used as a command line utility, __gyp-next__ can also be installed with [pipx](https://pypa.github.io/pipx) or [uv](https://docs.astral.sh/uv):
* `pipx install gyp-next ` # --or--
* `uv tool install gyp-next`
```
Installing to a new venv 'gyp-next'
installed package gyp-next 0.13.0, installed using Python 3.10.6
@ -17,10 +18,11 @@ done! ✨ 🌟 ✨
```
Or to run __gyp-next__ directly without installing it:
* `pipx run gyp-next --help`
* `pipx run gyp-next --help ` # --or--
* `uvx --from=gyp-next gyp --help`
```
NOTE: running app 'gyp' from 'gyp-next'
usage: usage: gyp [options ...] [build_file ...]
usage: gyp [options ...] [build_file ...]
options:
-h, --help show this help message and exit

View File

@ -637,7 +637,9 @@ _Same(
),
) # /RTC1
_Same(
_compile, "BrowseInformation", _Enumeration(["false", "true", "true"]) # /FR
_compile,
"BrowseInformation",
_Enumeration(["false", "true", "true"]), # /FR
) # /Fr
_Same(
_compile,
@ -695,7 +697,9 @@ _Same(
_Enumeration(["false", "Sync", "Async"], new=["SyncCThrow"]), # /EHsc # /EHa
) # /EHs
_Same(
_compile, "FavorSizeOrSpeed", _Enumeration(["Neither", "Speed", "Size"]) # /Ot
_compile,
"FavorSizeOrSpeed",
_Enumeration(["Neither", "Speed", "Size"]), # /Ot
) # /Os
_Same(
_compile,
@ -908,7 +912,9 @@ _target_machine_enumeration = _Enumeration(
) # /MACHINE:X64
_Same(
_link, "AssemblyDebug", _Enumeration(["", "true", "false"]) # /ASSEMBLYDEBUG
_link,
"AssemblyDebug",
_Enumeration(["", "true", "false"]), # /ASSEMBLYDEBUG
) # /ASSEMBLYDEBUG:DISABLE
_Same(
_link,
@ -1158,17 +1164,23 @@ _Renamed(_midl, "ValidateParameters", "ValidateAllParameters", _boolean) # /rob
_MSBuildOnly(_midl, "ApplicationConfigurationMode", _boolean) # /app_config
_MSBuildOnly(_midl, "ClientStubFile", _file_name) # /cstub
_MSBuildOnly(
_midl, "GenerateClientFiles", _Enumeration([], new=["Stub", "None"]) # /client stub
_midl,
"GenerateClientFiles",
_Enumeration([], new=["Stub", "None"]), # /client stub
) # /client none
_MSBuildOnly(
_midl, "GenerateServerFiles", _Enumeration([], new=["Stub", "None"]) # /client stub
_midl,
"GenerateServerFiles",
_Enumeration([], new=["Stub", "None"]), # /client stub
) # /client none
_MSBuildOnly(_midl, "LocaleID", _integer) # /lcid DECIMAL
_MSBuildOnly(_midl, "ServerStubFile", _file_name) # /sstub
_MSBuildOnly(_midl, "SuppressCompilerWarnings", _boolean) # /no_warn
_MSBuildOnly(_midl, "TrackerLogDirectory", _folder_name)
_MSBuildOnly(
_midl, "TypeLibFormat", _Enumeration([], new=["NewFormat", "OldFormat"]) # /newtlb
_midl,
"TypeLibFormat",
_Enumeration([], new=["NewFormat", "OldFormat"]), # /newtlb
) # /oldtlb

View File

@ -1346,8 +1346,7 @@ class TestSequenceFunctions(unittest.TestCase):
"EmbedManifest": "false",
"GenerateCatalogFiles": "true",
"InputResourceManifests": "asfsfdafs",
"ManifestResourceFile":
"$(IntDir)\\$(TargetFileName).embed.manifest.resfdsf",
"ManifestResourceFile": "$(IntDir)\\$(TargetFileName).embed.manifest.resfdsf", # noqa: E501
"OutputManifestFile": "$(TargetPath).manifestdfs",
"RegistrarScriptFile": "sdfsfd",
"ReplacementsFile": "sdffsd",
@ -1531,8 +1530,7 @@ class TestSequenceFunctions(unittest.TestCase):
"LinkIncremental": "",
},
"ManifestResourceCompile": {
"ResourceOutputFileName":
"$(IntDir)$(TargetFileName).embed.manifest.resfdsf"
"ResourceOutputFileName": "$(IntDir)$(TargetFileName).embed.manifest.resfdsf" # noqa: E501
},
}
self.maxDiff = 9999 # on failure display a long diff

View File

@ -220,6 +220,7 @@ def _RegistryGetValueUsingWinReg(key, value):
ImportError if winreg is unavailable.
"""
from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx # noqa: PLC0415
try:
root, subkey = key.split("\\", 1)
assert root == "HKLM" # Only need HKLM for now.

View File

@ -25,19 +25,21 @@ DEBUG_GENERAL = "general"
DEBUG_VARIABLES = "variables"
DEBUG_INCLUDES = "includes"
def EscapeForCString(string: bytes | str) -> str:
if isinstance(string, str):
string = string.encode(encoding='utf8')
string = string.encode(encoding="utf8")
backslash_or_double_quote = {ord('\\'), ord('"')}
result = ''
backslash_or_double_quote = {ord("\\"), ord('"')}
result = ""
for char in string:
if char in backslash_or_double_quote or not 32 <= char < 127:
result += '\\%03o' % char
result += "\\%03o" % char
else:
result += chr(char)
return result
def DebugOutput(mode, message, *args):
if "all" in gyp.debug or mode in gyp.debug:
ctx = ("unknown", 0, "unknown")
@ -114,7 +116,7 @@ def Load(
# These parameters are passed in order (as opposed to by key)
# because ActivePython cannot handle key parameters to __import__.
generator = __import__(generator_name, globals(), locals(), generator_name)
for (key, val) in generator.generator_default_variables.items():
for key, val in generator.generator_default_variables.items():
default_variables.setdefault(key, val)
output_dir = params["options"].generator_output or params["options"].toplevel_dir
@ -343,7 +345,7 @@ class RegeneratableOptionParser(argparse.ArgumentParser):
def gyp_main(args):
my_name = os.path.basename(sys.argv[0])
usage = "usage: %(prog)s [options ...] [build_file ...]"
usage = "%(prog)s [options ...] [build_file ...]"
parser = RegeneratableOptionParser(usage=usage.replace("%s", "%(prog)s"))
parser.add_argument(
@ -490,6 +492,7 @@ def gyp_main(args):
options, build_files_arg = parser.parse_args(args)
if options.version:
import pkg_resources # noqa: PLC0415
print(f"v{pkg_resources.get_distribution('gyp-next').version}")
return 0
build_files = build_files_arg

View File

@ -35,7 +35,6 @@ class GypError(Exception):
"""
def ExceptionAppend(e, msg):
"""Append a message to the given exception's message."""
if not e.args:
@ -312,14 +311,12 @@ def DeepDependencyTargets(target_dicts, roots):
def BuildFileTargets(target_list, build_file):
"""From a target_list, returns the subset from the specified build_file.
"""
"""From a target_list, returns the subset from the specified build_file."""
return [p for p in target_list if BuildFile(p) == build_file]
def AllTargets(target_list, target_dicts, build_file):
"""Returns all targets (direct and dependencies) for the specified build_file.
"""
"""Returns all targets (direct and dependencies) for the specified build_file."""
bftargets = BuildFileTargets(target_list, build_file)
deptargets = DeepDependencyTargets(target_dicts, bftargets)
return bftargets + deptargets
@ -421,6 +418,7 @@ def EnsureDirExists(path):
except OSError:
pass
def GetCompilerPredefines(): # -> dict
cmd = []
defines = {}
@ -448,15 +446,14 @@ def GetCompilerPredefines(): # -> dict
try:
os.close(fd)
stdout = subprocess.run(
real_cmd, shell=True,
capture_output=True, check=True
real_cmd, shell=True, capture_output=True, check=True
).stdout
except subprocess.CalledProcessError as e:
print(
"Warning: failed to get compiler predefines\n"
"cmd: %s\n"
"status: %d" % (e.cmd, e.returncode),
file=sys.stderr
file=sys.stderr,
)
return defines
finally:
@ -466,15 +463,14 @@ def GetCompilerPredefines(): # -> dict
real_cmd = [*cmd, "-dM", "-E", "-x", "c", input]
try:
stdout = subprocess.run(
real_cmd, shell=False,
capture_output=True, check=True
real_cmd, shell=False, capture_output=True, check=True
).stdout
except subprocess.CalledProcessError as e:
print(
"Warning: failed to get compiler predefines\n"
"cmd: %s\n"
"status: %d" % (e.cmd, e.returncode),
file=sys.stderr
file=sys.stderr,
)
return defines
@ -485,6 +481,7 @@ def GetCompilerPredefines(): # -> dict
defines[key] = " ".join(value)
return defines
def GetFlavorByPlatform():
"""Returns |params.flavor| if it's set, the system's default flavor else."""
flavors = {
@ -512,6 +509,7 @@ def GetFlavorByPlatform():
return "linux"
def GetFlavor(params):
if "flavor" in params:
return params["flavor"]

View File

@ -28,8 +28,12 @@ class TestTopologicallySorted(unittest.TestCase):
def GetEdge(node):
return tuple(graph[node])
assert gyp.common.TopologicallySorted(
graph.keys(), GetEdge) == ["a", "c", "d", "b"]
assert gyp.common.TopologicallySorted(graph.keys(), GetEdge) == [
"a",
"c",
"d",
"b",
]
def test_Cycle(self):
"""Test that an exception is thrown on a cyclic graph."""
@ -97,10 +101,7 @@ class TestGetFlavor(unittest.TestCase):
if throws:
mock_run.side_effect = subprocess.CalledProcessError(
returncode=1,
cmd=[
*expected_cmd,
"-dM", "-E", "-x", "c", expected_input
]
cmd=[*expected_cmd, "-dM", "-E", "-x", "c", expected_input],
)
else:
mock_process = MagicMock()
@ -115,12 +116,11 @@ class TestGetFlavor(unittest.TestCase):
flavor = gyp.common.GetFlavor({})
if env.get("CC_target") or env.get("CC"):
mock_run.assert_called_with(
[
*expected_cmd,
"-dM", "-E", "-x", "c", expected_input
],
[*expected_cmd, "-dM", "-E", "-x", "c", expected_input],
shell=sys.platform == "win32",
capture_output=True, check=True)
capture_output=True,
check=True,
)
return [defines, flavor]
[defines0, _] = mock_run({"CC": "cl.exe"}, "", ["cl.exe"], True)
@ -132,7 +132,7 @@ class TestGetFlavor(unittest.TestCase):
[defines2, flavor2] = mock_run(
{"CC_target": "/opt/wasi-sdk/bin/clang"},
"#define __wasm__ 1\n#define __wasi__ 1\n",
["/opt/wasi-sdk/bin/clang"]
["/opt/wasi-sdk/bin/clang"],
)
assert defines2 == {"__wasm__": "1", "__wasi__": "1"}
assert flavor2 == "wasi"
@ -140,7 +140,7 @@ class TestGetFlavor(unittest.TestCase):
[defines3, flavor3] = mock_run(
{"CC_target": "/opt/wasi-sdk/bin/clang --target=wasm32"},
"#define __wasm__ 1\n",
["/opt/wasi-sdk/bin/clang", "--target=wasm32"]
["/opt/wasi-sdk/bin/clang", "--target=wasm32"],
)
assert defines3 == {"__wasm__": "1"}
assert flavor3 == "wasm"
@ -148,7 +148,7 @@ class TestGetFlavor(unittest.TestCase):
[defines4, flavor4] = mock_run(
{"CC_target": "/emsdk/upstream/emscripten/emcc"},
"#define __EMSCRIPTEN__ 1\n",
["/emsdk/upstream/emscripten/emcc"]
["/emsdk/upstream/emscripten/emcc"],
)
assert defines4 == {"__EMSCRIPTEN__": "1"}
assert flavor4 == "emscripten"
@ -156,34 +156,31 @@ class TestGetFlavor(unittest.TestCase):
# Test path which include white space
[defines5, flavor5] = mock_run(
{
"CC_target": "\"/Users/Toyo Li/wasi-sdk/bin/clang\" -O3",
"CFLAGS": "--target=wasm32-wasi-threads -pthread"
"CC_target": '"/Users/Toyo Li/wasi-sdk/bin/clang" -O3',
"CFLAGS": "--target=wasm32-wasi-threads -pthread",
},
"#define __wasm__ 1\n#define __wasi__ 1\n#define _REENTRANT 1\n",
[
"/Users/Toyo Li/wasi-sdk/bin/clang",
"-O3",
"--target=wasm32-wasi-threads",
"-pthread"
]
"-pthread",
],
)
assert defines5 == {
"__wasm__": "1",
"__wasi__": "1",
"_REENTRANT": "1"
}
assert defines5 == {"__wasm__": "1", "__wasi__": "1", "_REENTRANT": "1"}
assert flavor5 == "wasi"
original_sep = os.sep
os.sep = "\\"
[defines6, flavor6] = mock_run(
{ "CC_target": "\"C:\\Program Files\\wasi-sdk\\clang.exe\"" },
{"CC_target": '"C:\\Program Files\\wasi-sdk\\clang.exe"'},
"#define __wasm__ 1\n#define __wasi__ 1\n",
["C:/Program Files/wasi-sdk/clang.exe"]
["C:/Program Files/wasi-sdk/clang.exe"],
)
os.sep = original_sep
assert defines6 == {"__wasm__": "1", "__wasi__": "1"}
assert flavor6 == "wasi"
if __name__ == "__main__":
unittest.main()

View File

@ -107,8 +107,9 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0):
xml_parts.append("/>%s" % new_line)
def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False,
win32=(sys.platform == "win32")):
def WriteXmlIfChanged(
content, path, encoding="utf-8", pretty=False, win32=(sys.platform == "win32")
):
"""Writes the XML content to disk, touching the file only if it has changed.
Args:

View File

@ -62,7 +62,6 @@ directly supplied to gyp. OTOH if both "a.gyp" and "b.gyp" are supplied to gyp
then the "all" target includes "b1" and "b2".
"""
import json
import os
import posixpath
@ -379,9 +378,10 @@ def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files, build
target_type = target_dicts[target_name]["type"]
target.is_executable = target_type == "executable"
target.is_static_library = target_type == "static_library"
target.is_or_has_linked_ancestor = (
target_type in {"executable", "shared_library"}
)
target.is_or_has_linked_ancestor = target_type in {
"executable",
"shared_library",
}
build_file = gyp.common.ParseQualifiedTarget(target_name)[0]
if build_file not in build_file_in_files:
@ -451,10 +451,10 @@ def _DoesTargetDependOnMatchingTargets(target):
target: the Target to look for."""
if target.match_status == MATCH_STATUS_DOESNT_MATCH:
return False
if (
target.match_status in {MATCH_STATUS_MATCHES,
MATCH_STATUS_MATCHES_BY_DEPENDENCY}
):
if target.match_status in {
MATCH_STATUS_MATCHES,
MATCH_STATUS_MATCHES_BY_DEPENDENCY,
}:
return True
for dep in target.deps:
if _DoesTargetDependOnMatchingTargets(dep):

View File

@ -177,9 +177,7 @@ class AndroidMkWriter:
self.WriteLn("LOCAL_IS_HOST_MODULE := true")
self.WriteLn("LOCAL_MULTILIB := $(GYP_HOST_MULTILIB)")
elif sdk_version > 0:
self.WriteLn(
"LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH)"
)
self.WriteLn("LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH)")
self.WriteLn("LOCAL_SDK_VERSION := %s" % sdk_version)
# Grab output directories; needed for Actions and Rules.
@ -588,7 +586,8 @@ class AndroidMkWriter:
local_files = []
for source in sources:
(root, ext) = os.path.splitext(source)
if ("$(gyp_shared_intermediate_dir)" in source
if (
"$(gyp_shared_intermediate_dir)" in source
or "$(gyp_intermediate_dir)" in source
or (IsCPPExtension(ext) and ext != local_cpp_extension)
):
@ -734,8 +733,7 @@ class AndroidMkWriter:
elif self.toolset == "host":
path = (
"$(call intermediates-dir-for,%s,%s,true,,"
"$(GYP_HOST_VAR_PREFIX))"
% (self.android_class, self.android_module)
"$(GYP_HOST_VAR_PREFIX))" % (self.android_class, self.android_module)
)
else:
path = (
@ -1001,9 +999,9 @@ class AndroidMkWriter:
# - i.e. that the resulting path is still inside the project tree. The
# path may legitimately have ended up containing just $(LOCAL_PATH), though,
# so we don't look for a slash.
assert local_path.startswith(
"$(LOCAL_PATH)"
), f"Path {path} attempts to escape from gyp path {self.path} !)"
assert local_path.startswith("$(LOCAL_PATH)"), (
f"Path {path} attempts to escape from gyp path {self.path} !)"
)
return local_path
def ExpandInputRoot(self, template, expansion, dirname):
@ -1045,9 +1043,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
base_path = gyp.common.RelativePath(os.path.dirname(build_file), options.depth)
# We write the file in the base_path directory.
output_file = os.path.join(options.depth, base_path, base_name)
assert (
not options.generator_output
), "The Android backend does not support options.generator_output."
assert not options.generator_output, (
"The Android backend does not support options.generator_output."
)
base_path = gyp.common.RelativePath(
os.path.dirname(build_file), options.toplevel_dir
)
@ -1067,9 +1065,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
makefile_name = "GypAndroid" + options.suffix + ".mk"
makefile_path = os.path.join(options.toplevel_dir, makefile_name)
assert (
not options.generator_output
), "The Android backend does not support options.generator_output."
assert not options.generator_output, (
"The Android backend does not support options.generator_output."
)
gyp.common.EnsureDirExists(makefile_path)
root_makefile = open(makefile_path, "w")

View File

@ -28,7 +28,6 @@ not be able to find the header file directories described in the generated
CMakeLists.txt file.
"""
import multiprocessing
import os
import signal

View File

@ -30,7 +30,6 @@ The specific formatting of the output generated by this module is subject
to change.
"""
import pprint
import gyp.common

View File

@ -13,7 +13,6 @@ by the input module.
The expected usage is "gyp -f gypsh -D OS=desired_os".
"""
import code
import sys

View File

@ -218,7 +218,7 @@ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
""" % {'python': sys.executable} # noqa: E501
""" % {"python": sys.executable} # noqa: E501
LINK_COMMANDS_ANDROID = """\
quiet_cmd_alink = AR($(TOOLSET)) $@
@ -443,21 +443,27 @@ DEPFLAGS = %(makedep_args)s -MF $(depfile).raw
define fixup_dep
# The depfile may not exist if the input file didn't have any #includes.
touch $(depfile).raw
# Fixup path as in (1).""" +
(r"""
sed -e "s|^$(notdir $@)|$@|" -re 's/\\\\([^$$])/\/\1/g' $(depfile).raw >> $(depfile)"""
if sys.platform == 'win32' else r"""
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)""") +
# Fixup path as in (1)."""
+ (
r"""
sed -e "s|^$(notdir $@)|$@|" -re 's/\\\\([^$$])/\/\1/g' $(depfile).raw >> $(depfile)"""
if sys.platform == "win32"
else r"""
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)"""
)
+ r"""
# Add extra rules as in (2).
# We remove slashes and replace spaces with new lines;
# remove blank lines;
# delete the first line and append a colon to the remaining lines.""" +
("""
# delete the first line and append a colon to the remaining lines."""
+ (
"""
sed -e 's/\\\\\\\\$$//' -e 's/\\\\\\\\/\\//g' -e 'y| |\\n|' $(depfile).raw |\\"""
if sys.platform == 'win32' else """
sed -e 's|\\\\||' -e 'y| |\\n|' $(depfile).raw |\\""") +
r"""
if sys.platform == "win32"
else """
sed -e 's|\\\\||' -e 'y| |\\n|' $(depfile).raw |\\"""
)
+ r"""
grep -v '^$$' |\
sed -e 1d -e 's|$$|:|' \
>> $(depfile)
@ -616,7 +622,7 @@ cmd_mac_package_framework = %(python)s gyp-mac-tool package-framework "$@" $(4)
quiet_cmd_infoplist = INFOPLIST $@
cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@"
""" % {'python': sys.executable} # noqa: E501
""" % {"python": sys.executable} # noqa: E501
def WriteRootHeaderSuffixRules(writer):
@ -733,11 +739,13 @@ def QuoteIfNecessary(string):
string = '"' + string.replace('"', '\\"') + '"'
return string
def replace_sep(string):
if sys.platform == 'win32':
string = string.replace('\\\\', '/').replace('\\', '/')
if sys.platform == "win32":
string = string.replace("\\\\", "/").replace("\\", "/")
return string
def StringToMakefileVariable(string):
"""Convert a string to a value that is acceptable as a make variable name."""
return re.sub("[^a-zA-Z0-9_]", "_", string)
@ -1439,9 +1447,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
for obj in objs:
assert " " not in obj, "Spaces in object filenames not supported (%s)" % obj
self.WriteLn(
"# Add to the list of files we specially track dependencies for."
)
self.WriteLn("# Add to the list of files we specially track dependencies for.")
self.WriteLn("all_deps += $(OBJS)")
self.WriteLn()
@ -1498,7 +1504,8 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
"$(OBJS): GYP_OBJCFLAGS := "
"$(DEFS_$(BUILDTYPE)) "
"$(INCS_$(BUILDTYPE)) "
"%s " % precompiled_header.GetInclude("m")
"%s "
% precompiled_header.GetInclude("m")
+ "$(CFLAGS_$(BUILDTYPE)) "
"$(CFLAGS_C_$(BUILDTYPE)) "
"$(CFLAGS_OBJC_$(BUILDTYPE))"
@ -1507,7 +1514,8 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
"$(OBJS): GYP_OBJCXXFLAGS := "
"$(DEFS_$(BUILDTYPE)) "
"$(INCS_$(BUILDTYPE)) "
"%s " % precompiled_header.GetInclude("mm")
"%s "
% precompiled_header.GetInclude("mm")
+ "$(CFLAGS_$(BUILDTYPE)) "
"$(CFLAGS_CC_$(BUILDTYPE)) "
"$(CFLAGS_OBJCC_$(BUILDTYPE))"
@ -2383,9 +2391,13 @@ def WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
"deps": replace_sep(
" ".join(sorted(SourceifyAndQuoteSpaces(bf) for bf in build_files))
),
"cmd": replace_sep(gyp.common.EncodePOSIXShellList(
[gyp_binary, "-fmake"] + gyp.RegenerateFlags(options) + build_files_args
)),
"cmd": replace_sep(
gyp.common.EncodePOSIXShellList(
[gyp_binary, "-fmake"]
+ gyp.RegenerateFlags(options)
+ build_files_args
)
),
}
)
@ -2458,8 +2470,8 @@ def GenerateOutput(target_list, target_dicts, data, params):
# wasm-ld doesn't support --start-group/--end-group
link_commands = LINK_COMMANDS_LINUX
if flavor in ["wasi", "wasm"]:
link_commands = link_commands.replace(' -Wl,--start-group', '').replace(
' -Wl,--end-group', ''
link_commands = link_commands.replace(" -Wl,--start-group", "").replace(
" -Wl,--end-group", ""
)
CC_target = replace_sep(GetEnvironFallback(("CC_target", "CC"), "$(CC)"))

View File

@ -361,7 +361,6 @@ def _ConfigWindowsTargetPlatformVersion(config_data, version):
def _BuildCommandLineForRuleRaw(
spec, cmd, cygwin_shell, has_input_path, quote_cmd, do_setup_env
):
if [x for x in cmd if "$(InputDir)" in x]:
input_dir_preamble = (
"set INPUTDIR=$(InputDir)\n"
@ -425,8 +424,7 @@ def _BuildCommandLineForRuleRaw(
# Return the path with forward slashes because the command using it might
# not support backslashes.
arguments = [
i if (i[:1] in "/-" or "=" in i) else _FixPath(i, "/")
for i in cmd[1:]
i if (i[:1] in "/-" or "=" in i) else _FixPath(i, "/") for i in cmd[1:]
]
arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in arguments]
arguments = [MSVSSettings.FixVCMacroSlashes(i) for i in arguments]
@ -1836,8 +1834,11 @@ def _CollapseSingles(parent, node):
# Recursively explorer the tree of dicts looking for projects which are
# the sole item in a folder which has the same name as the project. Bring
# such projects up one level.
if (isinstance(node, dict) and len(node) == 1 and
next(iter(node)) == parent + ".vcproj"):
if (
isinstance(node, dict)
and len(node) == 1
and next(iter(node)) == parent + ".vcproj"
):
return node[next(iter(node))]
if not isinstance(node, dict):
return node
@ -2908,7 +2909,7 @@ def _GetConfigurationCondition(name, settings, spec):
def _GetMSBuildProjectConfigurations(configurations, spec):
group = ["ItemGroup", {"Label": "ProjectConfigurations"}]
for (name, settings) in sorted(configurations.items()):
for name, settings in sorted(configurations.items()):
configuration, platform = _GetConfigurationAndPlatform(name, settings, spec)
designation = f"{configuration}|{platform}"
group.append(
@ -3002,10 +3003,11 @@ def _GetMSBuildConfigurationDetails(spec, build_file):
vctools_version = msbuild_attributes.get("VCToolsVersion")
config_type = msbuild_attributes.get("ConfigurationType")
_AddConditionalProperty(properties, condition, "ConfigurationType", config_type)
spectre_mitigation = msbuild_attributes.get('SpectreMitigation')
spectre_mitigation = msbuild_attributes.get("SpectreMitigation")
if spectre_mitigation:
_AddConditionalProperty(properties, condition, "SpectreMitigation",
spectre_mitigation)
_AddConditionalProperty(
properties, condition, "SpectreMitigation", spectre_mitigation
)
if config_type == "Driver":
_AddConditionalProperty(properties, condition, "DriverType", "WDM")
_AddConditionalProperty(
@ -3193,7 +3195,7 @@ def _GetMSBuildConfigurationGlobalProperties(spec, configurations, build_file):
new_paths = "$(ExecutablePath);" + ";".join(new_paths)
properties = {}
for (name, configuration) in sorted(configurations.items()):
for name, configuration in sorted(configurations.items()):
condition = _GetConfigurationCondition(name, configuration, spec)
attributes = _GetMSBuildAttributes(spec, configuration, build_file)
msbuild_settings = configuration["finalized_msbuild_settings"]
@ -3311,7 +3313,7 @@ def _GetMSBuildPropertyGroup(spec, label, properties):
def _GetMSBuildToolSettingsSections(spec, configurations):
groups = []
for (name, configuration) in sorted(configurations.items()):
for name, configuration in sorted(configurations.items()):
msbuild_settings = configuration["finalized_msbuild_settings"]
group = [
"ItemDefinitionGroup",
@ -3408,7 +3410,7 @@ def _FinalizeMSBuildSettings(spec, configuration):
# While MSVC works with just file name eg. "v8_pch.h", ClangCL requires
# the full path eg. "tools/msvs/pch/v8_pch.h" to find the file.
# P.S. Only ClangCL defines msbuild_toolset, for MSVC it is None.
if configuration.get("msbuild_toolset") != 'ClangCL':
if configuration.get("msbuild_toolset") != "ClangCL":
precompiled_header = os.path.split(precompiled_header)[1]
_ToolAppend(msbuild_settings, "ClCompile", "PrecompiledHeader", "Use")
_ToolAppend(
@ -3564,17 +3566,13 @@ def _AddSources2(
detail.append(["ExcludedFromBuild", "true"])
else:
for config_name, configuration in sorted(excluded_configurations):
condition = _GetConfigurationCondition(
config_name, configuration
)
condition = _GetConfigurationCondition(config_name, configuration)
detail.append(
["ExcludedFromBuild", {"Condition": condition}, "true"]
)
# Add precompile if needed
for config_name, configuration in spec["configurations"].items():
precompiled_source = configuration.get(
"msvs_precompiled_source", ""
)
precompiled_source = configuration.get("msvs_precompiled_source", "")
if precompiled_source != "":
precompiled_source = _FixPath(precompiled_source)
if not extensions_excluded_from_precompile:

View File

@ -1755,11 +1755,9 @@ class NinjaWriter:
+ " && ".join([ninja_syntax.escape(command) for command in postbuilds])
)
command_string = (
commands
+ "); G=$$?; "
commands + "); G=$$?; "
# Remove the final output if any postbuild failed.
"((exit $$G) || rm -rf %s) " % output
+ "&& exit $$G)"
"((exit $$G) || rm -rf %s) " % output + "&& exit $$G)"
)
if is_command_start:
return "(" + command_string + " && "
@ -1948,7 +1946,8 @@ class NinjaWriter:
)
else:
rspfile_content = gyp.msvs_emulation.EncodeRspFileList(
args, win_shell_flags.quote)
args, win_shell_flags.quote
)
command = (
"%s gyp-win-tool action-wrapper $arch " % sys.executable
+ rspfile
@ -2085,6 +2084,7 @@ def GetDefaultConcurrentLinks():
return pool_size
if sys.platform in ("win32", "cygwin"):
class MEMORYSTATUSEX(ctypes.Structure):
_fields_ = [
("dwLength", ctypes.c_ulong),
@ -2411,8 +2411,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
"cc_s",
description="CC $out",
command=(
"$cc $defines $includes $cflags $cflags_c "
"$cflags_pch_c -c $in -o $out"
"$cc $defines $includes $cflags $cflags_c $cflags_pch_c -c $in -o $out"
),
)
master_ninja.rule(
@ -2523,8 +2522,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
"solink",
description="SOLINK $lib",
restat=True,
command=mtime_preserving_solink_base
% {"suffix": "@$link_file_list"},
command=mtime_preserving_solink_base % {"suffix": "@$link_file_list"},
rspfile="$link_file_list",
rspfile_content=(
"-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive $libs"
@ -2709,7 +2707,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
command="$env %(python)s gyp-mac-tool compile-ios-framework-header-map "
"$out $framework $in && $env %(python)s gyp-mac-tool "
"copy-ios-framework-headers $framework $copy_headers"
% {'python': sys.executable},
% {"python": sys.executable},
)
master_ninja.rule(
"mac_tool",

View File

@ -679,9 +679,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
project_attributes["BuildIndependentTargetsInParallel"] = "YES"
if upgrade_check_project_version:
project_attributes["LastUpgradeCheck"] = upgrade_check_project_version
project_attributes[
"LastTestingUpgradeCheck"
] = upgrade_check_project_version
project_attributes["LastTestingUpgradeCheck"] = (
upgrade_check_project_version
)
project_attributes["LastSwiftUpdateCheck"] = upgrade_check_project_version
pbxp.SetProperty("attributes", project_attributes)
@ -734,8 +734,7 @@ def GenerateOutput(target_list, target_dicts, data, params):
"loadable_module+xcuitest": "com.apple.product-type.bundle.ui-testing",
"shared_library+bundle": "com.apple.product-type.framework",
"executable+extension+bundle": "com.apple.product-type.app-extension",
"executable+watch+extension+bundle":
"com.apple.product-type.watchkit-extension",
"executable+watch+extension+bundle": "com.apple.product-type.watchkit-extension", # noqa: E501
"executable+watch+bundle": "com.apple.product-type.application.watchapp",
"mac_kernel_extension+bundle": "com.apple.product-type.kernel-extension",
}
@ -780,8 +779,7 @@ def GenerateOutput(target_list, target_dicts, data, params):
type_bundle_key += "+watch+extension+bundle"
elif is_watch_app:
assert is_bundle, (
"ios_watch_app flag requires mac_bundle "
"(target %s)" % target_name
"ios_watch_app flag requires mac_bundle (target %s)" % target_name
)
type_bundle_key += "+watch+bundle"
elif is_bundle:
@ -1103,7 +1101,7 @@ def GenerateOutput(target_list, target_dicts, data, params):
eol = " \\"
makefile.write(f" {concrete_output}{eol}\n")
for (rule_source, concrete_outputs, message, action) in zip(
for rule_source, concrete_outputs, message, action in zip(
rule["rule_sources"],
concrete_outputs_by_rule_source,
messages,

View File

@ -584,8 +584,7 @@ class ParallelState:
self.error = False
def LoadTargetBuildFileCallback(self, result):
"""Handle the results of running LoadTargetBuildFile in another process.
"""
"""Handle the results of running LoadTargetBuildFile in another process."""
self.condition.acquire()
if not result:
self.error = True
@ -870,8 +869,9 @@ def ExpandVariables(input, phase, variables, build_file):
# This works around actions/rules which have more inputs than will
# fit on the command line.
if file_list:
contents_list = (contents if isinstance(contents, list)
else contents.split(" "))
contents_list = (
contents if isinstance(contents, list) else contents.split(" ")
)
replacement = contents_list[0]
if os.path.isabs(replacement):
raise GypError('| cannot handle absolute paths, got "%s"' % replacement)
@ -934,7 +934,6 @@ def ExpandVariables(input, phase, variables, build_file):
os.chdir(build_file_dir)
sys.path.append(os.getcwd())
try:
parsed_contents = shlex.split(contents)
try:
py_module = __import__(parsed_contents[0])
@ -965,7 +964,7 @@ def ExpandVariables(input, phase, variables, build_file):
stdout=subprocess.PIPE,
shell=use_shell,
cwd=build_file_dir,
check=False
check=False,
)
except Exception as e:
raise GypError(
@ -1003,9 +1002,7 @@ def ExpandVariables(input, phase, variables, build_file):
# ],
replacement = []
else:
raise GypError(
"Undefined variable " + contents + " in " + build_file
)
raise GypError("Undefined variable " + contents + " in " + build_file)
else:
replacement = variables[contents]
@ -1573,14 +1570,10 @@ def ExpandWildcardDependencies(targets, data):
if int(dependency_target_dict.get("suppress_wildcard", False)):
continue
dependency_target_name = dependency_target_dict["target_name"]
if (
dependency_target not in {"*", dependency_target_name}
):
if dependency_target not in {"*", dependency_target_name}:
continue
dependency_target_toolset = dependency_target_dict["toolset"]
if (
dependency_toolset not in {"*", dependency_target_toolset}
):
if dependency_toolset not in {"*", dependency_target_toolset}:
continue
dependency = gyp.common.QualifiedTarget(
dependency_build_file,
@ -1624,13 +1617,9 @@ def RemoveSelfDependencies(targets):
if dependencies:
for t in dependencies:
if t == target_name and (
targets[t]
.get("variables", {})
.get("prune_self_dependency", 0)
targets[t].get("variables", {}).get("prune_self_dependency", 0)
):
target_dict[dependency_key] = Filter(
dependencies, target_name
)
target_dict[dependency_key] = Filter(dependencies, target_name)
def RemoveLinkDependenciesFromNoneTargets(targets):
@ -2446,7 +2435,7 @@ def SetUpConfigurations(target, target_dict):
merged_configurations = {}
configs = target_dict["configurations"]
for (configuration, old_configuration_dict) in configs.items():
for configuration, old_configuration_dict in configs.items():
# Skip abstract configurations (saves work only).
if old_configuration_dict.get("abstract"):
continue
@ -2454,7 +2443,7 @@ def SetUpConfigurations(target, target_dict):
# Get the inheritance relationship right by making a copy of the target
# dict.
new_configuration_dict = {}
for (key, target_val) in target_dict.items():
for key, target_val in target_dict.items():
key_ext = key[-1:]
key_base = key[:-1] if key_ext in key_suffixes else key
if key_base not in non_configuration_keys:
@ -2734,9 +2723,7 @@ def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules):
# Make sure that there's no conflict among rule names and extensions.
rule_name = rule["rule_name"]
if rule_name in rule_names:
raise GypError(
f"rule {rule_name} exists in duplicate, target {target}"
)
raise GypError(f"rule {rule_name} exists in duplicate, target {target}")
rule_names[rule_name] = rule
rule_extension = rule["extension"]
@ -2835,8 +2822,7 @@ def ValidateActionsInTarget(target, target_dict, build_file):
def TurnIntIntoStrInDict(the_dict):
"""Given dict the_dict, recursively converts all integers into strings.
"""
"""Given dict the_dict, recursively converts all integers into strings."""
# Use items instead of iteritems because there's no need to try to look at
# reinserted keys and their associated values.
for k, v in the_dict.items():
@ -2854,8 +2840,7 @@ def TurnIntIntoStrInDict(the_dict):
def TurnIntIntoStrInList(the_list):
"""Given list the_list, recursively converts all integers into strings.
"""
"""Given list the_list, recursively converts all integers into strings."""
for index, item in enumerate(the_list):
if isinstance(item, int):
the_list[index] = str(item)

View File

@ -8,7 +8,6 @@
These functions are executed via gyp-mac-tool when using the Makefile generator.
"""
import fcntl
import fnmatch
import glob
@ -161,9 +160,9 @@ class MacTool:
header = fp.read(3)
except Exception:
return None
if header.startswith((b"\xFE\xFF", b"\xFF\xFE")):
if header.startswith((b"\xfe\xff", b"\xff\xfe")):
return "UTF-16"
elif header.startswith(b"\xEF\xBB\xBF"):
elif header.startswith(b"\xef\xbb\xbf"):
return "UTF-8"
else:
return None

View File

@ -74,8 +74,7 @@ def EncodeRspFileList(args, quote_cmd):
program = call + " " + os.path.normpath(program)
else:
program = os.path.normpath(args[0])
return (program + " "
+ " ".join(QuoteForRspFile(arg, quote_cmd) for arg in args[1:]))
return program + " " + " ".join(QuoteForRspFile(arg, quote_cmd) for arg in args[1:])
def _GenericRetrieve(root, default, path):
@ -934,14 +933,17 @@ class MsvsSettings:
includes whether it should run under cygwin (msvs_cygwin_shell), and
whether the commands should be quoted (msvs_quote_cmd)."""
# If the variable is unset, or set to 1 we use cygwin
cygwin = int(rule.get("msvs_cygwin_shell",
self.spec.get("msvs_cygwin_shell", 1))) != 0
cygwin = (
int(rule.get("msvs_cygwin_shell", self.spec.get("msvs_cygwin_shell", 1)))
!= 0
)
# Default to quoting. There's only a few special instances where the
# target command uses non-standard command line parsing and handle quotes
# and quote escaping differently.
quote_cmd = int(rule.get("msvs_quote_cmd", 1))
assert quote_cmd != 0 or cygwin != 1, \
assert quote_cmd != 0 or cygwin != 1, (
"msvs_quote_cmd=0 only applicable for msvs_cygwin_shell=0"
)
return MsvsSettings.RuleShellFlags(cygwin, quote_cmd)
def _HasExplicitRuleForExtension(self, spec, extension):
@ -1129,8 +1131,7 @@ def _ExtractImportantEnvironment(output_of_set):
for required in ("SYSTEMROOT", "TEMP", "TMP"):
if required not in env:
raise Exception(
'Environment variable "%s" '
"required to be set to valid path" % required
'Environment variable "%s" required to be set to valid path' % required
)
return env

View File

@ -9,7 +9,6 @@
These functions are executed via gyp-win-tool when using the ninja generator.
"""
import os
import re
import shutil
@ -158,7 +157,7 @@ class WinTool:
mt,
rc,
intermediate_manifest,
*manifests
*manifests,
):
"""A wrapper for handling creating a manifest resource and then executing
a link command."""

View File

@ -7,7 +7,6 @@ This module contains classes that help to emulate xcodebuild behavior on top of
other build systems, such as make and ninja.
"""
import copy
import os
import os.path
@ -477,7 +476,7 @@ class XcodeSettings:
"shared_library",
"static_library",
"loadable_module",
}, ("Unexpected type %s" % self.spec["type"])
}, "Unexpected type %s" % self.spec["type"]
target = self.spec["target_name"]
if self.spec["type"] in {"loadable_module", "shared_library", "static_library"}:
if target[:3] == "lib":
@ -1065,7 +1064,6 @@ class XcodeSettings:
if self._Test("DEPLOYMENT_POSTPROCESSING", "YES", default="NO") and self._Test(
"STRIP_INSTALLED_PRODUCT", "YES", default="NO"
):
default_strip_style = "debugging"
if (
self.spec["type"] == "loadable_module" or self._IsIosAppExtension()
@ -1125,8 +1123,7 @@ class XcodeSettings:
be deployed to a device. This should be run as the very last step of the
build."""
if not (
(self.isIOS
and (self.spec["type"] == "executable" or self._IsXCTest()))
(self.isIOS and (self.spec["type"] == "executable" or self._IsXCTest()))
or self.IsIosFramework()
):
return []
@ -1771,17 +1768,17 @@ def _GetXcodeEnv(
)
env["CONTENTS_FOLDER_PATH"] = xcode_settings.GetBundleContentsFolderPath()
env["EXECUTABLE_FOLDER_PATH"] = xcode_settings.GetBundleExecutableFolderPath()
env[
"UNLOCALIZED_RESOURCES_FOLDER_PATH"
] = xcode_settings.GetBundleResourceFolder()
env["UNLOCALIZED_RESOURCES_FOLDER_PATH"] = (
xcode_settings.GetBundleResourceFolder()
)
env["JAVA_FOLDER_PATH"] = xcode_settings.GetBundleJavaFolderPath()
env["FRAMEWORKS_FOLDER_PATH"] = xcode_settings.GetBundleFrameworksFolderPath()
env[
"SHARED_FRAMEWORKS_FOLDER_PATH"
] = xcode_settings.GetBundleSharedFrameworksFolderPath()
env[
"SHARED_SUPPORT_FOLDER_PATH"
] = xcode_settings.GetBundleSharedSupportFolderPath()
env["SHARED_FRAMEWORKS_FOLDER_PATH"] = (
xcode_settings.GetBundleSharedFrameworksFolderPath()
)
env["SHARED_SUPPORT_FOLDER_PATH"] = (
xcode_settings.GetBundleSharedSupportFolderPath()
)
env["PLUGINS_FOLDER_PATH"] = xcode_settings.GetBundlePlugInsFolderPath()
env["XPCSERVICES_FOLDER_PATH"] = xcode_settings.GetBundleXPCServicesFolderPath()
env["INFOPLIST_PATH"] = xcode_settings.GetBundlePlistPath()

View File

@ -102,9 +102,9 @@ def _TargetFromSpec(old_spec, params):
new_xcode_settings[key] = old_xcode_settings[key]
ninja_target["configurations"][config] = {}
ninja_target["configurations"][config][
"xcode_settings"
] = new_xcode_settings
ninja_target["configurations"][config]["xcode_settings"] = (
new_xcode_settings
)
ninja_target["mac_bundle"] = old_spec.get("mac_bundle", 0)
ninja_target["mac_xctest_bundle"] = old_spec.get("mac_xctest_bundle", 0)
@ -154,7 +154,6 @@ def IsValidTargetForWrapper(target_extras, executable_target_pattern, spec):
spec.get("type", "") == "executable"
and spec.get("product_extension", "") != "bundle"
):
# If there is a filter and the target does not match, exclude the target.
if executable_target_pattern is not None:
if not re.search(executable_target_pattern, target_name):

View File

@ -464,8 +464,7 @@ class XCObject:
self.id = "%08X%08X%08X" % tuple(id_ints)
def EnsureNoIDCollisions(self):
"""Verifies that no two objects have the same ID. Checks all descendants.
"""
"""Verifies that no two objects have the same ID. Checks all descendants."""
ids = {}
descendants = self.Descendants()
@ -1793,8 +1792,7 @@ class XCConfigurationList(XCObject):
configuration.DelBuildSetting(key)
def SetBaseConfiguration(self, value):
"""Sets the build configuration in all child XCBuildConfiguration objects.
"""
"""Sets the build configuration in all child XCBuildConfiguration objects."""
for configuration in self._properties["buildConfigurations"]:
configuration.SetBaseConfiguration(value)
@ -2178,9 +2176,7 @@ class PBXCopyFilesBuildPhase(XCBuildPhase):
subfolder = 0
relative_path = path[1:]
else:
raise ValueError(
f"Can't use path {path} in a {self.__class__.__name__}"
)
raise ValueError(f"Can't use path {path} in a {self.__class__.__name__}")
self._properties["dstPath"] = relative_path
self._properties["dstSubfolderSpec"] = subfolder
@ -2530,9 +2526,9 @@ class PBXNativeTarget(XCTarget):
# loadable modules, but there's precedent: Python loadable modules on
# Mac OS X use an .so extension.
if self._properties["productType"] == "com.googlecode.gyp.xcode.bundle":
self._properties[
"productType"
] = "com.apple.product-type.library.dynamic"
self._properties["productType"] = (
"com.apple.product-type.library.dynamic"
)
self.SetBuildSetting("MACH_O_TYPE", "mh_bundle")
self.SetBuildSetting("DYLIB_CURRENT_VERSION", "")
self.SetBuildSetting("DYLIB_COMPATIBILITY_VERSION", "")
@ -2540,9 +2536,10 @@ class PBXNativeTarget(XCTarget):
force_extension = suffix[1:]
if (
self._properties["productType"] in {
self._properties["productType"]
in {
"com.apple.product-type-bundle.unit.test",
"com.apple.product-type-bundle.ui-testing"
"com.apple.product-type-bundle.ui-testing",
}
) and force_extension is None:
force_extension = suffix[1:]
@ -2694,10 +2691,8 @@ class PBXNativeTarget(XCTarget):
other._properties["productType"] == static_library_type
or (
(
other._properties["productType"] in {
shared_library_type,
framework_type
}
other._properties["productType"]
in {shared_library_type, framework_type}
)
and (
(not other.HasBuildSetting("MACH_O_TYPE"))
@ -2706,7 +2701,6 @@ class PBXNativeTarget(XCTarget):
)
)
):
file_ref = other.GetProperty("productReference")
pbxproject = self.PBXProjectAncestor()
@ -2985,7 +2979,7 @@ class PBXProject(XCContainerPortal):
# Xcode seems to sort this list case-insensitively
self._properties["projectReferences"] = sorted(
self._properties["projectReferences"],
key=lambda x: x["ProjectRef"].Name().lower()
key=lambda x: x["ProjectRef"].Name().lower(),
)
else:
# The link already exists. Pull out the relevant data.
@ -3010,11 +3004,8 @@ class PBXProject(XCContainerPortal):
# define an explicit value for 'SYMROOT'.
symroots = self._DefinedSymroots(target)
for s in self._DefinedSymroots(target):
if (
(s is not None
and not self._IsUniqueSymrootForTarget(s))
or (s is None
and not inherit_unique_symroot)
if (s is not None and not self._IsUniqueSymrootForTarget(s)) or (
s is None and not inherit_unique_symroot
):
return False
return True if symroots else inherit_unique_symroot
@ -3118,7 +3109,8 @@ class PBXProject(XCContainerPortal):
product_group._properties["children"] = sorted(
product_group._properties["children"],
key=cmp_to_key(
lambda x, y, rp=remote_products: CompareProducts(x, y, rp)),
lambda x, y, rp=remote_products: CompareProducts(x, y, rp)
),
)
@ -3152,9 +3144,7 @@ class XCProjectFile(XCObject):
self._XCPrint(file, 0, "{ ")
else:
self._XCPrint(file, 0, "{\n")
for property, value in sorted(
self._properties.items()
):
for property, value in sorted(self._properties.items()):
if property == "objects":
self._PrintObjects(file)
else:
@ -3180,9 +3170,7 @@ class XCProjectFile(XCObject):
for class_name in sorted(objects_by_class):
self._XCPrint(file, 0, "\n")
self._XCPrint(file, 0, "/* Begin " + class_name + " section */\n")
for object in sorted(
objects_by_class[class_name], key=attrgetter("id")
):
for object in sorted(objects_by_class[class_name], key=attrgetter("id")):
object.Print(file)
self._XCPrint(file, 0, "/* End " + class_name + " section */\n")

View File

@ -9,7 +9,6 @@ Working around this: http://bugs.python.org/issue5752
TODO(bradnelson): Consider dropping this when we drop XP support.
"""
import xml.dom.minidom

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "gyp-next"
version = "0.20.3"
version = "0.20.4"
authors = [
{ name="Node.js contributors", email="ryzokuken@disroot.org" },
]

View File

@ -5,7 +5,6 @@
"""gyptest.py -- test runner for GYP tests."""
import argparse
import os
import platform

View File

@ -8,7 +8,6 @@
generate input suitable for graphviz to render a dependency graph of
targets."""
import collections
import json
import sys
@ -64,9 +63,7 @@ def WriteGraph(edges):
# the display by making it a box without an internal node.
target = targets[0]
build_file, target_name, toolset = ParseTarget(target)
print(
f' "{target}" [shape=box, label="{filename}\\n{target_name}"]'
)
print(f' "{target}" [shape=box, label="{filename}\\n{target_name}"]')
else:
# Group multiple nodes together in a subgraph.
print(' subgraph "cluster_%s" {' % filename)

View File

@ -6,7 +6,6 @@
"""Pretty-prints the contents of a GYP file."""
import re
import sys
@ -49,7 +48,7 @@ def mask_quotes(input):
def do_split(input, masked_input, search_re):
output = []
mask_output = []
for (line, masked_line) in zip(input, masked_input):
for line, masked_line in zip(input, masked_input):
m = search_re.match(masked_line)
while m:
split = len(m.group(1))

View File

@ -12,7 +12,6 @@
Then it outputs a possible build order.
"""
import os
import re
import sys
@ -113,7 +112,7 @@ def PrintDependencies(projects, deps):
print("---------------------------------------")
print("-- --")
for (project, dep_list) in sorted(deps.items()):
for project, dep_list in sorted(deps.items()):
print("Project : %s" % project)
print("Path : %s" % projects[project][0])
if dep_list:
@ -131,7 +130,7 @@ def PrintBuildOrder(projects, deps):
print("-- --")
built = []
for (project, _) in sorted(deps.items()):
for project, _ in sorted(deps.items()):
if project not in built:
BuildProject(project, built, projects, deps)
@ -139,7 +138,6 @@ def PrintBuildOrder(projects, deps):
def PrintVCProj(projects):
for project in projects:
print("-------------------------------------")
print("-------------------------------------")

View File

@ -12,7 +12,6 @@
It outputs the resulting xml to stdout.
"""
import os
import sys
from xml.dom.minidom import Node, parse
@ -48,11 +47,11 @@ class CmpNode:
node_string += node.getAttribute("Name")
all_nodes = []
for (name, value) in node.attributes.items():
for name, value in node.attributes.items():
all_nodes.append((name, value))
all_nodes.sort(CmpTuple())
for (name, value) in all_nodes:
for name, value in all_nodes:
node_string += name
node_string += value
@ -81,10 +80,10 @@ def PrettyPrintNode(node, indent=0):
print("{}<{}".format(" " * indent, node.nodeName))
all_attributes = []
for (name, value) in node.attributes.items():
for name, value in node.attributes.items():
all_attributes.append((name, value))
all_attributes.sort(CmpTuple())
for (name, value) in all_attributes:
for name, value in all_attributes:
print('{} {}="{}"'.format(" " * indent, name, value))
print("%s>" % (" " * indent))
if node.nodeValue:
@ -130,7 +129,7 @@ def FixFilenames(filenames, current_directory):
def AbsoluteNode(node):
"""Makes all the properties we know about in this node absolute."""
if node.attributes:
for (name, value) in node.attributes.items():
for name, value in node.attributes.items():
if name in [
"InheritedPropertySheets",
"RelativePath",
@ -163,7 +162,7 @@ def CleanupVcproj(node):
# Fix all the semicolon separated attributes to be sorted, and we also
# remove the dups.
if node.attributes:
for (name, value) in node.attributes.items():
for name, value in node.attributes.items():
sorted_list = sorted(value.split(";"))
unique_list = []
for i in sorted_list:
@ -252,7 +251,7 @@ def MergeAttributes(node1, node2):
if not node2.attributes:
return
for (name, value2) in node2.attributes.items():
for name, value2 in node2.attributes.items():
# Don't merge the 'Name' attribute.
if name == "Name":
continue