-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
SConstruct
88 lines (69 loc) · 3.08 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
88
#!/usr/bin/env python
import glob
env = SConscript("godot-cpp/SConstruct")
# For reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags
outpath = "bin"
def add_source_files(self, sources, files, allow_gen=False):
# Convert string to list of absolute paths (including expanding wildcard)
if isinstance(files, (str, bytes)):
# Keep SCons project-absolute path as they are (no wildcard support)
if files.startswith("#"):
if "*" in files:
print("ERROR: Wildcards can't be expanded in SCons project-absolute path: '{}'".format(files))
return
files = [files]
else:
# Exclude .gen.cpp files from globbing, to avoid including obsolete ones.
# They should instead be added manually.
skip_gen_cpp = "*" in files
dir_path = self.Dir(".").abspath
files = sorted(glob.glob(dir_path + "/" + files))
if skip_gen_cpp and not allow_gen:
files = [f for f in files if not f.endswith(".gen.cpp")]
# Add each path as compiled SharedObject following environment (self) configuration
for path in files:
obj = self.SharedObject(path)
if obj in sources:
print('WARNING: SharedObject "{}" already included in environment sources.'.format(obj))
continue
sources.append(obj)
def _register_library(name, path):
env.Append(CPPPATH=["#{}/".format(path)])
env.library_sources = []
# Recursively iterate through sub configs in source folders and perform steps defined there.
SConscript("{}/SCsub".format(path))
# Add documentation to the list of sources as well.
if env["target"] in ["editor", "template_debug"]:
doc_data = env.GodotCPPDocData("{}/gen/doc_data.gen.cpp".format(path), source=Glob("doc_classes/*.xml"))
env.library_sources.append(doc_data)
# Finally, register the library to be built.
if env["platform"] == "macos":
library = env.SharedLibrary(
"{}/{}.{}.{}.framework/{}.{}.{}".format(
outpath, name, env["platform"], env["target"], name, env["platform"], env["target"]
),
source=env.library_sources,
)
else:
library = env.SharedLibrary(
"{}/{}{}{}".format(outpath, name, env["suffix"], env["SHLIBSUFFIX"]),
source=env.library_sources,
)
Default(library)
return library
def _install_artifacts(name, path, depends):
install_artifacts = env.Install(name, path)
Default(install_artifacts)
env.Depends(install_artifacts, depends)
env.__class__.add_source_files = add_source_files
Export("env")
library_gdsion = _register_library("libgdsion", "src")
# Copy the build results into example and tests projects.
_install_artifacts("example", "bin", library_gdsion)
_install_artifacts("tests", "bin", library_gdsion)