Skip to content

Commit

Permalink
release building scripts and simple unified scripts to run and unpack
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonch committed May 17, 2024
1 parent e3e4d72 commit 70b90b8
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 18 deletions.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ DEV_DEPENDENCIES = \
merlin \
ocamlformat

.PHONY: test promote test-promote test-cc clean
.PHONY: test promote test-promote test-cc clean release-macos release-linux

default:
dune build src/bin/main.exe
Expand All @@ -35,6 +35,16 @@ default:
dune build src/bin/lucidcc.exe
cp -f _build/default/src/bin/lucidcc.exe lucidcc

macos-release:
dune build src/bin/main.exe
cp -f _build/default/src/bin/main.exe dpt
./scripts/build_macos_release.sh

linux-release:
dune build src/bin/main.exe
cp -f _build/default/src/bin/main.exe dpt
./scripts/build_linux_release.sh

all:
dune build src/bin/main.exe
cp -f _build/default/src/bin/main.exe dpt
Expand Down
46 changes: 46 additions & 0 deletions release/dpt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

script_dir=$(dirname $0)

macos_dir="$script_dir/macos/lucid"
linux_dir="$script_dir/linux/lucid"

# set bin_dir to the correct directory based on the OS
if [[ "$OSTYPE" == "darwin"* ]]; then
bin_dir=$macos_dir
if [ ! -f "$bin_dir/dpt" ]; then
echo "MacOS binary not found in $macos_dir"
echo "You may need to run the 'unpack.sh' script in the release directory"
exit 1
fi
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [ ! -f "$linux_dir/dpt" ]; then
echo "Linux binary not found in $linux_dir"
echo "You may need to run the 'unpack.sh' script in the release directory"
exit 1
fi
bin_dir=$linux_dir
else
echo "Unsupported OS -- you should build the project from source"
exit 1
fi

# run dpt in the appropriate directory
$bin_dir/dpt $@



# case "$1" in
# compile)
# shift # Remove the first argument and pass the rest to the compiler
# exec "$APPDIR/usr/bin/dptc" "$@"
# ;;
# interpret)
# shift # Remove the first argument and pass the rest to the interpreter
# exec "$APPDIR/usr/bin/dpt" "$@"
# ;;
# *)
# echo "Usage: $0 {compile|interpret} args"
# exit 1
# ;;
# esac
18 changes: 18 additions & 0 deletions release/unpack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# unpack the release tarballs in this script's directory

my_dir="$(dirname "$0")"

# check if each tarball exists and unpack it
if [ ! -f $my_dir/macos.tar.gz ]; then
echo "macos.tar.gz not found -- skipping"
else
tar -xvf $my_dir/macos.tar.gz
fi

if [ ! -f $my_dir/linux.tar.gz ]; then
echo "linux.tar.gz not found -- skipping"
else
tar -xvf $my_dir/linux.tar.gz
fi
30 changes: 21 additions & 9 deletions release/build_linux.sh → scripts/build_linux_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@ else
exit 1
fi

release_dir=./linux/lucid
lib_dir=$release_dir/lib
# make sure this is run from the repo root
if [ ! -d ".git" ]
then
echo "This script must be run from the root of the repository."
exit 1
fi

release_base=./release
os_base=linux
release_dir=$release_base/$os_base/lucid
lib_dir=$release_dir/libs

rm -rf $release_dir
mkdir -p $lib_dir
# 1. build the binary locally (in the parent directory)
cd ..
make
cd -
# make

# copy binary
cp ../dpt "$release_dir"/dpt
cp dpt "$release_dir"/dpt

# Run ldd on the binary and parse output
deps=$(ldd "$release_dir"/dpt | awk '/=>/ {print $3} !/=>/ {if ($1 ~ /^\//) print $1}')
Expand All @@ -44,8 +51,13 @@ for lib in $deps; do
fi
done

echo "patching binary dynamic lib paths"
patchelf --set-rpath '$ORIGIN/lib' "$release_dir"/dpt

echo "======================"
echo "Linux binary package built in $release_dir. Please distribute this entire folder and run dpt inside of it."
echo "======================"
# package os release in a tarball inside of the release dir
echo "Packaging release"
cd $release_base
tar -zcvf "$os_base".tar.gz $os_base
rm -rf $os_base

echo "done building linux release"
29 changes: 21 additions & 8 deletions release/build_macos.sh → scripts/build_macos_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,34 @@ then
exit
fi

release_dir=./macos/lucid
# make sure this is run from the repo root
if [ ! -d ".git" ]
then
echo "This script must be run from the root of the repository."
exit 1
fi

release_base=./release
os_base=macos
release_dir=$release_base/$os_base/lucid
lib_dir=$release_dir/libs

rm -rf $release_dir
mkdir -p $lib_dir

cd ..
make
cd -

cp ../dpt $release_dir/
cp dpt $release_dir/

# run dylibbundler to bundle the dynamic libraries (mainly z3)
echo "patching binary dynamic lib paths"
dylibbundler -od -b -x $release_dir/dpt -d $lib_dir -p @executable_path/libs/
# print release information
echo "======================"
echo "MacOS binary package built in $release_dir. Please distribute this entire folder and run dpt inside of it."
echo "======================"

# package os release in a tarball inside of the release dir
echo "Packaging release"
cd $release_base
tar -zcvf "$os_base".tar.gz $os_base
# remove the release directory
rm -rf $os_base

echo "done building macos release"

0 comments on commit 70b90b8

Please sign in to comment.