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 17cc_defaults { 18 name: "linkerconfig_defaults", 19 cflags: [ 20 "-Wall", 21 "-Werror", 22 "-Wextra", 23 ], 24 defaults: ["libapexutil-deps"], 25 static_libs: [ 26 "libapexutil", 27 "libbase", 28 "liblog", 29 ], 30 host_supported: true, 31} 32 33cc_defaults { 34 name: "linkerconfig_test_defaults", 35 defaults: ["linkerconfig_defaults"], 36 cflags: [ 37 "-g", 38 "-Wunused", 39 ], 40 test_suites: ["general-tests"], 41} 42 43cc_library_static { 44 name: "linkerconfig_modules", 45 defaults: [ "linkerconfig_defaults" ], 46 export_include_dirs: [ "modules/include" ], 47 srcs: [ 48 "modules/*.cc", 49 ], 50} 51 52cc_library_static { 53 name: "linkerconfig_contents", 54 defaults: [ "linkerconfig_defaults" ], 55 export_include_dirs: [ "contents/include" ], 56 static_libs: [ 57 "linkerconfig_modules", 58 ], 59 srcs: [ 60 "contents/namespace/*.cc", 61 "contents/section/*.cc", 62 "contents/configuration/*.cc", 63 "contents/context/*.cc", 64 "contents/common/*.cc", 65 ], 66} 67 68cc_library_static { 69 name: "linkerconfig_generator", 70 defaults : [ "linkerconfig_defaults" ], 71 export_include_dirs: [ "generator/include" ], 72 static_libs: [ 73 "linkerconfig_modules", 74 "linkerconfig_contents", 75 "libc++fs", 76 ], 77 srcs: [ 78 "generator/*.cc", 79 ], 80} 81 82cc_binary { 83 name: "linkerconfig", 84 defaults: [ "linkerconfig_defaults" ], 85 static_libs: [ 86 "linkerconfig_modules", 87 "linkerconfig_contents", 88 "linkerconfig_generator", 89 ], 90 srcs: [ 91 "main.cc", 92 ], 93 static_executable: true, 94 required: [ 95 // files from /system/etc 96 "sanitizer.libraries.txt", 97 "vndkcorevariant.libraries.txt", 98 // Note that even thought linkerconfig requires at least one version of VNDK APEXes, 99 // we can't list it here because the exact version is unknown at build-time. It is decided 100 // at runtime according to ro.vndk.version (or ro.product.vndk.version) 101 ], 102} 103 104cc_test { 105 name: "linkerconfig_modules_unittest", 106 defaults: [ "linkerconfig_test_defaults" ], 107 srcs: [ 108 "modules/tests/*_test.cc", 109 ], 110 static_libs: [ 111 "libgmock", 112 "linkerconfig_modules", 113 ], 114} 115 116cc_test { 117 name: "linkerconfig_backward_compatibility_test", 118 defaults: [ "linkerconfig_test_defaults" ], 119 srcs: [ 120 "contents/tests/backward_compatibility/*_test.cc", 121 ], 122 static_libs: [ 123 "linkerconfig_modules", 124 "linkerconfig_contents", 125 ], 126} 127 128cc_test { 129 name: "linkerconfig_generator_unittest", 130 defaults: [ "linkerconfig_test_defaults" ], 131 srcs: [ 132 "generator/tests/*_test.cc", 133 ], 134 static_libs: [ 135 "linkerconfig_modules", 136 "linkerconfig_contents", 137 "linkerconfig_generator", 138 ], 139 data: [ 140 "generator/tests/data/*.txt", 141 ], 142} 143 144cc_test { 145 name: "linkerconfig_contents_fulltest", 146 defaults: [ "linkerconfig_test_defaults" ], 147 local_include_dirs: [ 148 "contents/tests/configuration/include", 149 ], 150 srcs: [ 151 "contents/tests/configuration/*_test.cc", 152 ], 153 static_libs: [ 154 "linkerconfig_modules", 155 "linkerconfig_contents", 156 ], 157} 158 159prebuilt_etc { 160 name: "ld.config.recovery.txt", 161 recovery: true, 162 filename: "ld.config.txt", 163 src: ":generate_recovery_linker_config", 164} 165 166genrule { 167 name: "generate_recovery_linker_config", 168 recovery: true, 169 out: ["ld.config.txt"], 170 tools: ["linkerconfig"], 171 cmd: "$(location linkerconfig) --recovery --target $(genDir)", 172} 173