Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/build-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
arch: x64
target: win-x64
ext: .dll
- os: windows-latest
arch: wasm
target: browser-wasm
ext: .a
- os: macos-latest
arch: x64-arm64
target: osx
Expand All @@ -35,6 +39,12 @@ jobs:
uses: actions/checkout@v4
- name: Get CMake
uses: lukka/[email protected]
- name: Setup emscripten
uses: mymindstorm/setup-emsdk@v14
if: ${{ matrix.target == 'browser-wasm' }}
- name: Get latest ninja
uses: urkle/action-get-ninja@v1
if: ${{ matrix.target == 'browser-wasm' }}
- name: Setup Linux dependencies
if: ${{ runner.os == 'Linux' }}
run: |
Expand All @@ -46,7 +56,11 @@ jobs:
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
- name: CMake Configure
if: ${{ matrix.target != 'browser-wasm' }}
run: cmake -B build -S Platform -DFOSTER_OVERRIDE_TARGET=${{matrix.target}} -D CMAKE_SYSTEM_VERSION=10.0.26100.0
- name: CMake Configure
if: ${{ matrix.target == 'browser-wasm' }}
run: emcmake cmake -B build -S Platform -DFOSTER_OVERRIDE_TARGET=${{matrix.target}} -D CMAKE_SYSTEM_VERSION=10.0.26100.0
- name: CMake Build
run: cmake --build build --config Release
- name: Publish Artifact
Expand Down Expand Up @@ -76,6 +90,11 @@ jobs:
with:
name: ubuntu-latest-x64-build
path: Platform/libs/linux-x64
- name: Download browser-wasm libs
uses: actions/download-artifact@v4
with:
name: windows-latest-wasm-build
path: Platform/libs/browser-wasm
- name: Display structure of libs
run: ls -R
working-directory: Platform/libs
Expand Down
14 changes: 12 additions & 2 deletions Framework/Foster.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64;browser-wasm</RuntimeIdentifiers>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down Expand Up @@ -40,6 +40,10 @@
<IsMacOS>true</IsMacOS>
</PropertyGroup>

<PropertyGroup Condition="($(RuntimeIdentifier) == '' and $([MSBuild]::IsOSPlatform('Browser'))) or $(RuntimeIdentifier) == 'browser-wasm'">
<IsBrowser>true</IsBrowser>
</PropertyGroup>

<ItemGroup>
<Content Include="$(NativeLibsDir)win-x64\**" Visible="false">
<CopyToOutputDirectory Condition="'$(IsWindows)' == 'true'">PreserveNewest</CopyToOutputDirectory>
Expand All @@ -59,8 +63,14 @@
<Pack>True</Pack>
<Link>%(Filename)%(Extension)</Link>
</Content>
<Content Include="$(NativeLibsDir)browser-wasm\**" Visible="false">
<CopyToOutputDirectory Condition="'$(IsBrowser)' == 'true'">PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes\browser-wasm\native</PackagePath>
<Pack>True</Pack>
<Link>%(Filename)%(Extension)</Link>
</Content>
</ItemGroup>

<ItemGroup>
<None Include="$(ProjectDir)..\LICENSE" Pack="true" PackagePath="/" />
<None Include="$(ProjectDir)..\README.md" Pack="true" PackagePath="/" />
Expand Down
17 changes: 13 additions & 4 deletions Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)
project(FosterPlatform C)

# Set flag for building a universal binary on macOS
# Set flag for building a universal binary on macOS
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
endif()
Expand Down Expand Up @@ -58,8 +58,13 @@ if (NOT DEFINED FOSTER_SDL3_LIBS)
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
set(SDL_TEST_LIBRARY OFF)
set(SDL_SHARED ON)
set(SDL_STATIC OFF)
if (FOSTER_TARGET STREQUAL "browser-wasm")
set(SDL_SHARED OFF)
set(SDL_STATIC ON)
else()
set(SDL_SHARED ON)
set(SDL_STATIC OFF)
endif()

FetchContent_Declare(
SDL3
Expand All @@ -68,7 +73,11 @@ if (NOT DEFINED FOSTER_SDL3_LIBS)
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(SDL3)
set(FOSTER_SDL3_LIBS SDL3-shared)
if (FOSTER_TARGET STREQUAL "browser-wasm")
set(FOSTER_SDL3_LIBS SDL3-static)
else()
set(FOSTER_SDL3_LIBS SDL3-shared)
endif()
set(FOSTER_SDL3_INCLUDE ${SDL3_SOURCE_DIRS}/include)
endif()

Expand Down