blob: 289af0ad2f7aed7523fa94981b3cb4f39ecca99d [file] [log] [blame]
Kiyoung Kim61496fe2020-01-29 14:56:54 +09001/*
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
24using android::linkerconfig::contents::SectionType;
25using android::linkerconfig::modules::ApexInfo;
26using android::linkerconfig::modules::Namespace;
27using android::linkerconfig::modules::Section;
28
29namespace android {
30namespace linkerconfig {
31namespace contents {
32Section BuildApexArtSection(Context& ctx, const ApexInfo& apex_info) {
33 std::vector<Namespace> namespaces;
34
35 ctx.SetCurrentSection(SectionType::Other);
36
Martin Stjernholm832a4d22021-04-13 16:44:18 +010037 namespaces.emplace_back(BuildApexArtDefaultNamespace(ctx, apex_info));
Kiyoung Kim61496fe2020-01-29 14:56:54 +090038 namespaces.emplace_back(BuildApexPlatformNamespace(ctx));
Martin Stjernholmd1ad9bc2021-05-11 22:54:07 +010039 namespaces.emplace_back(BuildArtNamespace(ctx, apex_info, false));
Kiyoung Kim61496fe2020-01-29 14:56:54 +090040
Jooyung Hanbd7e5192020-11-06 10:18:03 +090041 std::set<std::string> visible_apexes;
Jooyung Han52ccfa72020-09-01 13:49:27 +090042
Jooyung Hanbd7e5192020-11-06 10:18:03 +090043 // APEXes with JNI libs or public libs should be visible
Jooyung Han52ccfa72020-09-01 13:49:27 +090044 for (const auto& apex : ctx.GetApexModules()) {
Jooyung Hanbd7e5192020-11-06 10:18:03 +090045 if (apex.jni_libs.size() > 0 || apex.public_libs.size() > 0) {
Jooyung Han52ccfa72020-09-01 13:49:27 +090046 visible_apexes.insert(apex.name);
47 }
48 }
49
50 return BuildSection(
51 ctx, apex_info.name, std::move(namespaces), visible_apexes);
Kiyoung Kim61496fe2020-01-29 14:56:54 +090052}
53} // namespace contents
54} // namespace linkerconfig
55} // namespace android