roc/ci/build_basic_cli.sh

53 lines
1.4 KiB
Bash
Raw Normal View History

2022-12-10 20:12:42 +03:00
#!/usr/bin/env bash
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euxo pipefail
git clone https://github.com/roc-lang/basic-cli.git
2023-12-23 17:13:53 +03:00
cd basic-cli
git checkout $RELEASE_TAG
cd ..
2022-12-10 20:12:42 +03:00
2023-08-11 21:21:53 +03:00
if [ "$(uname -s)" == "Linux" ]; then
2023-11-14 13:10:31 +03:00
# check if musl-tools is installed
if ! dpkg -l | grep -q musl-tools; then
# install musl-tools with timeout for sudo problems with CI
timeout 300s sudo apt-get install -y musl-tools
fi
2023-12-23 17:20:48 +03:00
cd basic-cli/platform # we cd to install the target for the right rust version
2023-08-11 21:21:53 +03:00
if [ "$(uname -m)" == "x86_64" ]; then
rustup target add x86_64-unknown-linux-musl
elif [ "$(uname -m)" == "aarch64" ]; then
2023-08-22 15:39:56 +03:00
rustup target add aarch64-unknown-linux-musl
2023-08-11 21:21:53 +03:00
fi
2023-02-07 16:30:32 +03:00
cd ../..
fi
2023-02-07 18:26:51 +03:00
mv $(ls -d artifact/* | grep "roc_nightly.*tar\.gz" | grep "$1") ./roc_nightly.tar.gz
2022-12-10 20:12:42 +03:00
# decompress the tar
2023-02-07 18:26:51 +03:00
tar -xzvf roc_nightly.tar.gz
2022-12-10 20:12:42 +03:00
2023-01-17 13:28:08 +03:00
# delete tar
2023-02-07 18:26:51 +03:00
rm roc_nightly.tar.gz
2023-01-17 13:28:08 +03:00
# simplify dir name
mv roc_nightly* roc_nightly
cd roc_nightly
2022-12-10 20:12:42 +03:00
# build the basic cli platform
2023-11-24 14:14:36 +03:00
./roc build ../basic-cli/examples/countdown.roc --optimize
2022-12-24 17:30:12 +03:00
2022-12-24 17:47:55 +03:00
# We need this extra variable so we can safely check if $2 is empty later
EXTRA_ARGS=${2:-}
2022-12-24 17:30:12 +03:00
# In some rare cases it's nice to be able to use the legacy linker, so we produce the .o file to be able to do that
2022-12-26 18:53:30 +03:00
if [ -n "${EXTRA_ARGS}" ];
2023-11-24 14:14:36 +03:00
then ./roc build $EXTRA_ARGS ../basic-cli/examples/countdown.roc --optimize
2022-12-24 17:30:12 +03:00
fi
2022-12-13 19:53:21 +03:00
cd ..