• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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::Namespace;
28 using android::linkerconfig::modules::Section;
29 
30 namespace android {
31 namespace linkerconfig {
32 namespace contents {
BuildVendorSection(Context & ctx)33 Section BuildVendorSection(Context& ctx) {
34   ctx.SetCurrentSection(SectionType::Vendor);
35   std::vector<Namespace> namespaces;
36 
37   namespaces.emplace_back(BuildVendorDefaultNamespace(ctx));
38   namespaces.emplace_back(BuildVndkNamespace(ctx, VndkUserPartition::Vendor));
39   namespaces.emplace_back(BuildSystemNamespace(ctx));
40   namespaces.emplace_back(BuildRsNamespace(ctx));
41 
42   if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
43     namespaces.emplace_back(BuildVndkInSystemNamespace(ctx));
44   }
45 
46   std::set<std::string> visible_apexes;
47 
48   // APEXes with public libs should be visible
49   for (const auto& apex : ctx.GetApexModules()) {
50     if (apex.public_libs.size() > 0) {
51       visible_apexes.insert(apex.name);
52     }
53   }
54 
55   android::linkerconfig::modules::LibProviders libs_providers = {};
56   if (ctx.IsVndkAvailable()) {
57     libs_providers[":vndk"] = android::linkerconfig::modules::LibProvider{
58         "vndk",
59         std::bind(BuildVndkNamespace, ctx, VndkUserPartition::Vendor),
60         {Var("VNDK_SAMEPROCESS_LIBRARIES_VENDOR"),
61          Var("VNDK_CORE_LIBRARIES_VENDOR")},
62     };
63   }
64 
65   return BuildSection(
66       ctx, "vendor", std::move(namespaces), visible_apexes, libs_providers);
67 }
68 }  // namespace contents
69 }  // namespace linkerconfig
70 }  // namespace android
71