Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 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 | |
Bob Badour | 2da5198 | 2021-02-03 22:30:12 -0800 | [diff] [blame] | 17 | package { |
| 18 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 19 | } |
| 20 | |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 21 | cc_defaults { |
| 22 | name: "linkerconfig_defaults", |
| 23 | cflags: [ |
| 24 | "-Wall", |
| 25 | "-Werror", |
| 26 | "-Wextra", |
| 27 | ], |
Jooyung Han | 86b57f6 | 2020-01-06 18:09:30 +0900 | [diff] [blame] | 28 | defaults: ["libapexutil-deps"], |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 29 | static_libs: [ |
Jooyung Han | 86b57f6 | 2020-01-06 18:09:30 +0900 | [diff] [blame] | 30 | "libapexutil", |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 31 | "libbase", |
| 32 | "liblog", |
Kiyoung Kim | 197857e | 2020-10-06 17:07:25 +0900 | [diff] [blame] | 33 | "libprotobuf-cpp-lite", |
Jooyung Han | b632392 | 2020-08-11 08:56:29 +0000 | [diff] [blame] | 34 | "libxml2", |
Kiyoung Kim | 197857e | 2020-10-06 17:07:25 +0900 | [diff] [blame] | 35 | "lib_linker_config_proto_lite", |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 36 | ], |
Jooyung Han | b632392 | 2020-08-11 08:56:29 +0000 | [diff] [blame] | 37 | target: { |
| 38 | host: { |
| 39 | static_libs: [ |
| 40 | "libicui18n", |
| 41 | "libicuuc", |
| 42 | ], |
| 43 | }, |
| 44 | not_windows: { |
| 45 | static_libs: ["libicuuc_stubdata"], |
| 46 | }, |
| 47 | }, |
Jooyung Han | a3d5d09 | 2019-09-26 23:23:50 +0900 | [diff] [blame] | 48 | host_supported: true, |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 49 | } |
| 50 | |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 51 | cc_defaults { |
| 52 | name: "linkerconfig_test_defaults", |
| 53 | defaults: ["linkerconfig_defaults"], |
| 54 | cflags: [ |
| 55 | "-g", |
| 56 | "-Wunused", |
| 57 | ], |
| 58 | test_suites: ["general-tests"], |
| 59 | } |
| 60 | |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 61 | cc_library_static { |
| 62 | name: "linkerconfig_modules", |
| 63 | defaults: [ "linkerconfig_defaults" ], |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 64 | export_include_dirs: [ "modules/include" ], |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 65 | srcs: [ |
| 66 | "modules/*.cc", |
| 67 | ], |
Jooyung Han | b632392 | 2020-08-11 08:56:29 +0000 | [diff] [blame] | 68 | generated_sources: ["apex-info-list"], |
Kiyoung Kim | b164506 | 2020-11-30 14:58:47 +0900 | [diff] [blame] | 69 | apex_available: [ |
| 70 | "//apex_available:platform", |
| 71 | "com.android.runtime", |
| 72 | ], |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 73 | } |
| 74 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 75 | cc_library_static { |
| 76 | name: "linkerconfig_contents", |
| 77 | defaults: [ "linkerconfig_defaults" ], |
| 78 | export_include_dirs: [ "contents/include" ], |
| 79 | static_libs: [ |
| 80 | "linkerconfig_modules", |
| 81 | ], |
| 82 | srcs: [ |
| 83 | "contents/namespace/*.cc", |
| 84 | "contents/section/*.cc", |
| 85 | "contents/configuration/*.cc", |
| 86 | "contents/context/*.cc", |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 87 | "contents/common/*.cc", |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 88 | ], |
Kiyoung Kim | b164506 | 2020-11-30 14:58:47 +0900 | [diff] [blame] | 89 | apex_available: [ |
| 90 | "//apex_available:platform", |
| 91 | "com.android.runtime", |
| 92 | ], |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 93 | } |
| 94 | |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 95 | cc_library_static { |
| 96 | name: "linkerconfig_generator", |
| 97 | defaults : [ "linkerconfig_defaults" ], |
| 98 | export_include_dirs: [ "generator/include" ], |
Kiyoung Kim | e9a77fe | 2019-05-23 11:04:20 +0900 | [diff] [blame] | 99 | static_libs: [ |
| 100 | "linkerconfig_modules", |
| 101 | "linkerconfig_contents", |
| 102 | ], |
| 103 | srcs: [ |
| 104 | "generator/*.cc", |
Kiyoung Kim | 15e3835 | 2019-07-11 17:07:03 +0900 | [diff] [blame] | 105 | ], |
Kiyoung Kim | b164506 | 2020-11-30 14:58:47 +0900 | [diff] [blame] | 106 | apex_available: [ |
| 107 | "//apex_available:platform", |
| 108 | "com.android.runtime", |
| 109 | ], |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | cc_binary { |
| 113 | name: "linkerconfig", |
| 114 | defaults: [ "linkerconfig_defaults" ], |
| 115 | static_libs: [ |
| 116 | "linkerconfig_modules", |
| 117 | "linkerconfig_contents", |
| 118 | "linkerconfig_generator", |
| 119 | ], |
| 120 | srcs: [ |
| 121 | "main.cc", |
| 122 | ], |
Jooyung Han | 3cb5bcd | 2020-02-12 04:21:16 +0900 | [diff] [blame] | 123 | required: [ |
| 124 | // files from /system/etc |
| 125 | "sanitizer.libraries.txt", |
| 126 | "vndkcorevariant.libraries.txt", |
Jooyung Han | 7c2b73a | 2020-02-12 08:53:51 +0900 | [diff] [blame] | 127 | // Note that even thought linkerconfig requires at least one version of VNDK APEXes, |
| 128 | // we can't list it here because the exact version is unknown at build-time. It is decided |
| 129 | // at runtime according to ro.vndk.version (or ro.product.vndk.version) |
Jooyung Han | 3cb5bcd | 2020-02-12 04:21:16 +0900 | [diff] [blame] | 130 | ], |
Martin Stjernholm | 908bfdb | 2020-08-07 19:00:55 +0100 | [diff] [blame] | 131 | target: { |
| 132 | android: { |
| 133 | // This binary needs to be static on device, but it's also packaged |
| 134 | // as a host prebuilt in runtime-module-host-exports. On host it |
| 135 | // should link all libraries statically except libc and other system |
| 136 | // libraries, so enable this only on device. |
| 137 | static_executable: true, |
| 138 | }, |
Martin Stjernholm | aefc84e | 2020-09-01 19:27:53 +0100 | [diff] [blame] | 139 | host: { |
| 140 | stl: "c++_static", // Link libc++ statically. |
| 141 | }, |
Martin Stjernholm | 908bfdb | 2020-08-07 19:00:55 +0100 | [diff] [blame] | 142 | }, |
Yi Kong | 867b202 | 2020-10-12 00:31:18 +0800 | [diff] [blame] | 143 | |
| 144 | // Device does not boot when global ThinLTO is enabled for linkerconfig. |
| 145 | // http://b/170573443 |
| 146 | lto: { |
| 147 | never: true, |
| 148 | }, |
Kiyoung Kim | b164506 | 2020-11-30 14:58:47 +0900 | [diff] [blame] | 149 | |
| 150 | apex_available: [ |
| 151 | "//apex_available:platform", |
| 152 | "com.android.runtime", |
| 153 | ], |
Kiyoung Kim | e9a77fe | 2019-05-23 11:04:20 +0900 | [diff] [blame] | 154 | } |
| 155 | |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 156 | cc_test { |
| 157 | name: "linkerconfig_modules_unittest", |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 158 | defaults: [ "linkerconfig_test_defaults" ], |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 159 | srcs: [ |
| 160 | "modules/tests/*_test.cc", |
| 161 | ], |
| 162 | static_libs: [ |
Jooyung Han | 33a9505 | 2019-12-06 19:47:30 +0900 | [diff] [blame] | 163 | "libgmock", |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 164 | "linkerconfig_modules", |
Kiyoung Kim | b972763 | 2020-12-08 16:14:57 +0900 | [diff] [blame] | 165 | "libc++fs", |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 166 | ], |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 167 | data: [ |
| 168 | "modules/tests/data/linker.config.*", |
| 169 | ], |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | cc_test { |
| 173 | name: "linkerconfig_backward_compatibility_test", |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 174 | defaults: [ "linkerconfig_test_defaults" ], |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 175 | srcs: [ |
| 176 | "contents/tests/backward_compatibility/*_test.cc", |
| 177 | ], |
| 178 | static_libs: [ |
| 179 | "linkerconfig_modules", |
| 180 | "linkerconfig_contents", |
| 181 | ], |
Kiyoung Kim | 15e3835 | 2019-07-11 17:07:03 +0900 | [diff] [blame] | 182 | } |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 183 | |
| 184 | cc_test { |
| 185 | name: "linkerconfig_generator_unittest", |
| 186 | defaults: [ "linkerconfig_test_defaults" ], |
| 187 | srcs: [ |
| 188 | "generator/tests/*_test.cc", |
| 189 | ], |
| 190 | static_libs: [ |
| 191 | "linkerconfig_modules", |
| 192 | "linkerconfig_contents", |
| 193 | "linkerconfig_generator", |
| 194 | ], |
| 195 | data: [ |
| 196 | "generator/tests/data/*.txt", |
| 197 | ], |
Kiyoung Kim | 84cbf00 | 2019-08-21 19:46:51 +0900 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | cc_test { |
| 201 | name: "linkerconfig_contents_fulltest", |
| 202 | defaults: [ "linkerconfig_test_defaults" ], |
| 203 | local_include_dirs: [ |
| 204 | "contents/tests/configuration/include", |
| 205 | ], |
| 206 | srcs: [ |
| 207 | "contents/tests/configuration/*_test.cc", |
| 208 | ], |
| 209 | static_libs: [ |
| 210 | "linkerconfig_modules", |
| 211 | "linkerconfig_contents", |
| 212 | ], |
Kiyoung Kim | 722dad6 | 2019-12-19 15:59:55 +0900 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | prebuilt_etc { |
| 216 | name: "ld.config.recovery.txt", |
| 217 | recovery: true, |
| 218 | filename: "ld.config.txt", |
| 219 | src: ":generate_recovery_linker_config", |
| 220 | } |
| 221 | |
| 222 | genrule { |
| 223 | name: "generate_recovery_linker_config", |
| 224 | recovery: true, |
Kiyoung Kim | 5c8366d | 2019-12-30 18:43:00 +0900 | [diff] [blame] | 225 | out: ["ld.config.txt"], |
Kiyoung Kim | 722dad6 | 2019-12-19 15:59:55 +0900 | [diff] [blame] | 226 | tools: ["linkerconfig"], |
Kiyoung Kim | 5c8366d | 2019-12-30 18:43:00 +0900 | [diff] [blame] | 227 | cmd: "$(location linkerconfig) --recovery --target $(genDir)", |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 228 | } |
Jooyung Han | fcaa89a | 2020-03-20 18:20:23 +0900 | [diff] [blame] | 229 | |
| 230 | genrule { |
| 231 | name: "linkerconfig_diff_test_host_tools", |
| 232 | out: ["linkerconfig_diff_test_host_tools.zip"], |
Kiyoung Kim | 197857e | 2020-10-06 17:07:25 +0900 | [diff] [blame] | 233 | tools: ["conv_apex_manifest", "conv_linker_config", "linkerconfig", "soong_zip"], |
Jooyung Han | fcaa89a | 2020-03-20 18:20:23 +0900 | [diff] [blame] | 234 | cmd: "HOST_OUT_BIN=$$(dirname $(location conv_apex_manifest)) && " + |
| 235 | "HOST_SOONG_OUT=$$(dirname $$HOST_OUT_BIN) && " + |
| 236 | "LIBCPLUSPLUS=$$(find $${HOST_SOONG_OUT}/lib64 -name \"libc++.*\") && " + |
| 237 | "mkdir -p $(genDir)/tools/bin && " + |
| 238 | "mkdir -p $(genDir)/tools/lib64 && " + |
| 239 | "cp $(location conv_apex_manifest) $(genDir)/tools/bin && " + |
Kiyoung Kim | 197857e | 2020-10-06 17:07:25 +0900 | [diff] [blame] | 240 | "cp $(location conv_linker_config) $(genDir)/tools/bin && " + |
Jooyung Han | fcaa89a | 2020-03-20 18:20:23 +0900 | [diff] [blame] | 241 | "cp $(location linkerconfig) $(genDir)/tools/bin && " + |
| 242 | "cp $$LIBCPLUSPLUS $(genDir)/tools/lib64 && " + |
| 243 | "$(location soong_zip) -C $(genDir)/tools -D $(genDir)/tools -o $(out)", |
| 244 | } |
| 245 | |
| 246 | sh_test_host { |
| 247 | name: "linkerconfig_diff_test", |
| 248 | src: "rundiff.sh", |
| 249 | filename: "linkerconfig_diff_test.sh", |
Jooyung Han | fcaa89a | 2020-03-20 18:20:23 +0900 | [diff] [blame] | 250 | test_config: "linkerconfig_diff_test.xml", |
| 251 | data: [ |
Jooyung Han | a8df505 | 2022-01-26 16:25:30 +0900 | [diff] [blame] | 252 | "testdata/root/**/*", |
| 253 | "testdata/root/**/.*", // copy .keep files |
| 254 | "testdata/golden_output/**/*", |
| 255 | "testdata/prepare_root.sh", |
Jooyung Han | fcaa89a | 2020-03-20 18:20:23 +0900 | [diff] [blame] | 256 | // workaround to use host tools(conv_apex_manifest, linkerconfig) on build server |
| 257 | // ":conv_apex_manifest", |
| 258 | // ":linkerconfig", |
| 259 | ":linkerconfig_diff_test_host_tools", |
| 260 | ], |
Julien Desprez | 18c550a | 2021-06-28 17:19:12 +0000 | [diff] [blame] | 261 | test_options: { |
| 262 | unit_test: true, |
| 263 | }, |
Martin Stjernholm | 908bfdb | 2020-08-07 19:00:55 +0100 | [diff] [blame] | 264 | } |