summaryrefslogtreecommitdiffstats
path: root/methods.py
diff options
context:
space:
mode:
Diffstat (limited to 'methods.py')
-rw-r--r--methods.py144
1 files changed, 21 insertions, 123 deletions
diff --git a/methods.py b/methods.py
index 9e881773c9..64c3839718 100644
--- a/methods.py
+++ b/methods.py
@@ -73,21 +73,13 @@ def print_error(*values: object) -> None:
def add_source_files_orig(self, sources, files, allow_gen=False):
# Convert string to list of absolute paths (including expanding wildcard)
- if isinstance(files, (str, bytes)):
- # Keep SCons project-absolute path as they are (no wildcard support)
- if files.startswith("#"):
- if "*" in files:
- print_error("Wildcards can't be expanded in SCons project-absolute path: '{}'".format(files))
- return
- files = [files]
- else:
- # Exclude .gen.cpp files from globbing, to avoid including obsolete ones.
- # They should instead be added manually.
- skip_gen_cpp = "*" in files
- dir_path = self.Dir(".").abspath
- files = sorted(glob.glob(dir_path + "/" + files))
- if skip_gen_cpp and not allow_gen:
- files = [f for f in files if not f.endswith(".gen.cpp")]
+ if isinstance(files, str):
+ # Exclude .gen.cpp files from globbing, to avoid including obsolete ones.
+ # They should instead be added manually.
+ skip_gen_cpp = "*" in files
+ files = self.Glob(files)
+ if skip_gen_cpp and not allow_gen:
+ files = [f for f in files if not str(f).endswith(".gen.cpp")]
# Add each path as compiled Object following environment (self) configuration
for path in files:
@@ -98,35 +90,6 @@ def add_source_files_orig(self, sources, files, allow_gen=False):
sources.append(obj)
-# The section name is used for checking
-# the hash table to see whether the folder
-# is included in the SCU build.
-# It will be something like "core/math".
-def _find_scu_section_name(subdir):
- section_path = os.path.abspath(subdir) + "/"
-
- folders = []
- folder = ""
-
- for i in range(8):
- folder = os.path.dirname(section_path)
- folder = os.path.basename(folder)
- if folder == base_folder_only:
- break
- folders += [folder]
- section_path += "../"
- section_path = os.path.abspath(section_path) + "/"
-
- section_name = ""
- for n in range(len(folders)):
- # section_name += folders[len(folders) - n - 1] + " "
- section_name += folders[len(folders) - n - 1]
- if n != (len(folders) - 1):
- section_name += "/"
-
- return section_name
-
-
def add_source_files_scu(self, sources, files, allow_gen=False):
if self["scu_build"] and isinstance(files, str):
if "*." not in files:
@@ -135,10 +98,8 @@ def add_source_files_scu(self, sources, files, allow_gen=False):
# If the files are in a subdirectory, we want to create the scu gen
# files inside this subdirectory.
subdir = os.path.dirname(files)
- if subdir != "":
- subdir += "/"
-
- section_name = _find_scu_section_name(subdir)
+ subdir = subdir if subdir == "" else subdir + "/"
+ section_name = self.Dir(subdir).tpath
# if the section name is in the hash table?
# i.e. is it part of the SCU build?
global _scu_folders
@@ -277,34 +238,6 @@ def get_version_info(module_version_string="", silent=False):
return version_info
-def parse_cg_file(fname, uniforms, sizes, conditionals):
- with open(fname, "r", encoding="utf-8") as fs:
- line = fs.readline()
-
- while line:
- if re.match(r"^\s*uniform", line):
- res = re.match(r"uniform ([\d\w]*) ([\d\w]*)")
- type = res.groups(1)
- name = res.groups(2)
-
- uniforms.append(name)
-
- if type.find("texobj") != -1:
- sizes.append(1)
- else:
- t = re.match(r"float(\d)x(\d)", type)
- if t:
- sizes.append(int(t.groups(1)) * int(t.groups(2)))
- else:
- t = re.match(r"float(\d)", type)
- sizes.append(int(t.groups(1)))
-
- if line.find("[branch]") != -1:
- conditionals.append(name)
-
- line = fs.readline()
-
-
def get_cmdline_bool(option, default):
"""We use `ARGUMENTS.get()` to check if options were manually overridden on the command line,
and SCons' _text2bool helper to convert them to booleans, otherwise they're handled as strings.
@@ -404,10 +337,6 @@ def convert_custom_modules_path(path):
return path
-def disable_module(self):
- self.disabled_modules.append(self.current_module)
-
-
def module_add_dependencies(self, module, dependencies, optional=False):
"""
Adds dependencies for a given module.
@@ -428,19 +357,21 @@ def module_check_dependencies(self, module):
Meant to be used in module `can_build` methods.
Returns a boolean (True if dependencies are satisfied).
"""
- missing_deps = []
+ missing_deps = set()
required_deps = self.module_dependencies[module][0] if module in self.module_dependencies else []
for dep in required_deps:
opt = "module_{}_enabled".format(dep)
- if opt not in self or not self[opt]:
- missing_deps.append(dep)
-
- if missing_deps != []:
- print_warning(
- "Disabling '{}' module as the following dependencies are not satisfied: {}".format(
- module, ", ".join(missing_deps)
+ if opt not in self or not self[opt] or not module_check_dependencies(self, dep):
+ missing_deps.add(dep)
+
+ if missing_deps:
+ if module not in self.disabled_modules:
+ print_warning(
+ "Disabling '{}' module as the following dependencies are not satisfied: {}".format(
+ module, ", ".join(missing_deps)
+ )
)
- )
+ self.disabled_modules.add(module)
return False
else:
return True
@@ -565,40 +496,7 @@ def detect_visual_c_compiler_version(tools_env):
vc_chosen_compiler_index = -1
vc_chosen_compiler_str = ""
- # Start with Pre VS 2017 checks which uses VCINSTALLDIR:
- if "VCINSTALLDIR" in tools_env:
- # print("Checking VCINSTALLDIR")
-
- # find() works with -1 so big ifs below are needed... the simplest solution, in fact
- # First test if amd64 and amd64_x86 compilers are present in the path
- vc_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64;")
- if vc_amd64_compiler_detection_index > -1:
- vc_chosen_compiler_index = vc_amd64_compiler_detection_index
- vc_chosen_compiler_str = "amd64"
-
- vc_amd64_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64_x86;")
- if vc_amd64_x86_compiler_detection_index > -1 and (
- vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index
- ):
- vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index
- vc_chosen_compiler_str = "amd64_x86"
-
- # Now check the 32 bit compilers
- vc_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN;")
- if vc_x86_compiler_detection_index > -1 and (
- vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_x86_compiler_detection_index
- ):
- vc_chosen_compiler_index = vc_x86_compiler_detection_index
- vc_chosen_compiler_str = "x86"
-
- vc_x86_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\x86_amd64;")
- 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 = vc_x86_amd64_compiler_detection_index
- vc_chosen_compiler_str = "x86_amd64"
-
- # and for VS 2017 and newer we check VCTOOLSINSTALLDIR:
+ # VS 2017 and newer should set VCTOOLSINSTALLDIR
if "VCTOOLSINSTALLDIR" in tools_env:
# Newer versions have a different path available
vc_amd64_compiler_detection_index = (