|
17 | 17 | # jdk.internal.lambda.dumpProxyClasses and configures Java 8 library rewriting |
18 | 18 | # through additional flags. |
19 | 19 |
|
20 | | -# exit on errors and uninitialized variables |
21 | | -set -eu |
22 | | - |
23 | 20 | RUNFILES="${RUNFILES:-$0.runfiles}" |
24 | | -RUNFILES_MANIFEST_FILE="${RUNFILES_MANIFEST_FILE:-$RUNFILES/MANIFEST}" |
25 | | - |
26 | | -IS_WINDOWS=false |
27 | | -case "$(uname | tr [:upper:] [:lower:])" in |
28 | | -msys*|mingw*|cygwin*) |
29 | | - IS_WINDOWS=true |
30 | | -esac |
31 | | - |
32 | | -if "$IS_WINDOWS" && ! type rlocation &> /dev/null; then |
33 | | - function rlocation() { |
34 | | - # Use 'sed' instead of 'awk', so if the absolute path ($2) has spaces, it |
35 | | - # will be printed completely. |
36 | | - local result="$(grep "$1" "${RUNFILES_MANIFEST_FILE}" | head -1)" |
37 | | - # If the entry has a space, it is a mapping from a runfiles-path to absolute |
38 | | - # path, otherwise it resolves to itself. |
39 | | - echo "$result" | grep -q " " \ |
40 | | - && echo "$result" | sed 's/^[^ ]* //' \ |
41 | | - || echo "$result" |
42 | | - } |
| 21 | +CHECK_FOR_EXE=0 |
| 22 | +if [[ ! -d $RUNFILES ]]; then |
| 23 | + # Try the Windows path |
| 24 | + RUNFILES="${RUNFILES:-$0.exe.runfiles}" |
| 25 | + CHECK_FOR_EXE=1 |
43 | 26 | fi |
| 27 | +RUNFILES_MANIFEST_FILE="${RUNFILES_MANIFEST_FILE:-$RUNFILES/MANIFEST}" |
| 28 | +export JAVA_RUNFILES=$RUNFILES |
| 29 | +export RUNFILES_LIB_DEBUG=1 |
| 30 | +# --- begin runfiles.bash initialization v2 --- |
| 31 | +# Copy-pasted from the Bazel Bash runfiles library v2. |
| 32 | +set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash |
| 33 | +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ |
| 34 | + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ |
| 35 | + source "$0.runfiles/$f" 2>/dev/null || \ |
| 36 | + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 37 | + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 38 | + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e |
| 39 | +# --- end runfiles.bash initialization v2 --- |
44 | 40 |
|
45 | | -# Find script to call: |
46 | | -# Windows (in MANIFEST): <repository_name>/<path/to>/tool |
47 | | -# Linux/MacOS (symlink): ${RUNFILES}/<repository_name>/<path/to>/tool |
48 | | -if "$IS_WINDOWS"; then |
49 | | - DESUGAR="$(rlocation "[^/]*/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar")" |
| 41 | +if [[ $CHECK_FOR_EXE -eq 0 ]]; then |
| 42 | + DESUGAR="$(rlocation "bazel_tools/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar")" |
50 | 43 | else |
51 | | - DESUGAR="$(find "${RUNFILES}" -path "*/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar" | head -1)" |
| 44 | + DESUGAR="$(rlocation "bazel_tools/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.exe")" |
52 | 45 | fi |
53 | 46 |
|
54 | 47 | readonly TMPDIR="$(mktemp -d)" |
|
118 | 111 | "--jvm_flag=-Djdk.internal.lambda.dumpProxyClasses=${TMPDIR}" \ |
119 | 112 | "$@" \ |
120 | 113 | "${DESUGAR_JAVA8_LIBS_CONFIG[@]}" |
| 114 | + |
0 commit comments