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