Skip to content

Commit ac572d5

Browse files
authored
Merge pull request #691 from Faless/build/3.x_tools
2 parents 95258f6 + c7b81a1 commit ac572d5

File tree

4 files changed

+131
-280
lines changed

4 files changed

+131
-280
lines changed

.github/workflows/ci.yml

Lines changed: 71 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,56 @@ name: Continuous integration
22
on: [push, pull_request]
33

44
jobs:
5-
linux:
6-
name: Build (Linux, GCC)
7-
runs-on: ubuntu-18.04
5+
build:
6+
name: ${{ matrix.name }}
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
include:
12+
- name: 🐧 Linux (GCC)
13+
os: ubuntu-18.04
14+
platform: linux
15+
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release
16+
artifact-path: bin/libgodot-cpp.linux.release.64.a
17+
godot_zip: Godot_v3.4-stable_linux_server.64.zip
18+
executable: Godot_v3.4-stable_linux_server.64
19+
20+
- name: 🏁 Windows (x86_64, MSVC)
21+
os: windows-2019
22+
platform: windows
23+
artifact-name: godot-cpp-windows-msvc2019-x86_64-release
24+
artifact-path: bin/libgodot-cpp.windows.release.64.lib
25+
26+
- name: 🏁 Windows (x86_64, MinGW)
27+
os: windows-2019
28+
platform: windows
29+
artifact-name: godot-cpp-linux-mingw-x86_64-release
30+
artifact-path: bin/libgodot-cpp.windows.release.64.a
31+
flags: use_mingw=yes
32+
33+
- name: 🍎 macOS (universal)
34+
os: macos-11
35+
platform: osx
36+
artifact-name: godot-cpp-macos-universal-release
37+
artifact-path: bin/libgodot-cpp.osx.release.64.a
38+
flags: macos_arch=universal
39+
godot_zip: Godot_v3.4-stable_osx.universal.zip
40+
executable: Godot.app/Contents/MacOS/Godot
41+
42+
- name: 🤖 Android (arm64)
43+
os: ubuntu-18.04
44+
platform: android
45+
artifact-name: godot-cpp-android-arm64-release
46+
artifact-path: bin/libgodot-cpp.android.release.arm64v8.a
47+
flags: android_arch=arm64v8
48+
49+
- name: 🍏 iOS (arm64)
50+
os: macos-11
51+
platform: ios
52+
artifact-name: godot-cpp-ios-arm64-release
53+
artifact-path: bin/libgodot-cpp.ios.release.arm64.a
54+
855
steps:
956
- name: Checkout
1057
uses: actions/checkout@v2
@@ -16,133 +63,48 @@ jobs:
1663
with:
1764
python-version: '3.x'
1865

19-
- name: Install dependencies
66+
- name: Linux dependencies
67+
if: ${{ matrix.platform == 'linux' }}
2068
run: |
2169
sudo apt-get update -qq
2270
sudo apt-get install -qqq build-essential pkg-config
23-
python -m pip install scons
24-
curl -LO https://downloads.tuxfamily.org/godotengine/3.4/Godot_v3.4-stable_linux_server.64.zip
25-
unzip Godot_v3.4-stable_linux_server.64.zip
26-
27-
- name: Build godot-cpp
28-
run: |
29-
scons target=release generate_bindings=yes -j $(nproc)
30-
31-
- name: Upload artifact
32-
uses: actions/upload-artifact@v2
33-
with:
34-
name: godot-cpp-linux-glibc2.27-x86_64-release
35-
path: bin/libgodot-cpp.linux.release.64.a
36-
if-no-files-found: error
3771
38-
- name: Build test GDNative library
39-
run: |
40-
scons target=release platform=linux bits=64 -j $(nproc) -C test
41-
42-
- name: Run test GDNative library
43-
run: |
44-
./Godot_v3.4-stable_linux_server.64 --path test -s script.gd
45-
46-
windows-msvc:
47-
name: Build (Windows, MSVC)
48-
runs-on: windows-2019
49-
steps:
50-
- name: Checkout
51-
uses: actions/checkout@v2
52-
with:
53-
submodules: recursive
54-
55-
- name: Set up Python (for SCons)
56-
uses: actions/setup-python@v2
57-
with:
58-
python-version: '3.x'
59-
60-
- name: Install dependencies
72+
- name: Install scons
6173
run: |
6274
python -m pip install scons
6375
64-
- name: Build godot-cpp
65-
run: |
66-
scons target=release generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS
67-
68-
- name: Upload artifact
69-
uses: actions/upload-artifact@v2
70-
with:
71-
name: godot-cpp-windows-msvc2019-x86_64-release
72-
path: bin/libgodot-cpp.windows.release.64.lib
73-
if-no-files-found: error
74-
75-
windows-mingw:
76-
name: Build (Windows, MinGW)
77-
runs-on: windows-2019
78-
steps:
79-
- name: Checkout
80-
uses: actions/checkout@v2
81-
with:
82-
submodules: recursive
83-
84-
- name: Set up Python (for SCons)
85-
uses: actions/setup-python@v2
86-
with:
87-
python-version: '3.x'
88-
89-
- name: Install dependencies
90-
run: |
91-
python -m pip install scons
92-
93-
- name: Setup MinGW for Windows/MinGW build
76+
- name: Windows dependency (MinGW)
77+
if: ${{ matrix.platform == 'windows' }}
9478
uses: egor-tensin/setup-mingw@v2
9579

