generated from godotengine/godot-cpp-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
153 lines (120 loc) · 5.81 KB
/
SConstruct
File metadata and controls
153 lines (120 loc) · 5.81 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env python
import os
import platform
import sys
import tools.scripts.system as system
from methods import *
from tools.scripts.msvs import *
from tools.scripts.options import *
local_env = Environment(tools=["default"], PLATFORM="")
customs = ["custom.py"]
customs = [os.path.abspath(path) for path in customs]
opts = Variables(customs, ARGUMENTS)
init_system_variables(ARGUMENTS)
init_options(local_env, opts, lib_name)
opts.Update(local_env)
cache_path = local_env["cache_path"]
if cache_path == "":
cache_path = ".scons_cache"
CacheDir(cache_path)
Help(opts.GenerateHelpText(local_env))
# To use MSVSProject/MSVSSolution the default system platform needs to be used
# The PLATFORM="" above in the default environment removes any platform specific tools
# and prevents the MSVS functions from working.
# Cloning another environment here where PLATFORM = system default fixes this issue when
# the user wants to generate a '.sln' file.
environment_to_clone = local_env
if local_env["vsproj"]:
environment_to_clone = Environment(tools=["default"])
opts.Update(environment_to_clone)
env = environment_to_clone.Clone()
if not is_submodule_initialized(system.engine_godot_dir):
sys.exit(1)
if not is_submodule_initialized(system.engine_godot_cpp_dir):
sys.exit(1)
if not is_submodule_initialized(system.thirdparty_imgui_dir_path):
sys.exit(1)
# Convert from game configuration to something godot/godot-cpp understands
game_target = env["target"]
if game_target in ["editor_game", "development"]:
env["target"] = "editor"
elif game_target == "profile":
env["target"] = "template_release"
elif game_target == "production":
env["target"] = "template_release"
ARGUMENTS["target"] = env["target"]
env = SConscript(os.path.join(system.engine_godot_cpp_dir, "SConstruct"), {"env": env, "customs": customs})
# Then convert back to the original target value
env["target"] = game_target
ARGUMENTS["target"] = env["target"]
if env["target"] in ["editor", "editor_game", "development", "template_debug"]:
try:
doc_data = env.GodotCPPDocData(os.path.join(system.project_src_dir, "gen", "doc_data.gen.cpp"), source=Glob("doc_classes/*.xml", strings=True))
except AttributeError:
print("Not including class reference as we're targeting a pre-4.4 baseline.")
all_directories = []
all_source_files = []
project_source_files = []
all_include_files = []
cpp_defines = []
# imgui
system.add_imgui(env, all_directories, all_source_files, project_source_files, all_include_files, cpp_defines)
# tests
system.add_doctest(all_directories, all_include_files, cpp_defines)
# godot-cpp
all_directories.extend(get_all_directories_recursive(env, system.godot_cpp_extension_dir_path))
all_directories.extend(get_all_directories_recursive(env, system.godot_cpp_gen_include_dir_path))
all_directories.extend(get_all_directories_recursive(env, system.godot_cpp_gen_src_dir_path))
all_directories.extend(get_all_directories_recursive(env, system.godot_cpp_include_dir_path))
all_directories.extend(get_all_directories_recursive(env, system.godot_cpp_src_dir_path))
all_include_files.extend(get_all_files_recursive(env, system.godot_cpp_extension_dir_path, "*.h"))
all_include_files.extend(get_all_files_recursive(env, system.godot_cpp_gen_include_dir_path, "*.hpp"))
all_source_files.extend(get_all_files_recursive(env, system.godot_cpp_gen_src_dir_path, "*.cpp"))
all_include_files.extend(get_all_files_recursive(env, system.godot_cpp_include_dir_path, "*.hpp"))
all_source_files.extend(get_all_files_recursive(env, system.godot_cpp_src_dir_path, "*.cpp"))
# project
all_directories.extend(get_all_directories_recursive(env, system.project_src_dir))
all_source_files.extend(get_all_files_recursive(env, system.project_src_dir, "*.cpp"))
project_source_files.extend(get_all_files_recursive(env, system.project_src_dir, "*.cpp"))
all_include_files.extend(get_all_files_recursive(env, system.project_src_dir, "*.h"))
system.add_cpp_defines(env, cpp_defines)
# Add plugins
system.add_plugins(system.project_plugins, env, customs, all_directories, project_source_files, all_source_files, all_include_files)
env.Append(CPPPATH=all_directories)
env.Append(CPPDEFINES=cpp_defines)
# Fixing warnings for LNK4099: PDB '' was not found with...
# This is only needed for CI purposes but included in the main build
# to avoid having to add extra CI build parameter in this script
if env["platform"] == "windows":
env.Append(LINKFLAGS=["/ignore:4099"])
# .dev doesn't inhibit compatibility, so we don't need to key it.
# .universal just means "compatible with all relevant arches" so we don't need to key it.
suffix = env['suffix'].replace(".dev", "").replace(".universal", "")
library_suffix = env.subst('$SHLIBSUFFIX')
if platform.system() == "Linux" and env["platform"] == "macos":
library_suffix = ".dylib"
lib_filename = "{}{}{}{}".format(env.subst('$SHLIBPREFIX'), lib_name, suffix, library_suffix)
if platform.system() == "Windows" and (env["platform"] in ["web", "android"]):
lib_filename = "lib" + lib_filename
library = env.SharedLibrary(
"bin/{}/{}".format(env['platform'], lib_filename),
source=project_source_files,
)
env.NoCache(library)
copy = env.Install("{}/bin/{}/".format(project_dir_name, env["platform"]), library)
if env["vsproj"]:
init_msvs()
resource_files = []
misc_files = []
misc_files.append(".runsettings")
misc_files.append(".editorconfig")
game_project_file = generate_vs_project(env, all_source_files, all_include_files, resource_files, misc_files)
env.NoCache(game_project_file)
vcxproj_files = []
vcxproj_files.append(os.path.join(system.engine_godot_dir, "godot.vcxproj"))
vcxproj_files.append(game_project_file)
game_solution_file = generate_vs_solution(env, vcxproj_files)
env.NoCache(game_solution_file)
else:
default_args = [library, copy]
Default(*default_args)