ci: add Python static analysis check via mypy

This commit is contained in:
Jiri Suchan 2022-08-23 22:21:46 +09:00
parent f47979f087
commit c5bd2f9dce
20 changed files with 105 additions and 59 deletions

View File

@ -27,7 +27,7 @@ jobs:
sudo apt-get install -qq dos2unix recode clang-format-13 libxml2-utils python3-pip moreutils sudo apt-get install -qq dos2unix recode clang-format-13 libxml2-utils python3-pip moreutils
sudo update-alternatives --remove-all clang-format || true sudo update-alternatives --remove-all clang-format || true
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 100 sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 100
sudo pip3 install black==22.3.0 pygments pytest sudo pip3 install black==22.3.0 pygments pytest==7.1.2 mypy==0.971
- name: File formatting checks (file_format.sh) - name: File formatting checks (file_format.sh)
run: | run: |
@ -41,6 +41,10 @@ jobs:
run: | run: |
bash ./misc/scripts/black_format.sh bash ./misc/scripts/black_format.sh
- name: Python scripts static analysis (mypy_check.sh)
run: |
bash ./misc/scripts/mypy_check.sh
- name: Python builders checks via pytest (pytest_builders.sh) - name: Python builders checks via pytest (pytest_builders.sh)
run: | run: |
bash ./misc/scripts/pytest_builders.sh bash ./misc/scripts/pytest_builders.sh

View File

@ -2,6 +2,7 @@
All such functions are invoked in a subprocess on Windows to prevent build flakiness. All such functions are invoked in a subprocess on Windows to prevent build flakiness.
""" """
import zlib
from platform_methods import subprocess_main from platform_methods import subprocess_main
@ -33,7 +34,6 @@ def make_certs_header(target, source, env):
g = open(dst, "w", encoding="utf-8") g = open(dst, "w", encoding="utf-8")
buf = f.read() buf = f.read()
decomp_size = len(buf) decomp_size = len(buf)
import zlib
# Use maximum zlib compression level to further reduce file size # Use maximum zlib compression level to further reduce file size
# (at the cost of initial build times). # (at the cost of initial build times).
@ -208,7 +208,7 @@ def make_license_header(target, source, env):
from collections import OrderedDict from collections import OrderedDict
projects = OrderedDict() projects: dict = OrderedDict()
license_list = [] license_list = []
with open(src_copyright, "r", encoding="utf-8") as copyright_file: with open(src_copyright, "r", encoding="utf-8") as copyright_file:
@ -230,7 +230,7 @@ def make_license_header(target, source, env):
part = {} part = {}
reader.next_line() reader.next_line()
data_list = [] data_list: list = []
for project in iter(projects.values()): for project in iter(projects.values()):
for part in project: for part in project:
part["file_index"] = len(data_list) part["file_index"] = len(data_list)

View File

@ -16,7 +16,7 @@ def make_default_controller_mappings(target, source, env):
g.write('#include "core/input/default_controller_mappings.h"\n') g.write('#include "core/input/default_controller_mappings.h"\n')
# ensure mappings have a consistent order # ensure mappings have a consistent order
platform_mappings = OrderedDict() platform_mappings: dict = OrderedDict()
for src_path in source: for src_path in source:
with open(src_path, "r") as f: with open(src_path, "r") as f:
# read mapping file and skip header # read mapping file and skip header

View File

