Skip to content

Commit

Permalink
Uncomment android_sdk/ndk_repository on Windows
Browse files Browse the repository at this point in the history
Revive #5023 (by @philwo) so that we can try to revive #4797.

`shell_commands` will put the whole cmd string into an array (`[cmd]`) before passing it to `subprocess.run`. This will make `subprocess.run` thinks that the first element of the array is the full path of the program, hence the weird error in #5023. We work around it with `batch_commands` which pass the cmd string directly into `subprocess.run` and let `subprocess.run` do the heavy-lifting.

/cc @philwo @meteorcloudy

Closes #6699.

PiperOrigin-RevId: 225547132
  • Loading branch information
rongjiecomputer authored and Copybara-Service committed Dec 14, 2018
1 parent c298acd commit 2200ffa
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 25 deletions.
6 changes: 2 additions & 4 deletions .bazelci/postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ platforms:
- "//third_party/ijar/..."
- "//tools/android/..."
windows:
batch_commands:
- powershell -Command "(Get-Content WORKSPACE) -Replace '# android_', 'android_' | Set-Content WORKSPACE"
build_flags:
- "--copt=-w"
- "--host_copt=-w"
Expand All @@ -159,10 +161,6 @@ platforms:
- "--copt=-w"
- "--host_copt=-w"
- "--test_env=JAVA_HOME"
# TODO(pcloudy): Need this for WindowsSubprocessTest.java.
# Remove this when release version Bazel sets SYSTEMDRIVE
# on Windows by default.
- "--test_env=SYSTEMDRIVE"
- "--test_timeout=1200"
test_targets:
- "--"
Expand Down
6 changes: 2 additions & 4 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ platforms:
- "-//src/test/shell/bazel/android:aar_integration_test"
- "-//src/test/shell/bazel/android:android_integration_test"
windows:
batch_commands:
- powershell -Command "(Get-Content WORKSPACE) -Replace '# android_', 'android_' | Set-Content WORKSPACE"
build_flags:
- "--copt=-w"
- "--host_copt=-w"
Expand All @@ -210,10 +212,6 @@ platforms:
- "--copt=-w"
- "--host_copt=-w"
- "--test_env=JAVA_HOME"
# TODO(pcloudy): Need this for WindowsSubprocessTest.java.
# Remove this when release version Bazel sets SYSTEMDRIVE
# on Windows by default.
- "--test_env=SYSTEMDRIVE"
- "--test_timeout=1200"
test_targets:
- "--"
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/com/google/devtools/build/android/dexer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ java_library(
"//third_party:junit4",
"//third_party:mockito",
"//third_party:truth",
"@bazel_tools//tools/java/runfiles",
] + select({
"//external:has_androidsdk": ["//external:android/dx_jar_import"],
"//conditions:default": [],
Expand All @@ -54,9 +55,9 @@ java_test(
":tests",
],
jvm_flags = [
"-Dtestmaindexlist=$(location :test_main_dex_list.txt)",
"-Dtestinputjar=$(location :tests)",
"-Dtestinputjar2=$(location :testdata)",
"-Dtestmaindexlist=io_bazel/$(location :test_main_dex_list.txt)",
"-Dtestinputjar=io_bazel/$(location :tests)",
"-Dtestinputjar2=io_bazel/$(location :testdata)",
],
runtime_deps = [
":tests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.android.dex.Dex;
import com.android.dx.dex.code.PositionList;
import com.google.common.io.ByteStreams;
import com.google.devtools.build.runfiles.Runfiles;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.HashSet;
Expand All @@ -34,13 +34,12 @@
@RunWith(JUnit4.class)
public class DexBuilderTest {

private static final Path WORKING_DIR = Paths.get(System.getProperty("user.dir"));

@Test
public void testBuildDexArchive() throws Exception {
DexBuilder.Options options = new DexBuilder.Options();
// Use Jar file that has this test in it as the input Jar
options.inputJar = WORKING_DIR.resolve(System.getProperty("testinputjar"));
Runfiles runfiles = Runfiles.create();
options.inputJar = Paths.get(runfiles.rlocation(System.getProperty("testinputjar")));
options.outputZip =
FileSystems.getDefault().getPath(System.getenv("TEST_TMPDIR"), "dex_builder_test.zip");
options.maxThreads = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import com.google.devtools.build.runfiles.Runfiles;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
Expand All @@ -49,13 +50,23 @@
@RunWith(JUnit4.class)
public class DexFileMergerTest {

private static final Path WORKING_DIR = Paths.get(System.getProperty("user.dir"));
private static final Path INPUT_JAR = WORKING_DIR.resolve(System.getProperty("testinputjar"));
private static final Path INPUT_JAR2 = WORKING_DIR.resolve(System.getProperty("testinputjar2"));
private static final Path MAIN_DEX_LIST_FILE =
WORKING_DIR.resolve(System.getProperty("testmaindexlist"));
private static final Path INPUT_JAR;
private static final Path INPUT_JAR2;
private static final Path MAIN_DEX_LIST_FILE;
static final String DEX_PREFIX = "classes";

static {
try {
Runfiles runfiles = Runfiles.create();

INPUT_JAR = Paths.get(runfiles.rlocation(System.getProperty("testinputjar")));
INPUT_JAR2 = Paths.get(runfiles.rlocation(System.getProperty("testinputjar2")));
MAIN_DEX_LIST_FILE = Paths.get(runfiles.rlocation(System.getProperty("testmaindexlist")));
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}

/** Exercises DexFileMerger to write a single .dex file. */
@Test
public void testMergeDexArchive_singleOutputDex() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.runfiles.Runfiles;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystems;
Expand All @@ -43,13 +44,23 @@
@RunWith(JUnit4.class)
public class DexFileSplitterTest {

private static final Path WORKING_DIR = Paths.get(System.getProperty("user.dir"));
private static final Path INPUT_JAR = WORKING_DIR.resolve(System.getProperty("testinputjar"));
private static final Path INPUT_JAR2 = WORKING_DIR.resolve(System.getProperty("testinputjar2"));
private static final Path MAIN_DEX_LIST_FILE =
WORKING_DIR.resolve(System.getProperty("testmaindexlist"));
private static final Path INPUT_JAR;
private static final Path INPUT_JAR2;
private static final Path MAIN_DEX_LIST_FILE;
static final String DEX_PREFIX = "classes";

static {
try {
Runfiles runfiles = Runfiles.create();

INPUT_JAR = Paths.get(runfiles.rlocation(System.getProperty("testinputjar")));
INPUT_JAR2 = Paths.get(runfiles.rlocation(System.getProperty("testinputjar2")));
MAIN_DEX_LIST_FILE = Paths.get(runfiles.rlocation(System.getProperty("testmaindexlist")));
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}

@Test
public void testSingleInputSingleOutput() throws Exception {
Path dexArchive = buildDexArchive();
Expand Down

0 comments on commit 2200ffa

Please sign in to comment.