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 | |
| 17 | cc_defaults { |
| 18 | name: "linkerconfig_defaults", |
| 19 | cflags: [ |
| 20 | "-Wall", |
| 21 | "-Werror", |
| 22 | "-Wextra", |
| 23 | ], |
Jooyung Han | 86b57f6 | 2020-01-06 18:09:30 +0900 | [diff] [blame] | 24 | defaults: ["libapexutil-deps"], |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 25 | static_libs: [ |
Jooyung Han | 86b57f6 | 2020-01-06 18:09:30 +0900 | [diff] [blame] | 26 | "libapexutil", |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 27 | "libbase", |
| 28 | "liblog", |
| 29 | ], |
Jooyung Han | a3d5d09 | 2019-09-26 23:23:50 +0900 | [diff] [blame] | 30 | host_supported: true, |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 31 | } |
| 32 | |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 33 | cc_defaults { |
| 34 | name: "linkerconfig_test_defaults", |
| 35 | defaults: ["linkerconfig_defaults"], |
| 36 | cflags: [ |
| 37 | "-g", |
| 38 | "-Wunused", |
| 39 | ], |
| 40 | test_suites: ["general-tests"], |
| 41 | } |
| 42 | |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 43 | cc_library_static { |
| 44 | name: "linkerconfig_modules", |
| 45 | defaults: [ "linkerconfig_defaults" ], |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 46 | export_include_dirs: [ "modules/include" ], |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 47 | srcs: [ |
| 48 | "modules/*.cc", |
| 49 | ], |
| 50 | } |
| 51 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 52 | cc_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", |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 64 | "contents/common/*.cc", |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 65 | ], |
| 66 | } |
| 67 | |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 68 | cc_library_static { |
| 69 | name: "linkerconfig_generator", |
| 70 | defaults : [ "linkerconfig_defaults" ], |
| 71 | export_include_dirs: [ "generator/include" ], |
Kiyoung Kim | e9a77fe | 2019-05-23 11:04:20 +0900 | [diff] [blame] | 72 | static_libs: [ |
| 73 | "linkerconfig_modules", |
| 74 | "linkerconfig_contents", |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 75 | "libc++fs", |
Kiyoung Kim | e9a77fe | 2019-05-23 11:04:20 +0900 | [diff] [blame] | 76 | ], |
| 77 | srcs: [ |
| 78 | "generator/*.cc", |
Kiyoung Kim | 15e3835 | 2019-07-11 17:07:03 +0900 | [diff] [blame] | 79 | ], |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | cc_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 | ], |
Kiyoung Kim | 15e3835 | 2019-07-11 17:07:03 +0900 | [diff] [blame] | 93 | static_executable: true, |
Jooyung Han | 3cb5bcd | 2020-02-12 04:21:16 +0900 | [diff] [blame] | 94 | required: [ |
| 95 | // files from /system/etc |
| 96 | "sanitizer.libraries.txt", |
| 97 | "vndkcorevariant.libraries.txt", |
Jooyung Han | 7c2b73a | 2020-02-12 08:53:51 +0900 | [diff] [blame] | 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) |
Jooyung Han | 3cb5bcd | 2020-02-12 04:21:16 +0900 | [diff] [blame] | 101 | ], |
Kiyoung Kim | e9a77fe | 2019-05-23 11:04:20 +0900 | [diff] [blame] | 102 | } |
| 103 | |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 104 | cc_test { |
| 105 | name: "linkerconfig_modules_unittest", |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 106 | defaults: [ "linkerconfig_test_defaults" ], |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 107 | srcs: [ |
| 108 | "modules/tests/*_test.cc", |
| 109 | ], |
| 110 | static_libs: [ |
Jooyung Han | 33a9505 | 2019-12-06 19:47:30 +0900 | [diff] [blame] | 111 | "libgmock", |
Kiyoung Kim | 7d422b3 | 2019-03-05 17:06:13 +0900 | [diff] [blame] | 112 | "linkerconfig_modules", |
| 113 | ], |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | cc_test { |
| 117 | name: "linkerconfig_backward_compatibility_test", |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 118 | defaults: [ "linkerconfig_test_defaults" ], |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 119 | srcs: [ |
| 120 | "contents/tests/backward_compatibility/*_test.cc", |
| 121 | ], |
| 122 | static_libs: [ |
| 123 | "linkerconfig_modules", |
| 124 | "linkerconfig_contents", |
| 125 | ], |
Kiyoung Kim | 15e3835 | 2019-07-11 17:07:03 +0900 | [diff] [blame] | 126 | } |
Kiyoung Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 127 | |
| 128 | cc_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 | ], |
Kiyoung Kim | 84cbf00 | 2019-08-21 19:46:51 +0900 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | cc_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 | ], |
Kiyoung Kim | 722dad6 | 2019-12-19 15:59:55 +0900 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | prebuilt_etc { |
| 160 | name: "ld.config.recovery.txt", |
| 161 | recovery: true, |
| 162 | filename: "ld.config.txt", |
| 163 | src: ":generate_recovery_linker_config", |
| 164 | } |
| 165 | |
| 166 | genrule { |
| 167 | name: "generate_recovery_linker_config", |
| 168 | recovery: true, |
Kiyoung Kim | 5c8366d | 2019-12-30 18:43:00 +0900 | [diff] [blame] | 169 | out: ["ld.config.txt"], |
Kiyoung Kim | 722dad6 | 2019-12-19 15:59:55 +0900 | [diff] [blame] | 170 | tools: ["linkerconfig"], |
Kiyoung Kim | 5c8366d | 2019-12-30 18:43:00 +0900 | [diff] [blame] | 171 | cmd: "$(location linkerconfig) --recovery --target $(genDir)", |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 172 | } |