1 /*
2 * Copyright (C) 2019 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 "linkerconfig/common.h"
20 #include "linkerconfig/context.h"
21 #include "linkerconfig/environment.h"
22 #include "linkerconfig/namespacebuilder.h"
23 #include "linkerconfig/section.h"
24
25 using android::linkerconfig::contents::SectionType;
26 using android::linkerconfig::modules::Namespace;
27 using android::linkerconfig::modules::Section;
28
29 namespace android {
30 namespace linkerconfig {
31 namespace contents {
BuildSystemSection(Context & ctx)32 Section BuildSystemSection(Context& ctx) {
33 ctx.SetCurrentSection(SectionType::System);
34 std::vector<Namespace> namespaces;
35
36 namespaces.emplace_back(BuildSystemDefaultNamespace(ctx));
37 if (android::linkerconfig::modules::IsTreblelizedDevice()) {
38 namespaces.emplace_back(BuildSphalNamespace(ctx));
39 namespaces.emplace_back(BuildRsNamespace(ctx));
40 namespaces.emplace_back(BuildProductNamespace(ctx, "product"));
41 if (ctx.IsVndkAvailable()) {
42 if (android::linkerconfig::modules::IsVendorVndkVersionDefined()) {
43 namespaces.emplace_back(
44 BuildVndkNamespace(ctx, VndkUserPartition::Vendor));
45 }
46 if (android::linkerconfig::modules::IsProductVndkVersionDefined()) {
47 namespaces.emplace_back(
48 BuildVndkNamespace(ctx, VndkUserPartition::Product));
49 }
50 }
51 }
52
53 std::set<std::string> visible_apexes;
54
55 // APEXes with JNI libs or public libs should be visible
56 for (const auto& apex : ctx.GetApexModules()) {
57 if (apex.jni_libs.size() > 0 || apex.public_libs.size() > 0) {
58 visible_apexes.insert(apex.name);
59 }
60 }
61
62 return BuildSection(ctx, "system", std::move(namespaces), visible_apexes);
63 }
64 } // namespace contents
65 } // namespace linkerconfig
66 } // namespace android
67