@ -526,7 +526,7 @@ def main() -> None:
) )
if os.path.exists(lang_file): if os.path.exists(lang_file):
try: try:
import polib import polib # type: ignore
except ImportError: except ImportError:
print("Base template strings localization requires `polib`.") print("Base template strings localization requires `polib`.")
exit(1) exit(1)
@ -739,9 +739,10 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
f.write(f"- {make_link(url, title)}\n\n") f.write(f"- {make_link(url, title)}\n\n")
# Properties overview # Properties overview
ml: List[Tuple[Optional[str], ...]] = []
if len(class_def.properties) > 0: if len(class_def.properties) > 0:
f.write(make_heading("Properties", "-")) f.write(make_heading("Properties", "-"))
ml: List[Tuple[Optional[str], ...]] = [] ml = []
for property_def in class_def.properties.values(): for property_def in class_def.properties.values():
type_rst = property_def.type_name.to_rst(state) type_rst = property_def.type_name.to_rst(state)
default = property_def.default_value default = property_def.default_value
@ -757,7 +758,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
# Constructors, Methods, Operators overview # Constructors, Methods, Operators overview
if len(class_def.constructors) > 0: if len(class_def.constructors) > 0:
f.write(make_heading("Constructors", "-")) f.write(make_heading("Constructors", "-"))
ml: List[Tuple[Optional[str], ...]] = [] ml = []
for method_list in class_def.constructors.values(): for method_list in class_def.constructors.values():
for m in method_list: for m in method_list:
ml.append(make_method_signature(class_def, m, "constructor", state)) ml.append(make_method_signature(class_def, m, "constructor", state))
@ -765,7 +766,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
if len(class_def.methods) > 0: if len(class_def.methods) > 0:
f.write(make_heading("Methods", "-")) f.write(make_heading("Methods", "-"))
ml: List[Tuple[Optional[str], ...]] = [] ml = []
for method_list in class_def.methods.values(): for method_list in class_def.methods.values():
for m in method_list: for m in method_list:
ml.append(make_method_signature(class_def, m, "method", state)) ml.append(make_method_signature(class_def, m, "method", state))
@ -773,7 +774,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
if len(class_def.operators) > 0: if len(class_def.operators) > 0:
f.write(make_heading("Operators", "-")) f.write(make_heading("Operators", "-"))
ml: List[Tuple[Optional[str], ...]] = [] ml = []
for method_list in class_def.operators.values(): for method_list in class_def.operators.values():
for m in method_list: for m in method_list:
ml.append(make_method_signature(class_def, m, "operator", state)) ml.append(make_method_signature(class_def, m, "operator", state))
@ -858,7 +859,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
f.write(make_heading("Annotations", "-")) f.write(make_heading("Annotations", "-"))
index = 0 index = 0
for method_list in class_def.annotations.values(): for method_list in class_def.annotations.values(): # type: ignore
for i, m in enumerate(method_list): for i, m in enumerate(method_list):
if index != 0: if index != 0:
f.write("----\n\n") f.write("----\n\n")
@ -1039,17 +1040,15 @@ def make_method_signature(
) -> Tuple[str, str]: ) -> Tuple[str, str]:
ret_type = "" ret_type = ""
is_method_def = isinstance(definition, MethodDef) if isinstance(definition, MethodDef):
if is_method_def:
ret_type = definition.return_type.to_rst(state) ret_type = definition.return_type.to_rst(state)
qualifiers = None qualifiers = None
if is_method_def or isinstance(definition, AnnotationDef): if isinstance(definition, (MethodDef, AnnotationDef)):
qualifiers = definition.qualifiers qualifiers = definition.qualifiers
out = "" out = ""
if isinstance(definition, MethodDef) and ref_type != "":
if is_method_def and ref_type != "":
if ref_type == "operator": if ref_type == "operator":
op_name = definition.name.replace("<", "\\<") # So operator "<" gets correctly displayed. op_name = definition.name.replace("<", "\\<") # So operator "<" gets correctly displayed.
out += f":ref:`{op_name}<class_{class_def.name}_{ref_type}_{sanitize_operator_name(definition.name, state)}_{definition.return_type.type_name}>` " out += f":ref:`{op_name}<class_{class_def.name}_{ref_type}_{sanitize_operator_name(definition.name, state)}_{definition.return_type.type_name}>` "
@ -1456,18 +1455,14 @@ def format_text_block(
escape_post = True escape_post = True
elif cmd.startswith("param"): elif cmd.startswith("param"):
valid_context = ( valid_context = isinstance(context, (MethodDef, SignalDef, AnnotationDef))
isinstance(context, MethodDef)
or isinstance(context, SignalDef)
or isinstance(context, AnnotationDef)
)
if not valid_context: if not valid_context:
print_error( print_error(
f'{state.current_class}.xml: Argument reference "{link_target}" used outside of method, signal, or annotation context in {context_name}.', f'{state.current_class}.xml: Argument reference "{link_target}" used outside of method, signal, or annotation context in {context_name}.',
state, state,
) )
else: else:
context_params: List[ParameterDef] = context.parameters context_params: List[ParameterDef] = context.parameters # type: ignore
found = False found = False
for param_def in context_params: for param_def in context_params:
if param_def.name == link_target: if param_def.name == link_target:

View File

@ -60,7 +60,7 @@ BASE_STRINGS = [
## <xml-line-number-hack from="https://stackoverflow.com/a/36430270/10846399"> ## <xml-line-number-hack from="https://stackoverflow.com/a/36430270/10846399">
import sys import sys
sys.modules["_elementtree"] = None sys.modules["_elementtree"] = None # type: ignore
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
## override the parser to get the line number ## override the parser to get the line number

View File

@ -9,6 +9,7 @@ import shutil
import subprocess import subprocess
import tempfile import tempfile
import uuid import uuid
import zlib
from platform_methods import subprocess_main from platform_methods import subprocess_main
@ -28,7 +29,6 @@ def make_doc_header(target, source, env):
buf = (docbegin + buf + docend).encode("utf-8") buf = (docbegin + buf + docend).encode("utf-8")
decomp_size = len(buf) decomp_size = len(buf)
import zlib
# Use maximum zlib compression level to further reduce file size # Use maximum zlib compression level to further reduce file size
# (at the cost of initial build times). # (at the cost of initial build times).
@ -88,9 +88,6 @@ def make_translations_header(target, source, env, category):
g.write("#ifndef _{}_TRANSLATIONS_H\n".format(category.upper())) g.write("#ifndef _{}_TRANSLATIONS_H\n".format(category.upper()))
g.write("#define _{}_TRANSLATIONS_H\n".format(category.upper())) g.write("#define _{}_TRANSLATIONS_H\n".format(category.upper()))
import zlib
import os.path
sorted_paths = sorted(source, key=lambda path: os.path.splitext(os.path.basename(path))[0]) sorted_paths = sorted(source, key=lambda path: os.path.splitext(os.path.basename(path))[0])
msgfmt_available = shutil.which("msgfmt") is not None msgfmt_available = shutil.which("msgfmt") is not None

View File

@ -8,6 +8,7 @@ import re
import shutil import shutil
import subprocess import subprocess
import sys import sys
from typing import Dict, Tuple
class Message: class Message:
@ -42,7 +43,7 @@ class Message:
return "\n".join(lines) return "\n".join(lines)
messages_map = {} # (id, context) -> Message. messages_map: Dict[Tuple[str, str], Message] = {} # (id, context) -> Message.
line_nb = False line_nb = False
@ -51,11 +52,11 @@ for arg in sys.argv[1:]:
print("Enabling line numbers in the context locations.") print("Enabling line numbers in the context locations.")
line_nb = True line_nb = True
else: else:
os.sys.exit("Non supported argument '" + arg + "'. Aborting.") sys.exit("Non supported argument '" + arg + "'. Aborting.")
if not os.path.exists("editor"): if not os.path.exists("editor"):
os.sys.exit("ERROR: This script should be started from the root of the git repo.") sys.exit("ERROR: This script should be started from the root of the git repo.")
matches = [] matches = []

View File

@ -3,6 +3,10 @@
All such functions are invoked in a subprocess on Windows to prevent build flakiness. All such functions are invoked in a subprocess on Windows to prevent build flakiness.
""" """
import os.path
from typing import Optional
from platform_methods import subprocess_main from platform_methods import subprocess_main
@ -30,7 +34,7 @@ class GLES3HeaderStruct:
self.specialization_values = [] self.specialization_values = []
def include_file_in_gles3_header(filename, header_data, depth): def include_file_in_gles3_header(filename: str, header_data: GLES3HeaderStruct, depth: int):
fs = open(filename, "r") fs = open(filename, "r")
line = fs.readline() line = fs.readline()
@ -91,8 +95,6 @@ def include_file_in_gles3_header(filename, header_data, depth):
while line.find("#include ") != -1: while line.find("#include ") != -1:
includeline = line.replace("#include ", "").strip()[1:-1] includeline = line.replace("#include ", "").strip()[1:-1]
import os.path
included_file = os.path.relpath(os.path.dirname(filename) + "/" + includeline) included_file = os.path.relpath(os.path.dirname(filename) + "/" + includeline)
if not included_file in header_data.vertex_included_files and header_data.reading == "vertex": if not included_file in header_data.vertex_included_files and header_data.reading == "vertex":
header_data.vertex_included_files += [included_file] header_data.vertex_included_files += [included_file]
@ -182,7 +184,7 @@ def include_file_in_gles3_header(filename, header_data, depth):
return header_data return header_data
def build_gles3_header(filename, include, class_suffix, header_data=None): def build_gles3_header(filename: str, include: str, class_suffix: str, header_data: Optional[GLES3HeaderStruct] = None):
header_data = header_data or GLES3HeaderStruct() header_data = header_data or GLES3HeaderStruct()
include_file_in_gles3_header(filename, header_data, 0) include_file_in_gles3_header(filename, header_data, 0)

View File

@ -4,13 +4,15 @@ All such functions are invoked in a subprocess on Windows to prevent build flaki
""" """
import os.path import os.path
from typing import Optional, Iterable
from platform_methods import subprocess_main from platform_methods import subprocess_main
def generate_inline_code(input_lines, insert_newline=True): def generate_inline_code(input_lines: Iterable[str], insert_newline: bool = True):
"""Take header data and generate inline code """Take header data and generate inline code
:param: list input_lines: values for shared inline code :param: input_lines: values for shared inline code
:return: str - generated inline value :return: str - generated inline value
""" """
output = [] output = []
@ -40,7 +42,7 @@ class RDHeaderStruct:
self.compute_offset = 0 self.compute_offset = 0
def include_file_in_rd_header(filename, header_data, depth): def include_file_in_rd_header(filename: str, header_data: RDHeaderStruct, depth: int) -> RDHeaderStruct:
fs = open(filename, "r") fs = open(filename, "r")
line = fs.readline() line = fs.readline()
@ -112,7 +114,7 @@ def include_file_in_rd_header(filename, header_data, depth):
return header_data return header_data
def build_rd_header(filename, header_data=None): def build_rd_header(filename: str, header_data: Optional[RDHeaderStruct] = None) -> None:
header_data = header_data or RDHeaderStruct() header_data = header_data or RDHeaderStruct()
include_file_in_rd_header(filename, header_data, 0) include_file_in_rd_header(filename, header_data, 0)
@ -171,7 +173,7 @@ class RAWHeaderStruct:
self.code = "" self.code = ""
def include_file_in_raw_header(filename, header_data, depth): def include_file_in_raw_header(filename: str, header_data: RAWHeaderStruct, depth: int) -> None:
fs = open(filename, "r") fs = open(filename, "r")
line = fs.readline() line = fs.readline()
@ -191,7 +193,7 @@ def include_file_in_raw_header(filename, header_data, depth):
fs.close() fs.close()
def build_raw_header(filename, header_data=None): def build_raw_header(filename: str, header_data: Optional[RAWHeaderStruct] = None):
header_data = header_data or RAWHeaderStruct() header_data = header_data or RAWHeaderStruct()
include_file_in_raw_header(filename, header_data, 0) include_file_in_raw_header(filename, header_data, 0)

View File

@ -1,6 +1,5 @@
import os import os
import re import re
import sys
import glob import glob
import subprocess import subprocess
from collections import OrderedDict from collections import OrderedDict
@ -663,7 +662,6 @@ def detect_visual_c_compiler_version(tools_env):
if vc_x86_amd64_compiler_detection_index > -1 and ( if vc_x86_amd64_compiler_detection_index > -1 and (
vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index
): ):
vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index
vc_chosen_compiler_str = "x86_amd64" vc_chosen_compiler_str = "x86_amd64"
return vc_chosen_compiler_str return vc_chosen_compiler_str
@ -781,7 +779,7 @@ def generate_vs_project(env, num_jobs):
f'bin\\godot.windows.{config}{dev}.{plat_id}{f".{name}" if name else ""}.exe' f'bin\\godot.windows.{config}{dev}.{plat_id}{f".{name}" if name else ""}.exe'
for config in ModuleConfigs.CONFIGURATIONS for config in ModuleConfigs.CONFIGURATIONS
for plat_id in ModuleConfigs.PLATFORM_IDS for plat_id in ModuleConfigs.PLATFORM_IDS
for dev in ModuleConfig.DEV_SUFFIX for dev in ModuleConfigs.DEV_SUFFIX
] ]
self.arg_dict["cpppaths"] += ModuleConfigs.for_every_variant(env["CPPPATH"] + [includes]) self.arg_dict["cpppaths"] += ModuleConfigs.for_every_variant(env["CPPPATH"] + [includes])
self.arg_dict["cppdefines"] += ModuleConfigs.for_every_variant(env["CPPDEFINES"] + defines) self.arg_dict["cppdefines"] += ModuleConfigs.for_every_variant(env["CPPDEFINES"] + defines)