96-
- name: Build godot-cpp
80+
- name: Build godot-cpp (debug)
9781
run: |
98-
scons target=release generate_bindings=yes use_mingw=yes -j $env:NUMBER_OF_PROCESSORS
99-
100-
- name: Upload artifact
101-
uses: actions/upload-artifact@v2
102-
with:
103-
name: godot-cpp-linux-mingw-x86_64-release
104-
path: bin/libgodot-cpp.windows.release.64.a
105-
if-no-files-found: error
106-
107-
macos:
108-
name: Build (macOS, Clang)
109-
runs-on: macos-11
110-
steps:
111-
- name: Checkout
112-
uses: actions/checkout@v2
113-
with:
114-
submodules: recursive
82+
scons platform=${{ matrix.platform }} target=debug generate_bindings=yes ${{ matrix.flags }} -j2
11583
116-
- name: Set up Python (for SCons)
117-
uses: actions/setup-python@v2
118-
with:
119-
python-version: '3.x'
84+
- name: Build test without rebuilding godot-cpp (debug)
85+
run: |
86+
cd test
87+
scons platform=${{ matrix.platform }} target=debug ${{ matrix.flags }} build_library=no -j2
12088
121-
- name: Install dependencies
89+
- name: Build test and godot-cpp (release)
12290
run: |
123-
python -m pip install scons
124-
curl -LO https://downloads.tuxfamily.org/godotengine/3.4/Godot_v3.4-stable_osx.universal.zip
125-
unzip Godot_v3.4-stable_osx.universal.zip
91+
cd test
92+
scons platform=${{ matrix.platform }} target=release ${{ matrix.flags }} -j2
12693
127-
- name: Build godot-cpp
94+
- name: Run test GDNative library
95+
if: ${{ matrix.platform == 'linux' || matrix.platform == 'osx' }}
12896
run: |
129-
scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu)
97+
curl -LO https://downloads.tuxfamily.org/godotengine/3.4/${{ matrix.godot_zip }}
98+
unzip ${{ matrix.godot_zip }}
99+
./${{ matrix.executable }} --path test -s script.gd
130100
131101
- name: Upload artifact
132102
uses: actions/upload-artifact@v2
133103
with:
134-
name: godot-cpp-macos-universal-release
135-
path: bin/libgodot-cpp.osx.release.64.a
104+
name: ${{ matrix.artifact-name }}
105+
path: ${{ matrix.artifact-path }}
136106
if-no-files-found: error
137107

138-
- name: Build test GDNative library
139-
run: |
140-
scons target=release platform=osx bits=64 macos_arch=universal -j $(sysctl -n hw.logicalcpu) -C test
141-
142-
- name: Run test GDNative library
143-
run: |
144-
./Godot.app/Contents/MacOS/Godot --path test -s script.gd
145-
146108
static-checks:
147109
name: Static Checks (clang-format)
148110
runs-on: ubuntu-20.04

SConstruct

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ opts.Add(
159159
)
160160
)
161161

