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 17package { 18 default_applicable_licenses: ["Android-Apache-2.0"], 19} 20 21cc_defaults { 22 name: "linkerconfig_defaults", 23 cflags: [ 24 "-Wall", 25 "-Werror", 26 "-Wextra", 27 ], 28 defaults: ["libapexutil-deps"], 29 shared_libs: [ 30 // Because the runtime apex depends on the shared libbase, 31 // linkerconfig can use it as shared as well to save more bits. 32 "libbase", 33 ], 34 static_libs: [ 35 "libapexutil", 36 "liblog_for_runtime_apex", 37 "libprotobuf-cpp-lite", 38 "libtinyxml2", 39 "lib_linker_config_proto_lite", 40 ], 41 target: { 42 host: { 43 static_libs: [ 44 "libicui18n", 45 "libicuuc", 46 ], 47 }, 48 not_windows: { 49 static_libs: ["libicuuc_stubdata"], 50 }, 51 }, 52 host_supported: true, 53} 54 55cc_defaults { 56 name: "linkerconfig_test_defaults", 57 defaults: ["linkerconfig_defaults"], 58 cflags: [ 59 "-g", 60 "-Wunused", 61 ], 62 test_suites: ["general-tests"], 63} 64 65cc_library_static { 66 name: "linkerconfig_modules", 67 defaults: [ "linkerconfig_defaults" ], 68 export_include_dirs: [ "modules/include" ], 69 srcs: [ 70 "modules/*.cc", 71 ], 72 generated_sources: ["apex-info-list-tinyxml"], 73 apex_available: [ 74 "com.android.runtime", 75 ], 76} 77 78cc_library_static { 79 name: "linkerconfig_contents", 80 defaults: [ "linkerconfig_defaults" ], 81 export_include_dirs: [ "contents/include" ], 82 static_libs: [ 83 "linkerconfig_modules", 84 ], 85 srcs: [ 86 "contents/namespace/*.cc", 87 "contents/section/*.cc", 88 "contents/configuration/*.cc", 89 "contents/context/*.cc", 90 "contents/common/*.cc", 91 ], 92 apex_available: [ 93 "com.android.runtime", 94 ], 95} 96 97cc_library_static { 98 name: "linkerconfig_generator", 99 defaults : [ "linkerconfig_defaults" ], 100 export_include_dirs: [ "generator/include" ], 101 static_libs: [ 102 "linkerconfig_modules", 103 "linkerconfig_contents", 104 ], 105 srcs: [ 106 "generator/*.cc", 107 ], 108 apex_available: [ 109 "com.android.runtime", 110 ], 111} 112 113cc_binary { 114 name: "linkerconfig", 115 defaults: [ "linkerconfig_defaults" ], 116 static_libs: [ 117 "linkerconfig_modules", 118 "linkerconfig_contents", 119 "linkerconfig_generator", 120 ], 121 srcs: [ 122 "main.cc", 123 ], 124 required: [ 125 // files from /system/etc 126 "sanitizer.libraries.txt", 127 ], 128 target: { 129 host: { 130 // Link libc++ and libbase statically on host for convenience(no need to set library paths) 131 stl: "c++_static", 132 static_libs: [ 133 "libbase", 134 ], 135 exclude_shared_libs: [ 136 "libbase", 137 ], 138 }, 139 }, 140 141 apex_available: [ 142 "com.android.runtime", 143 ], 144 145 sanitize: { 146 // linkerconfig should be able to run at the very early stage of boot process when 147 // /data/asan is not ready. So linkerconfig can't run with ASAN. 148 address: false, 149 }, 150} 151 152cc_test_host { 153 name: "linkerconfig_modules_unittest", 154 defaults: [ "linkerconfig_test_defaults" ], 155 srcs: [ 156 "modules/tests/*_test.cc", 157 ], 158 static_libs: [ 159 "libgmock", 160 "linkerconfig_modules", 161 ], 162 data: [ 163 "modules/tests/data/linker.config.*", 164 ], 165 test_options: { 166 unit_test: true, 167 }, 168} 169 170cc_test_host { 171 name: "linkerconfig_backward_compatibility_test", 172 defaults: [ "linkerconfig_test_defaults" ], 173 srcs: [ 174 "contents/tests/backward_compatibility/*_test.cc", 175 ], 176 static_libs: [ 177 "linkerconfig_modules", 178 "linkerconfig_contents", 179 ], 180 test_options: { 181 unit_test: true, 182 }, 183} 184 185cc_test_host { 186 name: "linkerconfig_generator_unittest", 187 defaults: [ "linkerconfig_test_defaults" ], 188 srcs: [ 189 "generator/tests/*_test.cc", 190 ], 191 static_libs: [ 192 "linkerconfig_modules", 193 "linkerconfig_contents", 194 "linkerconfig_generator", 195 ], 196 data: [ 197 "generator/tests/data/*.txt", 198 ], 199 test_options: { 200 unit_test: true, 201 }, 202} 203 204cc_test_host { 205 name: "linkerconfig_contents_fulltest", 206 defaults: [ "linkerconfig_test_defaults" ], 207 // TODO(b/231993627): Reenable isolated:true by deleting the explicit disable below 208 isolated: false, 209 local_include_dirs: [ 210 "contents/tests/configuration/include", 211 ], 212 srcs: [ 213 "contents/tests/configuration/*_test.cc", 214 ], 215 static_libs: [ 216 "libgmock", 217 "linkerconfig_modules", 218 "linkerconfig_contents", 219 ], 220 test_options: { 221 unit_test: true, 222 }, 223} 224 225prebuilt_etc { 226 name: "ld.config.recovery.txt", 227 recovery: true, 228 filename: "ld.config.txt", 229 src: ":generate_recovery_linker_config", 230} 231 232genrule { 233 name: "generate_recovery_linker_config", 234 recovery: true, 235 out: ["ld.config.txt"], 236 tools: ["linkerconfig"], 237 cmd: "$(location linkerconfig) --recovery --target $(genDir)", 238} 239 240sh_test_host { 241 name: "linkerconfig_diff_test", 242 src: "rundiff.sh", 243 filename: "linkerconfig_diff_test.sh", 244 test_config: "linkerconfig_diff_test.xml", 245 data: [ 246 "testdata/root/**/*", 247 "testdata/root/**/.*", // copy .keep files 248 "testdata/golden_output/**/*", 249 "testdata/prepare_root.sh", 250 ], 251 data_bins: [ 252 "conv_apex_manifest", 253 "conv_linker_config", 254 "linkerconfig", 255 ], 256 test_options: { 257 unit_test: true, 258 }, 259} 260