11
misc/scripts/mypy.ini Normal file
View File

@ -0,0 +1,11 @@
[mypy]
ignore_missing_imports = true
disallow_any_generics = True
pretty = True
show_column_numbers = True
warn_redundant_casts = True
warn_return_any = True
warn_unreachable = True
namespace_packages = True
explicit_package_bases = True

6
misc/scripts/mypy_check.sh Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -uo pipefail
echo -e "Python: mypy static analysis..."
mypy --config-file=./misc/scripts/mypy.ini .

View File

@ -5,6 +5,7 @@ import os.path
import shlex import shlex
import subprocess import subprocess
from dataclasses import dataclass from dataclasses import dataclass
from typing import Optional, List
def find_dotnet_cli(): def find_dotnet_cli():
@ -150,10 +151,7 @@ def find_any_msbuild_tool(mono_prefix):
return None return None
def run_msbuild(tools: ToolsLocation, sln: str, msbuild_args: [str] = None): def run_msbuild(tools: ToolsLocation, sln: str, msbuild_args: Optional[List[str]] = None):
if msbuild_args is None:
msbuild_args = []
using_msbuild_mono = False using_msbuild_mono = False
# Preference order: dotnet CLI > Standalone MSBuild > Mono's MSBuild # Preference order: dotnet CLI > Standalone MSBuild > Mono's MSBuild
@ -169,7 +167,7 @@ def run_msbuild(tools: ToolsLocation, sln: str, msbuild_args: [str] = None):
args += [sln] args += [sln]
if len(msbuild_args) > 0: if msbuild_args:
args += msbuild_args args += msbuild_args
print("Running MSBuild: ", " ".join(shlex.quote(arg) for arg in args), flush=True) print("Running MSBuild: ", " ".join(shlex.quote(arg) for arg in args), flush=True)

