From a1e7fd899fafe326b4713e1fa7d47680950af9cf Mon Sep 17 00:00:00 2001 From: Matt Lyons Date: Sat, 23 Nov 2024 08:45:42 -0600 Subject: [PATCH] Fix macOS icu dylib loading problems when MacPorts is not installed --- .github/workflows/package-main.yml | 14 +++++++++++++- .github/workflows/publish.yml | 14 +++++++++++++- .github/workflows/test.yml | 15 ++++++++++++++- c-sharp/ParanextDataProvider.csproj | 2 +- c-sharp/Program.cs | 8 ++++++++ 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/.github/workflows/package-main.yml b/.github/workflows/package-main.yml index bb107f069e..94867a0c17 100644 --- a/.github/workflows/package-main.yml +++ b/.github/workflows/package-main.yml @@ -27,10 +27,22 @@ jobs: if: ${{ matrix.os == 'macos-latest' }} uses: melusina-org/setup-macports@v1 + - name: Install loader tools on macOS + if: ${{ matrix.os == 'macos-latest' }} + run: | + sudo port -v install ld64 + - name: Install icu4c on macOS if: ${{ matrix.os == 'macos-latest' }} run: | - sudo port -v install icu + sudo port -v install icu @74.2_0 +universal + + - name: Fixup loader paths for icu4c + if: ${{ matrix.os == 'macos-latest' }} + run: | + sudo install_name_tool -change /opt/local/lib/libicudata.74.dylib @loader_path/libicudata.74.dylib /opt/local/lib/libicuuc.74.dylib + sudo install_name_tool -change /opt/local/lib/libicudata.74.dylib @loader_path/libicudata.74.dylib /opt/local/lib/libicui18n.74.dylib + sudo install_name_tool -change /opt/local/lib/libicuuc.74.dylib @loader_path/libicuuc.74.dylib /opt/local/lib/libicui18n.74.dylib - name: Checkout git repo uses: actions/checkout@v4 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae29240a3f..cb46756af0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,10 +27,22 @@ jobs: if: ${{ matrix.os == 'macos-latest' }} uses: melusina-org/setup-macports@v1 + - name: Install loader tools on macOS + if: ${{ matrix.os == 'macos-latest' }} + run: | + sudo port -v install ld64 + - name: Install icu4c on macOS if: ${{ matrix.os == 'macos-latest' }} run: | - sudo port -v install icu + sudo port -v install icu @74.2_0 +universal + + - name: Fixup loader paths for icu4c + if: ${{ matrix.os == 'macos-latest' }} + run: | + sudo install_name_tool -change /opt/local/lib/libicudata.74.dylib @loader_path/libicudata.74.dylib /opt/local/lib/libicuuc.74.dylib + sudo install_name_tool -change /opt/local/lib/libicudata.74.dylib @loader_path/libicudata.74.dylib /opt/local/lib/libicui18n.74.dylib + sudo install_name_tool -change /opt/local/lib/libicuuc.74.dylib @loader_path/libicuuc.74.dylib /opt/local/lib/libicui18n.74.dylib - name: Checkout git repo uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f5b8558ba..2cdb086b7e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,9 +30,22 @@ jobs: if: ${{ matrix.os == 'macos-latest' }} uses: melusina-org/setup-macports@v1 + - name: Install loader tools on macOS + if: ${{ matrix.os == 'macos-latest' }} + run: | + sudo port -v install ld64 + - name: Install icu4c on macOS if: ${{ matrix.os == 'macos-latest' }} - run: sudo port -v install icu + run: | + sudo port -v install icu @74.2_0 +universal + + - name: Fixup loader paths for icu4c + if: ${{ matrix.os == 'macos-latest' }} + run: | + sudo install_name_tool -change /opt/local/lib/libicudata.74.dylib @loader_path/libicudata.74.dylib /opt/local/lib/libicuuc.74.dylib + sudo install_name_tool -change /opt/local/lib/libicudata.74.dylib @loader_path/libicudata.74.dylib /opt/local/lib/libicui18n.74.dylib + sudo install_name_tool -change /opt/local/lib/libicuuc.74.dylib @loader_path/libicuuc.74.dylib /opt/local/lib/libicui18n.74.dylib - name: Check out Git repository uses: actions/checkout@v4 diff --git a/c-sharp/ParanextDataProvider.csproj b/c-sharp/ParanextDataProvider.csproj index 222e08e9a6..ecd2bff7fe 100644 --- a/c-sharp/ParanextDataProvider.csproj +++ b/c-sharp/ParanextDataProvider.csproj @@ -28,7 +28,7 @@ - + diff --git a/c-sharp/Program.cs b/c-sharp/Program.cs index 7e4cfce959..76e77fb14b 100644 --- a/c-sharp/Program.cs +++ b/c-sharp/Program.cs @@ -16,6 +16,14 @@ public static async Task Main() Console.WriteLine("Paranext data provider starting up"); Thread.CurrentThread.Name = "Main"; + // Turn on additional logging to help diagnose failures on macOS + if (OperatingSystem.IsMacOS()) + { + System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.ConsoleTraceListener()); + System.Diagnostics.Trace.AutoFlush = true; + System.Diagnostics.Trace.WriteLine("Trace logging enabled"); + } + using PapiClient papi = new(); try {