blob: f0a98b94c16eadf9ddb1fe2647b2f4667cbea01a [file] [log] [blame]
Kiyoung Kim7d422b32019-03-05 17:06:13 +09001/*
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 ],
Jooyung Han86b57f62020-01-06 18:09:30 +090024 defaults: ["libapexutil-deps"],
Kiyoung Kim7d422b32019-03-05 17:06:13 +090025 static_libs: [
Jooyung Han86b57f62020-01-06 18:09:30 +090026 "libapexutil",
Kiyoung Kim7d422b32019-03-05 17:06:13 +090027 "libbase",
28 "liblog",
29 ],
Jooyung Hana3d5d092019-09-26 23:23:50 +090030 host_supported: true,
Kiyoung Kim7d422b32019-03-05 17:06:13 +090031}
32
Kiyoung Kim853438d2019-07-16 09:51:14 +090033cc_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 Kim7d422b32019-03-05 17:06:13 +090043cc_library_static {
44 name: "linkerconfig_modules",
45 defaults: [ "linkerconfig_defaults" ],
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090046 export_include_dirs: [ "modules/include" ],
Kiyoung Kim7d422b32019-03-05 17:06:13 +090047 srcs: [
48 "modules/*.cc",
49 ],
50}
51
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090052cc_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 Stjernholmcb9df4f2019-10-02 20:47:12 +010064 "contents/common/*.cc",
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090065 ],
66}
67
Kiyoung Kim853438d2019-07-16 09:51:14 +090068cc_library_static {
69 name: "linkerconfig_generator",
70 defaults : [ "linkerconfig_defaults" ],
71 export_include_dirs: [ "generator/include" ],
Kiyoung Kime9a77fe2019-05-23 11:04:20 +090072 static_libs: [
73 "linkerconfig_modules",
74 "linkerconfig_contents",
Kiyoung Kim853438d2019-07-16 09:51:14 +090075 "libc++fs",
Kiyoung Kime9a77fe2019-05-23 11:04:20 +090076 ],
77 srcs: [
78 "generator/*.cc",
Kiyoung Kim15e38352019-07-11 17:07:03 +090079 ],
Kiyoung Kim853438d2019-07-16 09:51:14 +090080}
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 ],
Kiyoung Kim15e38352019-07-11 17:07:03 +090093 static_executable: true,
Jooyung Han3cb5bcd2020-02-12 04:21:16 +090094 required: [
95 // files from /system/etc
96 "sanitizer.libraries.txt",
97 "vndkcorevariant.libraries.txt",
Jooyung Han7c2b73a2020-02-12 08:53:51 +090098 // 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 Han3cb5bcd2020-02-12 04:21:16 +0900101 ],
Kiyoung Kime9a77fe2019-05-23 11:04:20 +0900102}
103
Kiyoung Kim7d422b32019-03-05 17:06:13 +0900104cc_test {
105 name: "linkerconfig_modules_unittest",
Kiyoung Kim853438d2019-07-16 09:51:14 +0900106 defaults: [ "linkerconfig_test_defaults" ],
Kiyoung Kim7d422b32019-03-05 17:06:13 +0900107 srcs: [
108 "modules/tests/*_test.cc",
109 ],
110 static_libs: [
Jooyung Han33a95052019-12-06 19:47:30 +0900111 "libgmock",
Kiyoung Kim7d422b32019-03-05 17:06:13 +0900112 "linkerconfig_modules",
113 ],
Kiyoung Kimff9cbf72019-03-14 18:26:24 +0900114}
115
116cc_test {
117 name: "linkerconfig_backward_compatibility_test",
Kiyoung Kim853438d2019-07-16 09:51:14 +0900118 defaults: [ "linkerconfig_test_defaults" ],
Kiyoung Kimff9cbf72019-03-14 18:26:24 +0900119 srcs: [
120 "contents/tests/backward_compatibility/*_test.cc",
121 ],
122 static_libs: [
123 "linkerconfig_modules",
124 "linkerconfig_contents",
125 ],
Kiyoung Kim15e38352019-07-11 17:07:03 +0900126}
Kiyoung Kim853438d2019-07-16 09:51:14 +0900127
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 ],
Kiyoung Kim84cbf002019-08-21 19:46:51 +0900142}
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 ],
Kiyoung Kim722dad62019-12-19 15:59:55 +0900157}
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,
Kiyoung Kim5c8366d2019-12-30 18:43:00 +0900169 out: ["ld.config.txt"],
Kiyoung Kim722dad62019-12-19 15:59:55 +0900170 tools: ["linkerconfig"],
Kiyoung Kim5c8366d2019-12-30 18:43:00 +0900171 cmd: "$(location linkerconfig) --recovery --target $(genDir)",
Martin Stjernholmcb9df4f2019-10-02 20:47:12 +0100172}