View File

@ -3,6 +3,11 @@ import sys
import platform import platform
import subprocess import subprocess
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from SCons import Environment
def is_active(): def is_active():
return True return True
@ -17,8 +22,6 @@ def can_build():
def get_opts(): def get_opts():
from SCons.Variables import BoolVariable, EnumVariable
return [ return [
("ANDROID_SDK_ROOT", "Path to the Android SDK", get_env_android_sdk_root()), ("ANDROID_SDK_ROOT", "Path to the Android SDK", get_env_android_sdk_root()),
("ndk_platform", 'Target platform (android-<api>, e.g. "android-24")', "android-24"), ("ndk_platform", 'Target platform (android-<api>, e.g. "android-24")', "android-24"),
@ -74,7 +77,7 @@ def install_ndk_if_needed(env):
env["ANDROID_NDK_ROOT"] = get_android_ndk_root(env) env["ANDROID_NDK_ROOT"] = get_android_ndk_root(env)
def configure(env): def configure(env: "Environment"):
# Validate arch. # Validate arch.
supported_arches = ["x86_32", "x86_64", "arm32", "arm64"] supported_arches = ["x86_32", "x86_64", "arm32", "arm64"]
if env["arch"] not in supported_arches: if env["arch"] not in supported_arches:

View File

@ -2,6 +2,11 @@ import os
import sys import sys
from methods import detect_darwin_sdk_path from methods import detect_darwin_sdk_path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from SCons import Environment
def is_active(): def is_active():
return True return True
@ -42,7 +47,7 @@ def get_flags():
] ]
def configure(env): def configure(env: "Environment"):
# Validate arch. # Validate arch.
supported_arches = ["x86_64", "arm64"] supported_arches = ["x86_64", "arm64"]
if env["arch"] not in supported_arches: if env["arch"] not in supported_arches:

