blob: 4a090814deac0cc819d94f0559a56a524630624e [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
Paul Duffind835daa2019-11-30 17:49:09 +000024func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
25 t.Helper()
26
27 fs := map[string][]byte{
Paul Duffina04c1072020-03-02 10:16:35 +000028 "Test.cpp": nil,
29 "include/Test.h": nil,
30 "include-android/AndroidTest.h": nil,
31 "include-host/HostTest.h": nil,
32 "arm64/include/Arm64Test.h": nil,
33 "libfoo.so": nil,
34 "aidl/foo/bar/Test.aidl": nil,
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +010035 "some/where/stubslib.map.txt": nil,
Paul Duffind835daa2019-11-30 17:49:09 +000036 }
37 return testSdkWithFs(t, bp, fs)
38}
39
Paul Duffina80fdec2019-12-03 15:25:00 +000040// Contains tests for SDK members provided by the cc package.
41
42func TestSdkIsCompileMultilibBoth(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +000043 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000044 sdk {
45 name: "mysdk",
46 native_shared_libs: ["sdkmember"],
47 }
48
49 cc_library_shared {
50 name: "sdkmember",
51 srcs: ["Test.cpp"],
Paul Duffina80fdec2019-12-03 15:25:00 +000052 stl: "none",
53 }
54 `)
55
Colin Cross7113d202019-11-20 16:39:12 -080056 armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile()
57 arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile()
Paul Duffina80fdec2019-12-03 15:25:00 +000058
59 var inputs []string
Paul Duffin1356d8c2020-02-25 19:26:33 +000060 buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests()
Paul Duffina80fdec2019-12-03 15:25:00 +000061 for _, bp := range buildParams {
62 if bp.Input != nil {
63 inputs = append(inputs, bp.Input.String())
64 }
65 }
66
67 // ensure that both 32/64 outputs are inputs of the sdk snapshot
68 ensureListContains(t, inputs, armOutput.String())
69 ensureListContains(t, inputs, arm64Output.String())
70}
71
72func TestBasicSdkWithCc(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +000073 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000074 sdk {
75 name: "mysdk",
76 native_shared_libs: ["sdkmember"],
77 }
78
Paul Duffina0843f62019-12-13 19:50:38 +000079 cc_library_shared {
80 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -080081 system_shared_libs: [],
Paul Duffina0843f62019-12-13 19:50:38 +000082 }
83
Paul Duffina80fdec2019-12-03 15:25:00 +000084 sdk_snapshot {
85 name: "mysdk@1",
86 native_shared_libs: ["sdkmember_mysdk_1"],
87 }
88
89 sdk_snapshot {
90 name: "mysdk@2",
91 native_shared_libs: ["sdkmember_mysdk_2"],
92 }
93
94 cc_prebuilt_library_shared {
95 name: "sdkmember",
96 srcs: ["libfoo.so"],
97 prefer: false,
98 system_shared_libs: [],
99 stl: "none",
100 }
101
102 cc_prebuilt_library_shared {
103 name: "sdkmember_mysdk_1",
104 sdk_member_name: "sdkmember",
105 srcs: ["libfoo.so"],
106 system_shared_libs: [],
107 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000108 // TODO: remove //apex_available:platform
109 apex_available: [
110 "//apex_available:platform",
111 "myapex",
112 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000113 }
114
115 cc_prebuilt_library_shared {
116 name: "sdkmember_mysdk_2",
117 sdk_member_name: "sdkmember",
118 srcs: ["libfoo.so"],
119 system_shared_libs: [],
120 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000121 // TODO: remove //apex_available:platform
122 apex_available: [
123 "//apex_available:platform",
124 "myapex2",
125 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000126 }
127
128 cc_library_shared {
129 name: "mycpplib",
130 srcs: ["Test.cpp"],
131 shared_libs: ["sdkmember"],
132 system_shared_libs: [],
133 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000134 apex_available: [
135 "myapex",
136 "myapex2",
137 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000138 }
139
140 apex {
141 name: "myapex",
142 native_shared_libs: ["mycpplib"],
143 uses_sdks: ["mysdk@1"],
144 key: "myapex.key",
145 certificate: ":myapex.cert",
146 }
147
148 apex {
149 name: "myapex2",
150 native_shared_libs: ["mycpplib"],
151 uses_sdks: ["mysdk@2"],
152 key: "myapex.key",
153 certificate: ":myapex.cert",
154 }
155 `)
156
Colin Cross7113d202019-11-20 16:39:12 -0800157 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_myapex").Rule("toc").Output
158 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_myapex2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000159
Colin Cross7113d202019-11-20 16:39:12 -0800160 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex")
161 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000162
163 // Depending on the uses_sdks value, different libs are linked
164 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
165 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
166}
167
Paul Duffina0843f62019-12-13 19:50:38 +0000168// Make sure the sdk can use host specific cc libraries static/shared and both.
169func TestHostSdkWithCc(t *testing.T) {
170 testSdkWithCc(t, `
171 sdk {
172 name: "mysdk",
173 device_supported: false,
174 host_supported: true,
175 native_shared_libs: ["sdkshared"],
176 native_static_libs: ["sdkstatic"],
177 }
178
179 cc_library_host_shared {
180 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000181 stl: "none",
182 }
183
184 cc_library_host_static {
185 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000186 stl: "none",
187 }
188 `)
189}
190
191// Make sure the sdk can use cc libraries static/shared and both.
192func TestSdkWithCc(t *testing.T) {
193 testSdkWithCc(t, `
194 sdk {
195 name: "mysdk",
196 native_shared_libs: ["sdkshared", "sdkboth1"],
197 native_static_libs: ["sdkstatic", "sdkboth2"],
198 }
199
200 cc_library_shared {
201 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000202 stl: "none",
203 }
204
205 cc_library_static {
206 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000207 stl: "none",
208 }
209
210 cc_library {
211 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000212 stl: "none",
213 }
214
215 cc_library {
216 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000217 stl: "none",
218 }
219 `)
220}
221
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000222func TestSnapshotWithObject(t *testing.T) {
223 result := testSdkWithCc(t, `
224 sdk {
225 name: "mysdk",
226 native_objects: ["crtobj"],
227 }
228
229 cc_object {
230 name: "crtobj",
231 stl: "none",
232 }
233 `)
234
235 result.CheckSnapshot("mysdk", "",
236 checkAndroidBpContents(`
237// This is auto-generated. DO NOT EDIT.
238
239cc_prebuilt_object {
240 name: "mysdk_crtobj@current",
241 sdk_member_name: "crtobj",
242 stl: "none",
243 arch: {
244 arm64: {
245 srcs: ["arm64/lib/crtobj.o"],
246 },
247 arm: {
248 srcs: ["arm/lib/crtobj.o"],
249 },
250 },
251}
252
253cc_prebuilt_object {
254 name: "crtobj",
255 prefer: false,
256 stl: "none",
257 arch: {
258 arm64: {
259 srcs: ["arm64/lib/crtobj.o"],
260 },
261 arm: {
262 srcs: ["arm/lib/crtobj.o"],
263 },
264 },
265}
266
267sdk_snapshot {
268 name: "mysdk@current",
269 native_objects: ["mysdk_crtobj@current"],
270}
271`),
272 checkAllCopyRules(`
273.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
274.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
275`),
276 )
277}
278
Paul Duffinc62a5102019-12-11 18:34:15 +0000279func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
280 result := testSdkWithCc(t, `
281 sdk {
282 name: "mysdk",
283 native_shared_libs: ["mynativelib1", "mynativelib2"],
284 }
285
286 cc_library_shared {
287 name: "mynativelib1",
288 srcs: [
289 "Test.cpp",
290 ],
291 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000292 stl: "none",
293 }
294
295 cc_library_shared {
296 name: "mynativelib2",
297 srcs: [
298 "Test.cpp",
299 ],
300 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000301 stl: "none",
302 }
303 `)
304
Paul Duffin1356d8c2020-02-25 19:26:33 +0000305 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000306 checkAllCopyRules(`
307include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800308.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
309.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
310.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
311.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000312`),
313 )
314}
315
Paul Duffina7cd8c82019-12-11 20:00:57 +0000316// Verify that when the shared library has some common and some arch specific properties that the generated
317// snapshot is optimized properly.
318func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
319 result := testSdkWithCc(t, `
320 sdk {
321 name: "mysdk",
322 native_shared_libs: ["mynativelib"],
323 }
324
325 cc_library_shared {
326 name: "mynativelib",
327 srcs: [
328 "Test.cpp",
329 "aidl/foo/bar/Test.aidl",
330 ],
331 export_include_dirs: ["include"],
332 arch: {
333 arm64: {
334 export_system_include_dirs: ["arm64/include"],
335 },
336 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000337 stl: "none",
338 }
339 `)
340
Paul Duffin1356d8c2020-02-25 19:26:33 +0000341 result.CheckSnapshot("mysdk", "",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000342 checkAndroidBpContents(`
343// This is auto-generated. DO NOT EDIT.
344
345cc_prebuilt_library_shared {
346 name: "mysdk_mynativelib@current",
347 sdk_member_name: "mynativelib",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000348 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000349 stl: "none",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000350 export_include_dirs: ["include/include"],
351 arch: {
352 arm64: {
353 srcs: ["arm64/lib/mynativelib.so"],
354 export_system_include_dirs: ["arm64/include/arm64/include"],
355 },
356 arm: {
357 srcs: ["arm/lib/mynativelib.so"],
358 },
359 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000360}
361
362cc_prebuilt_library_shared {
363 name: "mynativelib",
364 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000365 stl: "none",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000366 export_include_dirs: ["include/include"],
367 arch: {
368 arm64: {
369 srcs: ["arm64/lib/mynativelib.so"],
370 export_system_include_dirs: ["arm64/include/arm64/include"],
371 },
372 arm: {
373 srcs: ["arm/lib/mynativelib.so"],
374 },
375 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000376}
377
378sdk_snapshot {
379 name: "mysdk@current",
380 native_shared_libs: ["mysdk_mynativelib@current"],
381}
382`),
383 checkAllCopyRules(`
384include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800385.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000386arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800387.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000388 )
389}
390
Paul Duffin25ce04b2020-01-16 11:47:25 +0000391func TestSnapshotWithCcBinary(t *testing.T) {
392 result := testSdkWithCc(t, `
393 module_exports {
394 name: "mymodule_exports",
395 native_binaries: ["mynativebinary"],
396 }
397
398 cc_binary {
399 name: "mynativebinary",
400 srcs: [
401 "Test.cpp",
402 ],
403 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000404 }
405 `)
406
Paul Duffin1356d8c2020-02-25 19:26:33 +0000407 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000408 checkAndroidBpContents(`
409// This is auto-generated. DO NOT EDIT.
410
411cc_prebuilt_binary {
412 name: "mymodule_exports_mynativebinary@current",
413 sdk_member_name: "mynativebinary",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000414 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000415 compile_multilib: "both",
416 arch: {
417 arm64: {
418 srcs: ["arm64/bin/mynativebinary"],
419 },
420 arm: {
421 srcs: ["arm/bin/mynativebinary"],
422 },
423 },
424}
425
426cc_prebuilt_binary {
427 name: "mynativebinary",
428 prefer: false,
429 compile_multilib: "both",
430 arch: {
431 arm64: {
432 srcs: ["arm64/bin/mynativebinary"],
433 },
434 arm: {
435 srcs: ["arm/bin/mynativebinary"],
436 },
437 },
438}
439
440module_exports_snapshot {
441 name: "mymodule_exports@current",
442 native_binaries: ["mymodule_exports_mynativebinary@current"],
443}
444`),
445 checkAllCopyRules(`
446.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
447.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
448`),
449 )
450}
451
Paul Duffina04c1072020-03-02 10:16:35 +0000452func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
453 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
454 SkipIfNotLinux(t)
455
456 result := testSdkWithCc(t, `
457 module_exports {
458 name: "myexports",
459 device_supported: false,
460 host_supported: true,
461 native_binaries: ["mynativebinary"],
462 target: {
463 windows: {
464 enabled: true,
465 },
466 },
467 }
468
469 cc_binary {
470 name: "mynativebinary",
471 device_supported: false,
472 host_supported: true,
473 srcs: [
474 "Test.cpp",
475 ],
476 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000477 stl: "none",
478 target: {
479 windows: {
480 enabled: true,
481 },
482 },
483 }
484 `)
485
486 result.CheckSnapshot("myexports", "",
487 checkAndroidBpContents(`
488// This is auto-generated. DO NOT EDIT.
489
490cc_prebuilt_binary {
491 name: "myexports_mynativebinary@current",
492 sdk_member_name: "mynativebinary",
493 device_supported: false,
494 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000495 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100496 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000497 target: {
498 linux_glibc: {
499 compile_multilib: "both",
500 },
501 linux_glibc_x86_64: {
502 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
503 },
504 linux_glibc_x86: {
505 srcs: ["linux_glibc/x86/bin/mynativebinary"],
506 },
507 windows: {
508 compile_multilib: "64",
509 },
510 windows_x86_64: {
511 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
512 },
513 },
514}
515
516cc_prebuilt_binary {
517 name: "mynativebinary",
518 prefer: false,
519 device_supported: false,
520 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100521 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000522 target: {
523 linux_glibc: {
524 compile_multilib: "both",
525 },
526 linux_glibc_x86_64: {
527 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
528 },
529 linux_glibc_x86: {
530 srcs: ["linux_glibc/x86/bin/mynativebinary"],
531 },
532 windows: {
533 compile_multilib: "64",
534 },
535 windows_x86_64: {
536 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
537 },
538 },
539}
540
541module_exports_snapshot {
542 name: "myexports@current",
543 device_supported: false,
544 host_supported: true,
545 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000546 target: {
547 windows: {
548 compile_multilib: "64",
549 },
550 },
Paul Duffina04c1072020-03-02 10:16:35 +0000551}
552`),
553 checkAllCopyRules(`
554.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
555.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
556.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
557`),
558 )
559}
560
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100561// Test that we support the necessary flags for the linker binary, which is
562// special in several ways.
563func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
564 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
565 SkipIfNotLinux(t)
566
567 result := testSdkWithCc(t, `
568 module_exports {
569 name: "mymodule_exports",
570 host_supported: true,
571 device_supported: false,
572 native_binaries: ["linker"],
573 }
574
575 cc_binary {
576 name: "linker",
577 host_supported: true,
578 static_executable: true,
579 nocrt: true,
580 stl: "none",
581 srcs: [
582 "Test.cpp",
583 ],
584 compile_multilib: "both",
585 }
586 `)
587
588 result.CheckSnapshot("mymodule_exports", "",
589 checkAndroidBpContents(`
590// This is auto-generated. DO NOT EDIT.
591
592cc_prebuilt_binary {
593 name: "mymodule_exports_linker@current",
594 sdk_member_name: "linker",
595 device_supported: false,
596 host_supported: true,
597 installable: false,
598 stl: "none",
599 static_executable: true,
600 nocrt: true,
601 compile_multilib: "both",
602 arch: {
603 x86_64: {
604 srcs: ["x86_64/bin/linker"],
605 },
606 x86: {
607 srcs: ["x86/bin/linker"],
608 },
609 },
610}
611
612cc_prebuilt_binary {
613 name: "linker",
614 prefer: false,
615 device_supported: false,
616 host_supported: true,
617 stl: "none",
618 static_executable: true,
619 nocrt: true,
620 compile_multilib: "both",
621 arch: {
622 x86_64: {
623 srcs: ["x86_64/bin/linker"],
624 },
625 x86: {
626 srcs: ["x86/bin/linker"],
627 },
628 },
629}
630
631module_exports_snapshot {
632 name: "mymodule_exports@current",
633 device_supported: false,
634 host_supported: true,
635 native_binaries: ["mymodule_exports_linker@current"],
636}
637`),
638 checkAllCopyRules(`
639.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
640.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
641`),
642 )
643}
644
Paul Duffin9ab556f2019-12-11 18:42:17 +0000645func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000646 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000647 sdk {
648 name: "mysdk",
649 native_shared_libs: ["mynativelib"],
650 }
651
652 cc_library_shared {
653 name: "mynativelib",
654 srcs: [
655 "Test.cpp",
656 "aidl/foo/bar/Test.aidl",
657 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +0000658 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000659 export_include_dirs: ["include"],
660 aidl: {
661 export_aidl_headers: true,
662 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000663 stl: "none",
664 }
665 `)
666
Paul Duffin1356d8c2020-02-25 19:26:33 +0000667 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000668 checkAndroidBpContents(`
669// This is auto-generated. DO NOT EDIT.
670
671cc_prebuilt_library_shared {
672 name: "mysdk_mynativelib@current",
673 sdk_member_name: "mynativelib",
Paul Duffinbefa4b92020-03-04 14:22:45 +0000674 apex_available: [
675 "apex1",
676 "apex2",
677 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000678 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000679 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000680 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000681 arch: {
682 arm64: {
683 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000684 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000685 },
686 arm: {
687 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000688 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000689 },
690 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000691}
692
693cc_prebuilt_library_shared {
694 name: "mynativelib",
695 prefer: false,
Paul Duffinbefa4b92020-03-04 14:22:45 +0000696 apex_available: [
697 "apex1",
698 "apex2",
699 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000700 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000701 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000702 arch: {
703 arm64: {
704 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000705 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000706 },
707 arm: {
708 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000709 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000710 },
711 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000712}
713
714sdk_snapshot {
715 name: "mysdk@current",
716 native_shared_libs: ["mysdk_mynativelib@current"],
717}
718`),
719 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000720include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800721.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
722.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
723.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
724.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
725.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
726.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
727.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
728.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 +0000729`),
730 )
731}
732
Paul Duffin13f02712020-03-06 12:30:43 +0000733func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
734 result := testSdkWithCc(t, `
735 sdk {
736 name: "mysdk",
737 native_shared_libs: [
738 "mynativelib",
739 "myothernativelib",
740 "mysystemnativelib",
741 ],
742 }
743
744 cc_library {
745 name: "mysystemnativelib",
746 srcs: [
747 "Test.cpp",
748 ],
Paul Duffin13f02712020-03-06 12:30:43 +0000749 stl: "none",
750 }
751
752 cc_library_shared {
753 name: "myothernativelib",
754 srcs: [
755 "Test.cpp",
756 ],
757 system_shared_libs: [
758 // A reference to a library that is not an sdk member. Uses libm as that
759 // is in the default set of modules available to this test and so is available
760 // both here and also when the generated Android.bp file is tested in
761 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
762 // handles references to modules that are not sdk members.
763 "libm",
764 ],
765 stl: "none",
766 }
767
768 cc_library {
769 name: "mynativelib",
770 srcs: [
771 "Test.cpp",
772 ],
773 shared_libs: [
774 // A reference to another sdk member.
775 "myothernativelib",
776 ],
777 target: {
778 android: {
779 shared: {
780 shared_libs: [
781 // A reference to a library that is not an sdk member. The libc library
782 // is used here to check that the shared_libs property is handled correctly
783 // in a similar way to how libm is used to check system_shared_libs above.
784 "libc",
785 ],
786 },
787 },
788 },
Paul Duffin13f02712020-03-06 12:30:43 +0000789 stl: "none",
790 }
791 `)
792
793 result.CheckSnapshot("mysdk", "",
794 checkAndroidBpContents(`
795// This is auto-generated. DO NOT EDIT.
796
797cc_prebuilt_library_shared {
798 name: "mysdk_mynativelib@current",
799 sdk_member_name: "mynativelib",
800 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000801 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000802 shared_libs: [
803 "mysdk_myothernativelib@current",
804 "libc",
805 ],
806 arch: {
807 arm64: {
808 srcs: ["arm64/lib/mynativelib.so"],
809 },
810 arm: {
811 srcs: ["arm/lib/mynativelib.so"],
812 },
813 },
Paul Duffin13f02712020-03-06 12:30:43 +0000814}
815
816cc_prebuilt_library_shared {
817 name: "mynativelib",
818 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000819 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000820 shared_libs: [
821 "myothernativelib",
822 "libc",
823 ],
824 arch: {
825 arm64: {
826 srcs: ["arm64/lib/mynativelib.so"],
827 },
828 arm: {
829 srcs: ["arm/lib/mynativelib.so"],
830 },
831 },
Paul Duffin13f02712020-03-06 12:30:43 +0000832}
833
834cc_prebuilt_library_shared {
835 name: "mysdk_myothernativelib@current",
836 sdk_member_name: "myothernativelib",
837 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000838 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000839 system_shared_libs: ["libm"],
840 arch: {
841 arm64: {
842 srcs: ["arm64/lib/myothernativelib.so"],
843 },
844 arm: {
845 srcs: ["arm/lib/myothernativelib.so"],
846 },
847 },
Paul Duffin13f02712020-03-06 12:30:43 +0000848}
849
850cc_prebuilt_library_shared {
851 name: "myothernativelib",
852 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000853 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000854 system_shared_libs: ["libm"],
855 arch: {
856 arm64: {
857 srcs: ["arm64/lib/myothernativelib.so"],
858 },
859 arm: {
860 srcs: ["arm/lib/myothernativelib.so"],
861 },
862 },
Paul Duffin13f02712020-03-06 12:30:43 +0000863}
864
865cc_prebuilt_library_shared {
866 name: "mysdk_mysystemnativelib@current",
867 sdk_member_name: "mysystemnativelib",
868 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000869 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000870 arch: {
871 arm64: {
872 srcs: ["arm64/lib/mysystemnativelib.so"],
873 },
874 arm: {
875 srcs: ["arm/lib/mysystemnativelib.so"],
876 },
877 },
Paul Duffin13f02712020-03-06 12:30:43 +0000878}
879
880cc_prebuilt_library_shared {
881 name: "mysystemnativelib",
882 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000883 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000884 arch: {
885 arm64: {
886 srcs: ["arm64/lib/mysystemnativelib.so"],
887 },
888 arm: {
889 srcs: ["arm/lib/mysystemnativelib.so"],
890 },
891 },
Paul Duffin13f02712020-03-06 12:30:43 +0000892}
893
894sdk_snapshot {
895 name: "mysdk@current",
896 native_shared_libs: [
897 "mysdk_mynativelib@current",
898 "mysdk_myothernativelib@current",
899 "mysdk_mysystemnativelib@current",
900 ],
901}
902`),
903 checkAllCopyRules(`
904.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
905.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
906.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
907.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
908.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
909.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
910`),
911 )
912}
913
Paul Duffin9ab556f2019-12-11 18:42:17 +0000914func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina80fdec2019-12-03 15:25:00 +0000915 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
916 SkipIfNotLinux(t)
917
Paul Duffind835daa2019-11-30 17:49:09 +0000918 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000919 sdk {
920 name: "mysdk",
921 device_supported: false,
922 host_supported: true,
923 native_shared_libs: ["mynativelib"],
924 }
925
926 cc_library_shared {
927 name: "mynativelib",
928 device_supported: false,
929 host_supported: true,
930 srcs: [
931 "Test.cpp",
932 "aidl/foo/bar/Test.aidl",
933 ],
934 export_include_dirs: ["include"],
935 aidl: {
936 export_aidl_headers: true,
937 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000938 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +0000939 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +0000940 }
941 `)
942
Paul Duffin1356d8c2020-02-25 19:26:33 +0000943 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000944 checkAndroidBpContents(`
945// This is auto-generated. DO NOT EDIT.
946
947cc_prebuilt_library_shared {
948 name: "mysdk_mynativelib@current",
949 sdk_member_name: "mynativelib",
950 device_supported: false,
951 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000952 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +0000953 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +0000954 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000955 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000956 arch: {
957 x86_64: {
958 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000959 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000960 },
961 x86: {
962 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000963 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000964 },
965 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000966}
967
968cc_prebuilt_library_shared {
969 name: "mynativelib",
970 prefer: false,
971 device_supported: false,
972 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +0000973 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +0000974 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000975 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000976 arch: {
977 x86_64: {
978 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000979 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000980 },
981 x86: {
982 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000983 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000984 },
985 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000986}
987
988sdk_snapshot {
989 name: "mysdk@current",
990 device_supported: false,
991 host_supported: true,
992 native_shared_libs: ["mysdk_mynativelib@current"],
993}
994`),
995 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000996include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +0000997.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +0000998.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
999.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1000.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1001.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001002.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1003.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1004.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1005`),
1006 )
1007}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001008
Paul Duffina04c1072020-03-02 10:16:35 +00001009func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
1010 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1011 SkipIfNotLinux(t)
1012
1013 result := testSdkWithCc(t, `
1014 sdk {
1015 name: "mysdk",
1016 device_supported: false,
1017 host_supported: true,
1018 native_shared_libs: ["mynativelib"],
1019 target: {
1020 windows: {
1021 enabled: true,
1022 },
1023 },
1024 }
1025
1026 cc_library_shared {
1027 name: "mynativelib",
1028 device_supported: false,
1029 host_supported: true,
1030 srcs: [
1031 "Test.cpp",
1032 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001033 stl: "none",
1034 target: {
1035 windows: {
1036 enabled: true,
1037 },
1038 },
1039 }
1040 `)
1041
1042 result.CheckSnapshot("mysdk", "",
1043 checkAndroidBpContents(`
1044// This is auto-generated. DO NOT EDIT.
1045
1046cc_prebuilt_library_shared {
1047 name: "mysdk_mynativelib@current",
1048 sdk_member_name: "mynativelib",
1049 device_supported: false,
1050 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001051 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001052 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001053 target: {
1054 linux_glibc_x86_64: {
1055 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1056 },
1057 linux_glibc_x86: {
1058 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1059 },
1060 windows_x86_64: {
1061 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1062 },
1063 },
Paul Duffina04c1072020-03-02 10:16:35 +00001064}
1065
1066cc_prebuilt_library_shared {
1067 name: "mynativelib",
1068 prefer: false,
1069 device_supported: false,
1070 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001071 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001072 target: {
1073 linux_glibc_x86_64: {
1074 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1075 },
1076 linux_glibc_x86: {
1077 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1078 },
1079 windows_x86_64: {
1080 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1081 },
1082 },
Paul Duffina04c1072020-03-02 10:16:35 +00001083}
1084
1085sdk_snapshot {
1086 name: "mysdk@current",
1087 device_supported: false,
1088 host_supported: true,
1089 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001090 target: {
1091 windows: {
1092 compile_multilib: "64",
1093 },
1094 },
Paul Duffina04c1072020-03-02 10:16:35 +00001095}
1096`),
1097 checkAllCopyRules(`
1098.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1099.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1100.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1101`),
1102 )
1103}
1104
Paul Duffin9ab556f2019-12-11 18:42:17 +00001105func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1106 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001107 module_exports {
1108 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001109 native_static_libs: ["mynativelib"],
1110 }
1111
1112 cc_library_static {
1113 name: "mynativelib",
1114 srcs: [
1115 "Test.cpp",
1116 "aidl/foo/bar/Test.aidl",
1117 ],
1118 export_include_dirs: ["include"],
1119 aidl: {
1120 export_aidl_headers: true,
1121 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001122 stl: "none",
1123 }
1124 `)
1125
Paul Duffin1356d8c2020-02-25 19:26:33 +00001126 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001127 checkAndroidBpContents(`
1128// This is auto-generated. DO NOT EDIT.
1129
1130cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001131 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001132 sdk_member_name: "mynativelib",
Paul Duffin0cb37b92020-03-04 14:52:46 +00001133 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001134 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001135 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001136 arch: {
1137 arm64: {
1138 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001139 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001140 },
1141 arm: {
1142 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001143 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001144 },
1145 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001146}
1147
1148cc_prebuilt_library_static {
1149 name: "mynativelib",
1150 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001151 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001152 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001153 arch: {
1154 arm64: {
1155 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001156 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001157 },
1158 arm: {
1159 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001160 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001161 },
1162 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001163}
1164
Paul Duffine6029182019-12-16 17:43:48 +00001165module_exports_snapshot {
1166 name: "myexports@current",
1167 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001168}
1169`),
1170 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001171include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001172.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1173.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1174.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1175.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1176.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1177.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1178.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1179.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 +00001180`),
1181 )
1182}
1183
1184func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
1185 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1186 SkipIfNotLinux(t)
1187
1188 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001189 module_exports {
1190 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001191 device_supported: false,
1192 host_supported: true,
1193 native_static_libs: ["mynativelib"],
1194 }
1195
1196 cc_library_static {
1197 name: "mynativelib",
1198 device_supported: false,
1199 host_supported: true,
1200 srcs: [
1201 "Test.cpp",
1202 "aidl/foo/bar/Test.aidl",
1203 ],
1204 export_include_dirs: ["include"],
1205 aidl: {
1206 export_aidl_headers: true,
1207 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001208 stl: "none",
1209 }
1210 `)
1211
Paul Duffin1356d8c2020-02-25 19:26:33 +00001212 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001213 checkAndroidBpContents(`
1214// This is auto-generated. DO NOT EDIT.
1215
1216cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001217 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001218 sdk_member_name: "mynativelib",
1219 device_supported: false,
1220 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001221 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001222 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001223 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001224 arch: {
1225 x86_64: {
1226 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001227 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001228 },
1229 x86: {
1230 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001231 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001232 },
1233 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001234}
1235
1236cc_prebuilt_library_static {
1237 name: "mynativelib",
1238 prefer: false,
1239 device_supported: false,
1240 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001241 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001242 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001243 arch: {
1244 x86_64: {
1245 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001246 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001247 },
1248 x86: {
1249 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001250 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001251 },
1252 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001253}
1254
Paul Duffine6029182019-12-16 17:43:48 +00001255module_exports_snapshot {
1256 name: "myexports@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001257 device_supported: false,
1258 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001259 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001260}
1261`),
1262 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001263include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001264.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001265.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1266.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1267.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1268.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001269.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1270.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1271.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1272`),
1273 )
1274}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001275
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001276func TestSnapshotWithCcLibrary(t *testing.T) {
1277 result := testSdkWithCc(t, `
1278 module_exports {
1279 name: "myexports",
1280 native_libs: ["mynativelib"],
1281 }
1282
1283 cc_library {
1284 name: "mynativelib",
1285 srcs: [
1286 "Test.cpp",
1287 ],
1288 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001289 stl: "none",
1290 }
1291 `)
1292
1293 result.CheckSnapshot("myexports", "",
1294 checkAndroidBpContents(`
1295// This is auto-generated. DO NOT EDIT.
1296
1297cc_prebuilt_library {
1298 name: "myexports_mynativelib@current",
1299 sdk_member_name: "mynativelib",
1300 installable: false,
1301 stl: "none",
1302 export_include_dirs: ["include/include"],
1303 arch: {
1304 arm64: {
1305 static: {
1306 srcs: ["arm64/lib/mynativelib.a"],
1307 },
1308 shared: {
1309 srcs: ["arm64/lib/mynativelib.so"],
1310 },
1311 },
1312 arm: {
1313 static: {
1314 srcs: ["arm/lib/mynativelib.a"],
1315 },
1316 shared: {
1317 srcs: ["arm/lib/mynativelib.so"],
1318 },
1319 },
1320 },
1321}
1322
1323cc_prebuilt_library {
1324 name: "mynativelib",
1325 prefer: false,
1326 stl: "none",
1327 export_include_dirs: ["include/include"],
1328 arch: {
1329 arm64: {
1330 static: {
1331 srcs: ["arm64/lib/mynativelib.a"],
1332 },
1333 shared: {
1334 srcs: ["arm64/lib/mynativelib.so"],
1335 },
1336 },
1337 arm: {
1338 static: {
1339 srcs: ["arm/lib/mynativelib.a"],
1340 },
1341 shared: {
1342 srcs: ["arm/lib/mynativelib.so"],
1343 },
1344 },
1345 },
1346}
1347
1348module_exports_snapshot {
1349 name: "myexports@current",
1350 native_libs: ["myexports_mynativelib@current"],
1351}
1352`),
1353 checkAllCopyRules(`
1354include/Test.h -> include/include/Test.h
1355.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1356.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1357.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1358.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1359 )
1360}
1361
Paul Duffin13ad94f2020-02-19 16:19:27 +00001362func TestHostSnapshotWithMultiLib64(t *testing.T) {
1363 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1364 SkipIfNotLinux(t)
1365
1366 result := testSdkWithCc(t, `
1367 module_exports {
1368 name: "myexports",
1369 device_supported: false,
1370 host_supported: true,
1371 target: {
1372 host: {
1373 compile_multilib: "64",
1374 },
1375 },
1376 native_static_libs: ["mynativelib"],
1377 }
1378
1379 cc_library_static {
1380 name: "mynativelib",
1381 device_supported: false,
1382 host_supported: true,
1383 srcs: [
1384 "Test.cpp",
1385 "aidl/foo/bar/Test.aidl",
1386 ],
1387 export_include_dirs: ["include"],
1388 aidl: {
1389 export_aidl_headers: true,
1390 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001391 stl: "none",
1392 }
1393 `)
1394
Paul Duffin1356d8c2020-02-25 19:26:33 +00001395 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001396 checkAndroidBpContents(`
1397// This is auto-generated. DO NOT EDIT.
1398
1399cc_prebuilt_library_static {
1400 name: "myexports_mynativelib@current",
1401 sdk_member_name: "mynativelib",
1402 device_supported: false,
1403 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001404 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001405 stl: "none",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001406 export_include_dirs: ["include/include"],
1407 arch: {
1408 x86_64: {
1409 srcs: ["x86_64/lib/mynativelib.a"],
1410 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1411 },
1412 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001413}
1414
1415cc_prebuilt_library_static {
1416 name: "mynativelib",
1417 prefer: false,
1418 device_supported: false,
1419 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001420 stl: "none",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001421 export_include_dirs: ["include/include"],
1422 arch: {
1423 x86_64: {
1424 srcs: ["x86_64/lib/mynativelib.a"],
1425 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1426 },
1427 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001428}
1429
1430module_exports_snapshot {
1431 name: "myexports@current",
1432 device_supported: false,
1433 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001434 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001435 target: {
Paul Duffin6a7e9532020-03-20 17:50:07 +00001436 linux_glibc: {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001437 compile_multilib: "64",
1438 },
1439 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001440}`),
1441 checkAllCopyRules(`
1442include/Test.h -> include/include/Test.h
1443.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1444.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1445.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1446.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1447`),
1448 )
1449}
Paul Duffin91756d22020-02-21 16:29:57 +00001450
1451func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1452 result := testSdkWithCc(t, `
1453 sdk {
1454 name: "mysdk",
1455 native_header_libs: ["mynativeheaders"],
1456 }
1457
1458 cc_library_headers {
1459 name: "mynativeheaders",
1460 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001461 stl: "none",
1462 }
1463 `)
1464
Paul Duffin1356d8c2020-02-25 19:26:33 +00001465 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001466 checkAndroidBpContents(`
1467// This is auto-generated. DO NOT EDIT.
1468
1469cc_prebuilt_library_headers {
1470 name: "mysdk_mynativeheaders@current",
1471 sdk_member_name: "mynativeheaders",
Paul Duffin91756d22020-02-21 16:29:57 +00001472 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001473 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001474}
1475
1476cc_prebuilt_library_headers {
1477 name: "mynativeheaders",
1478 prefer: false,
Paul Duffin91756d22020-02-21 16:29:57 +00001479 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001480 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001481}
1482
1483sdk_snapshot {
1484 name: "mysdk@current",
1485 native_header_libs: ["mysdk_mynativeheaders@current"],
1486}
1487`),
1488 checkAllCopyRules(`
1489include/Test.h -> include/include/Test.h
1490`),
1491 )
1492}
1493
1494func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
1495 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1496 SkipIfNotLinux(t)
1497
1498 result := testSdkWithCc(t, `
1499 sdk {
1500 name: "mysdk",
1501 device_supported: false,
1502 host_supported: true,
1503 native_header_libs: ["mynativeheaders"],
1504 }
1505
1506 cc_library_headers {
1507 name: "mynativeheaders",
1508 device_supported: false,
1509 host_supported: true,
1510 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001511 stl: "none",
1512 }
1513 `)
1514
Paul Duffin1356d8c2020-02-25 19:26:33 +00001515 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001516 checkAndroidBpContents(`
1517// This is auto-generated. DO NOT EDIT.
1518
1519cc_prebuilt_library_headers {
1520 name: "mysdk_mynativeheaders@current",
1521 sdk_member_name: "mynativeheaders",
1522 device_supported: false,
1523 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001524 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001525 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001526}
1527
1528cc_prebuilt_library_headers {
1529 name: "mynativeheaders",
1530 prefer: false,
1531 device_supported: false,
1532 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001533 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001534 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001535}
1536
1537sdk_snapshot {
1538 name: "mysdk@current",
1539 device_supported: false,
1540 host_supported: true,
1541 native_header_libs: ["mysdk_mynativeheaders@current"],
1542}
1543`),
1544 checkAllCopyRules(`
1545include/Test.h -> include/include/Test.h
1546`),
1547 )
1548}
Paul Duffina04c1072020-03-02 10:16:35 +00001549
1550func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
1551 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1552 SkipIfNotLinux(t)
1553
1554 result := testSdkWithCc(t, `
1555 sdk {
1556 name: "mysdk",
1557 host_supported: true,
1558 native_header_libs: ["mynativeheaders"],
1559 }
1560
1561 cc_library_headers {
1562 name: "mynativeheaders",
1563 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001564 stl: "none",
1565 export_system_include_dirs: ["include"],
1566 target: {
1567 android: {
1568 export_include_dirs: ["include-android"],
1569 },
1570 host: {
1571 export_include_dirs: ["include-host"],
1572 },
1573 },
1574 }
1575 `)
1576
1577 result.CheckSnapshot("mysdk", "",
1578 checkAndroidBpContents(`
1579// This is auto-generated. DO NOT EDIT.
1580
1581cc_prebuilt_library_headers {
1582 name: "mysdk_mynativeheaders@current",
1583 sdk_member_name: "mynativeheaders",
1584 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001585 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001586 export_system_include_dirs: ["include/include"],
1587 target: {
1588 android: {
1589 export_include_dirs: ["include/include-android"],
1590 },
1591 linux_glibc: {
1592 export_include_dirs: ["include/include-host"],
1593 },
1594 },
Paul Duffina04c1072020-03-02 10:16:35 +00001595}
1596
1597cc_prebuilt_library_headers {
1598 name: "mynativeheaders",
1599 prefer: false,
1600 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001601 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001602 export_system_include_dirs: ["include/include"],
1603 target: {
1604 android: {
1605 export_include_dirs: ["include/include-android"],
1606 },
1607 linux_glibc: {
1608 export_include_dirs: ["include/include-host"],
1609 },
1610 },
Paul Duffina04c1072020-03-02 10:16:35 +00001611}
1612
1613sdk_snapshot {
1614 name: "mysdk@current",
1615 host_supported: true,
1616 native_header_libs: ["mysdk_mynativeheaders@current"],
1617}
1618`),
1619 checkAllCopyRules(`
1620include/Test.h -> include/include/Test.h
1621include-android/AndroidTest.h -> include/include-android/AndroidTest.h
1622include-host/HostTest.h -> include/include-host/HostTest.h
1623`),
1624 )
1625}
Martin Stjernholm10566a02020-03-24 01:19:52 +00001626
1627func TestSystemSharedLibPropagation(t *testing.T) {
Martin Stjernholm66a06942020-03-26 17:39:30 +00001628 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1629 SkipIfNotLinux(t)
1630
Martin Stjernholm10566a02020-03-24 01:19:52 +00001631 result := testSdkWithCc(t, `
1632 sdk {
1633 name: "mysdk",
1634 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
1635 }
1636
1637 cc_library {
1638 name: "sslnil",
1639 host_supported: true,
1640 }
1641
1642 cc_library {
1643 name: "sslempty",
1644 system_shared_libs: [],
1645 }
1646
1647 cc_library {
1648 name: "sslnonempty",
1649 system_shared_libs: ["sslnil"],
1650 }
1651 `)
1652
1653 result.CheckSnapshot("mysdk", "",
1654 checkAndroidBpContents(`
1655// This is auto-generated. DO NOT EDIT.
1656
1657cc_prebuilt_library_shared {
1658 name: "mysdk_sslnil@current",
1659 sdk_member_name: "sslnil",
1660 installable: false,
1661 arch: {
1662 arm64: {
1663 srcs: ["arm64/lib/sslnil.so"],
1664 },
1665 arm: {
1666 srcs: ["arm/lib/sslnil.so"],
1667 },
1668 },
1669}
1670
1671cc_prebuilt_library_shared {
1672 name: "sslnil",
1673 prefer: false,
1674 arch: {
1675 arm64: {
1676 srcs: ["arm64/lib/sslnil.so"],
1677 },
1678 arm: {
1679 srcs: ["arm/lib/sslnil.so"],
1680 },
1681 },
1682}
1683
1684cc_prebuilt_library_shared {
1685 name: "mysdk_sslempty@current",
1686 sdk_member_name: "sslempty",
1687 installable: false,
1688 system_shared_libs: [],
1689 arch: {
1690 arm64: {
1691 srcs: ["arm64/lib/sslempty.so"],
1692 },
1693 arm: {
1694 srcs: ["arm/lib/sslempty.so"],
1695 },
1696 },
1697}
1698
1699cc_prebuilt_library_shared {
1700 name: "sslempty",
1701 prefer: false,
1702 system_shared_libs: [],
1703 arch: {
1704 arm64: {
1705 srcs: ["arm64/lib/sslempty.so"],
1706 },
1707 arm: {
1708 srcs: ["arm/lib/sslempty.so"],
1709 },
1710 },
1711}
1712
1713cc_prebuilt_library_shared {
1714 name: "mysdk_sslnonempty@current",
1715 sdk_member_name: "sslnonempty",
1716 installable: false,
1717 system_shared_libs: ["mysdk_sslnil@current"],
1718 arch: {
1719 arm64: {
1720 srcs: ["arm64/lib/sslnonempty.so"],
1721 },
1722 arm: {
1723 srcs: ["arm/lib/sslnonempty.so"],
1724 },
1725 },
1726}
1727
1728cc_prebuilt_library_shared {
1729 name: "sslnonempty",
1730 prefer: false,
1731 system_shared_libs: ["sslnil"],
1732 arch: {
1733 arm64: {
1734 srcs: ["arm64/lib/sslnonempty.so"],
1735 },
1736 arm: {
1737 srcs: ["arm/lib/sslnonempty.so"],
1738 },
1739 },
1740}
1741
1742sdk_snapshot {
1743 name: "mysdk@current",
1744 native_shared_libs: [
1745 "mysdk_sslnil@current",
1746 "mysdk_sslempty@current",
1747 "mysdk_sslnonempty@current",
1748 ],
1749}
1750`))
1751
1752 result = testSdkWithCc(t, `
1753 sdk {
1754 name: "mysdk",
1755 host_supported: true,
1756 native_shared_libs: ["sslvariants"],
1757 }
1758
1759 cc_library {
1760 name: "sslvariants",
1761 host_supported: true,
1762 target: {
1763 android: {
1764 system_shared_libs: [],
1765 },
1766 },
1767 }
1768 `)
1769
1770 result.CheckSnapshot("mysdk", "",
1771 checkAndroidBpContents(`
1772// This is auto-generated. DO NOT EDIT.
1773
1774cc_prebuilt_library_shared {
1775 name: "mysdk_sslvariants@current",
1776 sdk_member_name: "sslvariants",
1777 host_supported: true,
1778 installable: false,
1779 target: {
1780 android: {
1781 system_shared_libs: [],
1782 },
1783 android_arm64: {
1784 srcs: ["android/arm64/lib/sslvariants.so"],
1785 },
1786 android_arm: {
1787 srcs: ["android/arm/lib/sslvariants.so"],
1788 },
1789 linux_glibc_x86_64: {
1790 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
1791 },
1792 linux_glibc_x86: {
1793 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
1794 },
1795 },
1796}
1797
1798cc_prebuilt_library_shared {
1799 name: "sslvariants",
1800 prefer: false,
1801 host_supported: true,
1802 target: {
1803 android: {
1804 system_shared_libs: [],
1805 },
1806 android_arm64: {
1807 srcs: ["android/arm64/lib/sslvariants.so"],
1808 },
1809 android_arm: {
1810 srcs: ["android/arm/lib/sslvariants.so"],
1811 },
1812 linux_glibc_x86_64: {
1813 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
1814 },
1815 linux_glibc_x86: {
1816 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
1817 },
1818 },
1819}
1820
1821sdk_snapshot {
1822 name: "mysdk@current",
1823 host_supported: true,
1824 native_shared_libs: ["mysdk_sslvariants@current"],
1825}
1826`))
1827}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001828
1829func TestStubsLibrary(t *testing.T) {
1830 result := testSdkWithCc(t, `
1831 sdk {
1832 name: "mysdk",
1833 native_shared_libs: ["stubslib"],
1834 }
1835
1836 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01001837 name: "internaldep",
1838 }
1839
1840 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001841 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01001842 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001843 stubs: {
1844 symbol_file: "some/where/stubslib.map.txt",
1845 versions: ["1", "2", "3"],
1846 },
1847 }
1848 `)
1849
1850 result.CheckSnapshot("mysdk", "",
1851 checkAndroidBpContents(`
1852// This is auto-generated. DO NOT EDIT.
1853
1854cc_prebuilt_library_shared {
1855 name: "mysdk_stubslib@current",
1856 sdk_member_name: "stubslib",
1857 installable: false,
1858 stubs: {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001859 versions: ["3"],
1860 },
1861 arch: {
1862 arm64: {
1863 srcs: ["arm64/lib/stubslib.so"],
1864 },
1865 arm: {
1866 srcs: ["arm/lib/stubslib.so"],
1867 },
1868 },
1869}
1870
1871cc_prebuilt_library_shared {
1872 name: "stubslib",
1873 prefer: false,
1874 stubs: {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001875 versions: ["3"],
1876 },
1877 arch: {
1878 arm64: {
1879 srcs: ["arm64/lib/stubslib.so"],
1880 },
1881 arm: {
1882 srcs: ["arm/lib/stubslib.so"],
1883 },
1884 },
1885}
1886
1887sdk_snapshot {
1888 name: "mysdk@current",
1889 native_shared_libs: ["mysdk_stubslib@current"],
1890}
1891`))
1892}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01001893
1894func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
1895 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1896 SkipIfNotLinux(t)
1897
1898 result := testSdkWithCc(t, `
1899 sdk {
1900 name: "mysdk",
1901 host_supported: true,
1902 native_shared_libs: ["stubslib"],
1903 }
1904
1905 cc_library {
1906 name: "internaldep",
1907 host_supported: true,
1908 }
1909
1910 cc_library {
1911 name: "stubslib",
1912 host_supported: true,
1913 shared_libs: ["internaldep"],
1914 stubs: {
1915 symbol_file: "some/where/stubslib.map.txt",
1916 versions: ["1", "2", "3"],
1917 },
1918 }
1919 `)
1920
1921 result.CheckSnapshot("mysdk", "",
1922 checkAndroidBpContents(`
1923// This is auto-generated. DO NOT EDIT.
1924
1925cc_prebuilt_library_shared {
1926 name: "mysdk_stubslib@current",
1927 sdk_member_name: "stubslib",
1928 host_supported: true,
1929 installable: false,
1930 stubs: {
1931 versions: ["3"],
1932 },
1933 target: {
1934 android_arm64: {
1935 srcs: ["android/arm64/lib/stubslib.so"],
1936 },
1937 android_arm: {
1938 srcs: ["android/arm/lib/stubslib.so"],
1939 },
1940 linux_glibc_x86_64: {
1941 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
1942 },
1943 linux_glibc_x86: {
1944 srcs: ["linux_glibc/x86/lib/stubslib.so"],
1945 },
1946 },
1947}
1948
1949cc_prebuilt_library_shared {
1950 name: "stubslib",
1951 prefer: false,
1952 host_supported: true,
1953 stubs: {
1954 versions: ["3"],
1955 },
1956 target: {
1957 android_arm64: {
1958 srcs: ["android/arm64/lib/stubslib.so"],
1959 },
1960 android_arm: {
1961 srcs: ["android/arm/lib/stubslib.so"],
1962 },
1963 linux_glibc_x86_64: {
1964 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
1965 },
1966 linux_glibc_x86: {
1967 srcs: ["linux_glibc/x86/lib/stubslib.so"],
1968 },
1969 },
1970}
1971
1972sdk_snapshot {
1973 name: "mysdk@current",
1974 host_supported: true,
1975 native_shared_libs: ["mysdk_stubslib@current"],
1976}
1977`))
1978}