Skip to content

Commit

Permalink
add linux arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
3ddelano committed Feb 18, 2025
1 parent 384a905 commit 6899e56
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 92 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,34 @@ jobs:
fail-fast: false
matrix:
include:
- identifier: linux-debug
name: 🐧 Linux Debug
- identifier: linux-x86-64-debug
name: 🐧 Linux x86_64 Debug
runner: ubuntu-24.04
target: template_debug
dev_build: yes
platform: linux
arch: x86_64
- identifier: linux-release
name: 🐧Linux Release
- identifier: linux-x86-64-release
name: 🐧Linux x86_64 Release
runner: ubuntu-24.04
target: template_release
dev_build: no
platform: linux
arch: x86_64
- identifier: linu-arm64-debug
name: 🐧 Linux arm64 Debug
runner: ubuntu-24.04
target: template_debug
dev_build: yes
platform: linux
arch: arm64
- identifier: linux-arm64-release
name: 🐧Linux arm64 Release
runner: ubuntu-24.04
target: template_release
dev_build: no
platform: linux
arch: arm64
- identifier: macos-debug
name: 🍎 macOS (universal) Debug
runner: macos-latest
Expand Down
169 changes: 85 additions & 84 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -17,65 +17,66 @@ 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)
if not os.path.exists(os.path.dirname(to_path)):
os.makedirs(os.path.dirname(to_path))
shutil.copyfile(from_path, to_path)

def copy_folder(from_path, to_path):
if not os.path.exists(to_path):
os.makedirs(to_path)
shutil.rmtree(to_path, ignore_errors=True)
shutil.copytree(from_path, to_path)
if not os.path.exists(to_path):
os.makedirs(to_path)
shutil.rmtree(to_path, ignore_errors=True)
shutil.copytree(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)
# Copy aar to plugin bin/android
copy_file(aar_file, plugin_bin_folder + "/android/eossdk-StaticSTDC-release.aar")
# 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)
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)
# Copy aar to plugin bin/android
copy_file(aar_file, plugin_bin_folder + "/android/eossdk-StaticSTDC-release.aar")
# 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)


genv = env
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}")
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":
so_variant = "LinuxArm64" if env["arch"] == "arm64" else "Linux"
copy_file(eos_sdk_folder + f"Bin/libEOSSDK-{so_variant}-Shipping.so", plugin_bin_folder + "/linux/libEOSSDK-{so_variant}-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}")



Expand All @@ -91,51 +92,51 @@ def on_complete(target, source, env):
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"])
# 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"])
env.Append(LIBS=["EOSSDK-Linux-Shipping"])

elif env["platform"] == "macos":
env.Append(LIBS=["EOSSDK-Mac-Shipping"])
env.Append(LIBS=["EOSSDK-Mac-Shipping"])

elif env["platform"] == "ios":
if env["arch"] != "arm64":
raise Exception("Only arm64 is supported on iOS.")
copy_folder(eos_sdk_folder + "Bin/IOS/EOSSDK.xcframework", plugin_bin_folder + "/ios/EOSSDK.xcframework")
env.Append(LINKFLAGS=[
"-F", plugin_bin_folder + f"/ios/EOSSDK.xcframework/ios-arm64{"-simulator" if env["ios_simulator"] else ""}",
'-framework', 'AuthenticationServices',
'-framework', 'EOSSDK',
])
if env["arch"] != "arm64":
raise Exception("Only arm64 is supported on iOS.")
copy_folder(eos_sdk_folder + "Bin/IOS/EOSSDK.xcframework", plugin_bin_folder + "/ios/EOSSDK.xcframework")
env.Append(LINKFLAGS=[
"-F", plugin_bin_folder + f"/ios/EOSSDK.xcframework/ios-arm64{"-simulator" if env["ios_simulator"] else ""}",
'-framework', 'AuthenticationServices',
'-framework', 'EOSSDK',
])

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"])
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,)
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,
)
library = env.SharedLibrary(
f"{plugin_bin_folder}/{platform}/{lib_name}{env['suffix']}{env['SHLIBSUFFIX']}",
source=sources,
)


# Disable scons cache for source files
Expand Down
12 changes: 8 additions & 4 deletions sample/addons/epic-online-services-godot/eosg.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ entry_symbol = "eosg_library_init"
compatibility_minimum = 4.1

[libraries]
linux.x86_64.debug = "bin/linux/libeosg.linux.template_debug.dev.x86_64.so"
linux.x86_64.release = "bin/linux/libeosg.linux.template_release.x86_64.so"
windows.x86_64.debug = "bin/windows/libeosg.windows.template_debug.dev.x86_64.dll"
windows.x86_64.release = "bin/windows/libeosg.windows.template_release.x86_64.dll"
linux.debug.x86_64 = "bin/linux/libeosg.linux.template_debug.dev.x86_64.so"
linux.release.x86_64 = "bin/linux/libeosg.linux.template_release.x86_64.so"
linux.debug.arm64 = "bin/linux/libeosg.linux.template_debug.dev.arm64.so"
linux.release.arm64 = "bin/linux/libeosg.linux.template_release.arm64.so"
windows.debug.x86_64 = "bin/windows/libeosg.windows.template_debug.dev.x86_64.dll"
windows.release.x86_64 = "bin/windows/libeosg.windows.template_release.x86_64.dll"
macos.debug = "bin/macos/libeosg.macos.template_debug.framework"
macos.release = "bin/macos/libeosg.macos.template_release.framework"
ios.debug = "bin/ios/libeosg.ios.template_debug.xcframework"
Expand All @@ -20,6 +22,8 @@ android.release.x86_64 = "bin/android/libeosg.android.template_release.x86_64.so
[dependencies]
linux.debug.x86_64 = {"bin/linux/libEOSSDK-Linux-Shipping.so": ""}
linux.release.x86_64 = {"bin/linux/libEOSSDK-Linux-Shipping.so": ""}
linux.debug.arm64 = {"bin/linux/libEOSSDK-LinuxArm64-Shipping.so": ""}
linux.release.arm64 = {"bin/linux/libEOSSDK-LinuxArm64-Shipping.so": ""}
windows.debug.x86_64 = {"bin/windows/EOSSDK-Win64-Shipping.dll": "", "bin/windows/x64/xaudio2_9redist.dll": ""}
windows.release.x86_64 = {"bin/windows/EOSSDK-Win64-Shipping.dll": "", "bin/windows/x64/xaudio2_9redist.dll": ""}
macos.debug = {"bin/macos/libeosg.macos.template_debug.framework/libEOSSDK-Mac-Shipping.dylib": ""}
Expand Down

0 comments on commit 6899e56

Please sign in to comment.