aboutsummaryrefslogtreecommitdiff
path: root/scripts/build/option_handler.py
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-07-09 07:03:54 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-07-21 20:35:14 +0200
commit72675c62265f141e8aef8b925b753aa31a354645 (patch)
tree4664643e55fe80a4065b184f2bb87613f0000a50 /scripts/build/option_handler.py
parent40e412da4a11de97dda041287e306ca285c50ccf (diff)
Separate build functions from SConstruct
Placed in scripts/build Streamline scons options with OptionsClass in scripts/build/option_handler.py Move `show_progress` cache function to scripts/build/cache.py Move `GlobRecursive` function to scripts/build/glob_recursive.py Make environment clone of godot-cpp's build Prevents environment leakage into godot-cpp
Diffstat (limited to 'scripts/build/option_handler.py')
-rw-r--r--scripts/build/option_handler.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/scripts/build/option_handler.py b/scripts/build/option_handler.py
new file mode 100644
index 0000000..3cebc1a
--- /dev/null
+++ b/scripts/build/option_handler.py
@@ -0,0 +1,39 @@
+from typing import Tuple, Iterable
+from SCons.Variables import Variables
+
+class OptionsClass:
+ def __init__(self, args):
+ self.opts = None
+ self.opt_list = []
+ self.args = args
+ self.saved_args = args.copy()
+
+ def Add(self, variableOrKey, *argv, **kwarg):
+
+ self.opt_list.append([variableOrKey, argv, kwarg])
+ # Neccessary to have our own build options without errors
+ if isinstance(variableOrKey, str):
+ self.args.pop(variableOrKey, True)
+ else:
+ self.args.pop(variableOrKey[0], True)
+
+ def Make(self, customs : Iterable[str]):
+ self.args = self.saved_args
+ profile = self.args.get("profile", "")
+ if profile:
+ if os.path.isfile(profile):
+ customs.append(profile)
+ elif os.path.isfile(profile + ".py"):
+ customs.append(profile + ".py")
+ self.opts = Variables(customs, self.args)
+ for opt in self.opt_list:
+ if opt[1] == None and opt[2] == None:
+ self.opts.Add(opt[0])
+ else:
+ self.opts.Add(opt[0], *opt[1], **opt[2])
+
+ def Finalize(self, env):
+ self.opts.Update(env)
+
+ def GenerateHelpText(self, env):
+ return self.opts.GenerateHelpText(env)