@@ -51,9 +51,13 @@ elif ARGUMENTS.get("platform", ""):
51
51
else :
52
52
raise ValueError ("Could not detect platform automatically, please specify with platform=<platform>" )
53
53
54
- # Default tools with no platform defaults to gnu toolchain.
55
- # We apply platform specific toolchains via our custom tools.
56
- env = Environment (tools = ["default" ], PLATFORM = "" )
54
+ try :
55
+ Import ("env" )
56
+ except :
57
+ # Default tools with no platform defaults to gnu toolchain.
58
+ # We apply platform specific toolchains via our custom tools.
59
+ env = Environment (tools = ["default" ], PLATFORM = "" )
60
+
57
61
env .PrependENVPath ("PATH" , os .getenv ("PATH" ))
58
62
59
63
# Default num_jobs to local cpu count if not user specified.
@@ -87,9 +91,9 @@ opts = Variables(customs, ARGUMENTS)
87
91
platforms = ("linux" , "macos" , "windows" , "android" , "ios" , "javascript" )
88
92
opts .Add (
89
93
EnumVariable (
90
- "platform" ,
91
- "Target platform" ,
92
- default_platform ,
94
+ key = "platform" ,
95
+ help = "Target platform" ,
96
+ default = env . get ( "platform" , default_platform ) ,
93
97
allowed_values = platforms ,
94
98
ignorecase = 2 ,
95
99
)
@@ -99,31 +103,53 @@ opts.Add(
99
103
# Godot release templates are only compatible with "template_release" builds.
100
104
# For this reason, we default to template_debug builds, unlike Godot which defaults to editor builds.
101
105
opts .Add (
102
- EnumVariable ("target" , "Compilation target" , "template_debug" , ("editor" , "template_release" , "template_debug" ))
106
+ EnumVariable (
107
+ key = "target" ,
108
+ help = "Compilation target" ,
109
+ default = env .get ("target" , "template_debug" ),
110
+ allowed_values = ("editor" , "template_release" , "template_debug" ),
111
+ )
103
112
)
104
113
opts .Add (
105
114
PathVariable (
106
- "gdextension_dir" ,
107
- "Path to a custom directory containing GDExtension interface header and API JSON file" ,
108
- None ,
109
- validate_gdextension_dir ,
115
+ key = "gdextension_dir" ,
116
+ help = "Path to a custom directory containing GDExtension interface header and API JSON file" ,
117
+ default = env . get ( "gdextension_dir" , None ) ,
118
+ validator = validate_gdextension_dir ,
110
119
)
111
120
)
112
121
opts .Add (
113
122
PathVariable (
114
- "custom_api_file" ,
115
- "Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`)" ,
116
- None ,
117
- validate_api_file ,
123
+ key = "custom_api_file" ,
124
+ help = "Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`)" ,
125
+ default = env .get ("custom_api_file" , None ),
126
+ validator = validate_api_file ,
127
+ )
128
+ )
129
+ opts .Add (
130
+ BoolVariable (
131
+ key = "generate_bindings" ,
132
+ help = "Force GDExtension API bindings generation. Auto-detected by default." ,
133
+ default = env .get ("generate_bindings" , False ),
118
134
)
119
135
)
120
136
opts .Add (
121
- BoolVariable ("generate_bindings" , "Force GDExtension API bindings generation. Auto-detected by default." , False )
137
+ BoolVariable (
138
+ key = "generate_template_get_node" ,
139
+ help = "Generate a template version of the Node class's get_node." ,
140
+ default = env .get ("generate_template_get_node" , True ),
141
+ )
122
142
)
123
- opts .Add (BoolVariable ("generate_template_get_node" , "Generate a template version of the Node class's get_node." , True ))
124
143
125
- opts .Add (BoolVariable ("build_library" , "Build the godot-cpp library." , True ))
126
- opts .Add (EnumVariable ("precision" , "Set the floating-point precision level" , "single" , ("single" , "double" )))
144
+ opts .Add (BoolVariable (key = "build_library" , help = "Build the godot-cpp library." , default = env .get ("build_library" , True )))
145
+ opts .Add (
146
+ EnumVariable (
147
+ key = "precision" ,
148
+ help = "Set the floating-point precision level" ,
149
+ default = env .get ("precision" , "single" ),
150
+ allowed_values = ("single" , "double" ),
151
+ )
152
+ )
127
153
128
154
# Add platform options
129
155
tools = {}
@@ -149,7 +175,15 @@ architecture_aliases = {
149
175
"ppc" : "ppc32" ,
150
176
"ppc64le" : "ppc64" ,
151
177
}
152
- opts .Add (EnumVariable ("arch" , "CPU architecture" , "" , architecture_array , architecture_aliases ))
178
+ opts .Add (
179
+ EnumVariable (
180
+ key = "arch" ,
181
+ help = "CPU architecture" ,
182
+ default = env .get ("arch" , "" ),
183
+ allowed_values = architecture_array ,
184
+ map = architecture_aliases ,
185
+ )
186
+ )
153
187
154
188
# Targets flags tool (optimizations, debug symbols)
155
189
target_tool = Tool ("targets" , toolpath = ["tools" ])
0 commit comments