@@ -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_platform_tools_paths (env ):
37
+ path = env .get ("custom_tools" , None )
38
+ if path is not None :
39
+ return [normalize_path (path , env ), "tools" ]
40
+ return ["tools" ]
41
+
42
+
43
+ def get_custom_platforms (env ):
44
+ path = env .get ("custom_tools" , None )
45
+ if path is None :
46
+ return []
47
+ platforms = []
48
+ for x in os .listdir (normalize_path (path , env )):
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
)
@@ -198,9 +230,9 @@ def options(opts, env):
198
230
)
199
231
)
200
232
201
- # Add platform options
202
- for pl in platforms :
203
- tool = Tool (pl , toolpath = [ "tools" ] )
233
+ # Add platform options (custom tools can override platforms)
234
+ for pl in sorted ( set ( platforms + custom_platforms )) :
235
+ tool = Tool (pl , toolpath = get_platform_tools_paths ( env ) )
204
236
if hasattr (tool , "options" ):
205
237
tool .options (opts )
206
238
@@ -259,7 +291,7 @@ def generate(env):
259
291
if env ["use_hot_reload" ]:
260
292
env .Append (CPPDEFINES = ["HOT_RELOAD_ENABLED" ])
261
293
262
- tool = Tool (env ["platform" ], toolpath = [ "tools" ] )
294
+ tool = Tool (env ["platform" ], toolpath = get_platform_tools_paths ( env ) )
263
295
264
296
if tool is None or not tool .exists (env ):
265
297
raise ValueError ("Required toolchain not found for platform " + env ["platform" ])
0 commit comments