Skip to content

Commit

Permalink
Fix macOS icu dylib loading problems when MacPorts is not installed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonsil authored Nov 25, 2024
1 parent 830cca4 commit 03846fc
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 5 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/package-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,36 @@ 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' }}
# LIB_DEPENDENCIES are of the form "<ICU lib short name> <dependency as ICU lib short name>"
# For example, libicuuc (shortened to "uc") depends on libicudata (shortened to "data")
# Dependencies can be seen by running "dyld_info -dependents /path/to/something.dylib"
run: |
ICU_VERSION=74
LIB_DEPENDENCIES="
i18n data
i18n uc
io data
io i18n
io uc
uc data
"
LIB_DEPENDENCIES=$(echo "$LIB_DEPENDENCIES" | sed '/^$/d')
while IFS= read -r line; do
set -- $line
sudo install_name_tool -change "/opt/local/lib/libicu$2.$ICU_VERSION.dylib" "@loader_path/libicu$2.$ICU_VERSION.dylib" "/opt/local/lib/libicu$1.$ICU_VERSION.dylib"
done <<< "$LIB_DEPENDENCIES"
- name: Checkout git repo
uses: actions/checkout@v4
Expand Down
28 changes: 27 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,36 @@ 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' }}
# LIB_DEPENDENCIES are of the form "<ICU lib short name> <dependency as ICU lib short name>"
# For example, libicuuc (shortened to "uc") depends on libicudata (shortened to "data")
# Dependencies can be seen by running "dyld_info -dependents /path/to/something.dylib"
run: |
ICU_VERSION=74
LIB_DEPENDENCIES="
i18n data
i18n uc
io data
io i18n
io uc
uc data
"
LIB_DEPENDENCIES=$(echo "$LIB_DEPENDENCIES" | sed '/^$/d')
while IFS= read -r line; do
set -- $line
sudo install_name_tool -change "/opt/local/lib/libicu$2.$ICU_VERSION.dylib" "@loader_path/libicu$2.$ICU_VERSION.dylib" "/opt/local/lib/libicu$1.$ICU_VERSION.dylib"
done <<< "$LIB_DEPENDENCIES"
- name: Checkout git repo
uses: actions/checkout@v4
Expand Down
29 changes: 28 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,36 @@ 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' }}
# LIB_DEPENDENCIES are of the form "<ICU lib short name> <dependency as ICU lib short name>"
# For example, libicuuc (shortened to "uc") depends on libicudata (shortened to "data")
# Dependencies can be seen by running "dyld_info -dependents /path/to/something.dylib"
run: |
ICU_VERSION=74
LIB_DEPENDENCIES="
i18n data
i18n uc
io data
io i18n
io uc
uc data
"
LIB_DEPENDENCIES=$(echo "$LIB_DEPENDENCIES" | sed '/^$/d')
while IFS= read -r line; do
set -- $line
sudo install_name_tool -change "/opt/local/lib/libicu$2.$ICU_VERSION.dylib" "@loader_path/libicu$2.$ICU_VERSION.dylib" "/opt/local/lib/libicu$1.$ICU_VERSION.dylib"
done <<< "$LIB_DEPENDENCIES"
- name: Check out Git repository
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions c-sharp/ParanextDataProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="icu.net" Version="2.10.0" />
<PackageReference Include="icu.net" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.1" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
Expand Down Expand Up @@ -60,7 +60,7 @@
by default.
-->
<ItemGroup>
<Content Include="/opt/local/lib/libicu*.??.dylib" Condition="$([MSBuild]::IsOsPlatform('macOS'))">
<Content Include="/opt/local/lib/libicu*.??.dylib" Exclude="/opt/local/lib/libicutest*.dylib;/opt/local/lib/libicutu*.dylib" Condition="$([MSBuild]::IsOsPlatform('macOS'))">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions c-sharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 03846fc

Please sign in to comment.