@@ -33,7 +33,26 @@ def validate_parent_dir(key, val, env):
33
33
raise UserError ("'%s' is not a directory: %s" % (key , os .path .dirname (val )))
34
34
35
35
36
- platforms = ("linux" , "macos" , "windows" , "android" , "ios" , "web" )
36
+ def get_custom_tools_path (env ):
37
+ path = env .get ("custom_tools" , None )
38
+ if path is not None :
39
+ return normalize_path (path , env )
40
+ return None
41
+
42
+
43
+ def get_custom_platforms (env ):
44
+ path = get_custom_tools_path (env )
45
+ if path is None :
46
+ return []
47
+ platforms = []
48
+ for x in os .listdir (path ):
49
+ if not x .endswith (".py" ):
50
+ continue
51
+ platforms .append (x .removesuffix (".py" ))
52
+ return platforms
53
+
54
+
55
+ platforms = ["linux" , "macos" , "windows" , "android" , "ios" , "web" ]
37
56
38
57
# CPU architecture options.
39
58
architecture_array = [
@@ -82,12 +101,25 @@ def options(opts, env):
82
101
else :
83
102
raise ValueError ("Could not detect platform automatically, please specify with platform=<platform>" )
84
103
104
+ opts .Add (
105
+ PathVariable (
106
+ key = "custom_tools" ,
107
+ help = "Path to directory containing custom tools" ,
108
+ default = env .get ("custom_tools" , None ),
109
+ validator = validate_dir ,
110
+ )
111
+ )
112
+
113
+ opts .Update (env )
114
+
115
+ custom_platforms = get_custom_platforms (env )
116
+
85
117
opts .Add (
86
118
EnumVariable (
87
119
key = "platform" ,
88
120
help = "Target platform" ,
89
121
default = env .get ("platform" , default_platform ),
90
- allowed_values = platforms ,
122
+ allowed_values = platforms + custom_platforms ,
91
123
ignorecase = 2 ,
92
124
)
93
125
)
@@ -204,6 +236,12 @@ def options(opts, env):
204
236
if hasattr (tool , "options" ):
205
237
tool .options (opts )
206
238
239
+ # Add custom options
240
+ for pl in custom_platforms :
241
+ tool = Tool (pl , toolpath = [get_custom_tools_path (env )])
242
+ if hasattr (tool , "options" ):
243
+ tool .options (opts )
244
+
207
245
# Targets flags tool (optimizations, debug symbols)
208
246
target_tool = Tool ("targets" , toolpath = ["tools" ])
209
247
target_tool .options (opts )
@@ -259,7 +297,10 @@ def generate(env):
259
297
if env ["use_hot_reload" ]:
260
298
env .Append (CPPDEFINES = ["HOT_RELOAD_ENABLED" ])
261
299
262
- tool = Tool (env ["platform" ], toolpath = ["tools" ])
300
+ if env ["platform" ] in platforms :
301
+ tool = Tool (env ["platform" ], toolpath = ["tools" ])
302
+ else :
303
+ tool = Tool (env ["platform" ], toolpath = [get_custom_tools_path (env )])
263
304
264
305
if tool is None or not tool .exists (env ):
265
306
raise ValueError ("Required toolchain not found for platform " + env ["platform" ])
0 commit comments