diff --git a/.gitignore b/.gitignore index ddffb61e935..bcbed82fd8d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ target .daml/ # dev-env +/dev-env/jdk /dev-env/var/ # Bazel diff --git a/BAZEL.md b/BAZEL.md index 901b3f8a345..107497e0e9c 100644 --- a/BAZEL.md +++ b/BAZEL.md @@ -244,7 +244,7 @@ file whenever you like, so don't worry too much. The first import of the project might fail due to a resolution error of the `bazel` binary. In order to solve this, configure the Bazel plugin settings with the location of the `bazel` binary, -by setting _Preferences_ -> _Bazel Settings_ -> _Bazel binary location_ +by setting _Preferences_ → _Bazel Settings_ → _Bazel binary location_ to `./dev-env/bin/bazel`. Now, re-trigger a sync of the workspace (IntelliJ Action: @@ -252,6 +252,22 @@ _Sync project with BUILD files_). This process will take a while. [intellij_project_view]: https://ij.bazel.build/docs/project-views.html +### Configuring the JDK in IntelliJ + +DAML downloads the version of the JDK it uses from Nix. A symlink will be +created by the dev-env utilities (make sure you've set these up) in +_dev-env/jdk_. + +TO configure IntelliJ to use this JDK: + +1. Open the _Project Structure_ window. +2. Under _Platform Settings_, select _SDKs_. +3. Press the _plus_ button and select "Add JDK". +4. Choose the _dev-env/jdk_ directory. +5. Name it "DAML JDK" or something similar. +6. Open _Project Settings_ → _Project_. +7. Select the DAML JDK from the _Project SDK_ list. + ### Overview over Bazel IntelliJ Integration The IntelliJ interface should largely look the same as under SBT. However, the diff --git a/dev-env/bin/dade-assist b/dev-env/bin/dade-assist index dc3067d94c6..6c4dcf7a6a0 100755 --- a/dev-env/bin/dade-assist +++ b/dev-env/bin/dade-assist @@ -2,4 +2,7 @@ DADE_CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source "$DADE_CURRENT_SCRIPT_DIR/../lib/dade-common" + +linkTool java out "${DADE_DEVENV_DIR}/jdk" + exec "${DADE_DEVENV_DIR}/lib/dade-dump-profile" diff --git a/dev-env/lib/dade-common b/dev-env/lib/dade-common index d7e67b7b983..af8ba1050d7 100644 --- a/dev-env/lib/dade-common +++ b/dev-env/lib/dade-common @@ -85,12 +85,20 @@ dadeGetOutput() { # relalized into. This is necessary, since Nix's --add-root produces a # unpredictable symlink name. # force: if set to 1, forces re-initialization of the tool. +# target: the output location (defaults to "$DADE_GC_ROOTS/$attribute"). buildTool() { - local attr=$1 + local attribute=$1 local outputName=$2 local force=$3 shift 3 - local target="$DADE_GC_ROOTS/$attr" + if [[ $# -gt 0 ]]; then + local target=$1 + local customTarget=1 + shift 1 + else + local target="$DADE_GC_ROOTS/$attribute" + local customTarget=0 + fi local hashfile="${target}.hash" local hash="nope" local currentHash="$(dadeBaseHash)" @@ -105,30 +113,41 @@ buildTool() { if [[ ! -e "$DADE_BUILD_RESULT" || "$force" -eq 1 || "$hash" != "$currentHash" ]]; then set -e test "$force" -eq 1 && forced=" (forced)" - errcho "Building tools.${attr}${forced}..." + errcho "Building tools.${attribute}${forced}..." # Allow to fail, so we can capture outpath and to capture the exit code too. set +e - outpath=$(nix-build "${DADE_BASE_ROOT}/nix/default.nix" -A tools.$attr -Q -o "${target}") + outpath=$(nix-build "${DADE_BASE_ROOT}/nix/default.nix" -A "tools.${attribute}" -Q -o "${target}") local dade_build_exit_code=$? set -e if [[ "$dade_build_exit_code" != "0" ]]; then - errcho "Build of tools.$attr has failed!" + errcho "Build of tools.$attribute has failed!" exit 1 fi - errcho "Built tools.$attr in $outpath and linked to $DADE_BUILD_RESULT" - printf "$currentHash" >| "$hashfile" + errcho "Built tools.$attribute in $outpath and linked to $DADE_BUILD_RESULT" + if [[ $customTarget -eq 0 ]]; then + printf "$currentHash" >| "$hashfile" + fi set +e fi } # execTool execTool() { - local attr=$1 + local attribute=$1 local outputName=$2 local binary=$3 shift 3 [[ $PATH =~ (^|.*:)$DADE_DEVENV_DIR/bin($|:.*) ]] || \ eval "$(${DADE_DEVENV_DIR}/bin/dade assist)" - buildTool $attr $outputName 0 + buildTool $attribute $outputName 0 exec "$(readlink "$DADE_BUILD_RESULT")/bin/$binary" "$@" } + +# linkTool +linkTool() { + local attribute=$1 + local outputName=$2 + local target=$3 + shift 3 + buildTool $attribute $outputName 1 $target +}