Skip to content

Commit

Permalink
Add tool for compiling ghcide from a local copy (digital-asset#16860)
Browse files Browse the repository at this point in the history
* Add tool for compiling ghcide from a local copy

* Allow custom output path, so different repos can use different files
  • Loading branch information
dylant-da authored May 16, 2023
1 parent f681e2a commit 224a6b1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bazel-haskell-deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ load("//bazel_tools/ghc-lib:repositories.bzl", "ghc_lib_and_dependencies")

GHCIDE_REV = "434991f74b4cdc6a0983a37ee976c4f62580c2e5"
GHCIDE_SHA256 = "d3f386643bdd68800cbfd61a5fb8868d6df8ecd23f2dd32331d84e3b7362d832"
GHCIDE_LOCAL_PATH = None
JS_JQUERY_VERSION = "3.3.1"
JS_DGTABLE_VERSION = "0.5.2"
JS_FLOT_VERSION = "0.8.3"
Expand Down Expand Up @@ -118,9 +119,9 @@ haskell_library(
patches = [
"@com_github_digital_asset_daml//bazel_tools:haskell-ghcide-binary-q.patch",
],
sha256 = GHCIDE_SHA256,
strip_prefix = "daml-ghcide-%s" % GHCIDE_REV,
urls = ["https://github.com/digital-asset/daml-ghcide/archive/%s.tar.gz" % GHCIDE_REV],
sha256 = None if GHCIDE_LOCAL_PATH != None else GHCIDE_SHA256,
strip_prefix = None if GHCIDE_LOCAL_PATH != None else "daml-ghcide-%s" % GHCIDE_REV,
url = "file://" + GHCIDE_LOCAL_PATH if GHCIDE_LOCAL_PATH != None else "https://github.com/digital-asset/daml-ghcide/archive/%s.tar.gz" % GHCIDE_REV,
)

ghc_lib_and_dependencies()
Expand Down
39 changes: 39 additions & 0 deletions dev-env/bin/update-ghcide-local
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/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

0 comments on commit 224a6b1

Please sign in to comment.