Jiakai Zhang | d539f86 | 2022-02-08 14:56:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <string> |
| 18 | #include <vector> |
| 19 | |
| 20 | #include "android-base/stringprintf.h" |
| 21 | #include "base/file_utils.h" |
| 22 | #include "base/globals.h" |
| 23 | |
| 24 | namespace art { |
| 25 | namespace testing { |
| 26 | |
| 27 | namespace { |
| 28 | |
| 29 | std::string GetDexFileName(const std::string& jar_prefix, bool host) { |
| 30 | std::string prefix(host ? GetAndroidRoot() : ""); |
| 31 | const char* apexPath = |
| 32 | (jar_prefix == "conscrypt") ? |
| 33 | kAndroidConscryptApexDefaultPath : |
| 34 | (jar_prefix == "core-icu4j" ? kAndroidI18nApexDefaultPath : kAndroidArtApexDefaultPath); |
| 35 | return android::base::StringPrintf( |
| 36 | "%s%s/javalib/%s.jar", prefix.c_str(), apexPath, jar_prefix.c_str()); |
| 37 | } |
| 38 | |
| 39 | } // namespace |
| 40 | |
| 41 | std::vector<std::string> GetLibCoreModuleNames(bool core_only) { |
| 42 | // Note: This must start with the CORE_IMG_JARS in Android.common_path.mk because that's what we |
| 43 | // use for compiling the boot.art image. It may contain additional modules from TEST_CORE_JARS. |
| 44 | |
| 45 | // CORE_IMG_JARS modules. |
| 46 | std::vector<std::string> modules{ |
| 47 | "core-oj", |
| 48 | "core-libart", |
| 49 | "okhttp", |
| 50 | "bouncycastle", |
| 51 | "apache-xml", |
| 52 | }; |
| 53 | |
| 54 | // Additional modules. |
| 55 | if (!core_only) { |
| 56 | modules.push_back("core-icu4j"); |
| 57 | modules.push_back("conscrypt"); |
| 58 | } |
| 59 | |
| 60 | return modules; |
| 61 | } |
| 62 | |
| 63 | std::vector<std::string> GetLibCoreDexFileNames(const std::vector<std::string>& modules) { |
| 64 | std::vector<std::string> result; |
| 65 | result.reserve(modules.size()); |
| 66 | for (const std::string& module : modules) { |
| 67 | result.push_back(GetDexFileName(module, !kIsTargetBuild)); |
| 68 | } |
| 69 | return result; |
| 70 | } |
| 71 | |
| 72 | std::vector<std::string> GetLibCoreDexFileNames(bool core_only) { |
| 73 | std::vector<std::string> modules = GetLibCoreModuleNames(core_only); |
| 74 | return GetLibCoreDexFileNames(modules); |
| 75 | } |
| 76 | |
| 77 | } // namespace testing |
| 78 | } // namespace art |