xref: /aosp_15_r20/system/linkerconfig/contents/section/vendor.cc (revision e5eeaa8e05bc25a862c0c861bda7c8a6bfb42dad)
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 // Namespace config for vendor processes.
18 
19 #include "linkerconfig/sectionbuilder.h"
20 
21 #include "linkerconfig/common.h"
22 #include "linkerconfig/environment.h"
23 #include "linkerconfig/namespacebuilder.h"
24 #include "linkerconfig/section.h"
25 
26 using android::linkerconfig::contents::SectionType;
27 using android::linkerconfig::modules::LibProvider;
28 using android::linkerconfig::modules::LibProviders;
29 using android::linkerconfig::modules::Namespace;
30 using android::linkerconfig::modules::Section;
31 
32 namespace android {
33 namespace linkerconfig {
34 namespace contents {
BuildVendorSection(Context & ctx)35 Section BuildVendorSection(Context& ctx) {
36   ctx.SetCurrentSection(SectionType::Vendor);
37   std::vector<Namespace> namespaces;
38 
39   namespaces.emplace_back(BuildVendorDefaultNamespace(ctx));
40   if (android::linkerconfig::modules::IsVendorVndkVersionDefined()) {
41     namespaces.emplace_back(BuildVndkNamespace(ctx, VndkUserPartition::Vendor));
42   }
43   namespaces.emplace_back(BuildSystemNamespace(ctx));
44   namespaces.emplace_back(BuildRsNamespace(ctx));
45 
46   if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
47     namespaces.emplace_back(BuildVndkInSystemNamespace(ctx));
48   }
49 
50   std::set<std::string> visible_apexes;
51 
52   // APEXes with public libs should be visible
53   for (const auto& apex : ctx.GetApexModules()) {
54     if (apex.public_libs.size() > 0) {
55       visible_apexes.insert(apex.name);
56     }
57   }
58 
59   LibProviders libs_providers = {};
60   if (android::linkerconfig::modules::IsVendorVndkVersionDefined()) {
61     libs_providers[":vndk"] = GetVndkProvider(ctx, VndkUserPartition::Vendor);
62   }
63 
64   AddVendorSubdirNamespaceProviders(ctx, libs_providers);
65 
66   return BuildSection(
67       ctx, "vendor", std::move(namespaces), visible_apexes, libs_providers);
68 }
69 }  // namespace contents
70 }  // namespace linkerconfig
71 }  // namespace android
72