forked from VoylinsGamedevJourney/gde_gozen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
129 lines (113 loc) · 3.65 KB
/
Copy pathSConstruct
File metadata and controls
129 lines (113 loc) · 3.65 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
#!/usr/bin/env python
import os
import platform as os_platform
LIBS_COMMON = [
"avcodec",
"avformat",
"swresample",
"swscale",
"avutil"]
LOCATION = "test_room/addons/gde_gozen/bin"
march_flags = {
"x86_64": "x86-64",
"arm64": "armv8-a"
}
env = SConscript("godot_cpp/SConstruct")
env.Append(CPPPATH=["src"])
env_suffix = env["suffix"]
env_shlibsuffix = env["SHLIBSUFFIX"]
jobs = ARGUMENTS.get("jobs", 4)
platform = ARGUMENTS.get("platform", "linux")
arch = ARGUMENTS.get("arch", "x86_64")
target = ARGUMENTS.get("target", "template_debug").split("_")[-1]
libpath = f"{LOCATION}/{platform}"
if "linux" in platform:
libpath += f"_{arch}/libgozen{env_suffix}{env_shlibsuffix}"
if arch == "arm64":
march_flags[arch] = "armv8-a"
env["CC"] = "aarch64-linux-gnu-gcc"
env["CXX"] = "aarch64-linux-gnu-g++"
env["LINK"] = "aarch64-linux-gnu-g++"
env.Append(
LINKFLAGS=["-static-libstdc++"],
CCFLAGS=[f"-march={march_flags[arch]}"],
CPPFLAGS=[
"-Iffmpeg/bin",
"-Iffmpeg/bin/include"],
LIBPATH=["ffmpeg/bin/lib"],
LIBS=LIBS_COMMON)
elif "windows" in platform:
libpath += f"_{arch}/libgozen{env_suffix}{env_shlibsuffix}"
if os_platform.system().lower() == "windows":
env.Append(LIBS=[
"avcodec.lib",
"avformat.lib",
"avutil.lib",
"swresample.lib",
"swscale.lib"])
else:
env.Append(LIBS=LIBS_COMMON)
env.Append(
CPPPATH=["ffmpeg/bin/include"],
LIBPATH=["ffmpeg/bin/bin"])
elif "macos" in platform:
# MacOS can only be build on a MacOS machine!
macos_base_path = f"{libpath}/{target}"
macos_lib_path = f"{macos_base_path}/lib"
libpath = f"{macos_base_path}/libgozen{env_suffix}{env_shlibsuffix}"
os.makedirs(macos_lib_path, exist_ok=True)
env.Append(
CPPPATH=["ffmpeg/bin/include"],
LIBPATH=[
"ffmpeg/bin/lib",
"ffmpeg/bin/include/libavcodec",
"ffmpeg/bin/include/libavformat",
"ffmpeg/bin/include/libavutil",
"ffmpeg/bin/include/libswresample",
"ffmpeg/bin/include/libswscale",
macos_lib_path,
"/usr/local/lib"],
LIBS=LIBS_COMMON,
LINKFLAGS=[ # macOS-specific linking flags
"-stdlib=libc++",
"-framework", "CoreFoundation",
"-framework", "CoreVideo",
"-framework", "CoreMedia",
"-framework", "AVFoundation",
"-rpath", "@loader_path/lib"]
)
elif "android" in platform:
libpath += f"_{arch}/libgozen{env_suffix}{env_shlibsuffix}"
if arch == "arm64":
env.Append(CCFLAGS=["-march=armv8-a"])
elif arch == "armv7a":
env.Append(CCFLAGS=["-march=armv7-a", "-mfloat-abi=softfp", "-mfpu=neon"])
env.Append(
LINKFLAGS=["-static-libstdc++"],
CPPFLAGS=[
"-Iffmpeg/bin",
"-Iffmpeg/bin/include"],
LIBPATH=["ffmpeg/bin/lib"],
LIBS=LIBS_COMMON)
elif "web" in platform:
web_bin_path = libpath
web_include_path = f"{web_bin_path}/include"
libpath += f"/libgozen{env_suffix}{env_shlibsuffix}"
env.Append(
CPPPATH=[web_include_path],
LIBPATH=[web_bin_path],
LIBS=LIBS_COMMON,
CCFLAGS=["-pthread"],
LINKFLAGS=[
"-pthread",
"-sUSE_PTHREADS=1",
"-sSHARED_MEMORY=1",
"-sALLOW_MEMORY_GROWTH=1",
]
)
else:
print(f"Warning: Unsupported platform '{platform}' in SConstruct.")
# Godot compiling stuff
src = Glob("src/*.cpp")
sharedlib = env.SharedLibrary(libpath, src)
Default(sharedlib)