ghcup-hs/.github/scripts/build.sh

77 lines
2.1 KiB
Bash
Raw Normal View History

2022-10-20 12:37:50 +00:00
#!/bin/sh
set -eux
. .github/scripts/prereq.sh
2022-11-22 11:41:44 +00:00
. .github/scripts/common.sh
2022-10-20 12:37:50 +00:00
2022-11-22 11:41:44 +00:00
# ensure ghcup
if ! command -v ghcup ; then
install_ghcup
fi
# ensure cabal-cache
if ! cabal-cache version ; then
download_cabal_cache "$HOME/.local/bin/cabal-cache"
2022-10-20 12:37:50 +00:00
fi
2022-11-22 11:41:44 +00:00
# ensure ghc
2022-10-20 12:37:50 +00:00
if [ "${RUNNER_OS}" != "FreeBSD" ] ; then
2022-11-22 11:41:44 +00:00
if [ "${DISTRO}" != "Debian" ] ; then # ! armv7 or aarch64 linux
if ! "ghc-${GHC_VER}" --numeric-version ; then
ghcup -v install ghc --set --force "$GHC_VER"
fi
if [ "$(cabal --numeric-version || true)" != "${CABAL_VER}" ] ; then
ghcup -v install cabal --force "$CABAL_VER"
fi
ghc --version
cabal --version
GHC="ghc-${GHC_VER}"
else
if [ "$(cabal --numeric-version || true)" != "${CABAL_VER}" ] ; then
ghcup -v install cabal --force "$CABAL_VER"
fi
cabal --version
GHC="ghc"
fi
else
2022-10-20 12:37:50 +00:00
ghc --version
cabal --version
GHC="ghc"
fi
2022-11-22 11:41:44 +00:00
git_describe
2022-10-20 12:37:50 +00:00
# build
ecabal update
if [ "${RUNNER_OS}" = "Linux" ] ; then
if [ "${ARCH}" = "32" ] ; then
2022-11-22 11:41:44 +00:00
build_with_cache -w "${GHC}" --ghc-options='-split-sections -optl-static' -ftui --enable-tests
2022-10-20 12:37:50 +00:00
elif [ "${ARCH}" = "64" ] ; then
2022-11-22 11:41:44 +00:00
build_with_cache -w "${GHC}" --ghc-options='-split-sections -optl-static' -ftui --enable-tests
2022-10-20 12:37:50 +00:00
else
2022-11-22 11:41:44 +00:00
build_with_cache -w "${GHC}" -ftui --enable-tests
2022-10-20 12:37:50 +00:00
fi
elif [ "${RUNNER_OS}" = "FreeBSD" ] ; then
2023-01-12 15:42:37 +00:00
build_with_cache -w "${GHC}" --ghc-options='-split-sections -pgmc clang++14' --constraint="zlib +bundled-c-zlib" --constraint="zip +disable-zstd" -ftui --enable-tests
2022-10-20 12:37:50 +00:00
elif [ "${RUNNER_OS}" = "Windows" ] ; then
2023-01-13 16:14:33 +00:00
build_with_cache -w "${GHC}" --constraint="zlib +bundled-c-zlib" --constraint="lzma +static" --constraint="text -simdutf" --enable-tests
2022-10-20 12:37:50 +00:00
else
2022-11-22 11:41:44 +00:00
build_with_cache -w "${GHC}" --constraint="zlib +bundled-c-zlib" --constraint="lzma +static" -ftui --enable-tests
2022-10-20 12:37:50 +00:00
fi
2022-11-22 11:41:44 +00:00
# set up artifacts
mkdir -p out
binary=$(cabal list-bin ghcup)
binary_test=$(cabal list-bin ghcup-test)
2022-10-20 12:37:50 +00:00
ver=$("${binary}" --numeric-version)
2022-11-22 11:41:44 +00:00
strip_binary "${binary}"
2023-01-13 04:07:32 +00:00
cp "${binary}" "out/${ARTIFACT}-${ver}${ext}"
cp "${binary_test}" "out/test-${ARTIFACT}-${ver}${ext}"
2022-10-20 12:37:50 +00:00
cp ./dist-newstyle/cache/plan.json "out/${ARTIFACT}.plan.json"