Skip to content

Commit

Permalink
Merge branch 'nodejs:main' into wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi authored Mar 8, 2024
2 parents ef48485 + 5f67810 commit fec298c
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/node-gyp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
with:
repository: nodejs/node-gyp
path: node-gyp
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18.x
- uses: actions/setup-python@v4
node-version: 20.x
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
- uses: google-github-actions/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: python
package-name: gyp-next
bump-minor-pre-major: true
config-file: release-please-config.json
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.16.2](https://github.com/nodejs/gyp-next/compare/v0.16.1...v0.16.2) (2024-03-07)


### Bug Fixes

* avoid quoting cflag name and parameter with space separator ([#223](https://github.com/nodejs/gyp-next/issues/223)) ([2b9703d](https://github.com/nodejs/gyp-next/commit/2b9703dbd5b3b8a935faf257c6103033b47bf8bf))

## [0.16.1](https://github.com/nodejs/gyp-next/compare/v0.16.0...v0.16.1) (2023-10-25)


Expand Down
6 changes: 3 additions & 3 deletions pylib/gyp/generator/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,9 @@ def ComputeOutput(self, spec):
% (self.android_class, self.android_module)
)
else:
path = "$(call intermediates-dir-for,{},{},,,$(GYP_VAR_PREFIX))".format(
self.android_class,
self.android_module,
path = (
f"$(call intermediates-dir-for,{self.android_class},"
f"{self.android_module},,,$(GYP_VAR_PREFIX))"
)

assert spec.get("product_dir") is None # TODO: not supported?
Expand Down
7 changes: 3 additions & 4 deletions pylib/gyp/generator/gypsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
# Use a banner that looks like the stock Python one and like what
# code.interact uses by default, but tack on something to indicate what
# locals are available, and identify gypsh.
banner = "Python {} on {}\nlocals.keys() = {}\ngypsh".format(
sys.version,
sys.platform,
repr(sorted(locals.keys())),
banner = (
f"Python {sys.version} on {sys.platform}\nlocals.keys() = "
f"{sorted(locals.keys())!r}\ngypsh"
)

code.interact(banner, local=locals)
21 changes: 8 additions & 13 deletions pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,11 +1778,9 @@ def _GetCopies(spec):
outer_dir = posixpath.split(src_bare)[1]
fixed_dst = _FixPath(dst)
full_dst = f'"{fixed_dst}\\{outer_dir}\\"'
cmd = 'mkdir {} 2>nul & cd "{}" && xcopy /e /f /y "{}" {}'.format(
full_dst,
_FixPath(base_dir),
outer_dir,
full_dst,
cmd = (
f'mkdir {full_dst} 2>nul & cd "{_FixPath(base_dir)}" '
f'&& xcopy /e /f /y "{outer_dir}" {full_dst}'
)
copies.append(
(
Expand All @@ -1794,10 +1792,9 @@ def _GetCopies(spec):
)
else:
fix_dst = _FixPath(cpy["destination"])
cmd = 'mkdir "{}" 2>nul & set ERRORLEVEL=0 & copy /Y "{}" "{}"'.format(
fix_dst,
_FixPath(src),
_FixPath(dst),
cmd = (
f'mkdir "{fix_dst}" 2>nul & set ERRORLEVEL=0 & '
f'copy /Y "{_FixPath(src)}" "{_FixPath(dst)}"'
)
copies.append(([src], [dst], cmd, f"Copying {src} to {fix_dst}"))
return copies
Expand Down Expand Up @@ -1899,10 +1896,8 @@ def _GetPlatformOverridesOfProject(spec):
for config_name, c in spec["configurations"].items():
config_fullname = _ConfigFullName(config_name, c)
platform = c.get("msvs_target_platform", _ConfigPlatform(c))
fixed_config_fullname = "{}|{}".format(
_ConfigBaseName(config_name, _ConfigPlatform(c)),
platform,
)
base_name = _ConfigBaseName(config_name, _ConfigPlatform(c))
fixed_config_fullname = f"{base_name}|{platform}"
if spec["toolset"] == "host" and generator_supports_multiple_toolsets:
fixed_config_fullname = f"{config_name}|x64"
config_platform_overrides[config_fullname] = fixed_config_fullname
Expand Down
10 changes: 4 additions & 6 deletions pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,18 +1135,16 @@ def EvalCondition(condition, conditions_key, phase, variables, build_file):
true_dict = condition[i + 1]
if type(true_dict) is not dict:
raise GypError(
"{} {} must be followed by a dictionary, not {}".format(
conditions_key, cond_expr, type(true_dict)
)
f"{conditions_key} {cond_expr} must be followed by a dictionary, "
f"not {type(true_dict)}"
)
if len(condition) > i + 2 and type(condition[i + 2]) is dict:
false_dict = condition[i + 2]
i = i + 3
if i != len(condition):
raise GypError(
"{} {} has {} unexpected trailing items".format(
conditions_key, cond_expr, len(condition) - i
)
f"{conditions_key} {cond_expr} has "
f"{len(condition) - i} unexpected trailing items"
)
else:
false_dict = None
Expand Down
10 changes: 4 additions & 6 deletions pylib/gyp/msvs_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,17 +830,15 @@ def _GetLdManifestFlags(
("VCLinkerTool", "UACUIAccess"), config, default="false"
)

inner = """
level = execution_level_map[execution_level]
inner = f"""
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='{}' uiAccess='{}' />
<requestedExecutionLevel level='{level}' uiAccess='{ui_access}' />
</requestedPrivileges>
</security>
</trustInfo>""".format(
execution_level_map[execution_level],
ui_access,
)
</trustInfo>"""
else:
inner = ""

Expand Down
29 changes: 17 additions & 12 deletions pylib/gyp/xcode_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ def GetCflags(self, configname, arch=None):

sdk_root = self._SdkPath()
if "SDKROOT" in self._Settings() and sdk_root:
cflags.append("-isysroot %s" % sdk_root)
cflags.append("-isysroot")
cflags.append(sdk_root)

if self.header_map_path:
cflags.append("-I%s" % self.header_map_path)
Expand Down Expand Up @@ -664,7 +665,8 @@ def GetCflags(self, configname, arch=None):
# TODO: Supporting fat binaries will be annoying.
self._WarnUnimplemented("ARCHS")
archs = ["i386"]
cflags.append("-arch " + archs[0])
cflags.append("-arch")
cflags.append(archs[0])

if archs[0] in ("i386", "x86_64"):
if self._Test("GCC_ENABLE_SSE3_EXTENSIONS", "YES", default="NO"):
Expand Down Expand Up @@ -924,17 +926,15 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None):
self._AppendPlatformVersionMinFlags(ldflags)

if "SDKROOT" in self._Settings() and self._SdkPath():
ldflags.append("-isysroot " + self._SdkPath())
ldflags.append("-isysroot")
ldflags.append(self._SdkPath())

for library_path in self._Settings().get("LIBRARY_SEARCH_PATHS", []):
ldflags.append("-L" + gyp_to_build_path(library_path))

if "ORDER_FILE" in self._Settings():
ldflags.append(
"-Wl,-order_file "
+ "-Wl,"
+ gyp_to_build_path(self._Settings()["ORDER_FILE"])
)
ldflags.append("-Wl,-order_file")
ldflags.append("-Wl," + gyp_to_build_path(self._Settings()["ORDER_FILE"]))

if not gyp.common.CrossCompileRequested():
if arch is not None:
Expand All @@ -946,15 +946,18 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None):
# TODO: Supporting fat binaries will be annoying.
self._WarnUnimplemented("ARCHS")
archs = ["i386"]
ldflags.append("-arch " + archs[0])
# Avoid quoting the space between -arch and the arch name
ldflags.append("-arch")
ldflags.append(archs[0])

# Xcode adds the product directory by default.
# Rewrite -L. to -L./ to work around http://www.openradar.me/25313838
ldflags.append("-L" + (product_dir if product_dir != "." else "./"))

install_name = self.GetInstallName()
if install_name and self.spec["type"] != "loadable_module":
ldflags.append("-install_name " + install_name.replace(" ", r"\ "))
ldflags.append("-install_name")
ldflags.append(install_name.replace(" ", r"\ "))

for rpath in self._Settings().get("LD_RUNPATH_SEARCH_PATHS", []):
ldflags.append("-Wl,-rpath," + rpath)
Expand All @@ -971,7 +974,8 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None):
platform_root = self._XcodePlatformPath(configname)
if sdk_root and platform_root:
ldflags.append("-F" + platform_root + "/Developer/Library/Frameworks/")
ldflags.append("-framework XCTest")
ldflags.append("-framework")
ldflags.append("XCTest")

is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension()
if sdk_root and is_extension:
Expand All @@ -987,7 +991,8 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None):
+ "/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit"
)
else:
ldflags.append("-e _NSExtensionMain")
ldflags.append("-e")
ldflags.append("_NSExtensionMain")
ldflags.append("-fapplication-extension")

self._Appendf(ldflags, "CLANG_CXX_LIBRARY", "-stdlib=%s")
Expand Down
53 changes: 53 additions & 0 deletions pylib/gyp/xcode_emulation_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3

"""Unit tests for the xcode_emulation.py file."""

from gyp.xcode_emulation import XcodeSettings
import sys
import unittest


class TestXcodeSettings(unittest.TestCase):
def setUp(self):
if sys.platform != "darwin":
self.skipTest("This test only runs on macOS")

def test_GetCflags(self):
target = {
"type": "static_library",
"configurations": {
"Release": {},
},
}
configuration_name = "Release"
xcode_settings = XcodeSettings(target)
cflags = xcode_settings.GetCflags(configuration_name, "arm64")

# Do not quote `-arch arm64` with spaces in one string.
self.assertEqual(
cflags,
["-fasm-blocks", "-mpascal-strings", "-Os", "-gdwarf-2", "-arch", "arm64"],
)

def GypToBuildPath(self, path):
return path

def test_GetLdflags(self):
target = {
"type": "static_library",
"configurations": {
"Release": {},
},
}
configuration_name = "Release"
xcode_settings = XcodeSettings(target)
ldflags = xcode_settings.GetLdflags(
configuration_name, "PRODUCT_DIR", self.GypToBuildPath, "arm64"
)

# Do not quote `-arch arm64` with spaces in one string.
self.assertEqual(ldflags, ["-arch", "arm64", "-LPRODUCT_DIR"])


if __name__ == "__main__":
unittest.main()
16 changes: 9 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "gyp-next"
version = "0.16.1"
version = "0.16.2"
authors = [
{ name="Node.js contributors", email="ryzokuken@disroot.org" },
]
Expand All @@ -29,7 +29,7 @@ classifiers = [
]

[project.optional-dependencies]
dev = ["flake8", "ruff", "pytest"]
dev = ["flake8", "ruff == 0.3.1", "pytest"]

[project.scripts]
gyp = "gyp:script_main"
Expand All @@ -38,6 +38,11 @@ gyp = "gyp:script_main"
"Homepage" = "https://github.com/nodejs/gyp-next"

[tool.ruff]
extend-exclude = ["pylib/packaging"]
line-length = 88
target-version = "py37"

[tool.ruff.lint]
select = [
"C4", # flake8-comprehensions
"C90", # McCabe cyclomatic complexity
Expand Down Expand Up @@ -101,14 +106,11 @@ ignore = [
"RUF012",
"UP031",
]
extend-exclude = ["pylib/packaging"]
line-length = 88
target-version = "py37"

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 101

[tool.ruff.pylint]
[tool.ruff.lint.pylint]
max-args = 11
max-branches = 108
max-returns = 10
Expand Down
5 changes: 5 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"release-type": "python",
"package-name": "gyp-next",
"bump-minor-pre-major": true
}

0 comments on commit fec298c

Please sign in to comment.