daml/dev-env/bin/update-ghcide-local
dylant-da 224a6b1747
Add tool for compiling ghcide from a local copy (#16860)
* Add tool for compiling ghcide from a local copy

* Allow custom output path, so different repos can use different files
2023-05-16 15:56:20 +00:00

40 lines
1011 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Get input directory, output file
target=${1:-daml-ghcide}
out=${2:-out.tar.gz}
target=$(realpath $target)
out=$(realpath ${out%.tar.gz}.tar.gz)
# Check target exists
if [[ ! -e "$target" ]]; then
echo "Local GHCIDE location '$target' does not exist"
exit 1
fi
if [[ ! -d "$target" ]]; then
echo "Local GHCIDE location '$target' is not a directory"
exit 1
fi
# Check that correct output path is set in bazel-haskell-deps.bzl
if [[ ! -e ./bazel-haskell-deps.bzl ]]; then
echo "Cannot find bazel-haskell-deps.bzl"
exit 1
fi
if ! grep -E "^GHCIDE_LOCAL_PATH *= *\"$out\"$" >/dev/null ./bazel-haskell-deps.bzl; then
echo "Cannot find a correct definition of GHCIDE_LOCAL_PATH"
echo "Make sure to redefine GHCIDE_LOCAL_PATH = \"$out\" in ./bazel-haskell-deps.bzl"
exit 1
fi
# Make new out
if [[ -e "$out" ]]; then rm "$out"; fi
cd "$target"
tar czf "$out" .
# Synchronize new result
bazel sync --only=ghcide_ghc_lib
bazel build @ghcide_ghc_lib//:ghcide