diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5433f91..ca424341 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: echo "FlecsVersionSuffix=build.$(git rev-list --count HEAD)" >> $GITHUB_ENV fi - - name: Setup Osx Environment + - name: Setup IOS SDK if: matrix.os == 'macos-13' shell: bash run: | @@ -66,6 +66,12 @@ jobs: echo "IOS_SDK=$IOS_SDK" >> $GITHUB_ENV echo "IOS_SIMULATOR_SDK=$IOS_SIMULATOR_SDK" >> $GITHUB_ENV + - name: Setup Emscripten SDK + if: matrix.os == 'macos-13' + uses: mymindstorm/setup-emsdk@v14 + with: + actions-cache-folder: 'emsdk-cache' + - name: Restore Dependencies shell: bash run: dotnet restore @@ -77,27 +83,52 @@ jobs: - name: Build Projects shell: bash run: | - if [ '${{ matrix.os }}' == 'macos-13' ]; then - dotnet build -c Debug --property:IosSdkPath=$IOS_SDK --property:IosSimulatorSdkPath=$IOS_SIMULATOR_SDK - dotnet build -c Release --property:IosSdkPath=$IOS_SDK --property:IosSimulatorSdkPath=$IOS_SIMULATOR_SDK - else - dotnet build -c Debug - dotnet build -c Release - fi + dotnet build -c Debug + dotnet build -c Release + + - name: Build Natives + shell: bash + if: matrix.os == 'macos-13' + working-directory: src/Flecs.NET.Native + run: | + dotnet build -c Debug -r linux-x64 + dotnet build -c Release -r linux-x64 + dotnet build -c Debug -r linux-arm64 + dotnet build -c Release -r linux-arm64 + + dotnet build -c Debug -r osx-x64 + dotnet build -c Release -r osx-x64 + dotnet build -c Debug -r osx-arm64 + dotnet build -c Release -r osx-arm64 + + dotnet build -c Debug -r win-x64 + dotnet build -c Release -r win-x64 + dotnet build -c Debug -r win-arm64 + dotnet build -c Release -r win-arm64 + + dotnet build -c Debug -r browser-wasm + dotnet build -c Release -r browser-wasm + + dotnet build -c Debug -r iossimulator-x64 + dotnet build -c Release -r iossimulator-x64 + dotnet build -c Debug -r iossimulator-arm64 + dotnet build -c Release -r iossimulator-arm64 + dotnet build -c Debug -r ios-arm64 + dotnet build -c Release -r ios-arm64 - name: Run Tests shell: bash - run: dotnet test --no-build + run: dotnet test -p:SkipNatives=true - name: Pack Nuget Packages shell: bash run: | if [ '${{ github.event.inputs.nuget-registry }}' == 'NuGet' ]; then - dotnet pack --property:VersionSuffix=$FlecsVersionSuffix -c Debug - dotnet pack --property:VersionSuffix=$FlecsVersionSuffix -c Release + dotnet pack --property:VersionSuffix=$FlecsVersionSuffix -p:SkipNatives=true -c Debug + dotnet pack --property:VersionSuffix=$FlecsVersionSuffix -p:SkipNatives=true -c Release else - dotnet pack --property:VersionSuffix=$FlecsVersionSuffix --property:FlecsPackPdb=true -c Debug - dotnet pack --property:VersionSuffix=$FlecsVersionSuffix --property:FlecsPackPdb=true -c Release + dotnet pack --property:VersionSuffix=$FlecsVersionSuffix --property:FlecsPackPdb=true -p:SkipNatives=true -c Debug + dotnet pack --property:VersionSuffix=$FlecsVersionSuffix --property:FlecsPackPdb=true -p:SkipNatives=true -c Release fi - name: Upload Artifacts diff --git a/README.md b/README.md index 63e349f5..df467738 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,8 @@ public record struct Velocity(float X, float Y); - Fully blittable interface with no runtime marshalling **Flecs.NET.Native - Precompiled native libraries** -- Provides both shared and static libraries for Windows, MacOS, and Linux +- Provides both shared and static libraries for Windows, MacOS, Linux, iOS, and WASM +- Static libraries are automatically linked for NativeAOT builds (`$(FlecsStaticPath)` available for manual linking for other targets) - Packaged with Zig for dependency free cross-compilation everywhere ## NuGet @@ -172,8 +173,6 @@ Reference the project and import the native libraries. You should now be able to net8.0 - - diff --git a/src/Flecs.NET.Benchmarks/Flecs.NET.Benchmarks.csproj b/src/Flecs.NET.Benchmarks/Flecs.NET.Benchmarks.csproj index c918b7e9..4cff973f 100644 --- a/src/Flecs.NET.Benchmarks/Flecs.NET.Benchmarks.csproj +++ b/src/Flecs.NET.Benchmarks/Flecs.NET.Benchmarks.csproj @@ -8,8 +8,6 @@ $(NoWarn);CS8618 - - diff --git a/src/Flecs.NET.Examples/Flecs.NET.Examples.csproj b/src/Flecs.NET.Examples/Flecs.NET.Examples.csproj index 293dbd96..c3bbae69 100644 --- a/src/Flecs.NET.Examples/Flecs.NET.Examples.csproj +++ b/src/Flecs.NET.Examples/Flecs.NET.Examples.csproj @@ -14,8 +14,6 @@ $(DefineConstants);$(Example) - - diff --git a/src/Flecs.NET.Native/Flecs.NET.Native.csproj b/src/Flecs.NET.Native/Flecs.NET.Native.csproj index d1583730..5b832366 100644 --- a/src/Flecs.NET.Native/Flecs.NET.Native.csproj +++ b/src/Flecs.NET.Native/Flecs.NET.Native.csproj @@ -1,25 +1,28 @@ - + Library netstandard2.1 - $(NoWarn);NU5128 + + + false + false + false + false + false + false + false + $(NoWarn);CS2008 true - true - false 4.0.2 - Flecs.NET.Native.Debug - Flecs.NET.Native.Release BeanCheeseBurrito BeanCheeseBurrito Native libraries for flecs - $(Title) https://github.com/BeanCheeseBurrito/Flecs.NET https://raw.githubusercontent.com/SanderMertens/flecs/master/docs/img/logo_small.png - icon.png MIT https://github.com/BeanCheeseBurrito/Flecs.NET Github @@ -27,132 +30,167 @@ - true - true - true - - $([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture) + $([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture) + - $(FlecsCompileOptions)-Dsoft-assert=true + + + + + Flecs.NET.Native.Debug + $(PackageId) + Debug + + + + + Flecs.NET.Native.Release + $(PackageId) + ReleaseFast + + + + + + + + + win-x64 + win-arm64 + + + + + linux-x64 + linux-arm64 + + + + + osx-x64 + osx-arm64 + + + + + + + $(HostRuntime) + - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + + + + + PreserveNewest + runtimes/ + + - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + + + + x86_64-windows-gnu + + + + + x86-windows-gnu + + + + + arm-windows-gnu + + + + + aarch64-windows-gnu + + + + + x86_64-linux-gnu + + + + + x86-linux-gnu + + + + + arm-linux-gnueabihf + + + + + aarch64-linux-gnu + + + + + x86_64-macos + + + + + aarch64-macos + + + + + x86_64-ios-simulator + --sysroot $(IOS_SIMULATOR_SDK) + + + + + aarch64-ios-simulator + --sysroot $(IOS_SIMULATOR_SDK) + + + + + aarch64-ios + --sysroot $(IOS_SDK) + + + + + wasm32-emscripten + --sysroot "$(EMSDK)/upstream/emscripten" + + + + + $(RuntimeIdentifier) + + + + + + + $(ZigArgs)-Dsoft-assert=true + - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - diff --git a/src/Flecs.NET.Native/Flecs.NET.Native.props b/src/Flecs.NET.Native/Flecs.NET.Native.props deleted file mode 100644 index 155863c2..00000000 --- a/src/Flecs.NET.Native/Flecs.NET.Native.props +++ /dev/null @@ -1,28 +0,0 @@ - - - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)debug')) - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)release')) - - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)linux-x64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)osx-x64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)win-x64/flecs.lib')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)iossimulator-x64/libflecs.a')) - - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)linux-arm64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)osx-arm64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)win-arm64/flecs.lib')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)ios-arm64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)iossimulator-arm64/libflecs.a')) - - $(FlecsStaticLibrary_linux-x64) - $(FlecsStaticLibrary_osx-x64) - $(FlecsStaticLibrary_win-x64) - $(FlecsStaticLibrary_iossimulator-x64) - - $(FlecsStaticLibrary_linux-arm64) - $(FlecsStaticLibrary_osx-arm64) - $(FlecsStaticLibrary_win-arm64) - $(FlecsStaticLibrary_ios-arm64 - $(FlecsStaticLibrary_iossimulator-arm64) - - diff --git a/src/Flecs.NET.Native/Flecs.NET.Native.targets b/src/Flecs.NET.Native/Flecs.NET.Native.targets deleted file mode 100644 index 61098b32..00000000 --- a/src/Flecs.NET.Native/Flecs.NET.Native.targets +++ /dev/null @@ -1,31 +0,0 @@ - - - - %(Filename)%(Extension) - Always - false - - - - %(Filename)%(Extension) - Always - false - - - - %(Filename)%(Extension) - Always - false - - - - %(Filename)%(Extension) - Always - false - - - diff --git a/src/Flecs.NET.Native/build.zig b/src/Flecs.NET.Native/build.zig index 154c5002..8880ffdf 100644 --- a/src/Flecs.NET.Native/build.zig +++ b/src/Flecs.NET.Native/build.zig @@ -40,6 +40,16 @@ pub fn compileFlecs(options: anytype, b: *Build, lib_type: LibType) void { lib.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ b.sysroot.?, "/usr/include" }) }); lib.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ b.sysroot.?, "/usr/lib" }) }); }, + .emscripten => { + if (b.sysroot == null) { + @panic("Pass '--sysroot \"$EMSDK/upstream/emscripten\"'"); + } + + const cache_include = b.pathJoin(&.{ b.sysroot.?, "cache", "sysroot", "include" }); + var dir = std.fs.openDirAbsolute(cache_include, std.fs.Dir.OpenDirOptions{ .access_sub_paths = true, .no_follow = true }) catch @panic("No emscripten cache. Generate it!"); + dir.close(); + lib.addIncludePath(.{ .cwd_relative = cache_include }); + }, else => {}, } @@ -53,6 +63,9 @@ pub fn build(b: *Build) void { .soft_assert = b.option(bool, "soft-assert", "Compile with the FLECS_SOFT_ASSERT define.") orelse false, }; - compileFlecs(options, b, LibType.Shared); + if (options.target.result.os.tag != .emscripten) { + compileFlecs(options, b, LibType.Shared); + } + compileFlecs(options, b, LibType.Static); } diff --git a/src/Flecs.NET.Native/buildTransitive/Flecs.NET.Native.props b/src/Flecs.NET.Native/buildTransitive/Flecs.NET.Native.props index 0c1a168e..9d48ea53 100644 --- a/src/Flecs.NET.Native/buildTransitive/Flecs.NET.Native.props +++ b/src/Flecs.NET.Native/buildTransitive/Flecs.NET.Native.props @@ -1,27 +1,6 @@ - - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)../static_libraries')) - - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)linux-x64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)win-x64/flecs.lib')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)osx-x64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)iossimulator-x64/libflecs.a')) - - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)linux-arm64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)osx-arm64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)win-arm64/flecs.lib')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)ios-arm64/libflecs.a')) - $([MSBuild]::NormalizePath('$(FlecsStaticLibraryFolder)iossimulator-arm64/libflecs.a')) - - $(FlecsStaticLibrary_linux-x64) - $(FlecsStaticLibrary_osx-x64) - $(FlecsStaticLibrary_win-x64) - $(FlecsStaticLibrary_iossimulator-x64) - - $(FlecsStaticLibrary_linux-arm64) - $(FlecsStaticLibrary_osx-arm64) - $(FlecsStaticLibrary_win-arm64) - $(FlecsStaticLibrary_ios-arm64 - $(FlecsStaticLibrary_iossimulator-arm64) - + + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)../static/$(RuntimeIdentifier)/native/')) + true + diff --git a/src/Flecs.NET.Native/buildTransitive/Flecs.NET.Native.targets b/src/Flecs.NET.Native/buildTransitive/Flecs.NET.Native.targets index d83c1cdf..12871f55 100644 --- a/src/Flecs.NET.Native/buildTransitive/Flecs.NET.Native.targets +++ b/src/Flecs.NET.Native/buildTransitive/Flecs.NET.Native.targets @@ -1,14 +1,7 @@ - - $(FlecsStaticLibrary_linux-x64) - $(FlecsStaticLibrary_osx-x64) - $(FlecsStaticLibrary_win-x64) - $(FlecsStaticLibrary_iossimulator-x64) - - $(FlecsStaticLibrary_linux-arm64) - $(FlecsStaticLibrary_osx-arm64) - $(FlecsStaticLibrary_win-arm64) - $(FlecsStaticLibrary_ios-arm64 - $(FlecsStaticLibrary_iossimulator-arm64) - + + + + + diff --git a/src/Flecs.NET.Tests/Flecs.NET.Tests.csproj b/src/Flecs.NET.Tests/Flecs.NET.Tests.csproj index e6e6bc63..72084c5e 100644 --- a/src/Flecs.NET.Tests/Flecs.NET.Tests.csproj +++ b/src/Flecs.NET.Tests/Flecs.NET.Tests.csproj @@ -8,8 +8,6 @@ $(NoWarn);xUnit2013;CS8500 - -