Skip to content

Commit f4eae74

Browse files
committed
Allowing cmake lib target override; Copy Windows-Arm lib over properly
1 parent 3f6c171 commit f4eae74

File tree

3 files changed

+55
-34
lines changed

3 files changed

+55
-34
lines changed

.github/workflows/build-libs.yml

+21-15
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,28 @@ jobs:
1919
include:
2020
- os: windows-latest
2121
arch: x64
22-
lib: x64/FosterPlatform.dll
22+
target: win-x64
23+
lib: FosterPlatform.dll
2324
- os: windows-latest
2425
arch: arm64
25-
lib: arm64/FosterPlatform.dll
26+
target: win-arm64
27+
lib: FosterPlatform.dll
2628
- os: macos-latest
2729
arch: x64-arm64
28-
lib: osx/libFosterPlatform.dylib
30+
target: osx
31+
lib: libFosterPlatform.dylib
2932
- os: ubuntu-latest
3033
arch: x64
31-
lib: lib64/libFosterPlatform.so
34+
target: linux-x64
35+
lib: libFosterPlatform.so
3236
- os: ubuntu-latest
3337
arch: arm64
34-
lib: libarm64/libFosterPlatform.so
38+
target: linux-arm64
39+
lib: libFosterPlatform.so
3540
- os: ubuntu-latest
3641
arch: arm32
37-
lib: libarm/libFosterPlatform.so
42+
target: linux-arm32
43+
lib: libFosterPlatform.so
3844
runs-on: ${{matrix.os}}
3945
steps:
4046
- name: Checkout
@@ -70,20 +76,20 @@ jobs:
7076
sudo apt-get install -y libsdl2-dev:armhf libwayland-dev:armhf libegl-dev:armhf libdrm-dev:armhf libxkbcommon-dev:armhf libpulse-dev:armhf
7177
- name: CMake Configure
7278
if: ${{ !(runner.os == 'Linux' && matrix.arch == 'arm64') && !(runner.os == 'Linux' && matrix.arch == 'arm32') }}
73-
run: cmake -B build -S Platform
79+
run: cmake -B build -S Platform -DFOSTER_OVERRIDE_TARGET=${{matrix.target}}
7480
- name: CMake Configure (Linux-arm64)
7581
if: ${{ runner.os == 'Linux' && matrix.arch == 'arm64' }}
76-
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
82+
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}}
7783
- name: CMake Configure (Linux-arm32)
7884
if: ${{ runner.os == 'Linux' && matrix.arch == 'arm32' }}
79-
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
85+
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}}
8086
- name: CMake Build
8187
run: cmake --build build --config Release
8288
- name: Publish Artifact
8389
uses: actions/[email protected]
8490
with:
8591
name: ${{matrix.os}}-${{matrix.arch}}-build
86-
path: Platform/libs/${{matrix.lib}}
92+
path: Platform/libs/${{matrix.target}}/${{matrix.lib}}
8793
UpdateLibs:
8894
if: github.ref == 'refs/heads/main'
8995
needs: [Build]
@@ -95,12 +101,12 @@ jobs:
95101
uses: actions/download-artifact@v3
96102
with:
97103
name: windows-latest-x64-build
98-
path: Platform/libs/x64
104+
path: Platform/libs/win-x64
99105
- name: Download windows arm lib
100106
uses: actions/download-artifact@v3
101107
with:
102108
name: windows-latest-arm64-build
103-
path: Platform/libs/arm64
109+
path: Platform/libs/win-arm64
104110
- name: Download macos lib
105111
uses: actions/download-artifact@v3
106112
with:
@@ -110,17 +116,17 @@ jobs:
110116
uses: actions/download-artifact@v3
111117
with:
112118
name: ubuntu-latest-x64-build
113-
path: Platform/libs/lib64
119+
path: Platform/libs/linux-x64
114120
- name: Download ubuntu lib (arm64)
115121
uses: actions/download-artifact@v3
116122
with:
117123
name: ubuntu-latest-arm64-build
118-
path: Platform/libs/libarm64
124+
path: Platform/libs/linux-arm64
119125
- name: Download ubuntu lib (arm32)
120126
uses: actions/download-artifact@v3
121127
with:
122128
name: ubuntu-latest-arm32-build
123-
path: Platform/libs/libarm
129+
path: Platform/libs/linux-arm32
124130
- name: Display structure of libs
125131
run: ls -R
126132
working-directory: Platform/libs

Framework/Foster.Framework.csproj

