Skip to content

Commit

Permalink
Bumepd to macos 15 and fixed NativeLibraryLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrohanea committed Dec 24, 2024
1 parent e3fcdcf commit e520af1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/dotnet-maui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
dotnet-maui-build:
runs-on: macos-14
runs-on: macos-15

env:
USE_WHISPER_MAUI: "TRUE"
Expand Down Expand Up @@ -38,10 +38,10 @@ jobs:
run: dotnet restore ./Whisper.net.Maui.Tests.sln

- name: Build ios-simulator
run: dotnet build ./tests/Whisper.net.Maui.Tests/Whisper.net.Maui.Tests.csproj -c Debug -f net9.0-ios -r iossimulator-arm64 -p:EmbedAssembliesIntoAppBundle=true -p:RunAOTCompilation=false -p:CodesignKey="" -p:CodesignProvision=""
run: dotnet build ./tests/Whisper.net.Maui.Tests/Whisper.net.Maui.Tests.csproj -c Release -f net9.0-ios -r iossimulator-arm64 -p:EmbedAssembliesIntoAppBundle=true -p:RunAOTCompilation=false -p:CodesignKey="" -p:CodesignProvision=""

- name: Build android
run: dotnet build ./tests/Whisper.net.Maui.Tests/Whisper.net.Maui.Tests.csproj -c Debug -f net9.0-android -p:EmbedAssembliesIntoApk=true
run: dotnet build ./tests/Whisper.net.Maui.Tests/Whisper.net.Maui.Tests.csproj -c Release -f net9.0-android -p:EmbedAssembliesIntoApk=true

- name: Find built apps
run: |
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
./test-results/*
dotnet-maui-test-ios:
runs-on: macos-14
runs-on: macos-15
needs: dotnet-maui-build

env:
Expand Down Expand Up @@ -132,4 +132,10 @@ jobs:

- name: run ios tests
run: xharness apple test --app=./maui-build-artifacts/com.companyname.whisper.net.maui.tests.app --output-directory=./test-results/ios --target=ios-simulator-64


- name: Upload Maui iOS xharness test results
uses: actions/upload-artifact@v4
with:
name: xharness-ios-test-results
path: |
./test-results/*
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:

jobs:
dotnet-macos:
runs-on: macos-14
runs-on: macos-15

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos-coreml-native-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
retention-days: 7

arm-native-build:
runs-on: macos-14
runs-on: macos-15

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos-native-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
retention-days: 7

arm-native-build:
runs-on: macos-14
runs-on: macos-15

steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions Whisper.net/LibraryLoader/LibdlLibraryLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace Whisper.net.LibraryLoader;

internal class LibdlLibraryLoader : ILibraryLoader
{
[DllImport("libdl", ExactSpelling = true, CharSet = CharSet.Auto, EntryPoint = "dlopen")]
[DllImport("libdl", CharSet = CharSet.Auto, EntryPoint = "dlopen")]
public static extern IntPtr NativeOpenLibraryLibdl(string? filename, int flags);

[DllImport("libdl", ExactSpelling = true, CharSet = CharSet.Auto, EntryPoint = "dlerror")]
[DllImport("libdl", CharSet = CharSet.Auto, EntryPoint = "dlerror")]
public static extern IntPtr GetLoadError();

[DllImport("libdl", ExactSpelling = true, CharSet = CharSet.Auto, EntryPoint = "dlclose")]
[DllImport("libdl", CharSet = CharSet.Auto, EntryPoint = "dlclose")]
public static extern int NativeCloseLibraryLibdl(IntPtr handle);

public void CloseLibrary(IntPtr handle)
Expand Down
3 changes: 1 addition & 2 deletions Whisper.net/LibraryLoader/NativeLibraryLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,14 @@ private static bool IsRuntimeSupported(RuntimeLibrary runtime, string platform,
private static IEnumerable<(string RuntimePath, RuntimeLibrary RuntimeLibrary)> GetRuntimePaths(string architecture, string platform)
{
var assemblyLocation = typeof(NativeLibraryLoader).Assembly.Location;
var environmentAppStartLocation = Environment.GetCommandLineArgs()[0];
// NetFramework and Mono will crash if we try to get the directory of an empty string.
var assemblySearchPaths = new[]
{
GetSafeDirectoryName(RuntimeOptions.LibraryPath),
AppDomain.CurrentDomain.RelativeSearchPath,
AppDomain.CurrentDomain.BaseDirectory,
GetSafeDirectoryName(assemblyLocation),
GetSafeDirectoryName(environmentAppStartLocation),
GetSafeDirectoryName(Environment.GetCommandLineArgs().FirstOrDefault()),
}.Where(it => !string.IsNullOrEmpty(it)).Distinct();

foreach (var library in RuntimeOptions.RuntimeLibraryOrder)
Expand Down

0 comments on commit e520af1

Please sign in to comment.