• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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        "vndkcorevariant.libraries.txt",
128        // Note that even thought linkerconfig requires at least one version of VNDK APEXes,
129        // we can't list it here because the exact version is unknown at build-time. It is decided
130        // at runtime according to ro.vndk.version (or ro.product.vndk.version)
131    ],
132    target: {
133        host: {
134            // Link libc++ and libbase statically on host for convenience(no need to set library paths)
135            stl: "c++_static",
136            static_libs: [
137                "libbase",
138            ],
139            exclude_shared_libs: [
140                "libbase",
141            ],
142        },
143    },
144
145    // Device does not boot when global ThinLTO is enabled for linkerconfig.
146    // http://b/170573443
147    lto: {
148        never: true,
149    },
150
151    apex_available: [
152        "com.android.runtime",
153    ],
154
155    sanitize: {
156        // linkerconfig should be able to run at the very early stage of boot process when
157        // /data/asan is not ready. So linkerconfig can't run with ASAN.
158        address: false,
159    },
160}
161
162cc_test {
163    name: "linkerconfig_modules_unittest",
164    defaults: [ "linkerconfig_test_defaults" ],
165    srcs: [
166        "modules/tests/*_test.cc",
167    ],
168    static_libs: [
169        "libgmock",
170        "linkerconfig_modules",
171        "libc++fs",
172    ],
173    data: [
174        "modules/tests/data/linker.config.*",
175    ],
176}
177
178cc_test {
179    name: "linkerconfig_backward_compatibility_test",
180    defaults: [ "linkerconfig_test_defaults" ],
181    srcs: [
182        "contents/tests/backward_compatibility/*_test.cc",
183    ],
184    static_libs: [
185        "linkerconfig_modules",
186        "linkerconfig_contents",
187    ],
188}
189
190cc_test {
191    name: "linkerconfig_generator_unittest",
192    defaults: [ "linkerconfig_test_defaults" ],
193    srcs: [
194        "generator/tests/*_test.cc",
195    ],
196    static_libs: [
197        "linkerconfig_modules",
198        "linkerconfig_contents",
199        "linkerconfig_generator",
200    ],
201    data: [
202        "generator/tests/data/*.txt",
203    ],
204}
205
206cc_test {
207    name: "linkerconfig_contents_fulltest",
208    defaults: [ "linkerconfig_test_defaults" ],
209    // TODO(b/231993627): Reenable isolated:true by deleting the explicit disable below
210    isolated: false,
211    local_include_dirs: [
212        "contents/tests/configuration/include",
213    ],
214    srcs: [
215        "contents/tests/configuration/*_test.cc",
216    ],
217    static_libs: [
218        "libgmock",
219        "linkerconfig_modules",
220        "linkerconfig_contents",
221    ],
222}
223
224prebuilt_etc {
225    name: "ld.config.recovery.txt",
226    recovery: true,
227    filename: "ld.config.txt",
228    src: ":generate_recovery_linker_config",
229}
230
231genrule {
232    name: "generate_recovery_linker_config",
233    recovery: true,
234    out: ["ld.config.txt"],
235    tools: ["linkerconfig"],
236    cmd: "$(location linkerconfig) --recovery --target $(genDir)",
237}
238
239sh_test_host {
240    name: "linkerconfig_diff_test",
241    src: "rundiff.sh",
242    filename: "linkerconfig_diff_test.sh",
243    test_config: "linkerconfig_diff_test.xml",
244    data: [
245        "testdata/root/**/*",
246        "testdata/root/**/.*", // copy .keep files
247        "testdata/golden_output/**/*",
248        "testdata/prepare_root.sh",
249    ],
250    data_bins: [
251        "conv_apex_manifest",
252        "conv_linker_config",
253        "linkerconfig",
254    ],
255    test_options: {
256        unit_test: true,
257    },
258}
259