Make running test possible with CMD.exe
Needed to use a .bat file to avoid an issue
where built-in modules shadowed the R8-defined
modules with same names.
Bug:
Change-Id: Ia18c011bf1968ece440251d17074d2a76b499264
diff --git a/build.gradle b/build.gradle
index f11c7ae..6feb7a8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -137,8 +137,14 @@
def sha1File = "${gzFile}.sha1"
inputs.file sha1File
outputs.file gzFile
- executable "bash"
- args "-c", "download_from_google_storage -n -b r8-deps -u -s ${sha1File}"
+ List<String> dlFromStorageArgs = ["-n", "-b", "r8-deps", "-u", "-s", "${sha1File}"]
+ if (OperatingSystem.current().isWindows()) {
+ executable "download_from_google_storage.bat"
+ args dlFromStorageArgs
+ } else {
+ executable "bash"
+ args "-c", "download_from_google_storage " + String.join(" ", dlFromStorageArgs)
+ }
}
}
}
@@ -427,7 +433,12 @@
task buildExampleJars {
dependsOn downloadProguard
def examplesDir = file("src/test/examples")
- def proguardScript = "third_party/proguard/proguard5.2.1/bin/proguard.sh"
+ def proguardScript
+ if (OperatingSystem.current().isWindows()) {
+ proguardScript = "third_party/proguard/proguard5.2.1/bin/proguard.bat"
+ } else {
+ proguardScript = "third_party/proguard/proguard5.2.1/bin/proguard.sh"
+ }
task "compile_examples"(type: JavaCompile) {
source = fileTree(dir: examplesDir, include: '**/*.java')
destinationDir = file("build/test/examples/classes")
@@ -459,11 +470,17 @@
// Enable these to get stdout and stderr redirected to files...
// standardOutput = new FileOutputStream('proguard.stdout')
// errorOutput = new FileOutputStream('proguard.stderr')
- executable "bash"
- args "-c", "${proguardScript} '-verbose -dontwarn java.** -injars ${jarPath}" +
+ def proguardArguments = "-verbose -dontwarn java.** -injars ${jarPath}" +
" -outjars ${proguardJarPath}" +
" -include ${proguardConfigPath}" +
- " -printmapping ${proguardMapPath}'"
+ " -printmapping ${proguardMapPath}"
+ if (OperatingSystem.current().isWindows()) {
+ executable "${proguardScript}"
+ args "${proguardArguments}"
+ } else {
+ executable "bash"
+ args "-c", "${proguardScript} '${proguardArguments}'"
+ }
outputs.file proguardJarPath
}
} else {
diff --git a/tools/gradle.py b/tools/gradle.py
index 1945557..64e6d51 100755
--- a/tools/gradle.py
+++ b/tools/gradle.py
@@ -14,7 +14,10 @@
GRADLE_DIR = os.path.join(utils.REPO_ROOT, 'third_party', 'gradle')
GRADLE_SHA1 = os.path.join(GRADLE_DIR, 'gradle.tar.gz.sha1')
-GRADLE = os.path.join(GRADLE_DIR, 'gradle', 'bin', 'gradle')
+if os.name == 'nt':
+ GRADLE = os.path.join(GRADLE_DIR, 'gradle', 'bin', 'gradle.bat')
+else:
+ GRADLE = os.path.join(GRADLE_DIR, 'gradle', 'bin', 'gradle')
def PrintCmd(s):
if type(s) is list:
diff --git a/tools/test.bat b/tools/test.bat
new file mode 100644
index 0000000..a343096
--- /dev/null
+++ b/tools/test.bat
@@ -0,0 +1,9 @@
+@echo off
+:: Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
+:: for details. All rights reserved. Use of this source code is governed by a
+:: BSD-style license that can be found in the LICENSE file.
+setlocal
+
+PATH=%~dp0;%PATH%
+
+python "%~dp0\test.py" %*
\ No newline at end of file