forked from frklan/DodgeTheCreeps-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
146 lines (110 loc) · 5.64 KB
/
Copy pathSConstruct
File metadata and controls
146 lines (110 loc) · 5.64 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
#!python
import os, subprocess
def sys_exec(args):
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
(out, err) = proc.communicate()
return out.rstrip("\r\n").lstrip()
opts = Variables([], ARGUMENTS)
# Gets the standard flags CC, CCX, etc.
env = DefaultEnvironment()
# Generates help for the -h scons option.
Help(opts.GenerateHelpText(env))
# Define our options
opts.Add(EnumVariable('target', "Compilation target", 'debug', ['debug', 'release']))
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx', 'ios', 'ios.simulator']))
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'build/lib/'))
opts.Add(PathVariable('target_name', 'The library name.', 'libdodge', PathVariable.PathAccept))
opts.Add(EnumVariable('static', "static lib", 'no', ['no', 'yes']))
opts.Add(PathVariable('godot_cpp_bindings_path', 'Path to Godot CPP', 'lib/godot-cpp/'))
opts.Add(PathVariable('godot_cpp_library', 'Godot CPP library name', 'libgodot-cpp', PathVariable.PathAccept))
# Updates the environment with the option variables.
opts.Update(env)
# Local dependency paths, adapt them to your setup
env['godot_headers_path'] = env['godot_cpp_bindings_path'] + 'godot_headers/'
# honour CC and CXX
env['CC'] = os.environ['CC']
env['CXX'] = os.environ['CXX']
# only support 64 at this time..
bits = 64
if env['platform'] == '':
print("No valid target platform selected.")
quit();
# Check our platform specifics
if env['platform'] == "osx":
env['target_path'] += 'osx/'
env['godot_cpp_library'] += '.osx'
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-g', '-arch', 'x86_64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
else:
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
elif env['platform'] == "ios":
env['target_path'] += 'ios/'
env['godot_cpp_library'] += '.ios'
IOS_PLATFORM_SDK = sys_exec(["xcode-select", "-p"]) + "/Platforms"
SDK_VERSION = sys_exec(["xcodebuild", "-sdk", "iphoneos", "-version", "|", "grep", "SDKVersion", "|", "awk", "'{print$2}'])"])
SDK_MIN_VERSION = "10.3"
env.Append(CCFLAGS = ['-arch', 'arm64', '-arch', 'armv7', '-arch', 'armv7s', '-std=c++17',
'-isysroot', ('%s/iPhoneOS.platform/Developer/SDKs/iPhoneOS%s.sdk' % (IOS_PLATFORM_SDK, SDK_VERSION)),
('-miphoneos-version-min=%s' % SDK_MIN_VERSION)])
env.Append(LINKFLAGS = ['-arch', 'arm64', '-arch', 'armv7', '-arch', 'armv7s',
'-isysroot', '%s/iPhoneOS.platform/Developer/SDKs/iPhoneOS%s.sdk' % (IOS_PLATFORM_SDK, SDK_VERSION) ,
'-miphoneos-version-min=%s' % SDK_MIN_VERSION])
if env['target'] in ('debug'):
env.Append(CCFLAGS = ['-g'])
else:
env.Append(CCFLAGS = ['-O3'])
elif env['platform'] == "ios.simulator":
env['static'] = 'yes'
env['target_path'] += 'ios/'
env['godot_cpp_library'] += '.ios.simulator'
IOS_PLATFORM_SDK = sys_exec(["xcode-select", "-p"]) + "/Platforms"
SDK_VERSION = sys_exec(["xcodebuild", "-sdk", "iphonesimulator", "-version", "|", "grep", "SDKVersion", "|", "awk", "'{print$2}'])"])
SDK_MIN_VERSION = "10.3"
env.Append(CCFLAGS = ['-arch', 'x86_64', '-std=c++17',
'-isysroot', ('%s/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator%s.sdk' % (IOS_PLATFORM_SDK, SDK_VERSION)),
('-miphoneos-version-min=%s' % SDK_MIN_VERSION)])
env.Append(LINKFLAGS = ['-arch', 'x86_64',
'-isysroot', '%s/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator%s.sdk' % (IOS_PLATFORM_SDK, SDK_VERSION) ,
'-miphoneos-version-min=%s' % SDK_MIN_VERSION])
if env['target'] in ('debug'):
env.Append(CCFLAGS = ['-g'])
else:
env.Append(CCFLAGS = ['-O3'])
elif env['platform'] in ('x11', 'linux'):
env['target_path'] += 'x11/'
env['godot_cpp_library'] += '.linux'
if env['target'] in ('debug'):
env.Append(CCFLAGS = ['-fPIC', '-g3','-Og', '-std=c++17'])
else:
env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c++17'])
elif env['platform'] == "windows":
env['target_path'] += 'win64/'
env['godot_cpp_library'] += '.windows'
# This makes sure to keep the session environment variables on windows,
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
env.Append(ENV = os.environ)
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS'])
if env['target'] in ('debug'):
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
else:
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '-MD'])
env['godot_cpp_library'] += '.' + env['target']
env['godot_cpp_library'] += '.' + str(bits)
env['target_name'] += '.' + env['platform'] + '.' + str(bits)
# make sure our binding library is properly includes
env.Append(CPPPATH=['.', env['godot_headers_path'], env['godot_cpp_bindings_path'] + 'include/', env['godot_cpp_bindings_path'] + 'include/core/', env['godot_cpp_bindings_path'] + 'include/gen/'])
env.Append(LIBPATH=[env['godot_cpp_bindings_path'] + 'bin/'])
env.Append(LIBS=[env['godot_cpp_library']])
# create version.cpp
sys_exec(["./makeversion.sh", "-o", "src/version.cpp"])
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=['godot/src/'])
sources = Glob('src/*.cpp')
sources += Glob('src/scenes/*.cpp')
if env['static'] == "yes":
library = env.StaticLibrary(target=env['target_path'] + env['target_name'] , source=sources)
else:
library = env.SharedLibrary(target=env['target_path'] + env['target_name'] , source=sources)
Default(library)