Skip to content

Commit

Permalink
feat: move symbols position
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Dec 9, 2024
1 parent 9e1c68f commit d1b3151
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
15 changes: 12 additions & 3 deletions cmake/post_install/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
if(APPLE)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
install(
CODE "
execute_process(
COMMAND \${CMAKE_SOURCE_DIR}/tools/mac_post_install.sh \${CMAKE_INSTALL_PREFIX} -r
)
")
endif()

install(
CODE "
execute_process(
COMMAND \${CMAKE_SOURCE_DIR}/tools/fix_mac_rpath.sh \${CMAKE_INSTALL_PREFIX}
COMMAND \${CMAKE_SOURCE_DIR}/tools/mac_post_install.sh \${CMAKE_INSTALL_PREFIX} -d
)
")
" CONFIGURATIONS RelWithDebInfo)
endif()
3 changes: 0 additions & 3 deletions source/binding/NodeJS/scripts/pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ 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
38 changes: 29 additions & 9 deletions tools/fix_mac_rpath.sh → tools/mac_post_install.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/bash

function remove_and_sign_adhoc {
if codesign -dv $1 2>&1 | grep "CodeDirectory" > /dev/null; then
codesign --remove-signature $1
fi
codesign -s - $1
}

install_dir=$1
shift

if ! [[ -d "$install_dir" ]]; then
echo "usage: $0 [maa framework install directory]"
Expand All @@ -19,6 +13,13 @@ if ! [[ -e $install_dir/bin/libMaaFramework.dylib ]]; then
exit 1
fi

function remove_and_sign_adhoc {
if codesign -dv $1 2>&1 | grep "CodeDirectory" > /dev/null; then
codesign --remove-signature $1
fi
codesign -s - $1
}

function fix_rpath() {
if ! otool -L $install_dir/bin/libMaaFramework.dylib | grep libc++ > /dev/null; then
echo "not linked to libc++, quit"
Expand Down Expand Up @@ -73,7 +74,26 @@ function collect_symbols() {
dsymutil $lib
fi
done
rm -r $install_dir/symbol
mkdir -p $install_dir/symbol
mv $install_dir/bin/*.dSYM $install_dir/symbol/
}

fix_rpath
collect_symbols
while getopts "rd" opt; do
case $opt in
r)
do_fix_rpath=true
;;
d)
do_collect_symbols=true
;;
esac
done

if [[ "$do_fix_rpath" == "true" ]]; then
fix_rpath
fi

if [[ "$do_collect_symbols" == "true" ]]; then
collect_symbols
fi

0 comments on commit d1b3151

Please sign in to comment.