View File

@ -4,6 +4,11 @@ import sys
from methods import get_compiler_version, using_gcc from methods import get_compiler_version, using_gcc
from platform_methods import detect_arch from platform_methods import detect_arch
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from SCons import Environment
def is_active(): def is_active():
return True return True
@ -55,7 +60,7 @@ def get_flags():
] ]
def configure(env): def configure(env: "Environment"):
# Validate arch. # Validate arch.
supported_arches = ["x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc32", "ppc64"] supported_arches = ["x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc32", "ppc64"]
if env["arch"] not in supported_arches: if env["arch"] not in supported_arches:

View File

@ -3,6 +3,11 @@ import sys
from methods import detect_darwin_sdk_path from methods import detect_darwin_sdk_path
from platform_methods import detect_arch from platform_methods import detect_arch
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from SCons import Environment
def is_active(): def is_active():
return True return True
@ -72,7 +77,7 @@ def get_mvk_sdk_path():
return os.path.join(os.path.join(dirname, ver_file), "MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/") return os.path.join(os.path.join(dirname, ver_file), "MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/")
def configure(env): def configure(env: "Environment"):
# Validate arch. # Validate arch.
supported_arches = ["x86_64", "arm64"] supported_arches = ["x86_64", "arm64"]
if env["arch"] not in supported_arches: if env["arch"] not in supported_arches:

