-
Notifications
You must be signed in to change notification settings - Fork 13
/
SCsub
56 lines (45 loc) · 1.95 KB
/
SCsub
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
#!/usr/bin/env python
import sys
Import('env')
# The main source files of our Slicer plugin. We could also
# do a Glob to get cpp files automatically but for now we'll
# use an opt-in process just to have better control over what goes
# into the final binary during development. (Especially because we
# have some test files mucking things up)
sources = [
"register_types.cpp",
"slicer.cpp",
"sliced_mesh.cpp",
"utils/slicer_face.cpp",
"utils/intersector.cpp",
"utils/triangulator.cpp"
]
# Linking the final Godot binaries can take a bit of time. Following advice
# from https://docs.godotengine.org/en/stable/development/cpp/custom_modules_in_cpp.html
# we instead put our main logic into a shared library (as this is more likely to require tweaking).
# This allows us to build the main binaries once and link them against quick to build artifacts dynamically
use_shared_libs = ARGUMENTS.get('slicer_shared', 'no') == 'yes'
module_env = env.Clone()
module_env.Append(CXXFLAGS=['-std=c++11'])
# Build the plugin as a shared library for faster builds
def configure_shared_lib_build():
module_env.Append(CCFLAGS=['-fPIC'])
if sys.platform == "darwin":
# OSX doesn't like all of the undefined symbol references when building
# a dynamic library so we need to tell the linker to ignore them
module_env.Append(LINKFLAGS=['-Wl,-undefined,dynamic_lookup'])
module_env['LIBS'] = []
shared_lib = module_env.SharedLibrary(target='#bin/slicer', source=sources)
module_env.Alias('slicer-shared', [shared_lib])
env.Append(LIBS=[shared_lib])
env.Append(LIBPATH=['#bin'])
# Build the plugin statically for more reliable builds
def configure_static_build():
module_env.Append(CCFLAGS=['-O2'])
module_env.add_source_files(env.modules_sources, sources)
if use_shared_libs:
configure_shared_lib_build()
else:
configure_static_build()
if ARGUMENTS.get('slicer_tests', 'no') == 'yes':
SConscript("tests/SCsub")