22import os
33
44
5- def normalize_path (val , env ):
6- return val if os .path .isabs (val ) else os .path .join (env .Dir ("#" ).abspath , val )
7-
8-
9- def validate_parent_dir (key , val , env ):
10- if not os .path .isdir (normalize_path (os .path .dirname (val ), env )):
11- raise UserError ("'%s' is not a directory: %s" % (key , os .path .dirname (val )))
12-
13-
145libname = "EXTENSION-NAME"
156projectdir = "demo"
167
@@ -20,33 +11,11 @@ customs = ["custom.py"]
2011customs = [os .path .abspath (path ) for path in customs ]
2112
2213opts = Variables (customs , ARGUMENTS )
23- opts .Add (
24- BoolVariable (
25- key = "compiledb" ,
26- help = "Generate compilation DB (`compile_commands.json`) for external tools" ,
27- default = localEnv .get ("compiledb" , False ),
28- )
29- )
30- opts .Add (
31- PathVariable (
32- key = "compiledb_file" ,
33- help = "Path to a custom `compile_commands.json` file" ,
34- default = localEnv .get ("compiledb_file" , "compile_commands.json" ),
35- validator = validate_parent_dir ,
36- )
37- )
3814opts .Update (localEnv )
3915
4016Help (opts .GenerateHelpText (localEnv ))
4117
4218env = localEnv .Clone ()
43- env ["compiledb" ] = False
44-
45- env .Tool ("compilation_db" )
46- compilation_db = env .CompilationDatabase (
47- normalize_path (localEnv ["compiledb_file" ], localEnv )
48- )
49- env .Alias ("compiledb" , compilation_db )
5019
5120env = SConscript ("godot-cpp/SConstruct" , {"env" : env , "customs" : customs })
5221
@@ -75,6 +44,4 @@ library = env.SharedLibrary(
7544copy = env .InstallAs ("{}/bin/{}/lib{}" .format (projectdir , env ["platform" ], file ), library )
7645
7746default_args = [library , copy ]
78- if localEnv .get ("compiledb" , False ):
79- default_args += [compilation_db ]
8047Default (* default_args )
0 commit comments