Skip to content

Commit 788061f

Browse files
committed
[ fix ] Make the DLL linking idempotent
1 parent 3431ba2 commit 788061f

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

.github/workflows/test-mac.yaml

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -68,46 +68,53 @@ jobs:
6868
stack test
6969
7070
- name: 🔗 Bundle ICU4C DLLs
71-
run: |
71+
run: | # Bundle ICU4C DLLs
7272
# Bundle ICU4C DLLs
73-
74-
# locate the executable
7573
executable=$(find $(stack path --local-install-root)/bin -name "als")
74+
# executable=als
7675
77-
# locate "libicuuc", the ID should also be its absolute path
76+
# get libicuuc's ID
7877
icuuc_id=$(otool -L $executable | grep icuuc | awk '{print $1}')
79-
icuuc_path=$icuuc_id
80-
81-
# locate "libicui18n", the ID should also be its absolute path
82-
icui18n_id=$(otool -L $executable | grep icui18n | awk '{print $1}')
83-
icui18n_path=$icui18n_id
84-
85-
# locate the directory of ICU4C DLLs
86-
libdir=$(dirname $icui18n_id)
87-
88-
# locate "libicudata"
89-
icudata_id=$(otool -L $icui18n_id | grep icudata | awk '{print $1}')
90-
icudata_path=$libdir/$(basename $icudata_id)
91-
92-
# copy DDLs into "lib/"
93-
mkdir lib/
94-
cp $icuuc_path lib/
95-
cp $icui18n_path lib/
96-
cp $icudata_path lib/
97-
98-
# use "install_name_tool" to update ALS to search for DDLs in "lib/" instead
99-
echo "[linker] before changing LC_LOAD_DYLIB of icuuc in ALS:"
100-
otool -l $executable | grep icuuc -B2
101-
echo "[linker] after changing LC_LOAD_DYLIB of icuuc in ALS:"
102-
install_name_tool -change $icuuc_id @loader_path/lib/$(basename $icuuc_id) $executable
103-
otool -l $executable | grep icuuc -B2
104-
105-
echo "[linker] before changing LC_LOAD_DYLIB of icui18n in ALS:"
106-
otool -l $executable | grep icui18n -B2
107-
echo "[linker] after changing LC_LOAD_DYLIB of icui18n in ALS:"
108-
install_name_tool -change $icui18n_id @loader_path/lib/$(basename $icui18n_id) $executable
109-
otool -l $executable | grep icui18n -B2
110-
78+
79+
if [ $(dirname $icuuc_id) = "@loader_path/lib" ]
80+
then
81+
echo "DDLs has already been prepared"
82+
ls lib
83+
else
84+
# if $icuuc_id does not begins with "@loader_path/lib"
85+
# then it should be an absolute path to the DLL
86+
icuuc_path=$icuuc_id
87+
88+
# path of dir of text-icu DLLs
89+
libdir=$(dirname $icuuc_path)
90+
91+
# get libicui18n's ID and path
92+
icui18n_id=$(otool -L $executable | grep icui18n | awk '{print $1}')
93+
icui18n_path=$icui18n_id
94+
95+
# get icudata's ID and path
96+
icudata_id=$(otool -L $icui18n_id | grep icudata | awk '{print $1}')
97+
icudata_path=$libdir/$(basename $icudata_id)
98+
99+
# copy DDLs into "lib/"
100+
mkdir lib/
101+
cp $icuuc_path lib/
102+
cp $icui18n_path lib/
103+
cp $icudata_path lib/
104+
105+
# use "install_name_tool" to update ALS to search for DDLs in "lib/" instead
106+
echo "[linker] before changing LC_LOAD_DYLIB of icuuc in ALS:"
107+
otool -l $executable | grep icuuc -B2
108+
echo "[linker] after changing LC_LOAD_DYLIB of icuuc in ALS:"
109+
install_name_tool -change $icuuc_id @loader_path/lib/$(basename $icuuc_id) $executable
110+
otool -l $executable | grep icuuc -B2
111+
112+
echo "[linker] before changing LC_LOAD_DYLIB of icui18n in ALS:"
113+
otool -l $executable | grep icui18n -B2
114+
echo "[linker] after changing LC_LOAD_DYLIB of icui18n in ALS:"
115+
install_name_tool -change $icui18n_id @loader_path/lib/$(basename $icui18n_id) $executable
116+
otool -l $executable | grep icui18n -B2
117+
fi
111118
112119
- name: 📦 Compress files
113120
id: zip

0 commit comments

Comments
 (0)