162+
opts.Add(BoolVariable("build_library", "Build the godot-cpp library.", True))
163+
162164
opts.Update(env)
163165
Help(opts.GenerateHelpText(env))
164166

@@ -173,11 +175,18 @@ if host_platform == "windows" and env["platform"] != "android":
173175

174176
opts.Update(env)
175177

178+
# Require C++14
179+
if host_platform == "windows" and env["platform"] == "windows" and not env["use_mingw"]:
180+
# MSVC
181+
env.Append(CCFLAGS=["/std:c++14"])
182+
else:
183+
env.Append(CCFLAGS=["-std=c++14"])
184+
176185
if env["platform"] == "linux" or env["platform"] == "freebsd":
177186
if env["use_llvm"]:
178187
env["CXX"] = "clang++"
179188

180-
env.Append(CCFLAGS=["-fPIC", "-std=c++14", "-Wwrite-strings"])
189+
env.Append(CCFLAGS=["-fPIC", "-Wwrite-strings"])
181190
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
182191

183192
if env["target"] == "debug":
@@ -206,8 +215,6 @@ elif env["platform"] == "osx":
206215
env.Append(LINKFLAGS=["-arch", env["macos_arch"]])
207216
env.Append(CCFLAGS=["-arch", env["macos_arch"]])
208217

