blob: b1eebe98c59fc859e09340e0f94694a0f5bc8175 [file] [log] [blame]
Paul Duffina80fdec2019-12-03 15:25:00 +00001// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package sdk
16
17import (
18 "testing"
19
Paul Duffin1356d8c2020-02-25 19:26:33 +000020 "android/soong/android"
Paul Duffina80fdec2019-12-03 15:25:00 +000021 "android/soong/cc"
22)
23
Martin Stjernholm7feceb22020-07-11 04:33:29 +010024var ccTestFs = map[string][]byte{
25 "Test.cpp": nil,
26 "include/Test.h": nil,
27 "include-android/AndroidTest.h": nil,
28 "include-host/HostTest.h": nil,
29 "arm64/include/Arm64Test.h": nil,
30 "libfoo.so": nil,
31 "aidl/foo/bar/Test.aidl": nil,
32 "some/where/stubslib.map.txt": nil,
33}
34
Paul Duffind835daa2019-11-30 17:49:09 +000035func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
36 t.Helper()
Martin Stjernholm7feceb22020-07-11 04:33:29 +010037 return testSdkWithFs(t, bp, ccTestFs)
Paul Duffind835daa2019-11-30 17:49:09 +000038}
39
Paul Duffina80fdec2019-12-03 15:25:00 +000040// Contains tests for SDK members provided by the cc package.
41
Martin Stjernholmcaa47d72020-07-11 04:52:24 +010042func TestSingleDeviceOsAssumption(t *testing.T) {
43 // Mock a module with DeviceSupported() == true.
44 s := &sdk{}
45 android.InitAndroidArchModule(s, android.DeviceSupported, android.MultilibCommon)
46
47 osTypes := s.getPossibleOsTypes()
48 if len(osTypes) != 1 {
49 // The snapshot generation assumes there is a single device OS. If more are
50 // added it might need to disable them by default, like it does for host
51 // OS'es.
52 t.Errorf("expected a single device OS, got %v", osTypes)
53 }
54}
55
Paul Duffina80fdec2019-12-03 15:25:00 +000056func TestSdkIsCompileMultilibBoth(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +000057 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000058 sdk {
59 name: "mysdk",
60 native_shared_libs: ["sdkmember"],
61 }
62
63 cc_library_shared {
64 name: "sdkmember",
65 srcs: ["Test.cpp"],
Paul Duffina80fdec2019-12-03 15:25:00 +000066 stl: "none",
67 }
68 `)
69
Colin Cross7113d202019-11-20 16:39:12 -080070 armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile()
71 arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile()
Paul Duffina80fdec2019-12-03 15:25:00 +000072
73 var inputs []string
Paul Duffin1356d8c2020-02-25 19:26:33 +000074 buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests()
Paul Duffina80fdec2019-12-03 15:25:00 +000075 for _, bp := range buildParams {
76 if bp.Input != nil {
77 inputs = append(inputs, bp.Input.String())
78 }
79 }
80
81 // ensure that both 32/64 outputs are inputs of the sdk snapshot
82 ensureListContains(t, inputs, armOutput.String())
83 ensureListContains(t, inputs, arm64Output.String())
84}
85
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010086func TestSdkCompileMultilibOverride(t *testing.T) {
87 result := testSdkWithCc(t, `
88 sdk {
89 name: "mysdk",
Martin Stjernholm89238f42020-07-10 00:14:03 +010090 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010091 native_shared_libs: ["sdkmember"],
92 compile_multilib: "64",
93 }
94
95 cc_library_shared {
96 name: "sdkmember",
Martin Stjernholm89238f42020-07-10 00:14:03 +010097 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010098 srcs: ["Test.cpp"],
99 stl: "none",
100 compile_multilib: "64",
101 }
102 `)
103
104 result.CheckSnapshot("mysdk", "",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100105 checkAndroidBpContents(`
106// This is auto-generated. DO NOT EDIT.
107
108cc_prebuilt_library_shared {
109 name: "mysdk_sdkmember@current",
110 sdk_member_name: "sdkmember",
Paul Duffind99d9972020-09-29 16:00:55 +0100111 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000112 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100113 host_supported: true,
114 installable: false,
115 stl: "none",
116 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100117 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100118 host: {
119 enabled: false,
120 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100121 android_arm64: {
122 srcs: ["android/arm64/lib/sdkmember.so"],
123 },
124 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900125 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100126 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100127 },
128 },
129}
130
131cc_prebuilt_library_shared {
132 name: "sdkmember",
133 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100134 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000135 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100136 host_supported: true,
137 stl: "none",
138 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100139 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100140 host: {
141 enabled: false,
142 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100143 android_arm64: {
144 srcs: ["android/arm64/lib/sdkmember.so"],
145 },
146 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900147 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100148 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100149 },
150 },
151}
152
153sdk_snapshot {
154 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100155 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100156 host_supported: true,
157 native_shared_libs: ["mysdk_sdkmember@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100158 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100159 target: {
160 host: {
161 enabled: false,
162 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900163 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100164 enabled: true,
165 },
166 },
Martin Stjernholm89238f42020-07-10 00:14:03 +0100167}
168`),
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100169 checkAllCopyRules(`
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100170.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
171.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100172`))
173}
174
Paul Duffina80fdec2019-12-03 15:25:00 +0000175func TestBasicSdkWithCc(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000176 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000177 sdk {
178 name: "mysdk",
179 native_shared_libs: ["sdkmember"],
180 }
181
Paul Duffina0843f62019-12-13 19:50:38 +0000182 cc_library_shared {
183 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -0800184 system_shared_libs: [],
Martin Stjernholmcc776012020-07-07 03:22:21 +0100185 stl: "none",
186 apex_available: ["mysdkapex"],
Paul Duffina0843f62019-12-13 19:50:38 +0000187 }
188
Paul Duffina80fdec2019-12-03 15:25:00 +0000189 sdk_snapshot {
190 name: "mysdk@1",
191 native_shared_libs: ["sdkmember_mysdk_1"],
192 }
193
194 sdk_snapshot {
195 name: "mysdk@2",
196 native_shared_libs: ["sdkmember_mysdk_2"],
197 }
198
199 cc_prebuilt_library_shared {
200 name: "sdkmember",
201 srcs: ["libfoo.so"],
202 prefer: false,
203 system_shared_libs: [],
204 stl: "none",
205 }
206
207 cc_prebuilt_library_shared {
208 name: "sdkmember_mysdk_1",
209 sdk_member_name: "sdkmember",
210 srcs: ["libfoo.so"],
211 system_shared_libs: [],
212 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000213 // TODO: remove //apex_available:platform
214 apex_available: [
215 "//apex_available:platform",
216 "myapex",
217 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000218 }
219
220 cc_prebuilt_library_shared {
221 name: "sdkmember_mysdk_2",
222 sdk_member_name: "sdkmember",
223 srcs: ["libfoo.so"],
224 system_shared_libs: [],
225 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000226 // TODO: remove //apex_available:platform
227 apex_available: [
228 "//apex_available:platform",
229 "myapex2",
230 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000231 }
232
233 cc_library_shared {
234 name: "mycpplib",
235 srcs: ["Test.cpp"],
236 shared_libs: ["sdkmember"],
237 system_shared_libs: [],
238 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000239 apex_available: [
240 "myapex",
241 "myapex2",
242 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000243 }
244
245 apex {
246 name: "myapex",
247 native_shared_libs: ["mycpplib"],
248 uses_sdks: ["mysdk@1"],
249 key: "myapex.key",
250 certificate: ":myapex.cert",
251 }
252
253 apex {
254 name: "myapex2",
255 native_shared_libs: ["mycpplib"],
256 uses_sdks: ["mysdk@2"],
257 key: "myapex.key",
258 certificate: ":myapex.cert",
259 }
Martin Stjernholmcc776012020-07-07 03:22:21 +0100260
261 apex {
262 name: "mysdkapex",
263 native_shared_libs: ["sdkmember"],
264 key: "myapex.key",
265 certificate: ":myapex.cert",
266 }
Paul Duffina80fdec2019-12-03 15:25:00 +0000267 `)
268
Colin Crossaede88c2020-08-11 12:17:01 -0700269 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
270 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000271
Colin Crossaede88c2020-08-11 12:17:01 -0700272 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1")
273 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000274
275 // Depending on the uses_sdks value, different libs are linked
276 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
277 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
278}
279
Paul Duffina0843f62019-12-13 19:50:38 +0000280// Make sure the sdk can use host specific cc libraries static/shared and both.
281func TestHostSdkWithCc(t *testing.T) {
282 testSdkWithCc(t, `
283 sdk {
284 name: "mysdk",
285 device_supported: false,
286 host_supported: true,
287 native_shared_libs: ["sdkshared"],
288 native_static_libs: ["sdkstatic"],
289 }
290
291 cc_library_host_shared {
292 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000293 stl: "none",
294 }
295
296 cc_library_host_static {
297 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000298 stl: "none",
299 }
300 `)
301}
302
303// Make sure the sdk can use cc libraries static/shared and both.
304func TestSdkWithCc(t *testing.T) {
305 testSdkWithCc(t, `
306 sdk {
307 name: "mysdk",
308 native_shared_libs: ["sdkshared", "sdkboth1"],
309 native_static_libs: ["sdkstatic", "sdkboth2"],
310 }
311
312 cc_library_shared {
313 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000314 stl: "none",
315 }
316
317 cc_library_static {
318 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000319 stl: "none",
320 }
321
322 cc_library {
323 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000324 stl: "none",
325 }
326
327 cc_library {
328 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000329 stl: "none",
330 }
331 `)
332}
333
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000334func TestSnapshotWithObject(t *testing.T) {
335 result := testSdkWithCc(t, `
336 sdk {
337 name: "mysdk",
338 native_objects: ["crtobj"],
339 }
340
341 cc_object {
342 name: "crtobj",
343 stl: "none",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100344 sanitize: {
345 never: true,
346 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000347 }
348 `)
349
350 result.CheckSnapshot("mysdk", "",
351 checkAndroidBpContents(`
352// This is auto-generated. DO NOT EDIT.
353
354cc_prebuilt_object {
355 name: "mysdk_crtobj@current",
356 sdk_member_name: "crtobj",
Paul Duffind99d9972020-09-29 16:00:55 +0100357 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000358 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000359 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100360 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100361 sanitize: {
362 never: true,
363 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000364 arch: {
365 arm64: {
366 srcs: ["arm64/lib/crtobj.o"],
367 },
368 arm: {
369 srcs: ["arm/lib/crtobj.o"],
370 },
371 },
372}
373
374cc_prebuilt_object {
375 name: "crtobj",
376 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100377 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000378 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000379 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100380 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100381 sanitize: {
382 never: true,
383 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000384 arch: {
385 arm64: {
386 srcs: ["arm64/lib/crtobj.o"],
387 },
388 arm: {
389 srcs: ["arm/lib/crtobj.o"],
390 },
391 },
392}
393
394sdk_snapshot {
395 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100396 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000397 native_objects: ["mysdk_crtobj@current"],
398}
399`),
400 checkAllCopyRules(`
401.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
402.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
403`),
404 )
405}
406
Paul Duffinc62a5102019-12-11 18:34:15 +0000407func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
408 result := testSdkWithCc(t, `
409 sdk {
410 name: "mysdk",
411 native_shared_libs: ["mynativelib1", "mynativelib2"],
412 }
413
414 cc_library_shared {
415 name: "mynativelib1",
416 srcs: [
417 "Test.cpp",
418 ],
419 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000420 stl: "none",
421 }
422
423 cc_library_shared {
424 name: "mynativelib2",
425 srcs: [
426 "Test.cpp",
427 ],
428 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000429 stl: "none",
430 }
431 `)
432
Paul Duffin1356d8c2020-02-25 19:26:33 +0000433 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000434 checkAllCopyRules(`
435include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800436.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
437.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
438.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
439.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000440`),
441 )
442}
443
Martin Stjernholmb0249572020-09-15 02:32:35 +0100444// Verify that when the shared library has some common and some arch specific
445// properties that the generated snapshot is optimized properly. Substruct
446// handling is tested with the sanitize clauses (but note there's a lot of
447// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000448func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
449 result := testSdkWithCc(t, `
450 sdk {
451 name: "mysdk",
452 native_shared_libs: ["mynativelib"],
453 }
454
455 cc_library_shared {
456 name: "mynativelib",
457 srcs: [
458 "Test.cpp",
459 "aidl/foo/bar/Test.aidl",
460 ],
461 export_include_dirs: ["include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100462 sanitize: {
463 fuzzer: false,
464 integer_overflow: true,
465 diag: { undefined: false },
466 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000467 arch: {
468 arm64: {
469 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100470 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100471 integer_overflow: false,
472 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000473 },
474 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000475 stl: "none",
476 }
477 `)
478
Paul Duffin1356d8c2020-02-25 19:26:33 +0000479 result.CheckSnapshot("mysdk", "",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000480 checkAndroidBpContents(`
481// This is auto-generated. DO NOT EDIT.
482
483cc_prebuilt_library_shared {
484 name: "mysdk_mynativelib@current",
485 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100486 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000487 apex_available: ["//apex_available:platform"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000488 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000489 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100490 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000491 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100492 sanitize: {
493 fuzzer: false,
494 diag: {
495 undefined: false,
496 },
497 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000498 arch: {
499 arm64: {
500 srcs: ["arm64/lib/mynativelib.so"],
501 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100502 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100503 integer_overflow: false,
504 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000505 },
506 arm: {
507 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100508 sanitize: {
509 integer_overflow: true,
510 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000511 },
512 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000513}
514
515cc_prebuilt_library_shared {
516 name: "mynativelib",
517 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100518 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000519 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000520 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100521 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000522 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100523 sanitize: {
524 fuzzer: false,
525 diag: {
526 undefined: false,
527 },
528 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000529 arch: {
530 arm64: {
531 srcs: ["arm64/lib/mynativelib.so"],
532 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100533 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100534 integer_overflow: false,
535 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000536 },
537 arm: {
538 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100539 sanitize: {
540 integer_overflow: true,
541 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000542 },
543 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000544}
545
546sdk_snapshot {
547 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100548 visibility: ["//visibility:public"],
Paul Duffina7cd8c82019-12-11 20:00:57 +0000549 native_shared_libs: ["mysdk_mynativelib@current"],
550}
551`),
552 checkAllCopyRules(`
553include/Test.h -> include/include/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +0000554.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000555arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800556.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000557 )
558}
559
Paul Duffin25ce04b2020-01-16 11:47:25 +0000560func TestSnapshotWithCcBinary(t *testing.T) {
561 result := testSdkWithCc(t, `
562 module_exports {
563 name: "mymodule_exports",
564 native_binaries: ["mynativebinary"],
565 }
566
567 cc_binary {
568 name: "mynativebinary",
569 srcs: [
570 "Test.cpp",
571 ],
572 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000573 }
574 `)
575
Paul Duffin1356d8c2020-02-25 19:26:33 +0000576 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000577 checkAndroidBpContents(`
578// This is auto-generated. DO NOT EDIT.
579
580cc_prebuilt_binary {
581 name: "mymodule_exports_mynativebinary@current",
582 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100583 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000584 apex_available: ["//apex_available:platform"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000585 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000586 compile_multilib: "both",
587 arch: {
588 arm64: {
589 srcs: ["arm64/bin/mynativebinary"],
590 },
591 arm: {
592 srcs: ["arm/bin/mynativebinary"],
593 },
594 },
595}
596
597cc_prebuilt_binary {
598 name: "mynativebinary",
599 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100600 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000601 apex_available: ["//apex_available:platform"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000602 compile_multilib: "both",
603 arch: {
604 arm64: {
605 srcs: ["arm64/bin/mynativebinary"],
606 },
607 arm: {
608 srcs: ["arm/bin/mynativebinary"],
609 },
610 },
611}
612
613module_exports_snapshot {
614 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100615 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000616 native_binaries: ["mymodule_exports_mynativebinary@current"],
617}
618`),
619 checkAllCopyRules(`
620.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
621.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
622`),
623 )
624}
625
Paul Duffina04c1072020-03-02 10:16:35 +0000626func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000627 result := testSdkWithCc(t, `
628 module_exports {
629 name: "myexports",
630 device_supported: false,
631 host_supported: true,
632 native_binaries: ["mynativebinary"],
633 target: {
634 windows: {
635 enabled: true,
636 },
637 },
638 }
639
640 cc_binary {
641 name: "mynativebinary",
642 device_supported: false,
643 host_supported: true,
644 srcs: [
645 "Test.cpp",
646 ],
647 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000648 stl: "none",
649 target: {
650 windows: {
651 enabled: true,
652 },
653 },
654 }
655 `)
656
657 result.CheckSnapshot("myexports", "",
658 checkAndroidBpContents(`
659// This is auto-generated. DO NOT EDIT.
660
661cc_prebuilt_binary {
662 name: "myexports_mynativebinary@current",
663 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100664 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000665 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000666 device_supported: false,
667 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000668 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100669 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000670 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100671 host: {
672 enabled: false,
673 },
Paul Duffina04c1072020-03-02 10:16:35 +0000674 linux_glibc: {
675 compile_multilib: "both",
676 },
677 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900678 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000679 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
680 },
681 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900682 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000683 srcs: ["linux_glibc/x86/bin/mynativebinary"],
684 },
685 windows: {
686 compile_multilib: "64",
687 },
688 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900689 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000690 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
691 },
692 },
693}
694
695cc_prebuilt_binary {
696 name: "mynativebinary",
697 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100698 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000699 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000700 device_supported: false,
701 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100702 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000703 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100704 host: {
705 enabled: false,
706 },
Paul Duffina04c1072020-03-02 10:16:35 +0000707 linux_glibc: {
708 compile_multilib: "both",
709 },
710 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900711 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000712 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
713 },
714 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900715 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000716 srcs: ["linux_glibc/x86/bin/mynativebinary"],
717 },
718 windows: {
719 compile_multilib: "64",
720 },
721 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900722 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000723 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
724 },
725 },
726}
727
728module_exports_snapshot {
729 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100730 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000731 device_supported: false,
732 host_supported: true,
733 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000734 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900735 windows: {
736 compile_multilib: "64",
737 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100738 host: {
739 enabled: false,
740 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900741 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100742 enabled: true,
743 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900744 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100745 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +0900746 },
747 windows_x86_64: {
748 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000749 },
750 },
Paul Duffina04c1072020-03-02 10:16:35 +0000751}
752`),
753 checkAllCopyRules(`
754.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
755.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
756.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
757`),
758 )
759}
760
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100761func TestSnapshotWithSingleHostOsType(t *testing.T) {
762 ctx, config := testSdkContext(`
763 cc_defaults {
764 name: "mydefaults",
765 device_supported: false,
766 host_supported: true,
767 compile_multilib: "64",
768 target: {
769 host: {
770 enabled: false,
771 },
772 linux_bionic: {
773 enabled: true,
774 },
775 },
776 }
777
778 module_exports {
779 name: "myexports",
780 defaults: ["mydefaults"],
781 native_shared_libs: ["mynativelib"],
782 native_binaries: ["mynativebinary"],
783 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
784 }
785
786 cc_library {
787 name: "mynativelib",
788 defaults: ["mydefaults"],
789 srcs: [
790 "Test.cpp",
791 ],
792 stl: "none",
793 }
794
795 cc_binary {
796 name: "mynativebinary",
797 defaults: ["mydefaults"],
798 srcs: [
799 "Test.cpp",
800 ],
801 stl: "none",
802 }
803 `, ccTestFs, []android.OsType{android.LinuxBionic})
804
805 result := runTests(t, ctx, config)
806
807 result.CheckSnapshot("myexports", "",
808 checkAndroidBpContents(`
809// This is auto-generated. DO NOT EDIT.
810
811cc_prebuilt_binary {
812 name: "myexports_mynativebinary@current",
813 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100814 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000815 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100816 device_supported: false,
817 host_supported: true,
818 installable: false,
819 stl: "none",
820 compile_multilib: "64",
821 target: {
822 host: {
823 enabled: false,
824 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100825 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900826 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100827 srcs: ["x86_64/bin/mynativebinary"],
828 },
829 },
830}
831
832cc_prebuilt_binary {
833 name: "mynativebinary",
834 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100835 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000836 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100837 device_supported: false,
838 host_supported: true,
839 stl: "none",
840 compile_multilib: "64",
841 target: {
842 host: {
843 enabled: false,
844 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100845 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900846 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100847 srcs: ["x86_64/bin/mynativebinary"],
848 },
849 },
850}
851
852cc_prebuilt_library_shared {
853 name: "myexports_mynativelib@current",
854 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100855 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000856 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100857 device_supported: false,
858 host_supported: true,
859 installable: false,
860 stl: "none",
861 compile_multilib: "64",
862 target: {
863 host: {
864 enabled: false,
865 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100866 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900867 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100868 srcs: ["x86_64/lib/mynativelib.so"],
869 },
870 },
871}
872
873cc_prebuilt_library_shared {
874 name: "mynativelib",
875 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100876 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000877 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100878 device_supported: false,
879 host_supported: true,
880 stl: "none",
881 compile_multilib: "64",
882 target: {
883 host: {
884 enabled: false,
885 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100886 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900887 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100888 srcs: ["x86_64/lib/mynativelib.so"],
889 },
890 },
891}
892
893module_exports_snapshot {
894 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100895 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100896 device_supported: false,
897 host_supported: true,
898 native_binaries: ["myexports_mynativebinary@current"],
899 native_shared_libs: ["myexports_mynativelib@current"],
900 compile_multilib: "64",
901 target: {
902 host: {
903 enabled: false,
904 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900905 linux_bionic_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100906 enabled: true,
907 },
908 },
909}
910`),
911 checkAllCopyRules(`
912.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
913.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
914`),
915 )
916}
917
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100918// Test that we support the necessary flags for the linker binary, which is
919// special in several ways.
920func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100921 result := testSdkWithCc(t, `
922 module_exports {
923 name: "mymodule_exports",
924 host_supported: true,
925 device_supported: false,
926 native_binaries: ["linker"],
927 }
928
929 cc_binary {
930 name: "linker",
931 host_supported: true,
932 static_executable: true,
933 nocrt: true,
934 stl: "none",
935 srcs: [
936 "Test.cpp",
937 ],
938 compile_multilib: "both",
939 }
940 `)
941
942 result.CheckSnapshot("mymodule_exports", "",
943 checkAndroidBpContents(`
944// This is auto-generated. DO NOT EDIT.
945
946cc_prebuilt_binary {
947 name: "mymodule_exports_linker@current",
948 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +0100949 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000950 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100951 device_supported: false,
952 host_supported: true,
953 installable: false,
954 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100955 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100956 static_executable: true,
957 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100958 target: {
959 host: {
960 enabled: false,
961 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100962 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900963 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100964 srcs: ["x86_64/bin/linker"],
965 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100966 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900967 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100968 srcs: ["x86/bin/linker"],
969 },
970 },
971}
972
973cc_prebuilt_binary {
974 name: "linker",
975 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100976 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000977 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100978 device_supported: false,
979 host_supported: true,
980 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100981 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100982 static_executable: true,
983 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100984 target: {
985 host: {
986 enabled: false,
987 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100988 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900989 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100990 srcs: ["x86_64/bin/linker"],
991 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100992 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900993 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100994 srcs: ["x86/bin/linker"],
995 },
996 },
997}
998
999module_exports_snapshot {
1000 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001001 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001002 device_supported: false,
1003 host_supported: true,
1004 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001005 target: {
1006 host: {
1007 enabled: false,
1008 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001009 linux_glibc_x86_64: {
1010 enabled: true,
1011 },
1012 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001013 enabled: true,
1014 },
1015 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001016}
1017`),
1018 checkAllCopyRules(`
1019.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1020.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1021`),
1022 )
1023}
1024
Paul Duffin9ab556f2019-12-11 18:42:17 +00001025func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001026 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001027 sdk {
1028 name: "mysdk",
1029 native_shared_libs: ["mynativelib"],
1030 }
1031
1032 cc_library_shared {
1033 name: "mynativelib",
1034 srcs: [
1035 "Test.cpp",
1036 "aidl/foo/bar/Test.aidl",
1037 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001038 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001039 export_include_dirs: ["include"],
1040 aidl: {
1041 export_aidl_headers: true,
1042 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001043 stl: "none",
1044 }
1045 `)
1046
Paul Duffin1356d8c2020-02-25 19:26:33 +00001047 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001048 checkAndroidBpContents(`
1049// This is auto-generated. DO NOT EDIT.
1050
1051cc_prebuilt_library_shared {
1052 name: "mysdk_mynativelib@current",
1053 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001054 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001055 apex_available: [
1056 "apex1",
1057 "apex2",
1058 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001059 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001060 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001061 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001062 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001063 arch: {
1064 arm64: {
1065 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001066 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001067 },
1068 arm: {
1069 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001070 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001071 },
1072 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001073}
1074
1075cc_prebuilt_library_shared {
1076 name: "mynativelib",
1077 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001078 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001079 apex_available: [
1080 "apex1",
1081 "apex2",
1082 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001083 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001084 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001085 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001086 arch: {
1087 arm64: {
1088 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001089 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001090 },
1091 arm: {
1092 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001093 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001094 },
1095 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001096}
1097
1098sdk_snapshot {
1099 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001100 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001101 native_shared_libs: ["mysdk_mynativelib@current"],
1102}
1103`),
1104 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001105include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001106.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1107.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1108.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1109.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1110.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1111.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1112.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1113.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001114`),
1115 )
1116}
1117
Paul Duffin13f02712020-03-06 12:30:43 +00001118func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1119 result := testSdkWithCc(t, `
1120 sdk {
1121 name: "mysdk",
1122 native_shared_libs: [
1123 "mynativelib",
1124 "myothernativelib",
1125 "mysystemnativelib",
1126 ],
1127 }
1128
1129 cc_library {
1130 name: "mysystemnativelib",
1131 srcs: [
1132 "Test.cpp",
1133 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001134 stl: "none",
1135 }
1136
1137 cc_library_shared {
1138 name: "myothernativelib",
1139 srcs: [
1140 "Test.cpp",
1141 ],
1142 system_shared_libs: [
1143 // A reference to a library that is not an sdk member. Uses libm as that
1144 // is in the default set of modules available to this test and so is available
1145 // both here and also when the generated Android.bp file is tested in
1146 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1147 // handles references to modules that are not sdk members.
1148 "libm",
1149 ],
1150 stl: "none",
1151 }
1152
1153 cc_library {
1154 name: "mynativelib",
1155 srcs: [
1156 "Test.cpp",
1157 ],
1158 shared_libs: [
1159 // A reference to another sdk member.
1160 "myothernativelib",
1161 ],
1162 target: {
1163 android: {
1164 shared: {
1165 shared_libs: [
1166 // A reference to a library that is not an sdk member. The libc library
1167 // is used here to check that the shared_libs property is handled correctly
1168 // in a similar way to how libm is used to check system_shared_libs above.
1169 "libc",
1170 ],
1171 },
1172 },
1173 },
Paul Duffin13f02712020-03-06 12:30:43 +00001174 stl: "none",
1175 }
1176 `)
1177
1178 result.CheckSnapshot("mysdk", "",
1179 checkAndroidBpContents(`
1180// This is auto-generated. DO NOT EDIT.
1181
1182cc_prebuilt_library_shared {
1183 name: "mysdk_mynativelib@current",
1184 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001185 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001186 apex_available: ["//apex_available:platform"],
Paul Duffin13f02712020-03-06 12:30:43 +00001187 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001188 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001189 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001190 shared_libs: [
1191 "mysdk_myothernativelib@current",
1192 "libc",
1193 ],
1194 arch: {
1195 arm64: {
1196 srcs: ["arm64/lib/mynativelib.so"],
1197 },
1198 arm: {
1199 srcs: ["arm/lib/mynativelib.so"],
1200 },
1201 },
Paul Duffin13f02712020-03-06 12:30:43 +00001202}
1203
1204cc_prebuilt_library_shared {
1205 name: "mynativelib",
1206 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001207 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001208 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001209 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001210 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001211 shared_libs: [
1212 "myothernativelib",
1213 "libc",
1214 ],
1215 arch: {
1216 arm64: {
1217 srcs: ["arm64/lib/mynativelib.so"],
1218 },
1219 arm: {
1220 srcs: ["arm/lib/mynativelib.so"],
1221 },
1222 },
Paul Duffin13f02712020-03-06 12:30:43 +00001223}
1224
1225cc_prebuilt_library_shared {
1226 name: "mysdk_myothernativelib@current",
1227 sdk_member_name: "myothernativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001228 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001229 apex_available: ["//apex_available:platform"],
Paul Duffin13f02712020-03-06 12:30:43 +00001230 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001231 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001232 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001233 system_shared_libs: ["libm"],
1234 arch: {
1235 arm64: {
1236 srcs: ["arm64/lib/myothernativelib.so"],
1237 },
1238 arm: {
1239 srcs: ["arm/lib/myothernativelib.so"],
1240 },
1241 },
Paul Duffin13f02712020-03-06 12:30:43 +00001242}
1243
1244cc_prebuilt_library_shared {
1245 name: "myothernativelib",
1246 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001247 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001248 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001249 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001250 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001251 system_shared_libs: ["libm"],
1252 arch: {
1253 arm64: {
1254 srcs: ["arm64/lib/myothernativelib.so"],
1255 },
1256 arm: {
1257 srcs: ["arm/lib/myothernativelib.so"],
1258 },
1259 },
Paul Duffin13f02712020-03-06 12:30:43 +00001260}
1261
1262cc_prebuilt_library_shared {
1263 name: "mysdk_mysystemnativelib@current",
1264 sdk_member_name: "mysystemnativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001265 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001266 apex_available: ["//apex_available:platform"],
Paul Duffin13f02712020-03-06 12:30:43 +00001267 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001268 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001269 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001270 arch: {
1271 arm64: {
1272 srcs: ["arm64/lib/mysystemnativelib.so"],
1273 },
1274 arm: {
1275 srcs: ["arm/lib/mysystemnativelib.so"],
1276 },
1277 },
Paul Duffin13f02712020-03-06 12:30:43 +00001278}
1279
1280cc_prebuilt_library_shared {
1281 name: "mysystemnativelib",
1282 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001283 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001284 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001285 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001286 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001287 arch: {
1288 arm64: {
1289 srcs: ["arm64/lib/mysystemnativelib.so"],
1290 },
1291 arm: {
1292 srcs: ["arm/lib/mysystemnativelib.so"],
1293 },
1294 },
Paul Duffin13f02712020-03-06 12:30:43 +00001295}
1296
1297sdk_snapshot {
1298 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001299 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001300 native_shared_libs: [
1301 "mysdk_mynativelib@current",
1302 "mysdk_myothernativelib@current",
1303 "mysdk_mysystemnativelib@current",
1304 ],
1305}
1306`),
1307 checkAllCopyRules(`
1308.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1309.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1310.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1311.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1312.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1313.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1314`),
1315 )
1316}
1317
Paul Duffin9ab556f2019-12-11 18:42:17 +00001318func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001319 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001320 sdk {
1321 name: "mysdk",
1322 device_supported: false,
1323 host_supported: true,
1324 native_shared_libs: ["mynativelib"],
1325 }
1326
1327 cc_library_shared {
1328 name: "mynativelib",
1329 device_supported: false,
1330 host_supported: true,
1331 srcs: [
1332 "Test.cpp",
1333 "aidl/foo/bar/Test.aidl",
1334 ],
1335 export_include_dirs: ["include"],
1336 aidl: {
1337 export_aidl_headers: true,
1338 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001339 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001340 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001341 }
1342 `)
1343
Paul Duffin1356d8c2020-02-25 19:26:33 +00001344 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001345 checkAndroidBpContents(`
1346// This is auto-generated. DO NOT EDIT.
1347
1348cc_prebuilt_library_shared {
1349 name: "mysdk_mynativelib@current",
1350 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001351 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001352 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001353 device_supported: false,
1354 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001355 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001356 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001357 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001358 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001359 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001360 target: {
1361 host: {
1362 enabled: false,
1363 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001364 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001365 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001366 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001367 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001368 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001369 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001370 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001371 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001372 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001373 },
1374 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001375}
1376
1377cc_prebuilt_library_shared {
1378 name: "mynativelib",
1379 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001380 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001381 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001382 device_supported: false,
1383 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001384 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001385 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001386 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001387 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001388 target: {
1389 host: {
1390 enabled: false,
1391 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001392 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001393 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001394 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001395 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001396 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001397 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001398 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001399 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001400 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001401 },
1402 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001403}
1404
1405sdk_snapshot {
1406 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001407 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001408 device_supported: false,
1409 host_supported: true,
1410 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001411 target: {
1412 host: {
1413 enabled: false,
1414 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001415 linux_glibc_x86_64: {
1416 enabled: true,
1417 },
1418 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001419 enabled: true,
1420 },
1421 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001422}
1423`),
1424 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001425include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001426.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001427.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1428.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1429.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1430.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001431.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1432.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1433.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1434`),
1435 )
1436}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001437
Paul Duffina04c1072020-03-02 10:16:35 +00001438func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001439 result := testSdkWithCc(t, `
1440 sdk {
1441 name: "mysdk",
1442 device_supported: false,
1443 host_supported: true,
1444 native_shared_libs: ["mynativelib"],
1445 target: {
1446 windows: {
1447 enabled: true,
1448 },
1449 },
1450 }
1451
1452 cc_library_shared {
1453 name: "mynativelib",
1454 device_supported: false,
1455 host_supported: true,
1456 srcs: [
1457 "Test.cpp",
1458 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001459 stl: "none",
1460 target: {
1461 windows: {
1462 enabled: true,
1463 },
1464 },
1465 }
1466 `)
1467
1468 result.CheckSnapshot("mysdk", "",
1469 checkAndroidBpContents(`
1470// This is auto-generated. DO NOT EDIT.
1471
1472cc_prebuilt_library_shared {
1473 name: "mysdk_mynativelib@current",
1474 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001475 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001476 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001477 device_supported: false,
1478 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001479 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001480 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001481 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001482 host: {
1483 enabled: false,
1484 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001485 linux_glibc: {
1486 compile_multilib: "both",
1487 },
Paul Duffina04c1072020-03-02 10:16:35 +00001488 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001489 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001490 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1491 },
1492 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001493 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001494 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1495 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001496 windows: {
1497 compile_multilib: "64",
1498 },
Paul Duffina04c1072020-03-02 10:16:35 +00001499 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001500 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001501 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1502 },
1503 },
Paul Duffina04c1072020-03-02 10:16:35 +00001504}
1505
1506cc_prebuilt_library_shared {
1507 name: "mynativelib",
1508 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001509 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001510 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001511 device_supported: false,
1512 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001513 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001514 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001515 host: {
1516 enabled: false,
1517 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001518 linux_glibc: {
1519 compile_multilib: "both",
1520 },
Paul Duffina04c1072020-03-02 10:16:35 +00001521 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001522 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001523 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1524 },
1525 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001526 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001527 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1528 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001529 windows: {
1530 compile_multilib: "64",
1531 },
Paul Duffina04c1072020-03-02 10:16:35 +00001532 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001533 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001534 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1535 },
1536 },
Paul Duffina04c1072020-03-02 10:16:35 +00001537}
1538
1539sdk_snapshot {
1540 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001541 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001542 device_supported: false,
1543 host_supported: true,
1544 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001545 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001546 windows: {
1547 compile_multilib: "64",
1548 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001549 host: {
1550 enabled: false,
1551 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001552 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001553 enabled: true,
1554 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001555 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001556 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +09001557 },
1558 windows_x86_64: {
1559 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001560 },
1561 },
Paul Duffina04c1072020-03-02 10:16:35 +00001562}
1563`),
1564 checkAllCopyRules(`
1565.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1566.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1567.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1568`),
1569 )
1570}
1571
Paul Duffin9ab556f2019-12-11 18:42:17 +00001572func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1573 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001574 module_exports {
1575 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001576 native_static_libs: ["mynativelib"],
1577 }
1578
1579 cc_library_static {
1580 name: "mynativelib",
1581 srcs: [
1582 "Test.cpp",
1583 "aidl/foo/bar/Test.aidl",
1584 ],
1585 export_include_dirs: ["include"],
1586 aidl: {
1587 export_aidl_headers: true,
1588 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001589 stl: "none",
1590 }
1591 `)
1592
Paul Duffin1356d8c2020-02-25 19:26:33 +00001593 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001594 checkAndroidBpContents(`
1595// This is auto-generated. DO NOT EDIT.
1596
1597cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001598 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001599 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001600 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001601 apex_available: ["//apex_available:platform"],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001602 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001603 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001604 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001605 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001606 arch: {
1607 arm64: {
1608 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001609 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001610 },
1611 arm: {
1612 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001613 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001614 },
1615 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001616}
1617
1618cc_prebuilt_library_static {
1619 name: "mynativelib",
1620 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001621 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001622 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001623 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001624 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001625 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001626 arch: {
1627 arm64: {
1628 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001629 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001630 },
1631 arm: {
1632 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001633 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001634 },
1635 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001636}
1637
Paul Duffine6029182019-12-16 17:43:48 +00001638module_exports_snapshot {
1639 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001640 visibility: ["//visibility:public"],
Paul Duffine6029182019-12-16 17:43:48 +00001641 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001642}
1643`),
1644 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001645include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001646.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1647.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1648.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1649.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1650.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1651.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1652.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1653.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001654`),
1655 )
1656}
1657
1658func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001659 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001660 module_exports {
1661 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001662 device_supported: false,
1663 host_supported: true,
1664 native_static_libs: ["mynativelib"],
1665 }
1666
1667 cc_library_static {
1668 name: "mynativelib",
1669 device_supported: false,
1670 host_supported: true,
1671 srcs: [
1672 "Test.cpp",
1673 "aidl/foo/bar/Test.aidl",
1674 ],
1675 export_include_dirs: ["include"],
1676 aidl: {
1677 export_aidl_headers: true,
1678 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001679 stl: "none",
1680 }
1681 `)
1682
Paul Duffin1356d8c2020-02-25 19:26:33 +00001683 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001684 checkAndroidBpContents(`
1685// This is auto-generated. DO NOT EDIT.
1686
1687cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001688 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001689 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001690 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001691 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001692 device_supported: false,
1693 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001694 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001695 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001696 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001697 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001698 target: {
1699 host: {
1700 enabled: false,
1701 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001702 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001703 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001704 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001705 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001706 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001707 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001708 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001709 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001710 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001711 },
1712 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001713}
1714
1715cc_prebuilt_library_static {
1716 name: "mynativelib",
1717 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001718 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001719 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001720 device_supported: false,
1721 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001722 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001723 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001724 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001725 target: {
1726 host: {
1727 enabled: false,
1728 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001729 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001730 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001731 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001732 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001733 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001734 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001735 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001736 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001737 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001738 },
1739 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001740}
1741
Paul Duffine6029182019-12-16 17:43:48 +00001742module_exports_snapshot {
1743 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001744 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001745 device_supported: false,
1746 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001747 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001748 target: {
1749 host: {
1750 enabled: false,
1751 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001752 linux_glibc_x86_64: {
1753 enabled: true,
1754 },
1755 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001756 enabled: true,
1757 },
1758 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001759}
1760`),
1761 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001762include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001763.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001764.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1765.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1766.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1767.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001768.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1769.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1770.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1771`),
1772 )
1773}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001774
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001775func TestSnapshotWithCcLibrary(t *testing.T) {
1776 result := testSdkWithCc(t, `
1777 module_exports {
1778 name: "myexports",
1779 native_libs: ["mynativelib"],
1780 }
1781
1782 cc_library {
1783 name: "mynativelib",
1784 srcs: [
1785 "Test.cpp",
1786 ],
1787 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001788 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001789 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001790 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001791 }
1792 `)
1793
1794 result.CheckSnapshot("myexports", "",
1795 checkAndroidBpContents(`
1796// This is auto-generated. DO NOT EDIT.
1797
1798cc_prebuilt_library {
1799 name: "myexports_mynativelib@current",
1800 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001801 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001802 apex_available: ["//apex_available:platform"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001803 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001804 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001805 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001806 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001807 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001808 export_include_dirs: ["include/include"],
1809 arch: {
1810 arm64: {
1811 static: {
1812 srcs: ["arm64/lib/mynativelib.a"],
1813 },
1814 shared: {
1815 srcs: ["arm64/lib/mynativelib.so"],
1816 },
1817 },
1818 arm: {
1819 static: {
1820 srcs: ["arm/lib/mynativelib.a"],
1821 },
1822 shared: {
1823 srcs: ["arm/lib/mynativelib.so"],
1824 },
1825 },
1826 },
1827}
1828
1829cc_prebuilt_library {
1830 name: "mynativelib",
1831 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001832 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001833 apex_available: ["//apex_available:platform"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001834 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001835 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001836 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001837 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001838 export_include_dirs: ["include/include"],
1839 arch: {
1840 arm64: {
1841 static: {
1842 srcs: ["arm64/lib/mynativelib.a"],
1843 },
1844 shared: {
1845 srcs: ["arm64/lib/mynativelib.so"],
1846 },
1847 },
1848 arm: {
1849 static: {
1850 srcs: ["arm/lib/mynativelib.a"],
1851 },
1852 shared: {
1853 srcs: ["arm/lib/mynativelib.so"],
1854 },
1855 },
1856 },
1857}
1858
1859module_exports_snapshot {
1860 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001861 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001862 native_libs: ["myexports_mynativelib@current"],
1863}
1864`),
1865 checkAllCopyRules(`
1866include/Test.h -> include/include/Test.h
1867.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1868.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1869.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1870.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1871 )
1872}
1873
Paul Duffin13ad94f2020-02-19 16:19:27 +00001874func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001875 result := testSdkWithCc(t, `
1876 module_exports {
1877 name: "myexports",
1878 device_supported: false,
1879 host_supported: true,
1880 target: {
1881 host: {
1882 compile_multilib: "64",
1883 },
1884 },
1885 native_static_libs: ["mynativelib"],
1886 }
1887
1888 cc_library_static {
1889 name: "mynativelib",
1890 device_supported: false,
1891 host_supported: true,
1892 srcs: [
1893 "Test.cpp",
1894 "aidl/foo/bar/Test.aidl",
1895 ],
1896 export_include_dirs: ["include"],
1897 aidl: {
1898 export_aidl_headers: true,
1899 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001900 stl: "none",
1901 }
1902 `)
1903
Paul Duffin1356d8c2020-02-25 19:26:33 +00001904 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001905 checkAndroidBpContents(`
1906// This is auto-generated. DO NOT EDIT.
1907
1908cc_prebuilt_library_static {
1909 name: "myexports_mynativelib@current",
1910 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001911 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001912 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001913 device_supported: false,
1914 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001915 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001916 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001917 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001918 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001919 target: {
1920 host: {
1921 enabled: false,
1922 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001923 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001924 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001925 srcs: ["x86_64/lib/mynativelib.a"],
1926 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1927 },
1928 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001929}
1930
1931cc_prebuilt_library_static {
1932 name: "mynativelib",
1933 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001934 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001935 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001936 device_supported: false,
1937 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001938 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001939 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001940 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001941 target: {
1942 host: {
1943 enabled: false,
1944 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001945 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001946 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001947 srcs: ["x86_64/lib/mynativelib.a"],
1948 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1949 },
1950 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001951}
1952
1953module_exports_snapshot {
1954 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001955 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001956 device_supported: false,
1957 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001958 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001959 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001960 target: {
1961 host: {
1962 enabled: false,
1963 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001964 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001965 enabled: true,
1966 },
1967 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001968}`),
1969 checkAllCopyRules(`
1970include/Test.h -> include/include/Test.h
1971.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1972.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1973.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1974.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1975`),
1976 )
1977}
Paul Duffin91756d22020-02-21 16:29:57 +00001978
1979func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1980 result := testSdkWithCc(t, `
1981 sdk {
1982 name: "mysdk",
1983 native_header_libs: ["mynativeheaders"],
1984 }
1985
1986 cc_library_headers {
1987 name: "mynativeheaders",
1988 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001989 stl: "none",
1990 }
1991 `)
1992
Paul Duffin1356d8c2020-02-25 19:26:33 +00001993 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001994 checkAndroidBpContents(`
1995// This is auto-generated. DO NOT EDIT.
1996
1997cc_prebuilt_library_headers {
1998 name: "mysdk_mynativeheaders@current",
1999 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002000 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002001 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002002 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002003 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002004 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00002005}
2006
2007cc_prebuilt_library_headers {
2008 name: "mynativeheaders",
2009 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002010 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002011 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002012 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002013 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002014 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00002015}
2016
2017sdk_snapshot {
2018 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002019 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002020 native_header_libs: ["mysdk_mynativeheaders@current"],
2021}
2022`),
2023 checkAllCopyRules(`
2024include/Test.h -> include/include/Test.h
2025`),
2026 )
2027}
2028
2029func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00002030 result := testSdkWithCc(t, `
2031 sdk {
2032 name: "mysdk",
2033 device_supported: false,
2034 host_supported: true,
2035 native_header_libs: ["mynativeheaders"],
2036 }
2037
2038 cc_library_headers {
2039 name: "mynativeheaders",
2040 device_supported: false,
2041 host_supported: true,
2042 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00002043 stl: "none",
2044 }
2045 `)
2046
Paul Duffin1356d8c2020-02-25 19:26:33 +00002047 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00002048 checkAndroidBpContents(`
2049// This is auto-generated. DO NOT EDIT.
2050
2051cc_prebuilt_library_headers {
2052 name: "mysdk_mynativeheaders@current",
2053 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002054 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002055 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002056 device_supported: false,
2057 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002058 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002059 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002060 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002061 target: {
2062 host: {
2063 enabled: false,
2064 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002065 linux_glibc_x86_64: {
2066 enabled: true,
2067 },
2068 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002069 enabled: true,
2070 },
2071 },
Paul Duffin91756d22020-02-21 16:29:57 +00002072}
2073
2074cc_prebuilt_library_headers {
2075 name: "mynativeheaders",
2076 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002077 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002078 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002079 device_supported: false,
2080 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002081 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002082 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002083 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002084 target: {
2085 host: {
2086 enabled: false,
2087 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002088 linux_glibc_x86_64: {
2089 enabled: true,
2090 },
2091 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002092 enabled: true,
2093 },
2094 },
Paul Duffin91756d22020-02-21 16:29:57 +00002095}
2096
2097sdk_snapshot {
2098 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002099 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002100 device_supported: false,
2101 host_supported: true,
2102 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002103 target: {
2104 host: {
2105 enabled: false,
2106 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002107 linux_glibc_x86_64: {
2108 enabled: true,
2109 },
2110 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002111 enabled: true,
2112 },
2113 },
Paul Duffin91756d22020-02-21 16:29:57 +00002114}
2115`),
2116 checkAllCopyRules(`
2117include/Test.h -> include/include/Test.h
2118`),
2119 )
2120}
Paul Duffina04c1072020-03-02 10:16:35 +00002121
2122func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00002123 result := testSdkWithCc(t, `
2124 sdk {
2125 name: "mysdk",
2126 host_supported: true,
2127 native_header_libs: ["mynativeheaders"],
2128 }
2129
2130 cc_library_headers {
2131 name: "mynativeheaders",
2132 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002133 stl: "none",
2134 export_system_include_dirs: ["include"],
2135 target: {
2136 android: {
2137 export_include_dirs: ["include-android"],
2138 },
2139 host: {
2140 export_include_dirs: ["include-host"],
2141 },
2142 },
2143 }
2144 `)
2145
2146 result.CheckSnapshot("mysdk", "",
2147 checkAndroidBpContents(`
2148// This is auto-generated. DO NOT EDIT.
2149
2150cc_prebuilt_library_headers {
2151 name: "mysdk_mynativeheaders@current",
2152 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002153 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002154 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002155 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002156 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002157 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002158 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002159 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002160 host: {
2161 enabled: false,
2162 },
Paul Duffina04c1072020-03-02 10:16:35 +00002163 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002164 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002165 },
2166 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002167 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002168 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002169 linux_glibc_x86_64: {
2170 enabled: true,
2171 },
2172 linux_glibc_x86: {
2173 enabled: true,
2174 },
Paul Duffina04c1072020-03-02 10:16:35 +00002175 },
Paul Duffina04c1072020-03-02 10:16:35 +00002176}
2177
2178cc_prebuilt_library_headers {
2179 name: "mynativeheaders",
2180 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002181 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002182 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002183 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002184 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002185 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002186 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002187 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002188 host: {
2189 enabled: false,
2190 },
Paul Duffina04c1072020-03-02 10:16:35 +00002191 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002192 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002193 },
2194 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002195 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002196 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002197 linux_glibc_x86_64: {
2198 enabled: true,
2199 },
2200 linux_glibc_x86: {
2201 enabled: true,
2202 },
Paul Duffina04c1072020-03-02 10:16:35 +00002203 },
Paul Duffina04c1072020-03-02 10:16:35 +00002204}
2205
2206sdk_snapshot {
2207 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002208 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002209 host_supported: true,
2210 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002211 target: {
2212 host: {
2213 enabled: false,
2214 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002215 linux_glibc_x86_64: {
2216 enabled: true,
2217 },
2218 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002219 enabled: true,
2220 },
2221 },
Paul Duffina04c1072020-03-02 10:16:35 +00002222}
2223`),
2224 checkAllCopyRules(`
Paul Duffined62b9c2020-06-16 16:12:50 +01002225include/Test.h -> common_os/include/include/Test.h
2226include-android/AndroidTest.h -> android/include/include-android/AndroidTest.h
2227include-host/HostTest.h -> linux_glibc/include/include-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002228`),
2229 )
2230}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002231
2232func TestSystemSharedLibPropagation(t *testing.T) {
2233 result := testSdkWithCc(t, `
2234 sdk {
2235 name: "mysdk",
2236 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2237 }
2238
2239 cc_library {
2240 name: "sslnil",
2241 host_supported: true,
2242 }
2243
2244 cc_library {
2245 name: "sslempty",
2246 system_shared_libs: [],
2247 }
2248
2249 cc_library {
2250 name: "sslnonempty",
2251 system_shared_libs: ["sslnil"],
2252 }
2253 `)
2254
2255 result.CheckSnapshot("mysdk", "",
2256 checkAndroidBpContents(`
2257// This is auto-generated. DO NOT EDIT.
2258
2259cc_prebuilt_library_shared {
2260 name: "mysdk_sslnil@current",
2261 sdk_member_name: "sslnil",
Paul Duffind99d9972020-09-29 16:00:55 +01002262 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002263 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002264 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002265 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002266 arch: {
2267 arm64: {
2268 srcs: ["arm64/lib/sslnil.so"],
2269 },
2270 arm: {
2271 srcs: ["arm/lib/sslnil.so"],
2272 },
2273 },
2274}
2275
2276cc_prebuilt_library_shared {
2277 name: "sslnil",
2278 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002279 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002280 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002281 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002282 arch: {
2283 arm64: {
2284 srcs: ["arm64/lib/sslnil.so"],
2285 },
2286 arm: {
2287 srcs: ["arm/lib/sslnil.so"],
2288 },
2289 },
2290}
2291
2292cc_prebuilt_library_shared {
2293 name: "mysdk_sslempty@current",
2294 sdk_member_name: "sslempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002295 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002296 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002297 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002298 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002299 system_shared_libs: [],
2300 arch: {
2301 arm64: {
2302 srcs: ["arm64/lib/sslempty.so"],
2303 },
2304 arm: {
2305 srcs: ["arm/lib/sslempty.so"],
2306 },
2307 },
2308}
2309
2310cc_prebuilt_library_shared {
2311 name: "sslempty",
2312 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002313 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002314 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002315 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002316 system_shared_libs: [],
2317 arch: {
2318 arm64: {
2319 srcs: ["arm64/lib/sslempty.so"],
2320 },
2321 arm: {
2322 srcs: ["arm/lib/sslempty.so"],
2323 },
2324 },
2325}
2326
2327cc_prebuilt_library_shared {
2328 name: "mysdk_sslnonempty@current",
2329 sdk_member_name: "sslnonempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002330 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002331 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002332 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002333 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002334 system_shared_libs: ["mysdk_sslnil@current"],
2335 arch: {
2336 arm64: {
2337 srcs: ["arm64/lib/sslnonempty.so"],
2338 },
2339 arm: {
2340 srcs: ["arm/lib/sslnonempty.so"],
2341 },
2342 },
2343}
2344
2345cc_prebuilt_library_shared {
2346 name: "sslnonempty",
2347 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002348 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002349 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002350 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002351 system_shared_libs: ["sslnil"],
2352 arch: {
2353 arm64: {
2354 srcs: ["arm64/lib/sslnonempty.so"],
2355 },
2356 arm: {
2357 srcs: ["arm/lib/sslnonempty.so"],
2358 },
2359 },
2360}
2361
2362sdk_snapshot {
2363 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002364 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002365 native_shared_libs: [
2366 "mysdk_sslnil@current",
2367 "mysdk_sslempty@current",
2368 "mysdk_sslnonempty@current",
2369 ],
2370}
2371`))
2372
2373 result = testSdkWithCc(t, `
2374 sdk {
2375 name: "mysdk",
2376 host_supported: true,
2377 native_shared_libs: ["sslvariants"],
2378 }
2379
2380 cc_library {
2381 name: "sslvariants",
2382 host_supported: true,
2383 target: {
2384 android: {
2385 system_shared_libs: [],
2386 },
2387 },
2388 }
2389 `)
2390
2391 result.CheckSnapshot("mysdk", "",
2392 checkAndroidBpContents(`
2393// This is auto-generated. DO NOT EDIT.
2394
2395cc_prebuilt_library_shared {
2396 name: "mysdk_sslvariants@current",
2397 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002398 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002399 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002400 host_supported: true,
2401 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002402 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002403 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002404 host: {
2405 enabled: false,
2406 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002407 android: {
2408 system_shared_libs: [],
2409 },
2410 android_arm64: {
2411 srcs: ["android/arm64/lib/sslvariants.so"],
2412 },
2413 android_arm: {
2414 srcs: ["android/arm/lib/sslvariants.so"],
2415 },
2416 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002417 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002418 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2419 },
2420 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002421 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002422 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2423 },
2424 },
2425}
2426
2427cc_prebuilt_library_shared {
2428 name: "sslvariants",
2429 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002430 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002431 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002432 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002433 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002434 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002435 host: {
2436 enabled: false,
2437 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002438 android: {
2439 system_shared_libs: [],
2440 },
2441 android_arm64: {
2442 srcs: ["android/arm64/lib/sslvariants.so"],
2443 },
2444 android_arm: {
2445 srcs: ["android/arm/lib/sslvariants.so"],
2446 },
2447 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002448 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002449 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2450 },
2451 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002452 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002453 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2454 },
2455 },
2456}
2457
2458sdk_snapshot {
2459 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002460 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002461 host_supported: true,
2462 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002463 target: {
2464 host: {
2465 enabled: false,
2466 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002467 linux_glibc_x86_64: {
2468 enabled: true,
2469 },
2470 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002471 enabled: true,
2472 },
2473 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002474}
2475`))
2476}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002477
2478func TestStubsLibrary(t *testing.T) {
2479 result := testSdkWithCc(t, `
2480 sdk {
2481 name: "mysdk",
2482 native_shared_libs: ["stubslib"],
2483 }
2484
2485 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002486 name: "internaldep",
2487 }
2488
2489 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002490 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002491 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002492 stubs: {
2493 symbol_file: "some/where/stubslib.map.txt",
2494 versions: ["1", "2", "3"],
2495 },
2496 }
2497 `)
2498
2499 result.CheckSnapshot("mysdk", "",
2500 checkAndroidBpContents(`
2501// This is auto-generated. DO NOT EDIT.
2502
2503cc_prebuilt_library_shared {
2504 name: "mysdk_stubslib@current",
2505 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002506 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002507 apex_available: ["//apex_available:platform"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002508 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002509 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002510 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002511 versions: [
2512 "1",
2513 "2",
2514 "3",
2515 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002516 },
2517 arch: {
2518 arm64: {
2519 srcs: ["arm64/lib/stubslib.so"],
2520 },
2521 arm: {
2522 srcs: ["arm/lib/stubslib.so"],
2523 },
2524 },
2525}
2526
2527cc_prebuilt_library_shared {
2528 name: "stubslib",
2529 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002530 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002531 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002532 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002533 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002534 versions: [
2535 "1",
2536 "2",
2537 "3",
2538 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002539 },
2540 arch: {
2541 arm64: {
2542 srcs: ["arm64/lib/stubslib.so"],
2543 },
2544 arm: {
2545 srcs: ["arm/lib/stubslib.so"],
2546 },
2547 },
2548}
2549
2550sdk_snapshot {
2551 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002552 visibility: ["//visibility:public"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002553 native_shared_libs: ["mysdk_stubslib@current"],
2554}
2555`))
2556}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002557
2558func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002559 result := testSdkWithCc(t, `
2560 sdk {
2561 name: "mysdk",
2562 host_supported: true,
2563 native_shared_libs: ["stubslib"],
2564 }
2565
2566 cc_library {
2567 name: "internaldep",
2568 host_supported: true,
2569 }
2570
2571 cc_library {
2572 name: "stubslib",
2573 host_supported: true,
2574 shared_libs: ["internaldep"],
2575 stubs: {
2576 symbol_file: "some/where/stubslib.map.txt",
2577 versions: ["1", "2", "3"],
2578 },
2579 }
2580 `)
2581
2582 result.CheckSnapshot("mysdk", "",
2583 checkAndroidBpContents(`
2584// This is auto-generated. DO NOT EDIT.
2585
2586cc_prebuilt_library_shared {
2587 name: "mysdk_stubslib@current",
2588 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002589 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002590 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002591 host_supported: true,
2592 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002593 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002594 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002595 versions: [
2596 "1",
2597 "2",
2598 "3",
2599 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002600 },
2601 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002602 host: {
2603 enabled: false,
2604 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002605 android_arm64: {
2606 srcs: ["android/arm64/lib/stubslib.so"],
2607 },
2608 android_arm: {
2609 srcs: ["android/arm/lib/stubslib.so"],
2610 },
2611 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002612 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002613 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2614 },
2615 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002616 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002617 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2618 },
2619 },
2620}
2621
2622cc_prebuilt_library_shared {
2623 name: "stubslib",
2624 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002625 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002626 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002627 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002628 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002629 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002630 versions: [
2631 "1",
2632 "2",
2633 "3",
2634 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002635 },
2636 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002637 host: {
2638 enabled: false,
2639 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002640 android_arm64: {
2641 srcs: ["android/arm64/lib/stubslib.so"],
2642 },
2643 android_arm: {
2644 srcs: ["android/arm/lib/stubslib.so"],
2645 },
2646 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002647 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002648 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2649 },
2650 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002651 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002652 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2653 },
2654 },
2655}
2656
2657sdk_snapshot {
2658 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002659 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002660 host_supported: true,
2661 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002662 target: {
2663 host: {
2664 enabled: false,
2665 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002666 linux_glibc_x86_64: {
2667 enabled: true,
2668 },
2669 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002670 enabled: true,
2671 },
2672 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002673}
2674`))
2675}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002676
2677func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002678 result := testSdkWithCc(t, `
2679 sdk {
2680 name: "mysdk",
2681 host_supported: true,
2682 native_shared_libs: ["mylib"],
2683 }
2684
2685 cc_library {
2686 name: "mylib",
2687 host_supported: true,
2688 unique_host_soname: true,
2689 }
2690 `)
2691
2692 result.CheckSnapshot("mysdk", "",
2693 checkAndroidBpContents(`
2694// This is auto-generated. DO NOT EDIT.
2695
2696cc_prebuilt_library_shared {
2697 name: "mysdk_mylib@current",
2698 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002699 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002700 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002701 host_supported: true,
2702 installable: false,
2703 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002704 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002705 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002706 host: {
2707 enabled: false,
2708 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002709 android_arm64: {
2710 srcs: ["android/arm64/lib/mylib.so"],
2711 },
2712 android_arm: {
2713 srcs: ["android/arm/lib/mylib.so"],
2714 },
2715 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002716 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002717 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2718 },
2719 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002720 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002721 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2722 },
2723 },
2724}
2725
2726cc_prebuilt_library_shared {
2727 name: "mylib",
2728 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002729 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002730 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002731 host_supported: true,
2732 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002733 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002734 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002735 host: {
2736 enabled: false,
2737 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002738 android_arm64: {
2739 srcs: ["android/arm64/lib/mylib.so"],
2740 },
2741 android_arm: {
2742 srcs: ["android/arm/lib/mylib.so"],
2743 },
2744 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002745 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002746 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2747 },
2748 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002749 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002750 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2751 },
2752 },
2753}
2754
2755sdk_snapshot {
2756 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002757 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002758 host_supported: true,
2759 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002760 target: {
2761 host: {
2762 enabled: false,
2763 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002764 linux_glibc_x86_64: {
2765 enabled: true,
2766 },
2767 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002768 enabled: true,
2769 },
2770 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002771}
2772`),
2773 checkAllCopyRules(`
2774.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2775.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2776.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2777.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2778`),
2779 )
2780}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002781
2782func TestNoSanitizerMembers(t *testing.T) {
2783 result := testSdkWithCc(t, `
2784 sdk {
2785 name: "mysdk",
2786 native_shared_libs: ["mynativelib"],
2787 }
2788
2789 cc_library_shared {
2790 name: "mynativelib",
2791 srcs: ["Test.cpp"],
2792 export_include_dirs: ["include"],
2793 arch: {
2794 arm64: {
2795 export_system_include_dirs: ["arm64/include"],
2796 sanitize: {
2797 hwaddress: true,
2798 },
2799 },
2800 },
2801 }
2802 `)
2803
2804 result.CheckSnapshot("mysdk", "",
2805 checkAndroidBpContents(`
2806// This is auto-generated. DO NOT EDIT.
2807
2808cc_prebuilt_library_shared {
2809 name: "mysdk_mynativelib@current",
2810 sdk_member_name: "mynativelib",
2811 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002812 apex_available: ["//apex_available:platform"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002813 installable: false,
2814 compile_multilib: "both",
2815 export_include_dirs: ["include/include"],
2816 arch: {
2817 arm64: {
2818 export_system_include_dirs: ["arm64/include/arm64/include"],
2819 },
2820 arm: {
2821 srcs: ["arm/lib/mynativelib.so"],
2822 },
2823 },
2824}
2825
2826cc_prebuilt_library_shared {
2827 name: "mynativelib",
2828 prefer: false,
2829 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002830 apex_available: ["//apex_available:platform"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002831 compile_multilib: "both",
2832 export_include_dirs: ["include/include"],
2833 arch: {
2834 arm64: {
2835 export_system_include_dirs: ["arm64/include/arm64/include"],
2836 },
2837 arm: {
2838 srcs: ["arm/lib/mynativelib.so"],
2839 },
2840 },
2841}
2842
2843sdk_snapshot {
2844 name: "mysdk@current",
2845 visibility: ["//visibility:public"],
2846 native_shared_libs: ["mysdk_mynativelib@current"],
2847}
2848`),
2849 checkAllCopyRules(`
2850include/Test.h -> include/include/Test.h
2851arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
2852.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
2853 )
2854}