Skip to content

Commit

Permalink
CI: add arm64 linux support
Browse files Browse the repository at this point in the history
  • Loading branch information
theofficialgman committed Feb 2, 2024
1 parent fa34c7e commit 81f8660
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
36 changes: 31 additions & 5 deletions .github/workflows/build-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,51 @@ jobs:
matrix:
include:
- os: windows-latest
arch: x64
lib: x64/FosterPlatform.dll
- os: macos-latest
arch: x64-arm64
lib: osx/libFosterPlatform.dylib
- os: ubuntu-latest
arch: x64
lib: lib64/libFosterPlatform.so
- os: ubuntu-latest
arch: arm64
lib: libarm64/libFosterPlatform.so
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Get CMake
uses: lukka/[email protected]
- name: Setup Linux dependencies
if: runner.os == 'Linux'
if: ${{ runner.os == 'Linux' && matrix.arch != 'arm64' }}
run: |
sudo apt-get update
sudo apt-get install libsdl2-dev
- name: Setup Linux dependencies (arm64)
if: ${{ runner.os == 'Linux' && matrix.arch == 'arm64' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
sudo sed -i "s/^deb/deb [arch=amd64,i386]/g" /etc/apt/sources.list
echo "deb [arch=arm64,armhf] http://ports.ubuntu.com/ $(lsb_release -s -c) main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=arm64,armhf] http://ports.ubuntu.com/ $(lsb_release -s -c)-updates main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
sudo dpkg --add-architecture arm64
sudo apt-get update
sudo apt-get install -y libsdl2-dev:arm64 libwayland-dev:arm64 libegl-dev:arm64 libdrm-dev:arm64 libxkbcommon-dev:arm64 libpulse-dev:arm64
- name: CMake Configure
if: ${{ matrix.arch != 'arm64' }}
run: cmake -B build -S Platform
- name: CMake Configure (arm64)
if: ${{ runner.os == 'Linux' && matrix.arch == 'arm64' }}
run: PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig cmake -B build -S Platform -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_SYSTEM_NAME=Linux
- name: CMake Build
run: cmake --build build --config Release
- name: Publish Artifact
uses: actions/[email protected]
with:
name: ${{matrix.os}}-build
name: ${{matrix.os}}-${{matrix.arch}}-build
path: Platform/libs/${{matrix.lib}}
UpdateLibs:
if: github.ref == 'refs/heads/main'
Expand All @@ -53,18 +74,23 @@ jobs:
- name: Download windows lib
uses: actions/download-artifact@v3
with:
name: windows-latest-build
name: windows-latest-x64-build
path: Platform/libs/x64
- name: Download macos lib
uses: actions/download-artifact@v3
with:
name: macos-latest-build
name: macos-latest-x64-arm64-build
path: Platform/libs/osx
- name: Download ubuntu lib
uses: actions/download-artifact@v3
with:
name: ubuntu-latest-build
name: ubuntu-latest-x64-build
path: Platform/libs/lib64
- name: Download ubuntu lib (arm64)
uses: actions/download-artifact@v3
with:
name: ubuntu-latest-arm64-build
path: Platform/libs/libarm64
- name: Display structure of libs
run: ls -R
working-directory: Platform/libs
Expand Down
8 changes: 7 additions & 1 deletion Framework/Foster.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@
<Link>FosterPlatform.dll</Link>
</Content>
<Content Include="$(NativeLibsDir)lib64\libFosterPlatform.so">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux'))">PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\linux-x64\native</PackagePath>
<Pack>True</Pack>
<Link>libFosterPlatform.so</Link>
</Content>
<Content Include="$(NativeLibsDir)libarm64\libFosterPlatform.so">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\linux-arm64\native</PackagePath>
<Pack>True</Pack>
<Link>libFosterPlatform.so</Link>
</Content>
<Content Include="$(NativeLibsDir)osx\libFosterPlatform.dylib">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('OSX'))">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\osx\native</PackagePath>
Expand Down
6 changes: 5 additions & 1 deletion Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ if (APPLE)
elseif (WIN32)
set(FosterTarget x64)
elseif (UNIX)
set(FosterTarget lib64)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(FosterTarget libarm64)
else()
set(FosterTarget lib64)
endif()
else()
message(FATAL_ERROR "Unknown Target!")
endif()
Expand Down

0 comments on commit 81f8660

Please sign in to comment.