summaryrefslogtreecommitdiffstats
path: root/methods.py
diff options
context:
space:
mode:
Diffstat (limited to 'methods.py')
-rw-r--r--methods.py84
1 files changed, 82 insertions, 2 deletions
diff --git a/methods.py b/methods.py
index 33ab894f92..18b4ceb74f 100644
--- a/methods.py
+++ b/methods.py
@@ -6,9 +6,23 @@ import subprocess
from collections import OrderedDict
from collections.abc import Mapping
from typing import Iterator
+from pathlib import Path
+from os.path import normpath, basename
+# Get the "Godot" folder name ahead of time
+base_folder_path = str(os.path.abspath(Path(__file__).parent)) + "/"
+base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
+# Listing all the folders we have converted
+# for SCU in scu_builders.py
+_scu_folders = set()
-def add_source_files(self, sources, files):
+
+def set_scu_folders(scu_folders):
+ global _scu_folders
+ _scu_folders = scu_folders
+
+
+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)
@@ -23,7 +37,7 @@ def add_source_files(self, sources, files):
skip_gen_cpp = "*" in files
dir_path = self.Dir(".").abspath
files = sorted(glob.glob(dir_path + "/" + files))
- if skip_gen_cpp:
+ if skip_gen_cpp and not allow_gen:
files = [f for f in files if not f.endswith(".gen.cpp")]
# Add each path as compiled Object following environment (self) configuration
@@ -35,6 +49,72 @@ def add_source_files(self, sources, files):
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:
+ return 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)
+ # if the section name is in the hash table?
+ # i.e. is it part of the SCU build?
+ global _scu_folders
+ if section_name not in (_scu_folders):
+ return False
+
+ if self["verbose"]:
+ print("SCU building " + section_name)
+
+ # Add all the gen.cpp files in the SCU directory
+ add_source_files_orig(self, sources, subdir + "scu/scu_*.gen.cpp", True)
+ return True
+ return False
+
+
+# Either builds the folder using the SCU system,
+# or reverts to regular build.
+def add_source_files(self, sources, files, allow_gen=False):
+ if not add_source_files_scu(self, sources, files, allow_gen):
+ # Wraps the original function when scu build is not active.
+ add_source_files_orig(self, sources, files, allow_gen)
+ return False
+ return True
+
+
def disable_warnings(self):
# 'self' is the environment
if self.msvc: