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

77 lines
2.0 KiB
Bash
Raw Permalink 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
2022-11-22 11:41:44 +00:00
build_with_cache -w "${GHC}" --ghc-options='-split-sections' --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
2022-11-22 11:41:44 +00:00
build_with_cache -w "${GHC}" --constraint="zlib +bundled-c-zlib" --constraint="lzma +static" --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}"
2022-10-20 12:37:50 +00:00
cp "${binary}" "out/${ARTIFACT}-${ver}"
2022-11-22 11:41:44 +00:00
cp "${binary_test}" "out/test-${ARTIFACT}-${ver}"
2022-10-20 12:37:50 +00:00
cp ./dist-newstyle/cache/plan.json "out/${ARTIFACT}.plan.json"