View File

@ -3,6 +3,11 @@ import os
import sys import sys
from platform_methods import detect_arch from platform_methods import detect_arch
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from SCons import Environment
def is_active(): def is_active():
return True return True
@ -39,7 +44,7 @@ def get_flags():
] ]
def configure(env): def configure(env: "Environment"):
# Validate arch. # Validate arch.
supported_arches = ["x86_32", "x86_64", "arm32"] supported_arches = ["x86_32", "x86_64", "arm32"]
if env["arch"] not in supported_arches: if env["arch"] not in supported_arches:
@ -83,7 +88,7 @@ def configure(env):
env.AppendUnique(CCFLAGS=["/utf-8"]) env.AppendUnique(CCFLAGS=["/utf-8"])
# ANGLE # ANGLE
angle_root = os.getenv("ANGLE_SRC_PATH") angle_root = os.environ["ANGLE_SRC_PATH"]
env.Prepend(CPPPATH=[angle_root + "/include"]) env.Prepend(CPPPATH=[angle_root + "/include"])
jobs = str(env.GetOption("num_jobs")) jobs = str(env.GetOption("num_jobs"))
angle_build_cmd = ( angle_build_cmd = (
@ -94,7 +99,7 @@ def configure(env):
+ " /p:Configuration=Release /p:Platform=" + " /p:Configuration=Release /p:Platform="
) )
if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"): if os.path.isfile(f"{angle_root}/winrt/10/src/angle.sln"):
env["build_angle"] = True env["build_angle"] = True
## Architecture ## Architecture

View File

@ -11,6 +11,10 @@ from emscripten_helpers import (
) )
from methods import get_compiler_version from methods import get_compiler_version
from SCons.Util import WhereIs from SCons.Util import WhereIs
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from SCons import Environment
def is_active(): def is_active():
@ -60,7 +64,7 @@ def get_flags():
] ]
def configure(env): def configure(env: "Environment"):
# Validate arch. # Validate arch.
supported_arches = ["wasm32"] supported_arches = ["wasm32"]
if env["arch"] not in supported_arches: if env["arch"] not in supported_arches:

View File

@ -4,6 +4,11 @@ import subprocess
import sys import sys
from platform_methods import detect_arch from platform_methods import detect_arch
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from SCons import Environment
# To match other platforms # To match other platforms
STACK_SIZE = 8388608 STACK_SIZE = 8388608
@ -588,7 +593,7 @@ def configure_mingw(env):
env.Append(BUILDERS={"RES": env.Builder(action=build_res_file, suffix=".o", src_suffix=".rc")}) env.Append(BUILDERS={"RES": env.Builder(action=build_res_file, suffix=".o", src_suffix=".rc")})
def configure(env): def configure(env: "Environment"):
# Validate arch. # Validate arch.
supported_arches = ["x86_32", "x86_64", "arm32", "arm64"] supported_arches = ["x86_32", "x86_64", "arm32", "arm64"]
if env["arch"] not in supported_arches: if env["arch"] not in supported_arches: