Skip to content

Commit

Permalink
More GithubAction/CMake changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBrixican committed Feb 9, 2024
1 parent a220473 commit 72ff3f6
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 39 deletions.
53 changes: 46 additions & 7 deletions .github/workflows/build-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,59 @@ jobs:
matrix:
include:
- os: windows-latest
arch: x64
lib: x64/FosterAudioPlatform.dll
- os: macos-latest
arch: x64-arm64
lib: osx/libFosterAudioPlatform.dylib
- os: ubuntu-latest
arch: x64
lib: lib64/libFosterAudioPlatform.so
- os: ubuntu-latest
arch: arm64
lib: libarm64/libFosterAudioPlatform.so
- os: ubuntu-latest
arch: arm32
lib: libarm/libFosterAudioPlatform.so
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v4.0.0
- name: Get CMake
uses: lukka/get-cmake@v3.27.4
- name: Setup Linux dependencies
if: runner.os == 'Linux'
- 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
- name: Setup Linux dependencies (arm32)
if: ${{ runner.os == 'Linux' && matrix.arch == 'arm32' }}
run: |
sudo apt-get update
sudo apt-get install libsdl2-dev
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
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 armhf
- name: CMake Configure
if: ${{ matrix.arch != 'arm64' && matrix.arch != 'arm32' }}
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 Configure (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
- name: CMake Build
run: cmake --build build --config Release
- name: Publish Artifact
uses: actions/upload-artifact@v3.1.3
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 +82,28 @@ 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: Download ubuntu lib (arm32)
uses: actions/download-artifact@v3
with:
name: ubuntu-latest-arm32-build
path: Platform/libs/libarm
- name: Display structure of libs
run: ls -R
working-directory: Platform/libs
Expand Down
14 changes: 13 additions & 1 deletion Foster.Audio/Foster.Audio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,23 @@
<Link>FosterAudioPlatform.dll</Link>
</Content>
<Content Include="$(NativeLibsDir)lib64\libFosterAudioPlatform.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>libFosterAudioPlatform.so</Link>
</Content>
<Content Include="$(NativeLibsDir)libarm64\libFosterAudioPlatform.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>libFosterAudioPlatform.so</Link>
</Content>
<Content Include="$(NativeLibsDir)libarm\libFosterAudioPlatform.so">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm'">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\linux-arm\native</PackagePath>
<Pack>True</Pack>
<Link>libFosterAudioPlatform.so</Link>
</Content>
<Content Include="$(NativeLibsDir)osx\libFosterAudioPlatform.dylib">
<CopyToOutputDirectory Condition="$([MSBuild]::IsOSPlatform('OSX'))">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\osx\native</PackagePath>
Expand Down
64 changes: 33 additions & 31 deletions Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,38 @@ target_include_directories(${TARGET_NAME}
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
)

# ignore some particularly annoying warnings from our third party libraries
if(MSVC)
# possible loss of data
add_definitions("/wd4244 /wd4267")
# truncation
add_definitions("/wd4305")
# signed/unsigned mismatch
add_definitions("/wd4018")
endif()

file(GLOB_RECURSE TP_DIR "src/third_party/*.c" "src/third_party/*.h")

message(${TP_DIR})

set_source_files_properties(
${TP_DIR}
PROPERTIES
COMPILE_FLAGS
"-Wno-everything"
)
#add_definitions(-w)
# miniaudio dependencies
# windows: none
# mac: none
# linux: pthreads, libm, libdl
# bsd: pthreads, libm

if (UNIX AND NOT APPLE)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_library(LIB_M m)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_library(LIB_DL dl)
target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_DL})
endif ()
target_link_libraries(${TARGET_NAME} PRIVATE Threads::Threads ${LIB_M})
endif ()

# Get platform target
if (APPLE)
set(FosterTarget osx)
elseif (WIN32)
set(FosterTarget x64)
elseif (UNIX)
set(FosterTarget lib64)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(FosterTarget libarm64)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(FosterTarget libarm)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv6l")
set(FosterTarget libarm)
else()
set(FosterTarget lib64)
endif()
else()
message(FATAL_ERROR "Unknown Target!")
endif()
Expand All @@ -79,18 +82,17 @@ if (MSVC)

# Warnings as Errors Enabled
target_compile_options(${TARGET_NAME} PRIVATE /WX)

# ignore some particularly annoying warnings from our third party libraries:
# possible loss of data
add_definitions("/wd4244 /wd4267")
# truncation
add_definitions("/wd4305")
# signed/unsigned mismatch
add_definitions("/wd4018")
endif()

if(WIN32)
target_compile_definitions(${TARGET_NAME} PRIVATE _UNICODE UNICODE _CRT_SECURE_NO_WARNINGS)
target_compile_definitions(${TARGET_NAME} PRIVATE NOMINMAX)
endif ()

# tracks which libraries we need to link, depends on Options above
set(LIBS "")

# Tell SDL it's going to be a shared lib
set_property(TARGET ${FOSTER_SDL2_LIBS} PROPERTY POSITION_INDEPENDENT_CODE ON)

# Link SDL
target_link_libraries(${TARGET_NAME} PRIVATE ${LIBS})

0 comments on commit 72ff3f6

Please sign in to comment.