Skip to content

Commit

Permalink
GitHub Actions: improve macOS releases
Browse files Browse the repository at this point in the history
Currently, releases for macOS are not very portable. The
binaries have hardcoded paths and might not run on other
systems. This commit improves the macOS binary releases
made via GitHub actions by bundling binary copies of libff,
libgmp and libsecp256k1, and by adjusting the rpath and
library names to make echidna run on other systems.
  • Loading branch information
elopez committed Nov 7, 2020
1 parent 48e7ed4 commit fc086d4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/scripts/build-macos-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

add_rpath()
{
BINARY="$1"
install_name_tool -add_rpath "@executable_path/." "$BINARY"
}

fix_path()
{
BINARY="$1"
MATCH="$2"
NEW="$3"
OLD=$(otool -L "$BINARY" | grep "$MATCH" | awk '{print $1}')
install_name_tool -change "$OLD" "$NEW" "$BINARY"
cp -n "$OLD" "$(dirname "$BINARY")/$(basename "$NEW")"
}


BUILD="$(mktemp -d)/echidna-test"
mkdir -p "$BUILD"
cp "$HOME/.local/bin/echidna-test" "$BUILD"

BINARY="$BUILD/echidna-test"
add_rpath "$BINARY"
fix_path "$BINARY" libsecp256k1 "@rpath/libsecp256k1.dylib"
fix_path "$BINARY" libff "@rpath/libff.dylib"
fix_path "$BINARY" libgmp "@rpath/libgmp.dylib"
fix_path "$BUILD/libff.dylib" libgmp "@rpath/libgmp.dylib"
fix_path "$BUILD/libsecp256k1.dylib" libgmp "@rpath/libgmp.dylib"

GZIP=-9 tar -czf echidna-test.tar.gz -C "$BUILD/.." echidna-test
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ jobs:
stack test --ghc-options="-Werror" --extra-include-dirs=$HOME/.local/include --extra-lib-dirs=$HOME/.local/lib
done
- name: Compress binary
- name: Amend and compress binaries (macOS)
if: runner.os == 'macOS'
run: .github/scripts/build-macos-release.sh

- name: Compress binary (Linux)
if: runner.os == 'Linux'
run: GZIP=-9 tar -czf echidna-test.tar.gz $HOME/.local/bin/echidna-test

- name: Upload artifact
Expand Down

0 comments on commit fc086d4

Please sign in to comment.