formacao
This commit is contained in:
+11
-3
@@ -87,7 +87,7 @@ class VisualStudioVersion:
|
||||
def _SetupScriptInternal(self, target_arch):
|
||||
"""Returns a command (with arguments) to be used to set up the
|
||||
environment."""
|
||||
assert target_arch in ("x86", "x64"), "target_arch not supported"
|
||||
assert target_arch in ("x86", "x64", "arm64"), "target_arch not supported"
|
||||
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
|
||||
# depot_tools build tools and should run SetEnv.Cmd to set up the
|
||||
# environment. The check for WindowsSDKDir alone is not sufficient because
|
||||
@@ -109,8 +109,16 @@ class VisualStudioVersion:
|
||||
)
|
||||
|
||||
# Always use a native executable, cross-compiling if necessary.
|
||||
host_arch = "amd64" if is_host_arch_x64 else "x86"
|
||||
msvc_target_arch = "amd64" if target_arch == "x64" else "x86"
|
||||
host_arch = (
|
||||
"amd64"
|
||||
if is_host_arch_x64
|
||||
else (
|
||||
"arm64"
|
||||
if os.environ.get("PROCESSOR_ARCHITECTURE") == "ARM64"
|
||||
else "x86"
|
||||
)
|
||||
)
|
||||
msvc_target_arch = {"x64": "amd64"}.get(target_arch, target_arch)
|
||||
arg = host_arch
|
||||
if host_arch != msvc_target_arch:
|
||||
arg += "_" + msvc_target_arch
|
||||
|
||||
+2
-3
@@ -13,6 +13,7 @@ import re
|
||||
import shlex
|
||||
import sys
|
||||
import traceback
|
||||
from importlib.metadata import version
|
||||
|
||||
import gyp.input
|
||||
from gyp.common import GypError
|
||||
@@ -491,9 +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}")
|
||||
print(f"v{version('gyp-next')}")
|
||||
return 0
|
||||
build_files = build_files_arg
|
||||
|
||||
|
||||
+1
-1
@@ -857,7 +857,7 @@ def _EscapeCommandLineArgumentForMSBuild(s):
|
||||
"""Escapes a Windows command-line argument for use by MSBuild."""
|
||||
|
||||
def _Replace(match):
|
||||
return (len(match.group(1)) / 2 * 4) * "\\" + '\\"'
|
||||
return (len(match.group(1)) // 2 * 4) * "\\" + '\\"'
|
||||
|
||||
# Escape all quotes so that they are interpreted literally.
|
||||
s = quote_replacer_regex2.sub(_Replace, s)
|
||||
|
||||
+2
-1
@@ -246,7 +246,7 @@ class NinjaWriter:
|
||||
if flavor == "win":
|
||||
# See docstring of msvs_emulation.GenerateEnvironmentFiles().
|
||||
self.win_env = {}
|
||||
for arch in ("x86", "x64"):
|
||||
for arch in ("x86", "x64", "arm64"):
|
||||
self.win_env[arch] = "environment." + arch
|
||||
|
||||
# Relative path from build output dir to base dir.
|
||||
@@ -2339,6 +2339,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
|
||||
master_ninja.variable("rc", "rc.exe")
|
||||
master_ninja.variable("ml_x86", "ml.exe")
|
||||
master_ninja.variable("ml_x64", "ml64.exe")
|
||||
master_ninja.variable("ml_arm64", "armasm64.exe")
|
||||
master_ninja.variable("mt", "mt.exe")
|
||||
else:
|
||||
master_ninja.variable("ld", CommandWithWrapper("LINK", wrappers, ld))
|
||||
|
||||
+26
-16
@@ -11,26 +11,36 @@ import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from gyp.generator import ninja
|
||||
from gyp.MSVSVersion import SelectVisualStudioVersion
|
||||
|
||||
|
||||
def _has_visual_studio():
|
||||
"""Check if Visual Studio can be detected by gyp's registry-based detection."""
|
||||
if not sys.platform.startswith("win"):
|
||||
return False
|
||||
try:
|
||||
SelectVisualStudioVersion("auto", allow_fallback=False)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
class TestPrefixesAndSuffixes(unittest.TestCase):
|
||||
@unittest.skipUnless(
|
||||
_has_visual_studio(),
|
||||
"requires Windows with a Visual Studio installation detected via the registry",
|
||||
)
|
||||
def test_BinaryNamesWindows(self):
|
||||
# These cannot run on non-Windows as they require a VS installation to
|
||||
# correctly handle variable expansion.
|
||||
if sys.platform.startswith("win"):
|
||||
writer = ninja.NinjaWriter(
|
||||
"foo", "wee", ".", ".", "build.ninja", ".", "build.ninja", "win"
|
||||
)
|
||||
spec = {"target_name": "wee"}
|
||||
self.assertTrue(
|
||||
writer.ComputeOutputFileName(spec, "executable").endswith(".exe")
|
||||
)
|
||||
self.assertTrue(
|
||||
writer.ComputeOutputFileName(spec, "shared_library").endswith(".dll")
|
||||
)
|
||||
self.assertTrue(
|
||||
writer.ComputeOutputFileName(spec, "static_library").endswith(".lib")
|
||||
)
|
||||
writer = ninja.NinjaWriter(
|
||||
"foo", "wee", ".", ".", "build.ninja", ".", "build.ninja", "win"
|
||||
)
|
||||
spec = {"target_name": "wee"}
|
||||
for key, ext in {
|
||||
"executable": ".exe",
|
||||
"shared_library": ".dll",
|
||||
"static_library": ".lib",
|
||||
}.items():
|
||||
self.assertTrue(writer.ComputeOutputFileName(spec, key).endswith(ext))
|
||||
|
||||
def test_BinaryNamesLinux(self):
|
||||
writer = ninja.NinjaWriter(
|
||||
|
||||
+1
-1
@@ -545,7 +545,7 @@ class MacTool:
|
||||
# If the user has multiple provisioning profiles installed that can be
|
||||
# used for ${bundle_identifier}, pick the most specific one (ie. the
|
||||
# provisioning profile whose pattern is the longest).
|
||||
selected_key = max(valid_provisioning_profiles, key=lambda v: len(v))
|
||||
selected_key = max(valid_provisioning_profiles, key=len)
|
||||
return valid_provisioning_profiles[selected_key]
|
||||
|
||||
def _LoadProvisioningProfile(self, profile_path):
|
||||
|
||||
+1
-1
@@ -1174,7 +1174,7 @@ def GenerateEnvironmentFiles(
|
||||
meet your requirement (e.g. for custom toolchains), you can pass
|
||||
"-G ninja_use_custom_environment_files" to the gyp to suppress file
|
||||
generation and use custom environment files prepared by yourself."""
|
||||
archs = ("x86", "x64")
|
||||
archs = ("x86", "x64", "arm64")
|
||||
if generator_flags.get("ninja_use_custom_environment_files", 0):
|
||||
cl_paths = {}
|
||||
for arch in archs:
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ def deepcopy(x):
|
||||
return _deepcopy_dispatch[type(x)](x)
|
||||
except KeyError:
|
||||
raise Error(
|
||||
"Unsupported type %s for deepcopy. Use copy.deepcopy "
|
||||
+ "or expand simple_copy support." % type(x)
|
||||
f"Unsupported type {type(x)} for deepcopy. Use copy.deepcopy "
|
||||
+ "or expand simple_copy support."
|
||||
)
|
||||
|
||||
|
||||
|
||||
+3
-20
@@ -21,27 +21,10 @@ from typing import (
|
||||
from . import requirements, specifiers, utils, version as version_module
|
||||
|
||||
T = typing.TypeVar("T")
|
||||
if sys.version_info[:2] >= (3, 8): # pragma: no cover
|
||||
from typing import Literal, TypedDict
|
||||
else: # pragma: no cover
|
||||
if typing.TYPE_CHECKING:
|
||||
from typing_extensions import Literal, TypedDict
|
||||
else:
|
||||
try:
|
||||
from typing_extensions import Literal, TypedDict
|
||||
except ImportError:
|
||||
|
||||
class Literal:
|
||||
def __init_subclass__(*_args, **_kwargs):
|
||||
pass
|
||||
|
||||
class TypedDict:
|
||||
def __init_subclass__(*_args, **_kwargs):
|
||||
pass
|
||||
|
||||
from typing import Literal, TypedDict
|
||||
|
||||
try:
|
||||
ExceptionGroup
|
||||
ExceptionGroup # Added in Python 3.11+
|
||||
except NameError: # pragma: no cover
|
||||
|
||||
class ExceptionGroup(Exception): # noqa: N818
|
||||
@@ -504,7 +487,7 @@ class _Validator(Generic[T]):
|
||||
self.raw_name = _RAW_TO_EMAIL_MAPPING[name]
|
||||
|
||||
def __get__(self, instance: "Metadata", _owner: Type["Metadata"]) -> T:
|
||||
# With Python 3.8, the caching can be replaced with functools.cached_property().
|
||||
# With Python 3.8+, the caching can be replaced with functools.cached_property().
|
||||
# No need to check the cache as attribute lookup will resolve into the
|
||||
# instance's __dict__ before __get__ is called.
|
||||
cache = instance.__dict__
|
||||
|
||||
+2
-14
@@ -127,10 +127,8 @@ def _normalize_string(string: str) -> str:
|
||||
def _abi3_applies(python_version: PythonVersion) -> bool:
|
||||
"""
|
||||
Determine if the Python version supports abi3.
|
||||
|
||||
PEP 384 was first implemented in Python 3.2.
|
||||
"""
|
||||
return len(python_version) > 1 and tuple(python_version) >= (3, 2)
|
||||
return len(python_version) > 1
|
||||
|
||||
|
||||
def _cpython_abis(py_version: PythonVersion, warn: bool = False) -> List[str]:
|
||||
@@ -146,17 +144,7 @@ def _cpython_abis(py_version: PythonVersion, warn: bool = False) -> List[str]:
|
||||
has_ext = "_d.pyd" in EXTENSION_SUFFIXES
|
||||
if with_debug or (with_debug is None and (has_refcount or has_ext)):
|
||||
debug = "d"
|
||||
if py_version < (3, 8):
|
||||
with_pymalloc = _get_config_var("WITH_PYMALLOC", warn)
|
||||
if with_pymalloc or with_pymalloc is None:
|
||||
pymalloc = "m"
|
||||
if py_version < (3, 3):
|
||||
unicode_size = _get_config_var("Py_UNICODE_SIZE", warn)
|
||||
if unicode_size == 4 or (
|
||||
unicode_size is None and sys.maxunicode == 0x10FFFF
|
||||
):
|
||||
ucs4 = "u"
|
||||
elif debug:
|
||||
if debug:
|
||||
# Debug builds can also load "normal" extension modules.
|
||||
# We can also assume no UCS-4 or pymalloc requirement.
|
||||
abis.append(f"cp{version}")
|
||||
|
||||
Reference in New Issue
Block a user