Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gyp_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# found in the LICENSE file.

import os
import sys
import subprocess
import sys


def IsCygwin():
Expand Down
2 changes: 1 addition & 1 deletion pylib/gyp/MSVSProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"""Visual Studio project reader/writer."""

import gyp.easy_xml as easy_xml
from gyp import easy_xml

# ------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions pylib/gyp/MSVSSettings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"""Unit tests for the MSVSSettings.py file."""

import unittest
import gyp.MSVSSettings as MSVSSettings

from io import StringIO

from gyp import MSVSSettings


class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion pylib/gyp/MSVSToolFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"""Visual Studio project reader/writer."""

import gyp.easy_xml as easy_xml
from gyp import easy_xml


class Writer:
Expand Down
3 changes: 1 addition & 2 deletions pylib/gyp/MSVSUserFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import re
import socket # for gethostname

import gyp.easy_xml as easy_xml

from gyp import easy_xml

# ------------------------------------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion pylib/gyp/MSVSUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import copy
import os


# A dictionary mapping supported target types to extensions.
TARGET_TYPE_EXT = {
"executable": "exe",
Expand Down
2 changes: 1 addition & 1 deletion pylib/gyp/MSVSVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"""Handle version information related to Visual Stuio."""

import errno
import glob
import os
import re
import subprocess
import sys
import glob


def JoinPath(*args):
Expand Down
22 changes: 11 additions & 11 deletions pylib/gyp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
# found in the LICENSE file.

from __future__ import annotations
import copy
import gyp.input

import argparse
import copy
import os.path
import re
import shlex
import sys
import traceback
from gyp.common import GypError

import gyp.input
from gyp.common import GypError

# Default debug modes for GYP
debug = {}
Expand Down Expand Up @@ -360,7 +361,7 @@ def gyp_main(args):
action="store",
env_name="GYP_CONFIG_DIR",
default=None,
help="The location for configuration files like " "include.gypi.",
help="The location for configuration files like include.gypi.",
)
parser.add_argument(
"-d",
Expand Down Expand Up @@ -529,14 +530,13 @@ def gyp_main(args):
generate_formats = re.split(r"[\s,]", generate_formats)
if generate_formats:
options.formats = generate_formats
# Nothing in the variable, default based on platform.
elif sys.platform == "darwin":
options.formats = ["xcode"]
elif sys.platform in ("win32", "cygwin"):
options.formats = ["msvs"]
else:
# Nothing in the variable, default based on platform.
if sys.platform == "darwin":
options.formats = ["xcode"]
elif sys.platform in ("win32", "cygwin"):
options.formats = ["msvs"]
else:
options.formats = ["make"]
options.formats = ["make"]

if not options.generator_output and options.use_environment:
g_o = os.environ.get("GYP_GENERATOR_OUTPUT")
Expand Down
8 changes: 3 additions & 5 deletions pylib/gyp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import filecmp
import os.path
import re
import tempfile
import sys
import subprocess
import shlex

import subprocess
import sys
import tempfile
from collections.abc import MutableSet


Expand All @@ -35,7 +34,6 @@ class GypError(Exception):
to the user. The main entry point will catch and display this.
"""

pass


def ExceptionAppend(e, msg):
Expand Down
24 changes: 13 additions & 11 deletions pylib/gyp/common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

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

import gyp.common
import unittest
import sys
import os
from unittest.mock import patch, MagicMock
import sys
import unittest
from unittest.mock import MagicMock, patch

import gyp.common


class TestTopologicallySorted(unittest.TestCase):
def test_Valid(self):
Expand Down Expand Up @@ -109,30 +111,30 @@ def mock_run(env, defines_stdout, expected_cmd):
return [defines, flavor]

[defines1, _] = mock_run({}, "", [])
assert {} == defines1
assert defines1 == {}

[defines2, flavor2] = mock_run(
{ "CC_target": "/opt/wasi-sdk/bin/clang" },
"#define __wasm__ 1\n#define __wasi__ 1\n",
["/opt/wasi-sdk/bin/clang"]
)
assert { "__wasm__": "1", "__wasi__": "1" } == defines2
assert defines2 == { "__wasm__": "1", "__wasi__": "1" }
assert flavor2 == "wasi"

[defines3, flavor3] = mock_run(
{ "CC_target": "/opt/wasi-sdk/bin/clang --target=wasm32" },
"#define __wasm__ 1\n",
["/opt/wasi-sdk/bin/clang", "--target=wasm32"]
)
assert { "__wasm__": "1" } == defines3
assert defines3 == { "__wasm__": "1" }
assert flavor3 == "wasm"

[defines4, flavor4] = mock_run(
{ "CC_target": "/emsdk/upstream/emscripten/emcc" },
"#define __EMSCRIPTEN__ 1\n",
["/emsdk/upstream/emscripten/emcc"]
)
assert { "__EMSCRIPTEN__": "1" } == defines4
assert defines4 == { "__EMSCRIPTEN__": "1" }
assert flavor4 == "emscripten"

# Test path which include white space
Expand All @@ -149,11 +151,11 @@ def mock_run(env, defines_stdout, expected_cmd):
"-pthread"
]
)
assert {
assert defines5 == {
"__wasm__": "1",
"__wasi__": "1",
"_REENTRANT": "1"
} == defines5
}
assert flavor5 == "wasi"

original_sep = os.sep
Expand All @@ -164,7 +166,7 @@ def mock_run(env, defines_stdout, expected_cmd):
["C:/Program Files/wasi-sdk/clang.exe"]
)
os.sep = original_sep
assert { "__wasm__": "1", "__wasi__": "1" } == defines6
assert defines6 == { "__wasm__": "1", "__wasi__": "1" }
assert flavor6 == "wasi"

if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions pylib/gyp/easy_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys
import re
import os
import locale
import os
import re
import sys
from functools import reduce


Expand Down
4 changes: 2 additions & 2 deletions pylib/gyp/easy_xml_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

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

import gyp.easy_xml as easy_xml
import unittest

from io import StringIO

from gyp import easy_xml


class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
Expand Down
7 changes: 4 additions & 3 deletions pylib/gyp/generator/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@
"""


import gyp.common
import json
import os
import posixpath

import gyp.common

debug = False

found_dependency_string = "Found dependency"
Expand Down Expand Up @@ -157,7 +158,7 @@ def _AddSources(sources, base_path, base_path_components, result):
and tracked in some other means."""
# NOTE: gyp paths are always posix style.
for source in sources:
if not len(source) or source.startswith("!!!") or source.startswith("$"):
if not len(source) or source.startswith(("!!!", "$")):
continue
# variable expansion may lead to //.
org_source = source
Expand Down Expand Up @@ -747,7 +748,7 @@ def GenerateOutput(target_list, target_dicts, data, params):

if not config.files:
raise Exception(
"Must specify files to analyze via config_path generator " "flag"
"Must specify files to analyze via config_path generator flag"
)

toplevel_dir = _ToGypPath(os.path.abspath(params["options"].toplevel_dir))
Expand Down
41 changes: 20 additions & 21 deletions pylib/gyp/generator/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
# Try to avoid setting global variables where possible.


import gyp
import gyp.common
import gyp.generator.make as make # Reuse global functions from make backend.
import os
import re
import subprocess

import gyp
import gyp.common
from gyp.generator import make # Reuse global functions from make backend.

generator_default_variables = {
"OS": "android",
"EXECUTABLE_PREFIX": "",
Expand Down Expand Up @@ -177,7 +178,7 @@ def Write(
self.WriteLn("LOCAL_MULTILIB := $(GYP_HOST_MULTILIB)")
elif sdk_version > 0:
self.WriteLn(
"LOCAL_MODULE_TARGET_ARCH := " "$(TARGET_$(GYP_VAR_PREFIX)ARCH)"
"LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH)"
)
self.WriteLn("LOCAL_SDK_VERSION := %s" % sdk_version)

Expand Down Expand Up @@ -587,11 +588,10 @@ def WriteSources(self, spec, configs, extra_sources):
local_files = []
for source in sources:
(root, ext) = os.path.splitext(source)
if "$(gyp_shared_intermediate_dir)" in source:
extra_sources.append(source)
elif "$(gyp_intermediate_dir)" in source:
extra_sources.append(source)
elif IsCPPExtension(ext) and ext != local_cpp_extension:
if ("$(gyp_shared_intermediate_dir)" in source
or "$(gyp_intermediate_dir)" in source
or (IsCPPExtension(ext) and ext != local_cpp_extension)
):
extra_sources.append(source)
else:
local_files.append(os.path.normpath(os.path.join(self.path, source)))
Expand Down Expand Up @@ -730,19 +730,18 @@ def ComputeOutput(self, spec):
path = "$($(GYP_HOST_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES)"
else:
path = "$($(GYP_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)"
# Other targets just get built into their intermediate dir.
elif self.toolset == "host":
path = (
"$(call intermediates-dir-for,%s,%s,true,,"
"$(GYP_HOST_VAR_PREFIX))"
% (self.android_class, self.android_module)
)
else:
# Other targets just get built into their intermediate dir.
if self.toolset == "host":
path = (
"$(call intermediates-dir-for,%s,%s,true,,"
"$(GYP_HOST_VAR_PREFIX))"
% (self.android_class, self.android_module)
)
else:
path = (
f"$(call intermediates-dir-for,{self.android_class},"
f"{self.android_module},,,$(GYP_VAR_PREFIX))"
)
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?
return os.path.join(path, self.ComputeOutputBasename(spec))
Expand Down
1 change: 1 addition & 0 deletions pylib/gyp/generator/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import os
import signal
import subprocess

import gyp.common
import gyp.xcode_emulation

Expand Down
5 changes: 3 additions & 2 deletions pylib/gyp/generator/compile_commands_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import gyp.common
import gyp.xcode_emulation
import json
import os

import gyp.common
import gyp.xcode_emulation

generator_additional_non_configuration_keys = []
generator_additional_path_sections = []
generator_extra_sources_for_rules = []
Expand Down
3 changes: 2 additions & 1 deletion pylib/gyp/generator/dump_dependency_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
# found in the LICENSE file.


import json
import os

import gyp
import gyp.common
import gyp.msvs_emulation
import json

generator_supports_multiple_toolsets = True

Expand Down
Loading
Loading