Skip to content

Commit 454ecd6

Browse files
committed
Remove env.get logic from defaults
• Didn't work in practice, always returning the fallback value instead
1 parent c1196a1 commit 454ecd6

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

tools/godotcpp.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def options(opts, env):
8686
EnumVariable(
8787
key="platform",
8888
help="Target platform",
89-
default=env.get("platform", default_platform),
89+
default=default_platform,
9090
allowed_values=platforms,
9191
ignorecase=2,
9292
)
@@ -99,60 +99,60 @@ def options(opts, env):
9999
EnumVariable(
100100
key="target",
101101
help="Compilation target",
102-
default=env.get("target", "template_debug"),
102+
default="template_debug",
103103
allowed_values=("editor", "template_release", "template_debug"),
104104
)
105105
)
106106
opts.Add(
107107
PathVariable(
108108
key="gdextension_dir",
109109
help="Path to a custom directory containing GDExtension interface header and API JSON file",
110-
default=env.get("gdextension_dir", None),
110+
default=None,
111111
validator=validate_dir,
112112
)
113113
)
114114
opts.Add(
115115
PathVariable(
116116
key="custom_api_file",
117117
help="Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`)",
118-
default=env.get("custom_api_file", None),
118+
default=None,
119119
validator=validate_file,
120120
)
121121
)
122122
opts.Add(
123123
BoolVariable(
124124
key="generate_bindings",
125125
help="Force GDExtension API bindings generation. Auto-detected by default.",
126-
default=env.get("generate_bindings", False),
126+
default=False,
127127
)
128128
)
129129
opts.Add(
130130
BoolVariable(
131131
key="generate_template_get_node",
132132
help="Generate a template version of the Node class's get_node.",
133-
default=env.get("generate_template_get_node", True),
133+
default=True,
134134
)
135135
)
136136
opts.Add(
137137
BoolVariable(
138138
key="build_library",
139139
help="Build the godot-cpp library.",
140-
default=env.get("build_library", True),
140+
default=True,
141141
)
142142
)
143143
opts.Add(
144144
EnumVariable(
145145
key="precision",
146146
help="Set the floating-point precision level",
147-
default=env.get("precision", "single"),
147+
default="single",
148148
allowed_values=("single", "double"),
149149
)
150150
)
151151
opts.Add(
152152
EnumVariable(
153153
key="arch",
154154
help="CPU architecture",
155-
default=env.get("arch", ""),
155+
default="",
156156
allowed_values=architecture_array,
157157
map=architecture_aliases,
158158
)
@@ -163,14 +163,14 @@ def options(opts, env):
163163
BoolVariable(
164164
key="compiledb",
165165
help="Generate compilation DB (`compile_commands.json`) for external tools",
166-
default=env.get("compiledb", False),
166+
default=False,
167167
)
168168
)
169169
opts.Add(
170170
PathVariable(
171171
key="compiledb_file",
172172
help="Path to a custom `compile_commands.json` file",
173-
default=env.get("compiledb_file", "compile_commands.json"),
173+
default="compile_commands.json",
174174
validator=validate_parent_dir,
175175
)
176176
)
@@ -179,13 +179,15 @@ def options(opts, env):
179179
BoolVariable(
180180
key="use_hot_reload",
181181
help="Enable the extra accounting required to support hot reload.",
182-
default=(env.get("target", "template_debug") != "template_release"),
182+
default=None,
183183
)
184184
)
185185

186186
opts.Add(
187187
BoolVariable(
188-
"disable_exceptions", "Force disabling exception handling code", default=env.get("disable_exceptions", True)
188+
key="disable_exceptions",
189+
help="Force disabling exception handling code",
190+
default=True,
189191
)
190192
)
191193

@@ -245,30 +247,32 @@ def generate(env):
245247

246248
print("Building for architecture " + env["arch"] + " on platform " + env["platform"])
247249

250+
tool = Tool(env["platform"], toolpath=["tools"])
251+
252+
if tool is None or not tool.exists(env):
253+
raise ValueError("Required toolchain not found for platform " + env["platform"])
254+
255+
tool.generate(env)
256+
target_tool = Tool("targets", toolpath=["tools"])
257+
target_tool.generate(env)
258+
259+
if not env.get("use_hot_reload"):
260+
env["use_hot_reload"] = env["target"] != "template_release"
248261
if env["use_hot_reload"]:
249262
env.Append(CPPDEFINES=["HOT_RELOAD_ENABLED"])
250263

251264
# Disable exception handling. Godot doesn't use exceptions anywhere, and this
252265
# saves around 20% of binary size and very significant build time.
253266
if env["disable_exceptions"]:
254-
if env.get("is_msvc", False):
267+
if env["is_msvc"]:
255268
env.Append(CPPDEFINES=[("_HAS_EXCEPTIONS", 0)])
256269
else:
257270
env.Append(CXXFLAGS=["-fno-exceptions"])
258-
elif env.get("is_msvc", False):
271+
elif env["is_msvc"]:
259272
env.Append(CXXFLAGS=["/EHsc"])
260273

261-
tool = Tool(env["platform"], toolpath=["tools"])
262-
263-
if tool is None or not tool.exists(env):
264-
raise ValueError("Required toolchain not found for platform " + env["platform"])
265-
266-
tool.generate(env)
267-
target_tool = Tool("targets", toolpath=["tools"])
268-
target_tool.generate(env)
269-
270274
# Require C++17
271-
if env.get("is_msvc", False):
275+
if env["is_msvc"]:
272276
env.Append(CXXFLAGS=["/std:c++17"])
273277
else:
274278
env.Append(CXXFLAGS=["-std=c++17"])
@@ -333,7 +337,7 @@ def _godot_cpp(env):
333337
default_args = [library]
334338

335339
# Add compiledb if the option is set
336-
if env.get("compiledb", False):
340+
if env["compiledb"]:
337341
default_args += ["compiledb"]
338342

339343
env.Default(*default_args)

tools/targets.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def generate(env):
9999

100100
# Set optimize and debug_symbols flags.
101101
# "custom" means do nothing and let users set their own optimization flags.
102-
if env.get("is_msvc", False):
102+
if not env.get("is_msvc"):
103+
env["is_msvc"] = False
104+
if env["is_msvc"]:
103105
if env["debug_symbols"]:
104106
env.Append(CCFLAGS=["/Zi", "/FS"])
105107
env.Append(LINKFLAGS=["/DEBUG:FULL"])

0 commit comments

Comments
 (0)