-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathSConstruct
More file actions
133 lines (111 loc) · 4.19 KB
/
SConstruct
File metadata and controls
133 lines (111 loc) · 4.19 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python
import os
import SCons
BINDIR = "game/bin"
env = SConscript("scripts/SConstruct")
env.PrependENVPath("PATH", os.getenv("PATH"))
env["disable_rtti"] = False
opts = env.SetupOptions()
env.FinalizeOptions()
# Needs Clone, else godot-cpp builds using our modified environment variables. eg: godot-cpp builds on C++20
OLD_ARGS = SCons.Script.ARGUMENTS.copy()
SCons.Script.ARGUMENTS["use_static_cpp"] = env["use_static_cpp"]
SCons.Script.ARGUMENTS["disable_exceptions"] = env["disable_exceptions"]
SCons.Script.ARGUMENTS["compiledb_file"] = "godot-cpp/compile_commands.json"
godot_env = SConscript("godot-cpp/SConstruct")
SCons.Script.ARGUMENTS = OLD_ARGS
# Make LIBS into a list which is easier to deal with.
godot_env["LIBS"] = [godot_env["LIBS"]]
env.Append(CPPPATH=godot_env["CPPPATH"])
env.Prepend(LIBS=godot_env["LIBS"])
SConscript("extension/deps/SCsub", "env")
Default(
env.CommandNoCache(
"extension/src/gen/commit_info.gen.hpp",
env.Value(env.get_git_info()),
env.Run(env.git_builder),
name_prefix="game",
)
)
Default(
env.CommandNoCache(
"extension/src/gen/license_info.gen.hpp",
["#COPYRIGHT", "#LICENSE.md"],
env.Run(env.license_builder),
name_prefix="game",
)
)
Default(
env.CommandNoCache(
"extension/src/gen/author_info.gen.hpp",
"#AUTHORS.md",
env.Run(env.author_builder),
name_prefix="game",
sections={
"Senior Developers": "AUTHORS_SENIOR_DEVELOPERS",
"Developers": "AUTHORS_DEVELOPERS",
"Contributors": "AUTHORS_CONTRIBUTORS",
"Consultants": "AUTHORS_CONSULTANTS",
"Artists": "AUTHORS_ARTISTS",
},
)
)
# For the 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
# tweak this if you want to use different folders, or more folders, to store your source code in.
paths = ["extension/src"]
doc_gen_file = os.path.join(paths[0], "gen/doc_data.gen.cpp")
env.Append(CPPPATH=[[env.Dir(p) for p in paths]])
sources = env.GlobRecursive("*.cpp", paths, doc_gen_file)
env.extension_sources = sources
if env["target"] in ["editor", "template_debug"]:
doc_data = godot_env.GodotCPPDocData(doc_gen_file, source=Glob("extension/doc_classes/*.xml"))
sources.append(doc_data)
# Remove unassociated intermediate binary files if allowed, usually the result of a renamed or deleted source file
if env["intermediate_delete"]:
from glob import glob
def remove_extension(file: str):
if file.find(".") == -1:
return file
return file[: file.rindex(".")]
found_one = False
for path in paths:
for obj_file in [file[: -len(".os")] for file in glob(path + "*.os", recursive=True)]:
found = False
for source_file in sources:
if remove_extension(str(source_file)) == obj_file:
found = True
break
if not found:
if not found_one:
found_one = True
print("Unassociated intermediate files found...")
print("Removing " + obj_file + ".os")
os.remove(obj_file + ".os")
if env["platform"] == "macos":
library = env.SharedLibrary(
BINDIR
+ "/openvic/libopenvic.{}.{}.framework/libopenvic.{}.{}".format(
godot_env["platform"], godot_env["target"], godot_env["platform"], godot_env["target"]
),
source=sources,
)
else:
suffix = ".{}.{}.{}".format(godot_env["platform"], godot_env["target"], godot_env["arch"])
library = env.SharedLibrary(
BINDIR + "/openvic/libopenvic{}{}".format(suffix, godot_env["SHLIBSUFFIX"]),
source=sources,
)
default_args = [library]
if "env" in locals():
# FIXME: This method mixes both cosmetic progress stuff and cache handling...
env.show_progress(env)
# Add compiledb if the option is set
if env.get("compiledb", False):
default_args += ["compiledb"]
Default(*default_args)