-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
SConstruct
124 lines (91 loc) · 4.29 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python
import os
import sys
import shutil
env = SConscript("godot-cpp/SConstruct")
lib_name = "libeosg"
plugin_bin_folder = "sample/addons/epic-online-services-godot/bin"
eos_sdk_folder = "thirdparty/eos-sdk/SDK/"
# Add source files
env.Append(CPPPATH=["src/", eos_sdk_folder + "Include/"])
sources = Glob("src/*.cpp")
platform = env["platform"]
build_target = env["target"]
def copy_file(from_path, to_path):
if not os.path.exists(os.path.dirname(to_path)):
os.makedirs(os.path.dirname(to_path))
shutil.copyfile(from_path, to_path)
def extract_eos_android_libraries():
libs_path = eos_sdk_folder + "Bin/Android/static-stdc++/libs/"
aar_file = eos_sdk_folder + "Bin/Android/static-stdc++/aar/eossdk-StaticSTDC-release.aar"
zip_file = libs_path + "eos-sdk.zip"
# Delete libs folder if exists
shutil.rmtree(libs_path, ignore_errors=True)
# Copy aar to zip file
copy_file(aar_file, zip_file)
# Create folder if doesnt exist
if not os.path.exists(libs_path + "extracted"):
os.makedirs(libs_path + "extracted")
# Unzip the file
shutil.unpack_archive(zip_file, libs_path + "extracted")
# Copy all folders from libs_path+"extracted/jni" to libs_path
for folder in os.listdir(libs_path + "extracted/jni"):
shutil.copytree(libs_path + "extracted/jni/" + folder, libs_path + folder)
# Delete extracted folder
shutil.rmtree(libs_path + "extracted", ignore_errors=True)
# Delete zip file
os.remove(zip_file)
def on_complete(target, source, env):
if platform == "windows":
shutil.rmtree(plugin_bin_folder + "/windows/x64", ignore_errors=True)
shutil.copytree(eos_sdk_folder + "Bin/x64", plugin_bin_folder + "/windows/x64")
copy_file(eos_sdk_folder + "Bin/EOSSDK-Win64-Shipping.dll", plugin_bin_folder + "/windows/EOSSDK-Win64-Shipping.dll")
elif platform == "linux":
copy_file(eos_sdk_folder + "Bin/libEOSSDK-Linux-Shipping.so", plugin_bin_folder + "/linux/libEOSSDK-Linux-Shipping.so")
elif platform == "macos":
framework_folder = plugin_bin_folder + f"/macos/{lib_name}.{platform}.{build_target}.framework"
# Copies EOS dylib inside framework folder
copy_file(eos_sdk_folder + "Bin/libEOSSDK-Mac-Shipping.dylib", framework_folder + f"/libEOSSDK-Mac-Shipping.dylib")
lib_path = f"{framework_folder}/{lib_name}.{platform}.{build_target}"
print(f"Updating libEOSSDK-Mac-Shipping.dylib path in {lib_path}")
os.system(f"install_name_tool -change @rpath/libEOSSDK-Mac-Shipping.dylib @loader_path/libEOSSDK-Mac-Shipping.dylib {lib_path}")
# For reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags
env.Append(LIBPATH=[eos_sdk_folder + "Lib/"])
env.Append(LIBPATH=[eos_sdk_folder + "Bin/"])
if env["platform"] == "windows":
# TODO: dont ignore this warning
# this disables LINK : error LNK1218: warning treated as error;
# so that it can build in github action with scons cache
env.Append(LINKFLAGS=["/ignore:4099"])
env.Append(LIBS=["EOSSDK-Win64-Shipping"])
elif env["platform"] == "linux":
env.Append(LIBS=["EOSSDK-Linux-Shipping"])
elif env["platform"] == "macos":
env.Append(LIBS=["EOSSDK-Mac-Shipping"])
elif env["platform"] == "android":
eos_android_arch = "arm64-v8a"
if env["arch"] == "x86_64":
eos_android_arch = "x86_64"
extract_eos_android_libraries()
env.Append(LIBPATH=[eos_sdk_folder + "Bin/Android/static-stdc++/libs/" + eos_android_arch + "/"])
env.Append(LIBS=["EOSSDK"])
if env["platform"] == "macos":
library = env.SharedLibrary(
f"{plugin_bin_folder}/macos/{lib_name}.{platform}.{build_target}.framework/{lib_name}.{platform}.{build_target}",
source=sources,)
else:
library = env.SharedLibrary(
f"{plugin_bin_folder}/{platform}/{lib_name}{env['suffix']}{env['SHLIBSUFFIX']}",
source=sources,
)
# Disable scons cache for source files
NoCache(sources)
complete_command = Command('complete', library, on_complete)
Depends(complete_command, library)
Default(complete_command)