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 #include "linkerconfig/sectionbuilder.h" 17 18 #include "linkerconfig/common.h" 19 #include "linkerconfig/log.h" 20 #include "linkerconfig/namespace.h" 21 #include "linkerconfig/namespacebuilder.h" 22 #include "linkerconfig/section.h" 23 24 namespace android { 25 namespace linkerconfig { 26 namespace contents { 27 28 using modules::Namespace; 29 using modules::Section; 30 31 Section BuildSection(const Context& ctx, const std::string& name, 32 std::vector<Namespace>&& namespaces, 33 const std::vector<std::string>& visible_apexes) { 34 // add additional visible APEX namespaces 35 for (const auto& apex : ctx.GetApexModules()) { 36 if (std::find(visible_apexes.begin(), visible_apexes.end(), apex.name) != 37 visible_apexes.end()) { 38 auto ns = ctx.BuildApexNamespace(apex, true); 39 namespaces.push_back(std::move(ns)); 40 } 41 } 42 43 // resolve provide/require constraints 44 Section section(std::move(name), std::move(namespaces)); 45 if (auto res = section.Resolve(ctx); !res.ok()) { 46 LOG(ERROR) << res.error(); 47 } 48 49 AddStandardSystemLinks(ctx, §ion); 50 return section; 51 } 52 } // namespace contents 53 } // namespace linkerconfig 54 } // namespace android 55