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/link.h" 18 19 #include "linkerconfig/log.h" 20 #include "linkerconfig/stringutil.h" 21 22 namespace android { 23 namespace linkerconfig { 24 namespace modules { 25 AddSharedLib(const std::vector<std::string> & lib_names)26void Link::AddSharedLib(const std::vector<std::string>& lib_names) { 27 if (!allow_all_shared_libs_) { 28 shared_libs_.insert(shared_libs_.end(), lib_names.begin(), lib_names.end()); 29 } 30 } 31 AllowAllSharedLibs()32void Link::AllowAllSharedLibs() { 33 if (!allow_all_shared_libs_) { 34 shared_libs_.clear(); 35 allow_all_shared_libs_ = true; 36 } 37 } 38 WriteConfig(ConfigWriter & writer) const39void Link::WriteConfig(ConfigWriter& writer) const { 40 const auto prefix = 41 "namespace." + origin_namespace_ + ".link." + target_namespace_ + "."; 42 if (allow_all_shared_libs_) { 43 writer.WriteLine(prefix + "allow_all_shared_libs = true"); 44 } else if (!shared_libs_.empty()) { 45 writer.WriteVar(prefix + "shared_libs", MergeLibs(shared_libs_)); 46 } else { 47 LOG(WARNING) << "Ignored empty shared libs link from " << origin_namespace_ 48 << " to " << target_namespace_; 49 } 50 } 51 52 } // namespace modules 53 } // namespace linkerconfig 54 } // namespace android 55