diff --git a/.github/scripts/install_name_tool_macos.sh b/.github/scripts/install_name_tool_macos.sh new file mode 100755 index 00000000..9cd9d1d0 --- /dev/null +++ b/.github/scripts/install_name_tool_macos.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +shopt -s -o nounset + +# +# change path to bundled dylibs in executables from absolute path (usr/local/lib/) to same directory +# +for exe in `ls *_x64` +do + echo "fixing paths in ${exe}" + for libpath in `otool -L ${exe} | grep "/" | grep -v "System" | awk '{print $1}'` + do + libfilename=${libpath##*/} + echo install_name_tool -change $libpath @executable_path/$libfilename $exe + install_name_tool -change $libpath @executable_path/$libfilename $exe + done +done + +# +# change path from each dylib to each other (dylibs can refer to other dylibs) from /usr/local/lib to @loader_path (same directory) +# if there is not dependency, then ignore the errors. +# +for libfilename in `ls *.dylib` +do + echo "fixing paths in ${libfilename}" + # + # set id of dynamic library to @loader_path/libname + # + echo install_name_tool -id "@loader_path/$libfilename" $libfilename + install_name_tool -id "@loader_path/$libfilename" $libfilename + + for dependentlibpath in `otool -L ${libfilename} | grep "/" | grep -v "System" | awk '{print $1}'` + do + dependentlibfilename=${dependentlibpath##*/} + # + # for each library, change path to dependent libraries to be based on @loader_path + # + echo install_name_tool -change $dependentlibpath @loader_path/$dependentlibfilename $libfilename + install_name_tool -change $dependentlibpath @loader_path/$dependentlibfilename $libfilename + done +done diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 63fd8e06..53f7334b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -268,10 +268,53 @@ jobs: # ./bin/ziptool || true # - - name: Upload ${{ matrix.os }} binaries + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + with: + limit-access-to-actor: false + + - name: handle shared object paths for Macos native build + if: matrix.platform == 'macos-latest' + shell: bash + run: | + cd build/bin + ls *_x64 | awk '{print $1}' | xargs -I '{}' otool -L '{}' | grep ")" | grep -v "build" | grep -v "System" | awk '{print $1}' | xargs -I '{}' cp -vn '{}' . || true + ls *.dylib | awk '{print $1}' | xargs -I '{}' otool -L '{}' | grep ")" | grep -v "build" | grep -v "System" | awk '{print $1}' | xargs -I '{}' cp -vn '{}' . || true + ls *.dylib | awk '{print $1}' | xargs -I '{}' otool -L '{}' | grep ")" | grep -v "build" | grep -v "System" | awk '{print $1}' | xargs -I '{}' cp -vn '{}' . || true + chmod u+w,+x * + ../../.github/scripts/install_name_tool_macos.sh + chmod 555 * + +# - name: handle shared object paths for Windows native build +# if: matrix.platform == 'windows-latest' +# shell: msys2 {0} +# run: | +# cd build/bin +# ls *_x64 | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep "=> /" | grep -v "build" | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true +# ls *.so | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep "=> /" | grep -v "build" | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true +# ls *.so | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep "=> /" | grep -v "build" | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true +# chmod u+w,+x * +# tar czvf ../linux64.tgz --dereference . +# cd ../.. +# fi +# +# - name: handle shared object paths for Linux native build +# if: matrix.platform == 'ubuntu-18.04' +# shell: bash +# run: | +# cd build/bin +# ls *_x64 | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep "=> /" | grep -v "build" | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true +# ls *.so | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep "=> /" | grep -v "build" | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true +# ls *.so | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep "=> /" | grep -v "build" | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true +# chmod u+w,+x * +# tar czvf ../linux64.tgz --dereference . +# cd ../.. +# fi +# + - name: Upload ${{ matrix.platform }} binaries uses: actions/upload-artifact@v3 with: - name: solvers-${{ matrix.os }} + name: solvers-${{ matrix.platform }} path: build/bin* - name: Setup tmate session