-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
87 lines (67 loc) · 2.45 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
import os
import fnmatch
def normalize_path(val, env):
return val if os.path.isabs(val) else os.path.join(env.Dir("#").abspath, val)
def validate_parent_dir(key, val, env):
if not os.path.isdir(normalize_path(os.path.dirname(val), env)):
raise UserError("'%s' is not a directory: %s" % (key, os.path.dirname(val)))
libname = "gdmatplot"
projectdir = "demo"
localEnv = Environment(tools=["default"], PLATFORM="")
customs = ["custom.py"]
customs = [os.path.abspath(path) for path in customs]
opts = Variables(customs, ARGUMENTS)
opts.Add(
BoolVariable(
key="compiledb",
help="Generate compilation DB (`compile_commands.json`) for external tools",
default=localEnv.get("compiledb", False),
)
)
opts.Add(
PathVariable(
key="compiledb_file",
help="Path to a custom `compile_commands.json` file",
default=localEnv.get("compiledb_file", "compile_commands.json"),
validator=validate_parent_dir,
)
)
opts.Update(localEnv)
Help(opts.GenerateHelpText(localEnv))
env = localEnv.Clone()
env["compiledb"] = False
env.Tool("compilation_db")
compilation_db = env.CompilationDatabase(
normalize_path(localEnv["compiledb_file"], localEnv)
)
env.Alias("compiledb", compilation_db)
env = SConscript("godot-cpp/SConstruct", {"env": env, "customs": customs})
LIBS = []
if env["platform"] == "linux":
LIBS = ['dl']
env.Append(CPPPATH=["src/"])
env.Append(CPPFLAGS=[])
env.Append(LIBS=LIBS)
sources = Glob("src/*.cpp") + ["src/gdmatplot_gnuplot_library.cxx"]
file = "{}{}{}".format(libname, env["suffix"], env["SHLIBSUFFIX"])
if env["platform"] == "macos":
platlibname = "{}.{}.{}".format(libname, env["platform"], env["target"])
file = "{}.framework/{}".format(env["platform"], platlibname, platlibname)
libraryfile = "demo/addons/gdmatplot/{}/{}".format(env["platform"], file)
library = env.SharedLibrary(
libraryfile,
source=sources,
)
copy_commands = []
for fn in [ "README.md", "LICENSE.md", "NOTICE.md" ]:
copy_commands += [Command(f"demo/addons/gdmatplot/{fn}", fn, Copy("$TARGET", "$SOURCE"))]
if len(copy_commands) > 1:
Requires(copy_commands[-1], copy_commands[-2])
clone_addon = env.Install("demo3d/addons", "demo/addons/gdmatplot")
Requires(clone_addon, copy_commands[-1])
AlwaysBuild(clone_addon)
default_args = [library] + copy_commands + [clone_addon]
if localEnv.get("compiledb", False):
default_args += [compilation_db]
Default(*default_args)