Fix java_stub_template.txt on Windows
To define a associative arrary in bash, we need `declare -A` instead of `declare -a`,
but `declare -A` is not supported on macOS, so fall back to the old implementation of rlocation on macOS.
Related issue:
MOS_MIGRATED_REVID=147144803
@@ -74,14 +74,14 @@ die() {
}
# Windows
-PLATFORM="$OSTYPE"
function is_windows() {
# On windows, the shell test actually running on msys
- if [[ "${PLATFORM}" =~ msys* ]]; then
- true
- else
- false
- fi
+ [[ "${OSTYPE}" =~ msys* ]]
+}
+
+# macOS
+function is_macos() {
+ [[ "${OSTYPE}" =~ darwin* ]]
}
# Parse arguments sequentially until the first unrecognized arg is encountered.
@@ -177,6 +177,7 @@ if [ -z "$RUNFILES_MANIFEST_ONLY" ]; then
fi
}
else
+ if ! is_macos; then
# Read file into my_array
oifs=$IFS
IFS=$'\n'
@@ -184,19 +185,25 @@ else
IFS=$oifs
# Process each runfile line into a [key,value] entry in runfiles_array
- declare -a runfiles_array
+ # declare -A is not supported on macOS because an old version of bash is used.
+ declare -A runfiles_array
for line in "${my_array[@]}"
do
line_split=($line)
runfiles_array[${line_split[0]}]=${line_split[1]}
done
+ fi
function rlocation() {
if [[ "$1" = /* ]]; then
echo $1
+ else
+ if is_macos; then
+ echo $(grep "^$1 " $RUNFILES_MANIFEST_FILE | awk '{ print $2 }')
else
echo ${runfiles_array[$1]}
fi
+ fi
}
fi
