-
-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
723 additions
and
1,257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
freebsd_instance: | ||
image_family: freebsd-13-1 | ||
disk: 100 | ||
|
||
task: | ||
timeout_in: 120m | ||
env: | ||
AWS_ACCESS_KEY_ID: ENCRYPTED[7e381ce808bf572cdde8ea4b7023d06b631844d3dabfdb193b15e76a78555ad7f605afc34d8a51c69ab1b277c3c2e304] | ||
AWS_SECRET_ACCESS_KEY: ENCRYPTED[640639db00f954f466c90613b79ae3b364268cd153c7e4f8cab16c75c2bdf72c9ffe18f14b4f0ae2fc0bdf21beadb3f2] | ||
S3_HOST: ENCRYPTED[ef3162480f5b404ac20c12fb8cb55b664102463cea1b49cec4260b67e22f0b4b8da51c9c547a5c3da8ef22146459e324] | ||
TARBALL_EXT: "tar.xz" | ||
ARCH: 64 | ||
ARTIFACT: "x86_64-freebsd" | ||
DISTRO: "na" | ||
RUNNER_OS: "FreeBSD" | ||
ADD_CABAL_ARGS: "--enable-split-sections" | ||
GITHUB_WORKSPACE: ${CIRRUS_WORKING_DIR} | ||
install_script: pkg install -y hs-cabal-install git bash misc/compat10x misc/compat11x misc/compat12x gmake patchelf | ||
script: | ||
- bash .github/scripts/build.sh | ||
binaries_artifacts: | ||
path: "out/*" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/bash | ||
|
||
set -eux | ||
|
||
. .github/scripts/prereq.sh | ||
. .github/scripts/common.sh | ||
|
||
|
||
# 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" | ||
fi | ||
|
||
|
||
# build | ||
ecabal update | ||
|
||
case "$(uname)" in | ||
MSYS_*|MINGW*) | ||
for ghc in $(cat bindist/ghcs-Msys) ; do | ||
GHC_VERSION="${ghc%,*}" | ||
args=( -O2 -w "ghc-$GHC_VERSION" --project-file cabal.project --disable-profiling --disable-tests --enable-executable-stripping ${ADD_CABAL_ARGS}) | ||
ghcup install ghc "${GHC_VERSION}" | ||
"ghc-${GHC_VERSION}" --info | ||
# Shorten binary names | ||
sed -i.bak -e 's/haskell-language-server/hls/g' \ | ||
-e 's/haskell_language_server/hls/g' \ | ||
haskell-language-server.cabal cabal.project | ||
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \ | ||
src/**/*.hs exe/*.hs | ||
|
||
|
||
# shellcheck disable=SC2068 | ||
build_with_cache ${args[@]} exe:hls exe:hls-wrapper | ||
|
||
mkdir -p "$CI_PROJECT_DIR/out" | ||
|
||
# shellcheck disable=SC2068 | ||
cp "$(cabal list-bin -v0 ${args[@]} exe:hls)" "$CI_PROJECT_DIR/out/haskell-language-server-${GHC_VERSION}"${ext} | ||
# shellcheck disable=SC2068 | ||
cp "$(cabal list-bin -v0 ${args[@]} exe:hls-wrapper)" "$CI_PROJECT_DIR/out/haskell-language-server-wrapper"${ext} | ||
ghcup rm ghc "${GHC_VERSION}" | ||
done | ||
;; | ||
*) | ||
sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project | ||
emake --version | ||
emake GHCUP=ghcup CABAL_CACHE_BIN=cabal-cache S3_HOST="${S3_HOST}" S3_KEY="${ARTIFACT}" hls | ||
emake GHCUP=ghcup bindist | ||
rm -rf out/*.*.* | ||
;; | ||
esac | ||
|
||
cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json" | ||
|
||
|
||
# create tarball/zip | ||
TARBALL_PREFIX="haskell-language-server" | ||
case "${TARBALL_EXT}" in | ||
zip) | ||
HLS_VERSION="$("$CI_PROJECT_DIR/out/haskell-language-server-8.10.7" --numeric-version)" | ||
cd "$CI_PROJECT_DIR/out/" | ||
zip "${TARBALL_PREFIX}-${HLS_VERSION}-${ARTIFACT}.zip" haskell-language-server-* | ||
find . -type f ! -name '*.zip' -delete | ||
;; | ||
tar.xz) | ||
emake --version | ||
HLS_VERSION="$(emake -s -C out/bindist/haskell-language-server-* version)" | ||
emake TARBALL="${TARBALL_PREFIX}-${HLS_VERSION}-${ARTIFACT}.tar.xz" bindist-tar | ||
rm -rf out/bindist | ||
;; | ||
*) | ||
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}" | ||
;; | ||
esac | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
#!/bin/sh | ||
|
||
if [ "${RUNNER_OS}" = "Windows" ] ; then | ||
ext=".exe" | ||
else | ||
ext='' | ||
fi | ||
|
||
# Colors | ||
BLACK="0;30" | ||
GRAY="1;30" | ||
RED="0;31" | ||
LT_RED="1;31" | ||
BROWN="0;33" | ||
LT_BROWN="1;33" | ||
GREEN="0;32" | ||
LT_GREEN="1;32" | ||
BLUE="0;34" | ||
LT_BLUE="1;34" | ||
PURPLE="0;35" | ||
LT_PURPLE="1;35" | ||
CYAN="0;36" | ||
LT_CYAN="1;36" | ||
WHITE="1;37" | ||
LT_GRAY="0;37" | ||
|
||
ecabal() { | ||
cabal "$@" | ||
} | ||
|
||
sync_from() { | ||
if [ "${RUNNER_OS}" != "Windows" ] ; then | ||
cabal_store_path="$(dirname "$(cabal help user-config | tail -n 1 | xargs)")/store" | ||
fi | ||
|
||
cabal-cache sync-from-archive \ | ||
--host-name-override="${S3_HOST}" \ | ||
--host-port-override=443 \ | ||
--host-ssl-override=True \ | ||
--region us-west-2 \ | ||
$([ "${RUNNER_OS}" != "Windows" ] && echo --store-path="$cabal_store_path") \ | ||
--archive-uri "s3://haskell-language-server/${ARTIFACT}" | ||
} | ||
|
||
sync_to() { | ||
if [ "${RUNNER_OS}" != "Windows" ] ; then | ||
cabal_store_path="$(dirname "$(cabal help user-config | tail -n 1 | xargs)")/store" | ||
fi | ||
|
||
cabal-cache sync-to-archive \ | ||
--host-name-override="${S3_HOST}" \ | ||
--host-port-override=443 \ | ||
--host-ssl-override=True \ | ||
--region us-west-2 \ | ||
$([ "${RUNNER_OS}" != "Windows" ] && echo --store-path="$cabal_store_path") \ | ||
--archive-uri "s3://haskell-language-server/${ARTIFACT}" | ||
} | ||
|
||
raw_eghcup() { | ||
"$GHCUP_BIN/ghcup${ext}" -v -c "$@" | ||
} | ||
|
||
eghcup() { | ||
if [ "${OS}" = "Windows" ] ; then | ||
"$GHCUP_BIN/ghcup${ext}" -c -s "file:/$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml" "$@" | ||
else | ||
"$GHCUP_BIN/ghcup${ext}" -c -s "file://$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml" "$@" | ||
fi | ||
} | ||
|
||
sha_sum() { | ||
if [ "${OS}" = "FreeBSD" ] ; then | ||
sha256 "$@" | ||
else | ||
sha256sum "$@" | ||
fi | ||
|
||
} | ||
|
||
git_describe() { | ||
git config --global --get-all safe.directory | grep '^\*$' || git config --global --add safe.directory "*" | ||
git describe --always | ||
} | ||
|
||
download_cabal_cache() { | ||
( | ||
set -e | ||
dest="$HOME/.local/bin/cabal-cache" | ||
url="" | ||
exe="" | ||
cd /tmp | ||
case "${RUNNER_OS}" in | ||
"Linux") | ||
case "${DISTRO}" in | ||
"Alpine") | ||
case "${ARCH}" in | ||
"32") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/1.0.5.1/i386-linux-alpine-cabal-cache-1.0.5.1 | ||
;; | ||
"64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/1.0.5.1/x86_64-linux-alpine-static-cabal-cache-1.0.5.1 | ||
;; | ||
esac | ||
;; | ||
*) | ||
case "${ARCH}" in | ||
"64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/1.0.5.1/x86_64-linux-alpine-static-cabal-cache-1.0.5.1 | ||
;; | ||
"ARM64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/1.0.5.1/aarch64-linux-cabal-cache-1.0.5.1 | ||
;; | ||
"ARM") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/1.0.5.1/armv7-linux-cabal-cache-1.0.5.1 | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
"FreeBSD") | ||
url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/1.0.5.1/x86_64-freebsd-cabal-cache-1.0.5.1 | ||
;; | ||
"Windows") | ||
exe=".exe" | ||
url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/1.0.5.1/x86_64-mingw64-cabal-cache-1.0.5.1.exe | ||
;; | ||
"macOS") | ||
case "${ARCH}" in | ||
"ARM64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/1.0.5.1/aarch64-apple-darwin-cabal-cache-1.0.5.1 | ||
;; | ||
"64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/1.0.5.1/x86_64-apple-darwin-cabal-cache-1.0.5.1 | ||
;; | ||
esac | ||
;; | ||
esac | ||
|
||
if [ -n "${url}" ] ; then | ||
case "${url##*.}" in | ||
"gz") | ||
curl -L -o - "${url}" | gunzip > cabal-cache${exe} | ||
;; | ||
*) | ||
curl -o cabal-cache${exe} -L "${url}" | ||
;; | ||
esac | ||
chmod +x cabal-cache${exe} | ||
cp "cabal-cache${exe}" "${dest}${exe}" | ||
fi | ||
) | ||
} | ||
|
||
build_with_cache() { | ||
ecabal configure "$@" | ||
ecabal build --dependencies-only "$@" --dry-run | ||
sync_from | ||
ecabal build --dependencies-only "$@" || sync_to | ||
sync_to | ||
ecabal build "$@" | ||
sync_to | ||
} | ||
|
||
install_ghcup() { | ||
find "$GHCUP_INSTALL_BASE_PREFIX" | ||
mkdir -p "$GHCUP_BIN" | ||
mkdir -p "$GHCUP_BIN"/../cache | ||
|
||
if [ "${RUNNER_OS}" = "FreeBSD" ] ; then | ||
curl -o ghcup https://downloads.haskell.org/ghcup/tmp/x86_64-portbld-freebsd-ghcup-0.1.18.1 | ||
chmod +x ghcup | ||
mv ghcup "$HOME/.local/bin/ghcup" | ||
else | ||
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh | ||
fi | ||
} | ||
|
||
strip_binary() { | ||
( | ||
set -e | ||
binary=$1 | ||
if [ "${RUNNER_OS}" = "macOS" ] ; then | ||
strip "${binary}" | ||
else | ||
if [ "${RUNNER_OS}" != "Windows" ] ; then | ||
strip -s "${binary}" | ||
fi | ||
fi | ||
) | ||
} | ||
|
||
# GitLab Pipelines log section delimiters | ||
# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664 | ||
start_section() { | ||
name="$1" | ||
echo -e "section_start:$(date +%s):$name\015\033[0K" | ||
} | ||
|
||
end_section() { | ||
name="$1" | ||
echo -e "section_end:$(date +%s):$name\015\033[0K" | ||
} | ||
|
||
echo_color() { | ||
local color="$1" | ||
local msg="$2" | ||
echo -e "\033[${color}m${msg}\033[0m" | ||
} | ||
|
||
error() { echo_color "${RED}" "$1"; } | ||
warn() { echo_color "${LT_BROWN}" "$1"; } | ||
info() { echo_color "${LT_BLUE}" "$1"; } | ||
|
||
fail() { error "error: $1"; exit 1; } | ||
|
||
run() { | ||
info "Running $*..." | ||
"$@" || ( error "$* failed"; return 1; ) | ||
} | ||
|
||
emake() { | ||
if command -v gmake >/dev/null 2>&1 ; then | ||
gmake "$@" | ||
else | ||
make "$@" | ||
fi | ||
} | ||
|
||
mktempdir() { | ||
case "$(uname -s)" in | ||
"Darwin"|"darwin") | ||
mktemp -d -t hls_ci.XXXXXXX | ||
;; | ||
*) | ||
mktemp -d | ||
;; | ||
esac | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/sh | ||
|
||
mkdir -p "$HOME"/.local/bin | ||
|
||
export PATH="$HOME/.local/bin:$PATH" | ||
|
||
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1 | ||
export BOOTSTRAP_HASKELL_GHC_VERSION="${GHC_VER:-recommended}" | ||
export BOOTSTRAP_HASKELL_CABAL_VERSION="${CABAL_VER:-recommended}" | ||
export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes | ||
|
||
if [ "${RUNNER_OS}" = "Windows" ] ; then | ||
# on windows use pwd to get unix style path | ||
CI_PROJECT_DIR="$(pwd)" | ||
export CI_PROJECT_DIR | ||
export GHCUP_INSTALL_BASE_PREFIX="/c" | ||
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/ghcup/bin" | ||
export PATH="$GHCUP_BIN:$PATH" | ||
export CABAL_DIR="C:\\Users\\runneradmin\\AppData\\Roaming\\cabal" | ||
else | ||
export CI_PROJECT_DIR="${GITHUB_WORKSPACE}" | ||
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR" | ||
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin" | ||
export PATH="$GHCUP_BIN:$PATH" | ||
export CABAL_DIR="$CI_PROJECT_DIR/cabal" | ||
export CABAL_CACHE="$CI_PROJECT_DIR/cabal-cache" | ||
fi | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
export TZ=Asia/Singapore | ||
|
||
if [ "${RUNNER_OS}" = "macOS" ] ; then | ||
if ! command -v brew ; then | ||
[ -e "$HOME/.brew" ] || | ||
git clone --depth=1 https://github.com/Homebrew/brew "$HOME/.brew" | ||
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH" | ||
brew update | ||
fi | ||
if ! command -v git ; then | ||
brew install git | ||
fi | ||
if ! command -v realpath ; then | ||
brew install coreutils | ||
fi | ||
|
||
brew install autoconf automake make tree | ||
if [ "${ARCH}" = "ARM64" ] ; then | ||
brew install llvm@11 | ||
export PATH="$HOME/.brew/opt/llvm@11/bin:$PATH" | ||
export CC="$HOME/.brew/opt/llvm@11/bin/clang" | ||
export CXX="$HOME/.brew/opt/llvm@11/bin/clang++" | ||
export LD=ld | ||
export AR="$HOME/.brew/opt/llvm@11/bin/llvm-ar" | ||
export RANLIB="$HOME/.brew/opt/llvm@11/bin/llvm-ranlib" | ||
fi | ||
fi | ||
|
Oops, something went wrong.