Kiyoung Kim | 61496fe | 2020-01-29 14:56:54 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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 "linkerconfig/sectionbuilder.h" |
| 18 | |
| 19 | #include <vector> |
| 20 | |
| 21 | #include "linkerconfig/namespacebuilder.h" |
| 22 | #include "linkerconfig/section.h" |
| 23 | |
| 24 | using android::linkerconfig::contents::SectionType; |
| 25 | using android::linkerconfig::modules::ApexInfo; |
| 26 | using android::linkerconfig::modules::Namespace; |
| 27 | using android::linkerconfig::modules::Section; |
| 28 | |
| 29 | namespace android { |
| 30 | namespace linkerconfig { |
| 31 | namespace contents { |
| 32 | Section BuildApexArtSection(Context& ctx, const ApexInfo& apex_info) { |
| 33 | std::vector<Namespace> namespaces; |
| 34 | |
| 35 | ctx.SetCurrentSection(SectionType::Other); |
| 36 | |
Martin Stjernholm | 832a4d2 | 2021-04-13 16:44:18 +0100 | [diff] [blame] | 37 | namespaces.emplace_back(BuildApexArtDefaultNamespace(ctx, apex_info)); |
Kiyoung Kim | 61496fe | 2020-01-29 14:56:54 +0900 | [diff] [blame] | 38 | namespaces.emplace_back(BuildApexPlatformNamespace(ctx)); |
Martin Stjernholm | d1ad9bc | 2021-05-11 22:54:07 +0100 | [diff] [blame^] | 39 | namespaces.emplace_back(BuildArtNamespace(ctx, apex_info, false)); |
Kiyoung Kim | 61496fe | 2020-01-29 14:56:54 +0900 | [diff] [blame] | 40 | |
Jooyung Han | bd7e519 | 2020-11-06 10:18:03 +0900 | [diff] [blame] | 41 | std::set<std::string> visible_apexes; |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 42 | |
Jooyung Han | bd7e519 | 2020-11-06 10:18:03 +0900 | [diff] [blame] | 43 | // APEXes with JNI libs or public libs should be visible |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 44 | for (const auto& apex : ctx.GetApexModules()) { |
Jooyung Han | bd7e519 | 2020-11-06 10:18:03 +0900 | [diff] [blame] | 45 | if (apex.jni_libs.size() > 0 || apex.public_libs.size() > 0) { |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 46 | visible_apexes.insert(apex.name); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return BuildSection( |
| 51 | ctx, apex_info.name, std::move(namespaces), visible_apexes); |
Kiyoung Kim | 61496fe | 2020-01-29 14:56:54 +0900 | [diff] [blame] | 52 | } |
| 53 | } // namespace contents |
| 54 | } // namespace linkerconfig |
| 55 | } // namespace android |