209-
env.Append(CCFLAGS=["-std=c++14"])
210-
211218
if env["macos_deployment_target"] != "default":
212219
env.Append(CCFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
213220
env.Append(LINKFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
@@ -216,13 +223,7 @@ elif env["platform"] == "osx":
216223
env.Append(CCFLAGS=["-isysroot", env["macos_sdk_path"]])
217224
env.Append(LINKFLAGS=["-isysroot", env["macos_sdk_path"]])
218225

219-
env.Append(
220-
LINKFLAGS=[
221-
"-framework",
222-
"Cocoa",
223-
"-Wl,-undefined,dynamic_lookup",
224-
]
225-
)
226+
env.Append(LINKFLAGS=["-Wl,-undefined,dynamic_lookup"])
226227

227228
if env["target"] == "debug":
228229
env.Append(CCFLAGS=["-Og", "-g"])
@@ -233,7 +234,6 @@ elif env["platform"] == "ios":
233234
if env["ios_simulator"]:
234235
sdk_name = "iphonesimulator"
235236
env.Append(CCFLAGS=["-mios-simulator-version-min=10.0"])
236-
env["LIBSUFFIX"] = ".simulator" + env["LIBSUFFIX"]
237237
else:
238238
sdk_name = "iphoneos"
239239
env.Append(CCFLAGS=["-miphoneos-version-min=10.0"])
@@ -250,14 +250,13 @@ elif env["platform"] == "ios":
250250
env["CXX"] = compiler_path + "clang++"
251251
env["AR"] = compiler_path + "ar"
252252
env["RANLIB"] = compiler_path + "ranlib"
253+
env["SHLIBSUFFIX"] = ".dylib"
253254

254-
env.Append(CCFLAGS=["-std=c++14", "-arch", env["ios_arch"], "-isysroot", sdk_path])
255+
env.Append(CCFLAGS=["-arch", env["ios_arch"], "-isysroot", sdk_path])
255256
env.Append(
256257
LINKFLAGS=[
257258
"-arch",
258259
env["ios_arch"],
259-
"-framework",
260-
"Cocoa",
261260
"-Wl,-undefined,dynamic_lookup",
262261
"-isysroot",
263262
sdk_path,
@@ -296,14 +295,20 @@ elif env["platform"] == "windows":
296295
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
297296
env = Environment(ENV=os.environ, tools=["mingw"])
298297
opts.Update(env)
299-
# env = env.Clone(tools=['mingw'])
298+
299+
# Still need to use C++14.
300+
env.Append(CCFLAGS=["-std=c++14"])
301+
# Don't want lib prefixes
302+
env["IMPLIBPREFIX"] = ""
303+
env["SHLIBPREFIX"] = ""
300304

301305
env["SPAWN"] = mySpawn
306+
env.Replace(ARFLAGS=["q"])
302307

303308
# Native or cross-compilation using MinGW
304309
if host_platform == "linux" or host_platform == "freebsd" or host_platform == "osx" or env["use_mingw"]:
305310
# These options are for a release build even using target=debug
306-
env.Append(CCFLAGS=["-O3", "-std=c++14", "-Wwrite-strings"])
311+
env.Append(CCFLAGS=["-O3", "-Wwrite-strings"])
307312
env.Append(
308313
LINKFLAGS=[
309314
"--static",
@@ -318,9 +323,10 @@ elif env["platform"] == "android":
318323
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
319324
env = Environment(ENV=os.environ, tools=["mingw"])
320325
opts.Update(env)
321-
# env = env.Clone(tools=['mingw'])
322326

327+
# Long line hack. Use custom spawn, quick AR append (to avoid files with the same names to override each other).
323328
env["SPAWN"] = mySpawn
329+
env.Replace(ARFLAGS=["q"])
324330

325331
# Verify NDK root
326332
if not "ANDROID_NDK_ROOT" in env:
@@ -385,11 +391,12 @@ elif env["platform"] == "android":
385391
# Setup tools
386392
env["CC"] = toolchain + "/bin/clang"
387393
env["CXX"] = toolchain + "/bin/clang++"
388-
env["AR"] = toolchain + "/bin/" + arch_info["tool_path"] + "-ar"
389-
env["AS"] = toolchain + "/bin/" + arch_info["tool_path"] + "-as"
390-
env["LD"] = toolchain + "/bin/" + arch_info["tool_path"] + "-ld"
391-
env["STRIP"] = toolchain + "/bin/" + arch_info["tool_path"] + "-strip"
392-
env["RANLIB"] = toolchain + "/bin/" + arch_info["tool_path"] + "-ranlib"
394+
env["AR"] = toolchain + "/bin/llvm-ar"
395+
env["AS"] = toolchain + "/bin/llvm-as"
396+
env["LD"] = toolchain + "/bin/llvm-ld"
397+
env["STRIP"] = toolchain + "/bin/llvm-strip"
398+
env["RANLIB"] = toolchain + "/bin/llvm-ranlib"
399+
env["SHLIBSUFFIX"] = ".so"
393400

394401
env.Append(
395402
CCFLAGS=[
@@ -399,6 +406,7 @@ elif env["platform"] == "android":
399406
]
400407
)
401408
env.Append(CCFLAGS=arch_info["ccflags"])
409+
env.Append(LINKFLAGS=["--target=" + arch_info["target"] + env["android_api_level"], "-march=" + arch_info["march"]])
402410

403411
if env["target"] == "debug":
404412
env.Append(CCFLAGS=["-Og", "-g"])
@@ -478,14 +486,25 @@ if env["platform"] == "android":
478486
arch_suffix = env["android_arch"]
479487
elif env["platform"] == "ios":
480488
arch_suffix = env["ios_arch"]
489+
if env["ios_simulator"]:
490+
arch_suffix += ".simulator"
481491
elif env["platform"] == "osx":
482492
if env["macos_arch"] != "universal":
483493
arch_suffix = env["macos_arch"]
484494
elif env["platform"] == "javascript":
485495
arch_suffix = "wasm"
496+
# Expose it to projects that import this env.
497+
env["arch_suffix"] = arch_suffix
486498

487-
library = env.StaticLibrary(
488-
target="bin/" + "libgodot-cpp.{}.{}.{}{}".format(env["platform"], env["target"], arch_suffix, env["LIBSUFFIX"]),
489-
source=sources,
490-
)
491-
Default(library)
499+
library = None
500+
env["OBJSUFFIX"] = ".{}.{}.{}{}".format(env["platform"], env["target"], arch_suffix, env["OBJSUFFIX"])
501+
library_name = "libgodot-cpp.{}.{}.{}{}".format(env["platform"], env["target"], arch_suffix, env["LIBSUFFIX"])
502+
503+
if env["build_library"]:
504+
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
505+
Default(library)
506+
507+
env.Append(CPPPATH=[env.Dir(f) for f in [env["headers_dir"], "include", "include/gen", "include/core"]])
508+
env.Append(LIBPATH=[env.Dir("bin")])
509+
env.Append(LIBS=library_name)
510+
Return("env")

0 commit comments

Comments
 (0)