Skip to content

Commit

Permalink
feat: add macos symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Dec 9, 2024
1 parent aee9c00 commit 9e1c68f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,13 @@ jobs:
-DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ \
-DBUILD_NODEJS_BINDING=ON
cmake --build build --preset 'NinjaMulti - Release' -j 16
cmake --build build --preset 'NinjaMulti - RelWithDebInfo' -j 16
- name: Install
shell: bash
if: always()
run: |
cmake --install build --prefix install
cmake --install build --prefix install --config RelWithDebInfo
cp -r docs install
cp README*.md install
Expand Down
8 changes: 8 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@
"configuration": "Release",
"jobs": 16
},
{
"name": "NinjaMulti - RelWithDebInfo",
"displayName": "Ninja MultiConfig RelWithDebInfo",
"description": "Ninja MultiConfig RelWithDebInfo",
"configurePreset": "NinjaMulti",
"configuration": "RelWithDebInfo",
"jobs": 16
},
{
"name": "NinjaMulti Win32 - Debug",
"displayName": "Ninja MultiConfig Win32 Debug",
Expand Down
3 changes: 3 additions & 0 deletions source/binding/NodeJS/scripts/pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ async function main() {
if (/MaaPiCli/.test(file)) {
continue
}
if (/dSYM/.test(file)) {
continue
}
await fs.copyFile(path.join(maaBinPath, file), path.join(sepPackPath, file))
}

Expand Down
82 changes: 49 additions & 33 deletions tools/fix_mac_rpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,61 @@ if ! [[ -e $install_dir/bin/libMaaFramework.dylib ]]; then
exit 1
fi

if ! otool -L $install_dir/bin/libMaaFramework.dylib | grep libc++ > /dev/null; then
echo "not linked to libc++, quit"
exit 0
fi
function fix_rpath() {
if ! otool -L $install_dir/bin/libMaaFramework.dylib | grep libc++ > /dev/null; then
echo "not linked to libc++, quit"
exit 0
fi

libcxx_path=`otool -L $install_dir/bin/libMaaFramework.dylib | grep libc++ | awk '{print $1}'`
libcxx_path=`otool -L $install_dir/bin/libMaaFramework.dylib | grep libc++ | awk '{print $1}'`

echo "libc++.1.dylib: $libcxx_path"
echo "libc++.1.dylib: $libcxx_path"

if [[ "$libcxx_path" == "@loader_path/libc++.1.dylib" ]]; then
echo "already linked to @loader_path/libc++, quit"
exit 0
fi
if [[ "$libcxx_path" == "@loader_path/libc++.1.dylib" ]]; then
echo "already linked to @loader_path/libc++, quit"
exit 0
fi

echo "change $libcxx_path to @loader_path/libc++.1.dylib"
echo "change $libcxx_path to @loader_path/libc++.1.dylib"

for lib in libc++ libc++abi libunwind; do
rm $install_dir/bin/$lib.1.dylib
rm $install_dir/bin/$lib.dylib
mv $install_dir/bin/$lib.1.0.dylib $install_dir/bin/$lib.1.dylib
for lib in libc++ libc++abi libunwind; do
rm $install_dir/bin/$lib.1.dylib
rm $install_dir/bin/$lib.dylib
mv $install_dir/bin/$lib.1.0.dylib $install_dir/bin/$lib.1.dylib

bin=$install_dir/bin/$lib.1.dylib
echo "processing $bin"
if otool -L $bin | grep @rpath/libc++.1 > /dev/null; then
install_name_tool -change @rpath/libc++.1.dylib @loader_path/libc++.1.dylib $bin
fi
if otool -L $bin | grep @rpath/libc++abi.1 > /dev/null; then
install_name_tool -change @rpath/libc++abi.1.dylib @loader_path/libc++abi.1.dylib $bin
fi
if otool -L $bin | grep @rpath/libunwind.1 > /dev/null; then
install_name_tool -change @rpath/libunwind.1.dylib @loader_path/libunwind.1.dylib $bin
fi
bin=$install_dir/bin/$lib.1.dylib
echo "processing $bin"
if otool -L $bin | grep @rpath/libc++.1 > /dev/null; then
install_name_tool -change @rpath/libc++.1.dylib @loader_path/libc++.1.dylib $bin
fi
if otool -L $bin | grep @rpath/libc++abi.1 > /dev/null; then
install_name_tool -change @rpath/libc++abi.1.dylib @loader_path/libc++abi.1.dylib $bin
fi
if otool -L $bin | grep @rpath/libunwind.1 > /dev/null; then
install_name_tool -change @rpath/libunwind.1.dylib @loader_path/libunwind.1.dylib $bin
fi

remove_and_sign_adhoc $bin
done

remove_and_sign_adhoc $bin
done
for bin in $install_dir/bin/*; do
if [[ -f $bin ]]; then
echo "processing $bin"
install_name_tool -change $libcxx_path "@loader_path/libc++.1.dylib" $bin

for bin in $install_dir/bin/*; do
echo "processing $bin"
install_name_tool -change $libcxx_path "@loader_path/libc++.1.dylib" $bin
remove_and_sign_adhoc $bin
fi
done
}

function collect_symbols() {
for lib in $install_dir/bin/*; do
if [[ -f $lib ]] && basename $lib | grep -i maa > /dev/null; then
echo "collect debug symbols of $lib"
dsymutil $lib
fi
done
}

remove_and_sign_adhoc $bin
done
fix_rpath
collect_symbols

0 comments on commit 9e1c68f

Please sign in to comment.