Skip to content

Commit c4bb242

Browse files
jpluscplusmmvdan
authored andcommitted
gen: use envvars to specify deps' locations
This updates the "gen" script by adding a pair of environment variables that allow developers to control where the script looks for two required dependencies: jextract and libcue. Defaults are set up so that when the variables aren't present the script's behaviour doesn't change, Also: tidy up and add comments. Signed-off-by: Jonathan Matthews <[email protected]> Change-Id: Iaabdca1496f541aa7c22315be9b8669ac51ec5fd Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue-api-java/+/1199055 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 2f61332 commit c4bb242

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

gen

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
2+
set -euo pipefail
23

3-
set -e
4-
srcdir="$(cd `dirname "$0"` && pwd)"
5-
cd "$srcdir"
4+
# Change into the project's root directory.
5+
cd "$(dirname "$0")"
66

7-
# TODO: remove this.
8-
PATH=$PATH:$HOME/src/jextract-22/bin
7+
# Allow for a machine-specific pointer to the jextract executable to be
8+
# communicated via the JEXTPATH variable, defaulting to a value for one
9+
# specific developer's machine.
10+
if ! command -v jextract >/dev/null; then
11+
: ${JEXTPATH:=$HOME/src/jextract-22/bin}
12+
PATH=$PATH:$JEXTPATH
13+
fi
914

10-
# TODO: find this in a more reliable way.
11-
CUE_H=$HOME/src/libcue/cue.h
15+
# Allow for a machine-specific pointer to the source of libcue to be
16+
# communicated via the LIBCUE variable, defaulting to a value for one specific
17+
# developer's machine.
18+
: ${LIBCUE:=$HOME/src/libcue}
1219

1320
rm -rf src/main/java/org/cuelang/libcue
14-
jextract -t org.cuelang.libcue --output src/main/java -lcue --use-system-load-library @includes.txt $CUE_H
21+
jextract -t org.cuelang.libcue --output src/main/java -lcue --use-system-load-library @includes.txt "$LIBCUE/cue.h"

0 commit comments

Comments
 (0)