aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2017-02-09 15:14:28 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-02-09 19:27:27 +0000
commitf1813e48e42adfaa93ad1c6468cbc77f70d8df7f (patch)
tree2fe08bdcbf5249fab7562adc9fd4d18664348f28 /src/main/java/com/google
parent92f182bd1058ac05db8592d3f390826d2f94ed98 (diff)
Java template windows performance
Address issue #2426 Closes #2427. -- PiperOrigin-RevId: 147031246 MOS_MIGRATED_REVID=147031246
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt20
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template_windows.txt4
2 files changed, 18 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt
index 36575d52ab..8b0b9538c2 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt
@@ -74,10 +74,10 @@ die() {
}
# Windows
-PLATFORM="$(uname -s | tr 'A-Z' 'a-z')"
+PLATFORM="$OSTYPE"
function is_windows() {
# On windows, the shell test actually running on msys
- if [[ "${PLATFORM}" =~ msys_nt* ]]; then
+ if [[ "${PLATFORM}" =~ msys* ]]; then
true
else
false
@@ -177,11 +177,25 @@ if [ -z "$RUNFILES_MANIFEST_ONLY" ]; then
fi
}
else
+ # Read file into my_array
+ oifs=$IFS
+ IFS=$'\n'
+ my_array=( $(sed -e 's/\r//g' "$RUNFILES_MANIFEST_FILE") )
+ IFS=$oifs
+
+ # Process each runfile line into a [key,value] entry in runfiles_array
+ declare -a runfiles_array
+ for line in "${my_array[@]}"
+ do
+ line_split=($line)
+ runfiles_array[${line_split[0]}]=${line_split[1]}
+ done
+
function rlocation() {
if [[ "$1" = /* ]]; then
echo $1
else
- echo $(grep "^$1 " $RUNFILES_MANIFEST_FILE | awk '{ print $2 }')
+ echo ${runfiles_array[$1]}
fi
}
fi
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template_windows.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template_windows.txt
index 179d55cdee..445da77dca 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template_windows.txt
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template_windows.txt
@@ -20,13 +20,11 @@
@SETLOCAL ENABLEEXTENSIONS
@set bash_path=%bash_exe_path%
-@set cygpath_path=%cygpath_exe_path%
@rem launcher=${$0%.cmd}
@set launcher=%~dp0%~n0
-@rem sh_path=$($cygpath_path -m $launcher)
-@for /f %%i in ('%cygpath_path% -m %launcher%') do @set sh_path=%%i
+@set sh_path=%launcher:\=/%
@rem replaces $ with \$ in $*, then puts it on the command line
@rem Cribbed from here: http://ss64.com/nt/syntax-replace.html