diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe6fdfe..cb3a4d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -106,6 +106,7 @@ jobs: run: > dotnet test LibLouis.NET.Test/LibLouis.NET.Test.csproj --configuration Release + -warnaserror -p:RestoreAdditionalProjectSources=${{ github.workspace }}/local-feed # Managed packages. Split from native-linux because building LibLouis.NET resolves diff --git a/LibLouis.NET.Test/LiblouisHeapTests.cs b/LibLouis.NET.Test/LiblouisHeapTests.cs index aaa7509..c32270a 100644 --- a/LibLouis.NET.Test/LiblouisHeapTests.cs +++ b/LibLouis.NET.Test/LiblouisHeapTests.cs @@ -17,6 +17,10 @@ public unsafe class LiblouisHeapTests { private static readonly string[] Tables = ["da-dk-g26.ctb", "da-dk-g16-markers.ctb"]; + // The C runtimes a mingw-built liblouis.dll can import free() from: msvcrt.dll for the gcc + // builds, ucrtbase.dll for llvm-mingw. + private static readonly string[] WindowsRuntimes = ["msvcrt.dll", "ucrtbase.dll"]; + private static string[] TablePaths() => [.. Tables.Select(t => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tables", t))]; @@ -123,7 +127,7 @@ public void FindImport_FindsFreeInTheLiblouisWeShip() nint module = NativeLibrary.Load("liblouis", typeof(LibLouis).Assembly, DllImportSearchPath.SafeDirectories); nint free = LiblouisHeap.FindImport((byte*)module, "free"u8); - nint[] runtimeFrees = [.. new[] { "msvcrt.dll", "ucrtbase.dll" } + nint[] runtimeFrees = [.. WindowsRuntimes .Select(name => NativeLibrary.TryLoad(name, out nint runtime) ? NativeLibrary.GetExport(runtime, "free") : 0)]; Assert.NotEqual(0, free); diff --git a/build/build_managed_packages.sh b/build/build_managed_packages.sh index 08c3ca8..c141b16 100755 --- a/build/build_managed_packages.sh +++ b/build/build_managed_packages.sh @@ -21,7 +21,8 @@ if [ -n "${NUGET_LOCAL_FEED:-}" ]; then restore_args="-p:RestoreAdditionalProjectSources=$NUGET_LOCAL_FEED" fi -dotnet build --configuration Release $restore_args "$REPO_ROOT/LibLouis.NET.slnx" +# -warnaserror keeps the build warning free: a warning fails the packages rather than shipping. +dotnet build --configuration Release -warnaserror $restore_args "$REPO_ROOT/LibLouis.NET.slnx" if [ -z "${SKIP_TESTS:-}" ]; then dotnet test --configuration Release --no-build "$REPO_ROOT/LibLouis.NET.slnx"