diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-11 15:42:40 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-11 15:42:40 +0000 |
commit | 873dd2f354cb2e35b1a0d103e41c664b70a1183e (patch) | |
tree | 8eb629a5d2491bd3ddff9b00bf6985ecef6cb2cf | |
parent | 77b4920fdc5ee4cd45f7591d49db9e01d3b20b3c (diff) | |
parent | cc72237faafba4a53c6314a6993757d7f22e217f (diff) | |
download | vogar-android13-frc-adbd-release.tar.gz |
Snap for 8712302 from cc72237faafba4a53c6314a6993757d7f22e217f to tm-frc-adbd-releaset_frc_adb_330444000android13-frc-adbd-release
Change-Id: Ie628498ba30164d4ec2059507c788bb2a56b7b87
-rw-r--r-- | src/vogar/ModeId.java | 16 | ||||
-rw-r--r-- | src/vogar/Vogar.java | 3 | ||||
-rw-r--r-- | src/vogar/android/AndroidSdk.java | 84 |
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)); } |