11
11
from binding_generator import scons_generate_bindings , scons_emit_files
12
12
13
13
14
- def add_sources (sources , dir , extension ):
15
- for f in os .listdir (dir ):
16
- if f .endswith ("." + extension ):
17
- sources .append (dir + "/" + f )
18
-
19
-
20
14
def get_cmdline_bool (option , default ):
21
15
"""We use `ARGUMENTS.get()` to check if options were manually overridden on the command line,
22
16
and SCons' _text2bool helper to convert them to booleans, otherwise they're handled as strings.
@@ -29,6 +23,10 @@ def get_cmdline_bool(option, default):
29
23
30
24
31
25
def normalize_path (val , env ):
26
+ """Normalize a path that was provided by the user on the command line
27
+ and is thus either an absolute path or relative to the top level directory (#)
28
+ where the command was run
29
+ """
32
30
return val if os .path .isabs (val ) else os .path .join (env .Dir ("#" ).abspath , val )
33
31
34
32
@@ -49,9 +47,10 @@ def validate_parent_dir(key, val, env):
49
47
50
48
def get_platform_tools_paths (env ):
51
49
path = env .get ("custom_tools" , None )
50
+ tools_path = env .Dir ("tools" ).srcnode ().abspath
52
51
if path is None :
53
- return ["tools" ]
54
- return [normalize_path (path , env ), "tools" ]
52
+ return [tools_path ]
53
+ return [normalize_path (path , env ), tools_path ]
55
54
56
55
57
56
def get_custom_platforms (env ):
@@ -387,8 +386,22 @@ def generate(env):
387
386
388
387
389
388
def _godot_cpp (env ):
390
- extension_dir = normalize_path (env .get ("gdextension_dir" , env .Dir ("gdextension" ).abspath ), env )
391
- api_file = normalize_path (env .get ("custom_api_file" , env .File (extension_dir + "/extension_api.json" ).abspath ), env )
389
+ extension_dir = env .get ("gdextension_dir" , None )
390
+ # A user provided extension_dir is relative to where they are running from (#)
391
+ # But our gdextension directory is here in the source tree
392
+ if extension_dir is not None :
393
+ extension_dir = normalize_path (extension_dir , env )
394
+ else :
395
+ extension_dir = env .Dir ("gdextension" ).srcnode ().abspath
396
+
397
+ api_file = env .get ("custom_api_file" , None )
398
+ # A user provided api_file is relative to where they are running from (#)
399
+ # But a default api_file is relative to extension_dir
400
+ if api_file is not None :
401
+ api_file = normalize_path (api_file , env )
402
+ else :
403
+ api_file = os .path .join (extension_dir , "extension_api.json" )
404
+
392
405
bindings = env .GodotCPPBindings (
393
406
env .Dir ("." ),
394
407
[
@@ -403,15 +416,12 @@ def _godot_cpp(env):
403
416
env .NoCache (bindings )
404
417
405
418
# Sources to compile
406
- sources = []
407
- add_sources (sources , "src" , "cpp" )
408
- add_sources (sources , "src/classes" , "cpp" )
409
- add_sources (sources , "src/core" , "cpp" )
410
- add_sources (sources , "src/variant" , "cpp" )
419
+ sources = env .Glob ("src/*.cpp" )
420
+ sources += env .Glob ("src/*/*.cpp" )
411
421
sources .extend ([f for f in bindings if str (f ).endswith (".cpp" )])
412
422
413
423
# Includes
414
- env .AppendUnique (CPPPATH = [env .Dir (d ) for d in [ extension_dir , "include" , "gen/include" ] ])
424
+ env .AppendUnique (CPPPATH = [env .Dir (extension_dir ), env . Dir ( "include" ). srcnode (), env . Dir ( "gen/include" ) ])
415
425
416
426
library = None
417
427
library_name = "libgodot-cpp" + env ["suffix" ] + env ["LIBSUFFIX" ]
0 commit comments