From 9e1c68ff6f21f85974d3fc4c93215a712ade000a Mon Sep 17 00:00:00 2001 From: nekosu Date: Mon, 9 Dec 2024 15:18:30 +0800 Subject: [PATCH] feat: add macos symbols --- .github/workflows/build.yml | 4 +- CMakePresets.json | 8 +++ source/binding/NodeJS/scripts/pack.ts | 3 + tools/fix_mac_rpath.sh | 82 ++++++++++++++++----------- 4 files changed, 62 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b2391adcf..6d76846a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/CMakePresets.json b/CMakePresets.json index e10d3549a..33439caa9 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -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", diff --git a/source/binding/NodeJS/scripts/pack.ts b/source/binding/NodeJS/scripts/pack.ts index 34ce817cd..80288b060 100644 --- a/source/binding/NodeJS/scripts/pack.ts +++ b/source/binding/NodeJS/scripts/pack.ts @@ -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)) } diff --git a/tools/fix_mac_rpath.sh b/tools/fix_mac_rpath.sh index 580591011..9258f3e4d 100755 --- a/tools/fix_mac_rpath.sh +++ b/tools/fix_mac_rpath.sh @@ -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