+26-8
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,45 @@
2525
<NativeLibsDir>$(ProjectDir)..\Platform\libs\</NativeLibsDir>
2626
</PropertyGroup>
2727

28+
<PropertyGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == 'X64')">
29+
<IsX64>true</IsX64>
30+
</PropertyGroup>
31+
32+
<PropertyGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == 'Arm64')">
33+
<IsArm64>true</IsArm64>
34+
</PropertyGroup>
35+
36+
<PropertyGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) == 'Arm32')">
37+
<IsArm32>true</IsArm32>
38+
</PropertyGroup>
39+
2840
<ItemGroup>
29-
<Content Include="$(NativeLibsDir)x64\FosterPlatform.dll">
30-
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Windows'))">PreserveNewest</CopyToOutputDirectory>
41+
<Content Include="$(NativeLibsDir)win-x64\FosterPlatform.dll">
42+
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Windows')) AND $(IsArm64) != 'true'">PreserveNewest</CopyToOutputDirectory>
3143
<PackagePath>runtimes\win-x64\native</PackagePath>
3244
<Pack>True</Pack>
3345
<Link>FosterPlatform.dll</Link>
3446
</Content>
35-
<Content Include="$(NativeLibsDir)lib64\libFosterPlatform.so">
36-
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">PreserveNewest</CopyToOutputDirectory>
47+
<Content Include="$(NativeLibsDir)win-arm64\FosterPlatform.dll">
48+
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Windows')) AND $(IsArm64) == 'true'">PreserveNewest</CopyToOutputDirectory>
49+
<PackagePath>runtimes\win-arm64\native</PackagePath>
50+
<Pack>True</Pack>
51+
<Link>FosterPlatform.dll</Link>
52+
</Content>
53+
<Content Include="$(NativeLibsDir)linux-x64\libFosterPlatform.so">
54+
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND $(IsX64) == 'true'">PreserveNewest</CopyToOutputDirectory>
3755
<PackagePath>runtimes\linux-x64\native</PackagePath>
3856
<Pack>True</Pack>
3957
<Link>libFosterPlatform.so</Link>
4058
</Content>
41-
<Content Include="$(NativeLibsDir)libarm64\libFosterPlatform.so">
42-
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">PreserveNewest</CopyToOutputDirectory>
59+
<Content Include="$(NativeLibsDir)linux-arm64\libFosterPlatform.so">
60+
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND $(IsArm64) == 'true'">PreserveNewest</CopyToOutputDirectory>
4361
<PackagePath>runtimes\linux-arm64\native</PackagePath>
4462
<Pack>True</Pack>
4563
<Link>libFosterPlatform.so</Link>
4664
</Content>
47-
<Content Include="$(NativeLibsDir)libarm\libFosterPlatform.so">
48-
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm'">PreserveNewest</CopyToOutputDirectory>
65+
<Content Include="$(NativeLibsDir)linux-arm32\libFosterPlatform.so">
66+
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND $(IsArm32) == 'true'">PreserveNewest</CopyToOutputDirectory>
4967
<PackagePath>runtimes\linux-arm\native</PackagePath>
5068
<Pack>True</Pack>
5169
<Link>libFosterPlatform.so</Link>

Platform/CMakeLists.txt

+8-11
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,21 @@ target_include_directories(${TARGET_NAME}
3535
)
3636

3737
# Get platform target
38-
message(STATUS "System Processor: ${CMAKE_SYSTEM_PROCESSOR}")
39-
if (APPLE)
38+
if (FOSTER_OVERRIDE_TARGET)
39+
set(FosterTarget ${FOSTER_OVERRIDE_TARGET})
40+
elseif (APPLE)
4041
set(FosterTarget osx)
4142
elseif (WIN32)
42-
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
43-
set(FosterTarget arm64)
44-
else()
45-
set(FosterTarget x64)
46-
endif()
43+
set(FosterTarget win-x64)
4744
elseif (UNIX)
4845
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
49-
set(FosterTarget libarm64)
46+
set(FosterTarget linux-arm64)
5047
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
51-
set(FosterTarget libarm)
48+
set(FosterTarget linux-arm32)
5249
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv6l")
53-
set(FosterTarget libarm)
50+
set(FosterTarget linux-arm32)
5451
else()
55-
set(FosterTarget lib64)
52+
set(FosterTarget linux-x64)
5653
endif()
5754
else()
5855
message(FATAL_ERROR "Unknown Target!")

0 commit comments

Comments
 (0)