aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-27 01:19:56 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-27 01:19:56 +0000
commit80b356fda6c27dceec0cd32f6bbc000101a3015b (patch)
tree8eb629a5d2491bd3ddff9b00bf6985ecef6cb2cf
parent415357b7203e42e0fc728be752cd32bfc601f628 (diff)
parent550b7de96aa98392d4cc43418dc7c6773515624b (diff)
downloadvogar-android13-qpr1-s3-release.tar.gz
Change-Id: I933de348b13f0ca2dad7df26c5fb697a502748c0
-rw-r--r--src/vogar/ModeId.java16
-rw-r--r--src/vogar/Vogar.java3
-rw-r--r--src/vogar/android/AndroidSdk.java84
3 files changed, 58 insertions, 45 deletions
diff --git a/src/vogar/ModeId.java b/src/vogar/ModeId.java
index 613722a..c918104 100644
--- a/src/vogar/ModeId.java
+++ b/src/vogar/ModeId.java
@@ -35,31 +35,35 @@ public enum ModeId {
/**
* $BOOTCLASSPATH for art+libcore only.
* (Intended for use with dalvikvm only.)
- * See TARGET_TEST_CORE_JARS in android/art/build/Android.common_path.mk
*/
private static final String[] DEVICE_JARS = new String[] {
+ // ART module BCP libraries. See CORE_IMG_JARS in art/build/Android.common_path.mk.
"core-oj",
"core-libart",
- "core-icu4j",
- "conscrypt",
"okhttp",
"bouncycastle",
"apache-xml",
+ // Stubs for dependencies from other APEX modules. If tests require it, this could use
+ // platform (xxx.module.platform.api.stubs) or even intra-core
+ // (xxx.module.intra.core.api.stubs) API stubs. However it's currently not necessary, so
+ // let's stick to public APIs for hygiene.
+ "i18n.module.public.api.stubs",
+ "conscrypt.module.public.api.stubs",
};
/**
* $BOOTCLASSPATH for art+libcore only (host version).
* (Intended for use with dalvikvm only.)
- * See HOST_TEST_CORE_JARS in android/art/build/Android.common_path.mk
+ * See HOST_TEST_CORE_JARS in art/build/Android.common_path.mk
*/
private static final String[] HOST_JARS = new String[] {
"core-oj-hostdex",
"core-libart-hostdex",
- "core-icu4j-hostdex",
- "conscrypt-hostdex",
"okhttp-hostdex",
"bouncycastle-hostdex",
"apache-xml-hostdex",
+ "core-icu4j-hostdex",
+ "conscrypt-hostdex",
};
/**
diff --git a/src/vogar/Vogar.java b/src/vogar/Vogar.java
index 5a51ff4..59a0616 100644
--- a/src/vogar/Vogar.java
+++ b/src/vogar/Vogar.java
@@ -665,7 +665,8 @@ public final class Vogar {
AndroidSdk androidSdk = null;
if (modeId.requiresAndroidSdk()) {
- androidSdk = AndroidSdk.createAndroidSdk(console, mkdir, modeId, language);
+ androidSdk = AndroidSdk.createAndroidSdk(console, mkdir, modeId, language,
+ !actionFiles.isEmpty());
}
if (runnerType == null) {
diff --git a/src/vogar/android/AndroidSdk.java b/src/vogar/android/AndroidSdk.java
index c8873c8..15c936d 100644
--- a/src/vogar/android/AndroidSdk.java
+++ b/src/vogar/android/AndroidSdk.java
@@ -70,7 +70,8 @@ public class AndroidSdk {
* compilation class path and android jar path.
*/
public static AndroidSdk createAndroidSdk(
- Log log, Mkdir mkdir, ModeId modeId, Language language) {
+ Log log, Mkdir mkdir, ModeId modeId, Language language,
+ boolean supportBuildFromSource) {
List<String> path = new Command.Builder(log).args("which", ARBITRARY_BUILD_TOOL_NAME)
.permitNonZeroExitStatus(true)
.execute();
@@ -175,39 +176,43 @@ public class AndroidSdk {
desugarJarPath = desugarJar.getPath();
- String pattern = outDir +
- "target/common/obj/JAVA_LIBRARIES/%s_intermediates/classes";
- if (modeId.isHost()) {
- pattern = outDir + "host/common/obj/JAVA_LIBRARIES/%s_intermediates/classes";
- }
- pattern += ".jar";
-
- String[] jarNames = modeId.getJarNames();
- compilationClasspath = new File[jarNames.length];
- List<String> missingJars = new ArrayList<>();
- for (int i = 0; i < jarNames.length; i++) {
- String jar = jarNames[i];
- File file;
+ if (!supportBuildFromSource) {
+ compilationClasspath = new File[]{};
+ } else {
+ String pattern = outDir +
+ "target/common/obj/JAVA_LIBRARIES/%s_intermediates/classes";
if (modeId.isHost()) {
- if ("conscrypt-hostdex".equals(jar)) {
- jar = "conscrypt-host-hostdex";
- } else if ("core-icu4j-hostdex".equals(jar)) {
- jar = "core-icu4j-host-hostdex";
- }
- file = new File(String.format(pattern, jar));
- } else {
- file = findApexJar(jar, pattern);
- if (file.exists()) {
- log.verbose("Using jar " + jar + " from " + file);
+ pattern = outDir + "host/common/obj/JAVA_LIBRARIES/%s_intermediates/classes";
+ }
+ pattern += ".jar";
+
+ String[] jarNames = modeId.getJarNames();
+ compilationClasspath = new File[jarNames.length];
+ List<String> missingJars = new ArrayList<>();
+ for (int i = 0; i < jarNames.length; i++) {
+ String jar = jarNames[i];
+ File file;
+ if (modeId.isHost()) {
+ if ("conscrypt-hostdex".equals(jar)) {
+ jar = "conscrypt-host-hostdex";
+ } else if ("core-icu4j-hostdex".equals(jar)) {
+ jar = "core-icu4j-host-hostdex";
+ }
+ file = new File(String.format(pattern, jar));
} else {
- missingJars.add(jar);
+ file = findApexJar(jar, pattern);
+ if (file.exists()) {
+ log.verbose("Using jar " + jar + " from " + file);
+ } else {
+ missingJars.add(jar);
+ }
}
+ compilationClasspath[i] = file;
+ }
+ if (!missingJars.isEmpty()) {
+ logMissingJars(log, missingJars);
+ throw new RuntimeException("Unable to locate all jars needed for compilation");
}
- compilationClasspath[i] = file;
- }
- if (!missingJars.isEmpty()) {
- logMissingJars(log, missingJars);
- throw new RuntimeException("Unable to locate all jars needed for compilation");
}
} else {
throw new RuntimeException("Couldn't derive Android home from "
@@ -222,7 +227,9 @@ public class AndroidSdk {
private static void logMissingJars(Log log, List<String> missingJars) {
StringBuilder makeCommand = new StringBuilder().append("m ");
for (String jarName : missingJars) {
- log.warn("Missing compilation jar " + jarName + " from APEX " + apexForJar(jarName));
+ String apex = apexForJar(jarName);
+ log.warn("Missing compilation jar " + jarName +
+ (apex != null ? " from APEX " + apex : ""));
makeCommand.append(jarName).append(" ");
}
log.info("Suggested make command: " + makeCommand);
@@ -230,10 +237,8 @@ public class AndroidSdk {
/** Returns the name of the APEX a particular jar might be located in */
private static String apexForJar(String jar) {
- if ("conscrypt".equals(jar)) {
- return "com.android.conscrypt";
- } else if ("core-icu4j".equals(jar)) {
- return "com.android.i18n";
+ if (jar.endsWith(".api.stubs")) {
+ return null; // API stubs aren't in any APEX.
}
return "com.android.art.testing";
}
@@ -244,9 +249,12 @@ public class AndroidSdk {
* always non-null but possibly non-existent and so the caller should check.
*/
private static File findApexJar(String jar, String filePattern) {
- File file = new File(String.format(filePattern, jar + "." + apexForJar(jar)));
- if (file.exists()) {
- return file;
+ String apex = apexForJar(jar);
+ if (apex != null) {
+ File file = new File(String.format(filePattern, jar + "." + apex));
+ if (file.exists()) {
+ return file;
+ }
}
return new File(String.format(filePattern, jar));
}