-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSConstruct
102 lines (85 loc) · 2.88 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"""
For building basic release do scons target=template_debug within this folder.
For building tests with debug symbols do scons target=template_debug dev_build=yes -Q tests=1
For actual debugging, just start debugging the same way as debugging godot directly. The path for the executable would be something like
path/to/godot --editor --path ${workspaceFolder}/project
"""
#!/usr/bin/env python
import os
from glob import glob
from pathlib import Path
env = SConscript("godot-cpp/SConstruct")
# build with already installed static lib, also need to remove third_party_dir from CPPPath and maybe change LIBPATH
# env.Append(CPPPATH=["src/", "/usr/include"])
# env.Append(LIBPATH='/usr/lib')
# env.Append(LIBS=["osdGPU"])
vars = Variables(None, ARGUMENTS)
vars.Add(BoolVariable("tests", "Build tests", False))
vars.Update(env)
run_tests = env.get('tests')
# compile local
thirdparty_dir = "thirdparty/opensubdiv/"
thirdparty_sources = [
"far/error.cpp",
"far/topologyDescriptor.cpp",
"far/topologyRefiner.cpp",
"far/topologyRefinerFactory.cpp",
"sdc/crease.cpp",
"sdc/typeTraits.cpp",
"vtr/fvarLevel.cpp",
"vtr/fvarRefinement.cpp",
"vtr/level.cpp",
"vtr/quadRefinement.cpp",
"vtr/refinement.cpp",
"vtr/sparseSelector.cpp",
"vtr/triRefinement.cpp",
]
thirdparty_sources = [thirdparty_dir +
file for file in thirdparty_sources]
cpp_path = ["src/", thirdparty_dir]
if(run_tests):
cpp_path.append(["thirdparty/doctest", "test/"])
env.Append(CPPPATH=cpp_path)
cpp_defines = []
if "CPPDEFINES" in env:
cpp_defines = env["CPPDEFINES"]
cpp_defines.append("_USE_MATH_DEFINES")
if run_tests:
cpp_defines.append("TESTS_ENABLED")
env.Append(CPPDEFINES=cpp_defines)
sources = Glob("src/*.cpp")
sources.extend(Glob("src/*/*.cpp"))
sources.extend(thirdparty_sources)
if (run_tests):
sources.extend(Glob("test/*.cpp"))
sources.extend(Glob("test/*/*.cpp"))
# Find gdextension path even if the directory or extension is renamed.
(extension_path,) = glob("project/addons/*/*.gdextension")
# Find the addon path
addon_path = "project/addons/godot_subdiv"
# Find the extension name from the gdextension file (e.g. example).
extension_name = "godot_subdiv"
# if you do dev builds it currently appends .dev. This isn't compatible with the gdextension file so removing here
build_suffix = env["suffix"].replace(".dev.", ".")
# Create the library target
if env["platform"] == "macos":
library = env.SharedLibrary(
"{}/bin/lib{}.{}.{}.framework/{1}.{2}.{3}".format(
addon_path,
extension_name,
env["platform"],
env["target"],
),
source=sources,
)
else:
library = env.SharedLibrary(
"{}/bin/lib{}{}{}".format(
addon_path,
extension_name,
build_suffix,
env["SHLIBSUFFIX"]
),
source=sources,
)
Default(library)