Skip to content

Commit

Permalink
Allowing cmake lib target override; Copy Windows-Arm lib over properly
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelFB committed Jul 3, 2024
1 parent 3f6c171 commit f4eae74
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 34 deletions.
36 changes: 21 additions & 15 deletions .github/workflows/build-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,28 @@ jobs:
include:
- os: windows-latest
arch: x64
lib: x64/FosterPlatform.dll
target: win-x64
lib: FosterPlatform.dll
- os: windows-latest
arch: arm64
lib: arm64/FosterPlatform.dll
target: win-arm64
lib: FosterPlatform.dll
- os: macos-latest
arch: x64-arm64
lib: osx/libFosterPlatform.dylib
target: osx
lib: libFosterPlatform.dylib
- os: ubuntu-latest
arch: x64
lib: lib64/libFosterPlatform.so
target: linux-x64
lib: libFosterPlatform.so
- os: ubuntu-latest
arch: arm64
lib: libarm64/libFosterPlatform.so
target: linux-arm64
lib: libFosterPlatform.so
- os: ubuntu-latest
arch: arm32
lib: libarm/libFosterPlatform.so
target: linux-arm32
lib: libFosterPlatform.so
runs-on: ${{matrix.os}}
steps:
- name: Checkout
Expand Down Expand Up @@ -70,20 +76,20 @@ jobs:
sudo apt-get install -y libsdl2-dev:armhf libwayland-dev:armhf libegl-dev:armhf libdrm-dev:armhf libxkbcommon-dev:armhf libpulse-dev:armhf
- name: CMake Configure
if: ${{ !(runner.os == 'Linux' && matrix.arch == 'arm64') && !(runner.os == 'Linux' && matrix.arch == 'arm32') }}
run: cmake -B build -S Platform
run: cmake -B build -S Platform -DFOSTER_OVERRIDE_TARGET=${{matrix.target}}
- name: CMake Configure (Linux-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
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 -DFOSTER_OVERRIDE_TARGET=${{matrix.target}}
- name: CMake Configure (Linux-arm32)
if: ${{ runner.os == 'Linux' && matrix.arch == 'arm32' }}
run: PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig cmake -B build -S Platform -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_SYSTEM_PROCESSOR=armv7l -DCMAKE_SYSTEM_NAME=Linux
run: PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig cmake -B build -S Platform -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_SYSTEM_PROCESSOR=armv7l -DCMAKE_SYSTEM_NAME=Linux -DFOSTER_OVERRIDE_TARGET=${{matrix.target}}
- name: CMake Build
run: cmake --build build --config Release
- name: Publish Artifact
uses: actions/[email protected]
with:
name: ${{matrix.os}}-${{matrix.arch}}-build
path: Platform/libs/${{matrix.lib}}
path: Platform/libs/${{matrix.target}}/${{matrix.lib}}
UpdateLibs:
if: github.ref == 'refs/heads/main'
needs: [Build]
Expand All @@ -95,12 +101,12 @@ jobs:
uses: actions/download-artifact@v3
with:
name: windows-latest-x64-build
path: Platform/libs/x64
path: Platform/libs/win-x64
- name: Download windows arm lib
uses: actions/download-artifact@v3
with:
name: windows-latest-arm64-build
path: Platform/libs/arm64
path: Platform/libs/win-arm64
- name: Download macos lib
uses: actions/download-artifact@v3
with:
Expand All @@ -110,17 +116,17 @@ jobs:
uses: actions/download-artifact@v3
with:
name: ubuntu-latest-x64-build
path: Platform/libs/lib64
path: Platform/libs/linux-x64
- name: Download ubuntu lib (arm64)
uses: actions/download-artifact@v3
with:
name: ubuntu-latest-arm64-build
path: Platform/libs/libarm64
path: Platform/libs/linux-arm64
- name: Download ubuntu lib (arm32)
uses: actions/download-artifact@v3
with:
name: ubuntu-latest-arm32-build
path: Platform/libs/libarm
path: Platform/libs/linux-arm32
- name: Display structure of libs
run: ls -R
working-directory: Platform/libs
Expand Down
34 changes: 26 additions & 8 deletions Framework/Foster.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,45 @@
<NativeLibsDir>$(ProjectDir)..\Platform\libs\</NativeLibsDir>
</PropertyGroup>

<PropertyGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == 'X64')">
<IsX64>true</IsX64>
</PropertyGroup>

<PropertyGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == 'Arm64')">
<IsArm64>true</IsArm64>
</PropertyGroup>

<PropertyGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == 'Arm32')">
<IsArm32>true</IsArm32>
</PropertyGroup>

<ItemGroup>
<Content Include="$(NativeLibsDir)x64\FosterPlatform.dll">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Windows'))">PreserveNewest</CopyToOutputDirectory>
<Content Include="$(NativeLibsDir)win-x64\FosterPlatform.dll">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Windows')) AND $(IsArm64) != 'true'">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\win-x64\native</PackagePath>
<Pack>True</Pack>
<Link>FosterPlatform.dll</Link>
</Content>
<Content Include="$(NativeLibsDir)lib64\libFosterPlatform.so">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">PreserveNewest</CopyToOutputDirectory>
<Content Include="$(NativeLibsDir)win-arm64\FosterPlatform.dll">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Windows')) AND $(IsArm64) == 'true'">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\win-arm64\native</PackagePath>
<Pack>True</Pack>
<Link>FosterPlatform.dll</Link>
</Content>
<Content Include="$(NativeLibsDir)linux-x64\libFosterPlatform.so">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND $(IsX64) == 'true'">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>
<Content Include="$(NativeLibsDir)linux-arm64\libFosterPlatform.so">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND $(IsArm64) == 'true'">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\linux-arm64\native</PackagePath>
<Pack>True</Pack>
<Link>libFosterPlatform.so</Link>
</Content>
<Content Include="$(NativeLibsDir)libarm\libFosterPlatform.so">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm'">PreserveNewest</CopyToOutputDirectory>
<Content Include="$(NativeLibsDir)linux-arm32\libFosterPlatform.so">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND $(IsArm32) == 'true'">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\linux-arm\native</PackagePath>
<Pack>True</Pack>
<Link>libFosterPlatform.so</Link>
Expand Down
19 changes: 8 additions & 11 deletions Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,21 @@ target_include_directories(${TARGET_NAME}
)

# Get platform target
message(STATUS "System Processor: ${CMAKE_SYSTEM_PROCESSOR}")
if (APPLE)
if (FOSTER_OVERRIDE_TARGET)
set(FosterTarget ${FOSTER_OVERRIDE_TARGET})
elseif (APPLE)
set(FosterTarget osx)
elseif (WIN32)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(FosterTarget arm64)
else()
set(FosterTarget x64)
endif()
set(FosterTarget win-x64)
elseif (UNIX)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(FosterTarget libarm64)
set(FosterTarget linux-arm64)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(FosterTarget libarm)
set(FosterTarget linux-arm32)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv6l")
set(FosterTarget libarm)
set(FosterTarget linux-arm32)
else()
set(FosterTarget lib64)
set(FosterTarget linux-x64)
endif()
else()
message(FATAL_ERROR "Unknown Target!")
Expand Down

0 comments on commit f4eae74

Please sign in to comment.