blob: 780da9fc3ca14802c2e623be21bd889d6444d6aa [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 stl: "none",
405 }
406 `)
407
Paul Duffin1356d8c2020-02-25 19:26:33 +0000408 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000409 checkAndroidBpContents(`
410// This is auto-generated. DO NOT EDIT.
411
412cc_prebuilt_binary {
413 name: "mymodule_exports_mynativebinary@current",
414 sdk_member_name: "mynativebinary",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000415 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000416 compile_multilib: "both",
417 arch: {
418 arm64: {
419 srcs: ["arm64/bin/mynativebinary"],
420 },
421 arm: {
422 srcs: ["arm/bin/mynativebinary"],
423 },
424 },
425}
426
427cc_prebuilt_binary {
428 name: "mynativebinary",
429 prefer: false,
430 compile_multilib: "both",
431 arch: {
432 arm64: {
433 srcs: ["arm64/bin/mynativebinary"],
434 },
435 arm: {
436 srcs: ["arm/bin/mynativebinary"],
437 },
438 },
439}
440
441module_exports_snapshot {
442 name: "mymodule_exports@current",
443 native_binaries: ["mymodule_exports_mynativebinary@current"],
444}
445`),
446 checkAllCopyRules(`
447.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
448.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
449`),
450 )
451}
452
Paul Duffina04c1072020-03-02 10:16:35 +0000453func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
454 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
455 SkipIfNotLinux(t)
456
457 result := testSdkWithCc(t, `
458 module_exports {
459 name: "myexports",
460 device_supported: false,
461 host_supported: true,
462 native_binaries: ["mynativebinary"],
463 target: {
464 windows: {
465 enabled: true,
466 },
467 },
468 }
469
470 cc_binary {
471 name: "mynativebinary",
472 device_supported: false,
473 host_supported: true,
474 srcs: [
475 "Test.cpp",
476 ],
477 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000478 stl: "none",
479 target: {
480 windows: {
481 enabled: true,
482 },
483 },
484 }
485 `)
486
487 result.CheckSnapshot("myexports", "",
488 checkAndroidBpContents(`
489// This is auto-generated. DO NOT EDIT.
490
491cc_prebuilt_binary {
492 name: "myexports_mynativebinary@current",
493 sdk_member_name: "mynativebinary",
494 device_supported: false,
495 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000496 installable: false,
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,
521 target: {
522 linux_glibc: {
523 compile_multilib: "both",
524 },
525 linux_glibc_x86_64: {
526 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
527 },
528 linux_glibc_x86: {
529 srcs: ["linux_glibc/x86/bin/mynativebinary"],
530 },
531 windows: {
532 compile_multilib: "64",
533 },
534 windows_x86_64: {
535 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
536 },
537 },
538}
539
540module_exports_snapshot {
541 name: "myexports@current",
542 device_supported: false,
543 host_supported: true,
544 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000545 target: {
546 windows: {
547 compile_multilib: "64",
548 },
549 },
Paul Duffina04c1072020-03-02 10:16:35 +0000550}
551`),
552 checkAllCopyRules(`
553.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
554.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
555.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
556`),
557 )
558}
559
Paul Duffin9ab556f2019-12-11 18:42:17 +0000560func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000561 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000562 sdk {
563 name: "mysdk",
564 native_shared_libs: ["mynativelib"],
565 }
566
567 cc_library_shared {
568 name: "mynativelib",
569 srcs: [
570 "Test.cpp",
571 "aidl/foo/bar/Test.aidl",
572 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +0000573 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000574 export_include_dirs: ["include"],
575 aidl: {
576 export_aidl_headers: true,
577 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000578 stl: "none",
579 }
580 `)
581
Paul Duffin1356d8c2020-02-25 19:26:33 +0000582 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000583 checkAndroidBpContents(`
584// This is auto-generated. DO NOT EDIT.
585
586cc_prebuilt_library_shared {
587 name: "mysdk_mynativelib@current",
588 sdk_member_name: "mynativelib",
Paul Duffinbefa4b92020-03-04 14:22:45 +0000589 apex_available: [
590 "apex1",
591 "apex2",
592 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000593 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000594 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000595 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000596 arch: {
597 arm64: {
598 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000599 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000600 },
601 arm: {
602 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000603 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000604 },
605 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000606}
607
608cc_prebuilt_library_shared {
609 name: "mynativelib",
610 prefer: false,
Paul Duffinbefa4b92020-03-04 14:22:45 +0000611 apex_available: [
612 "apex1",
613 "apex2",
614 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000615 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000616 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000617 arch: {
618 arm64: {
619 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000620 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000621 },
622 arm: {
623 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000624 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000625 },
626 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000627}
628
629sdk_snapshot {
630 name: "mysdk@current",
631 native_shared_libs: ["mysdk_mynativelib@current"],
632}
633`),
634 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000635include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800636.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
637.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
638.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
639.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
640.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
641.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
642.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
643.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 +0000644`),
645 )
646}
647
Paul Duffin13f02712020-03-06 12:30:43 +0000648func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
649 result := testSdkWithCc(t, `
650 sdk {
651 name: "mysdk",
652 native_shared_libs: [
653 "mynativelib",
654 "myothernativelib",
655 "mysystemnativelib",
656 ],
657 }
658
659 cc_library {
660 name: "mysystemnativelib",
661 srcs: [
662 "Test.cpp",
663 ],
Paul Duffin13f02712020-03-06 12:30:43 +0000664 stl: "none",
665 }
666
667 cc_library_shared {
668 name: "myothernativelib",
669 srcs: [
670 "Test.cpp",
671 ],
672 system_shared_libs: [
673 // A reference to a library that is not an sdk member. Uses libm as that
674 // is in the default set of modules available to this test and so is available
675 // both here and also when the generated Android.bp file is tested in
676 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
677 // handles references to modules that are not sdk members.
678 "libm",
679 ],
680 stl: "none",
681 }
682
683 cc_library {
684 name: "mynativelib",
685 srcs: [
686 "Test.cpp",
687 ],
688 shared_libs: [
689 // A reference to another sdk member.
690 "myothernativelib",
691 ],
692 target: {
693 android: {
694 shared: {
695 shared_libs: [
696 // A reference to a library that is not an sdk member. The libc library
697 // is used here to check that the shared_libs property is handled correctly
698 // in a similar way to how libm is used to check system_shared_libs above.
699 "libc",
700 ],
701 },
702 },
703 },
Paul Duffin13f02712020-03-06 12:30:43 +0000704 stl: "none",
705 }
706 `)
707
708 result.CheckSnapshot("mysdk", "",
709 checkAndroidBpContents(`
710// This is auto-generated. DO NOT EDIT.
711
712cc_prebuilt_library_shared {
713 name: "mysdk_mynativelib@current",
714 sdk_member_name: "mynativelib",
715 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000716 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000717 shared_libs: [
718 "mysdk_myothernativelib@current",
719 "libc",
720 ],
721 arch: {
722 arm64: {
723 srcs: ["arm64/lib/mynativelib.so"],
724 },
725 arm: {
726 srcs: ["arm/lib/mynativelib.so"],
727 },
728 },
Paul Duffin13f02712020-03-06 12:30:43 +0000729}
730
731cc_prebuilt_library_shared {
732 name: "mynativelib",
733 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000734 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000735 shared_libs: [
736 "myothernativelib",
737 "libc",
738 ],
739 arch: {
740 arm64: {
741 srcs: ["arm64/lib/mynativelib.so"],
742 },
743 arm: {
744 srcs: ["arm/lib/mynativelib.so"],
745 },
746 },
Paul Duffin13f02712020-03-06 12:30:43 +0000747}
748
749cc_prebuilt_library_shared {
750 name: "mysdk_myothernativelib@current",
751 sdk_member_name: "myothernativelib",
752 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000753 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000754 system_shared_libs: ["libm"],
755 arch: {
756 arm64: {
757 srcs: ["arm64/lib/myothernativelib.so"],
758 },
759 arm: {
760 srcs: ["arm/lib/myothernativelib.so"],
761 },
762 },
Paul Duffin13f02712020-03-06 12:30:43 +0000763}
764
765cc_prebuilt_library_shared {
766 name: "myothernativelib",
767 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000768 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000769 system_shared_libs: ["libm"],
770 arch: {
771 arm64: {
772 srcs: ["arm64/lib/myothernativelib.so"],
773 },
774 arm: {
775 srcs: ["arm/lib/myothernativelib.so"],
776 },
777 },
Paul Duffin13f02712020-03-06 12:30:43 +0000778}
779
780cc_prebuilt_library_shared {
781 name: "mysdk_mysystemnativelib@current",
782 sdk_member_name: "mysystemnativelib",
783 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000784 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000785 arch: {
786 arm64: {
787 srcs: ["arm64/lib/mysystemnativelib.so"],
788 },
789 arm: {
790 srcs: ["arm/lib/mysystemnativelib.so"],
791 },
792 },
Paul Duffin13f02712020-03-06 12:30:43 +0000793}
794
795cc_prebuilt_library_shared {
796 name: "mysystemnativelib",
797 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000798 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000799 arch: {
800 arm64: {
801 srcs: ["arm64/lib/mysystemnativelib.so"],
802 },
803 arm: {
804 srcs: ["arm/lib/mysystemnativelib.so"],
805 },
806 },
Paul Duffin13f02712020-03-06 12:30:43 +0000807}
808
809sdk_snapshot {
810 name: "mysdk@current",
811 native_shared_libs: [
812 "mysdk_mynativelib@current",
813 "mysdk_myothernativelib@current",
814 "mysdk_mysystemnativelib@current",
815 ],
816}
817`),
818 checkAllCopyRules(`
819.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
820.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
821.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
822.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
823.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
824.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
825`),
826 )
827}
828
Paul Duffin9ab556f2019-12-11 18:42:17 +0000829func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina80fdec2019-12-03 15:25:00 +0000830 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
831 SkipIfNotLinux(t)
832
Paul Duffind835daa2019-11-30 17:49:09 +0000833 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000834 sdk {
835 name: "mysdk",
836 device_supported: false,
837 host_supported: true,
838 native_shared_libs: ["mynativelib"],
839 }
840
841 cc_library_shared {
842 name: "mynativelib",
843 device_supported: false,
844 host_supported: true,
845 srcs: [
846 "Test.cpp",
847 "aidl/foo/bar/Test.aidl",
848 ],
849 export_include_dirs: ["include"],
850 aidl: {
851 export_aidl_headers: true,
852 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000853 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +0000854 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +0000855 }
856 `)
857
Paul Duffin1356d8c2020-02-25 19:26:33 +0000858 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000859 checkAndroidBpContents(`
860// This is auto-generated. DO NOT EDIT.
861
862cc_prebuilt_library_shared {
863 name: "mysdk_mynativelib@current",
864 sdk_member_name: "mynativelib",
865 device_supported: false,
866 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000867 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +0000868 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +0000869 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000870 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000871 arch: {
872 x86_64: {
873 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000874 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000875 },
876 x86: {
877 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000878 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000879 },
880 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000881}
882
883cc_prebuilt_library_shared {
884 name: "mynativelib",
885 prefer: false,
886 device_supported: false,
887 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +0000888 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +0000889 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000890 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000891 arch: {
892 x86_64: {
893 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000894 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000895 },
896 x86: {
897 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000898 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000899 },
900 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000901}
902
903sdk_snapshot {
904 name: "mysdk@current",
905 device_supported: false,
906 host_supported: true,
907 native_shared_libs: ["mysdk_mynativelib@current"],
908}
909`),
910 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000911include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +0000912.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +0000913.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
914.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
915.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
916.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +0000917.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
918.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
919.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
920`),
921 )
922}
Paul Duffin9ab556f2019-12-11 18:42:17 +0000923
Paul Duffina04c1072020-03-02 10:16:35 +0000924func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
925 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
926 SkipIfNotLinux(t)
927
928 result := testSdkWithCc(t, `
929 sdk {
930 name: "mysdk",
931 device_supported: false,
932 host_supported: true,
933 native_shared_libs: ["mynativelib"],
934 target: {
935 windows: {
936 enabled: true,
937 },
938 },
939 }
940
941 cc_library_shared {
942 name: "mynativelib",
943 device_supported: false,
944 host_supported: true,
945 srcs: [
946 "Test.cpp",
947 ],
Paul Duffina04c1072020-03-02 10:16:35 +0000948 stl: "none",
949 target: {
950 windows: {
951 enabled: true,
952 },
953 },
954 }
955 `)
956
957 result.CheckSnapshot("mysdk", "",
958 checkAndroidBpContents(`
959// This is auto-generated. DO NOT EDIT.
960
961cc_prebuilt_library_shared {
962 name: "mysdk_mynativelib@current",
963 sdk_member_name: "mynativelib",
964 device_supported: false,
965 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000966 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000967 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000968 target: {
969 linux_glibc_x86_64: {
970 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
971 },
972 linux_glibc_x86: {
973 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
974 },
975 windows_x86_64: {
976 srcs: ["windows/x86_64/lib/mynativelib.dll"],
977 },
978 },
Paul Duffina04c1072020-03-02 10:16:35 +0000979}
980
981cc_prebuilt_library_shared {
982 name: "mynativelib",
983 prefer: false,
984 device_supported: false,
985 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000986 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000987 target: {
988 linux_glibc_x86_64: {
989 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
990 },
991 linux_glibc_x86: {
992 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
993 },
994 windows_x86_64: {
995 srcs: ["windows/x86_64/lib/mynativelib.dll"],
996 },
997 },
Paul Duffina04c1072020-03-02 10:16:35 +0000998}
999
1000sdk_snapshot {
1001 name: "mysdk@current",
1002 device_supported: false,
1003 host_supported: true,
1004 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001005 target: {
1006 windows: {
1007 compile_multilib: "64",
1008 },
1009 },
Paul Duffina04c1072020-03-02 10:16:35 +00001010}
1011`),
1012 checkAllCopyRules(`
1013.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1014.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1015.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1016`),
1017 )
1018}
1019
Paul Duffin9ab556f2019-12-11 18:42:17 +00001020func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1021 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001022 module_exports {
1023 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001024 native_static_libs: ["mynativelib"],
1025 }
1026
1027 cc_library_static {
1028 name: "mynativelib",
1029 srcs: [
1030 "Test.cpp",
1031 "aidl/foo/bar/Test.aidl",
1032 ],
1033 export_include_dirs: ["include"],
1034 aidl: {
1035 export_aidl_headers: true,
1036 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001037 stl: "none",
1038 }
1039 `)
1040
Paul Duffin1356d8c2020-02-25 19:26:33 +00001041 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001042 checkAndroidBpContents(`
1043// This is auto-generated. DO NOT EDIT.
1044
1045cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001046 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001047 sdk_member_name: "mynativelib",
Paul Duffin0cb37b92020-03-04 14:52:46 +00001048 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001049 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001050 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001051 arch: {
1052 arm64: {
1053 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001054 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001055 },
1056 arm: {
1057 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001058 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001059 },
1060 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001061}
1062
1063cc_prebuilt_library_static {
1064 name: "mynativelib",
1065 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001066 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001067 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001068 arch: {
1069 arm64: {
1070 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001071 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001072 },
1073 arm: {
1074 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001075 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001076 },
1077 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001078}
1079
Paul Duffine6029182019-12-16 17:43:48 +00001080module_exports_snapshot {
1081 name: "myexports@current",
1082 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001083}
1084`),
1085 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001086include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001087.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1088.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1089.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1090.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1091.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1092.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1093.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1094.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 +00001095`),
1096 )
1097}
1098
1099func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
1100 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1101 SkipIfNotLinux(t)
1102
1103 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001104 module_exports {
1105 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001106 device_supported: false,
1107 host_supported: true,
1108 native_static_libs: ["mynativelib"],
1109 }
1110
1111 cc_library_static {
1112 name: "mynativelib",
1113 device_supported: false,
1114 host_supported: true,
1115 srcs: [
1116 "Test.cpp",
1117 "aidl/foo/bar/Test.aidl",
1118 ],
1119 export_include_dirs: ["include"],
1120 aidl: {
1121 export_aidl_headers: true,
1122 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001123 stl: "none",
1124 }
1125 `)
1126
Paul Duffin1356d8c2020-02-25 19:26:33 +00001127 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001128 checkAndroidBpContents(`
1129// This is auto-generated. DO NOT EDIT.
1130
1131cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001132 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001133 sdk_member_name: "mynativelib",
1134 device_supported: false,
1135 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001136 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001137 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001138 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001139 arch: {
1140 x86_64: {
1141 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001142 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001143 },
1144 x86: {
1145 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001146 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001147 },
1148 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001149}
1150
1151cc_prebuilt_library_static {
1152 name: "mynativelib",
1153 prefer: false,
1154 device_supported: false,
1155 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001156 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001157 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001158 arch: {
1159 x86_64: {
1160 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001161 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001162 },
1163 x86: {
1164 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001165 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001166 },
1167 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001168}
1169
Paul Duffine6029182019-12-16 17:43:48 +00001170module_exports_snapshot {
1171 name: "myexports@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001172 device_supported: false,
1173 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001174 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001175}
1176`),
1177 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001178include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001179.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001180.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1181.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1182.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1183.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001184.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1185.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1186.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1187`),
1188 )
1189}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001190
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001191func TestSnapshotWithCcLibrary(t *testing.T) {
1192 result := testSdkWithCc(t, `
1193 module_exports {
1194 name: "myexports",
1195 native_libs: ["mynativelib"],
1196 }
1197
1198 cc_library {
1199 name: "mynativelib",
1200 srcs: [
1201 "Test.cpp",
1202 ],
1203 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001204 stl: "none",
1205 }
1206 `)
1207
1208 result.CheckSnapshot("myexports", "",
1209 checkAndroidBpContents(`
1210// This is auto-generated. DO NOT EDIT.
1211
1212cc_prebuilt_library {
1213 name: "myexports_mynativelib@current",
1214 sdk_member_name: "mynativelib",
1215 installable: false,
1216 stl: "none",
1217 export_include_dirs: ["include/include"],
1218 arch: {
1219 arm64: {
1220 static: {
1221 srcs: ["arm64/lib/mynativelib.a"],
1222 },
1223 shared: {
1224 srcs: ["arm64/lib/mynativelib.so"],
1225 },
1226 },
1227 arm: {
1228 static: {
1229 srcs: ["arm/lib/mynativelib.a"],
1230 },
1231 shared: {
1232 srcs: ["arm/lib/mynativelib.so"],
1233 },
1234 },
1235 },
1236}
1237
1238cc_prebuilt_library {
1239 name: "mynativelib",
1240 prefer: false,
1241 stl: "none",
1242 export_include_dirs: ["include/include"],
1243 arch: {
1244 arm64: {
1245 static: {
1246 srcs: ["arm64/lib/mynativelib.a"],
1247 },
1248 shared: {
1249 srcs: ["arm64/lib/mynativelib.so"],
1250 },
1251 },
1252 arm: {
1253 static: {
1254 srcs: ["arm/lib/mynativelib.a"],
1255 },
1256 shared: {
1257 srcs: ["arm/lib/mynativelib.so"],
1258 },
1259 },
1260 },
1261}
1262
1263module_exports_snapshot {
1264 name: "myexports@current",
1265 native_libs: ["myexports_mynativelib@current"],
1266}
1267`),
1268 checkAllCopyRules(`
1269include/Test.h -> include/include/Test.h
1270.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1271.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1272.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1273.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1274 )
1275}
1276
Paul Duffin13ad94f2020-02-19 16:19:27 +00001277func TestHostSnapshotWithMultiLib64(t *testing.T) {
1278 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1279 SkipIfNotLinux(t)
1280
1281 result := testSdkWithCc(t, `
1282 module_exports {
1283 name: "myexports",
1284 device_supported: false,
1285 host_supported: true,
1286 target: {
1287 host: {
1288 compile_multilib: "64",
1289 },
1290 },
1291 native_static_libs: ["mynativelib"],
1292 }
1293
1294 cc_library_static {
1295 name: "mynativelib",
1296 device_supported: false,
1297 host_supported: true,
1298 srcs: [
1299 "Test.cpp",
1300 "aidl/foo/bar/Test.aidl",
1301 ],
1302 export_include_dirs: ["include"],
1303 aidl: {
1304 export_aidl_headers: true,
1305 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001306 stl: "none",
1307 }
1308 `)
1309
Paul Duffin1356d8c2020-02-25 19:26:33 +00001310 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001311 checkAndroidBpContents(`
1312// This is auto-generated. DO NOT EDIT.
1313
1314cc_prebuilt_library_static {
1315 name: "myexports_mynativelib@current",
1316 sdk_member_name: "mynativelib",
1317 device_supported: false,
1318 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001319 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001320 stl: "none",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001321 export_include_dirs: ["include/include"],
1322 arch: {
1323 x86_64: {
1324 srcs: ["x86_64/lib/mynativelib.a"],
1325 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1326 },
1327 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001328}
1329
1330cc_prebuilt_library_static {
1331 name: "mynativelib",
1332 prefer: false,
1333 device_supported: false,
1334 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001335 stl: "none",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001336 export_include_dirs: ["include/include"],
1337 arch: {
1338 x86_64: {
1339 srcs: ["x86_64/lib/mynativelib.a"],
1340 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1341 },
1342 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001343}
1344
1345module_exports_snapshot {
1346 name: "myexports@current",
1347 device_supported: false,
1348 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001349 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001350 target: {
Paul Duffin6a7e9532020-03-20 17:50:07 +00001351 linux_glibc: {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001352 compile_multilib: "64",
1353 },
1354 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001355}`),
1356 checkAllCopyRules(`
1357include/Test.h -> include/include/Test.h
1358.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1359.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1360.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1361.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1362`),
1363 )
1364}
Paul Duffin91756d22020-02-21 16:29:57 +00001365
1366func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1367 result := testSdkWithCc(t, `
1368 sdk {
1369 name: "mysdk",
1370 native_header_libs: ["mynativeheaders"],
1371 }
1372
1373 cc_library_headers {
1374 name: "mynativeheaders",
1375 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001376 stl: "none",
1377 }
1378 `)
1379
Paul Duffin1356d8c2020-02-25 19:26:33 +00001380 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001381 checkAndroidBpContents(`
1382// This is auto-generated. DO NOT EDIT.
1383
1384cc_prebuilt_library_headers {
1385 name: "mysdk_mynativeheaders@current",
1386 sdk_member_name: "mynativeheaders",
Paul Duffin91756d22020-02-21 16:29:57 +00001387 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001388 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001389}
1390
1391cc_prebuilt_library_headers {
1392 name: "mynativeheaders",
1393 prefer: false,
Paul Duffin91756d22020-02-21 16:29:57 +00001394 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001395 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001396}
1397
1398sdk_snapshot {
1399 name: "mysdk@current",
1400 native_header_libs: ["mysdk_mynativeheaders@current"],
1401}
1402`),
1403 checkAllCopyRules(`
1404include/Test.h -> include/include/Test.h
1405`),
1406 )
1407}
1408
1409func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
1410 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1411 SkipIfNotLinux(t)
1412
1413 result := testSdkWithCc(t, `
1414 sdk {
1415 name: "mysdk",
1416 device_supported: false,
1417 host_supported: true,
1418 native_header_libs: ["mynativeheaders"],
1419 }
1420
1421 cc_library_headers {
1422 name: "mynativeheaders",
1423 device_supported: false,
1424 host_supported: true,
1425 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001426 stl: "none",
1427 }
1428 `)
1429
Paul Duffin1356d8c2020-02-25 19:26:33 +00001430 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001431 checkAndroidBpContents(`
1432// This is auto-generated. DO NOT EDIT.
1433
1434cc_prebuilt_library_headers {
1435 name: "mysdk_mynativeheaders@current",
1436 sdk_member_name: "mynativeheaders",
1437 device_supported: false,
1438 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001439 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001440 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001441}
1442
1443cc_prebuilt_library_headers {
1444 name: "mynativeheaders",
1445 prefer: false,
1446 device_supported: false,
1447 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001448 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001449 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001450}
1451
1452sdk_snapshot {
1453 name: "mysdk@current",
1454 device_supported: false,
1455 host_supported: true,
1456 native_header_libs: ["mysdk_mynativeheaders@current"],
1457}
1458`),
1459 checkAllCopyRules(`
1460include/Test.h -> include/include/Test.h
1461`),
1462 )
1463}
Paul Duffina04c1072020-03-02 10:16:35 +00001464
1465func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
1466 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1467 SkipIfNotLinux(t)
1468
1469 result := testSdkWithCc(t, `
1470 sdk {
1471 name: "mysdk",
1472 host_supported: true,
1473 native_header_libs: ["mynativeheaders"],
1474 }
1475
1476 cc_library_headers {
1477 name: "mynativeheaders",
1478 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001479 stl: "none",
1480 export_system_include_dirs: ["include"],
1481 target: {
1482 android: {
1483 export_include_dirs: ["include-android"],
1484 },
1485 host: {
1486 export_include_dirs: ["include-host"],
1487 },
1488 },
1489 }
1490 `)
1491
1492 result.CheckSnapshot("mysdk", "",
1493 checkAndroidBpContents(`
1494// This is auto-generated. DO NOT EDIT.
1495
1496cc_prebuilt_library_headers {
1497 name: "mysdk_mynativeheaders@current",
1498 sdk_member_name: "mynativeheaders",
1499 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001500 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001501 export_system_include_dirs: ["include/include"],
1502 target: {
1503 android: {
1504 export_include_dirs: ["include/include-android"],
1505 },
1506 linux_glibc: {
1507 export_include_dirs: ["include/include-host"],
1508 },
1509 },
Paul Duffina04c1072020-03-02 10:16:35 +00001510}
1511
1512cc_prebuilt_library_headers {
1513 name: "mynativeheaders",
1514 prefer: false,
1515 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001516 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001517 export_system_include_dirs: ["include/include"],
1518 target: {
1519 android: {
1520 export_include_dirs: ["include/include-android"],
1521 },
1522 linux_glibc: {
1523 export_include_dirs: ["include/include-host"],
1524 },
1525 },
Paul Duffina04c1072020-03-02 10:16:35 +00001526}
1527
1528sdk_snapshot {
1529 name: "mysdk@current",
1530 host_supported: true,
1531 native_header_libs: ["mysdk_mynativeheaders@current"],
1532}
1533`),
1534 checkAllCopyRules(`
1535include/Test.h -> include/include/Test.h
1536include-android/AndroidTest.h -> include/include-android/AndroidTest.h
1537include-host/HostTest.h -> include/include-host/HostTest.h
1538`),
1539 )
1540}
Martin Stjernholm10566a02020-03-24 01:19:52 +00001541
1542func TestSystemSharedLibPropagation(t *testing.T) {
Martin Stjernholm66a06942020-03-26 17:39:30 +00001543 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1544 SkipIfNotLinux(t)
1545
Martin Stjernholm10566a02020-03-24 01:19:52 +00001546 result := testSdkWithCc(t, `
1547 sdk {
1548 name: "mysdk",
1549 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
1550 }
1551
1552 cc_library {
1553 name: "sslnil",
1554 host_supported: true,
1555 }
1556
1557 cc_library {
1558 name: "sslempty",
1559 system_shared_libs: [],
1560 }
1561
1562 cc_library {
1563 name: "sslnonempty",
1564 system_shared_libs: ["sslnil"],
1565 }
1566 `)
1567
1568 result.CheckSnapshot("mysdk", "",
1569 checkAndroidBpContents(`
1570// This is auto-generated. DO NOT EDIT.
1571
1572cc_prebuilt_library_shared {
1573 name: "mysdk_sslnil@current",
1574 sdk_member_name: "sslnil",
1575 installable: false,
1576 arch: {
1577 arm64: {
1578 srcs: ["arm64/lib/sslnil.so"],
1579 },
1580 arm: {
1581 srcs: ["arm/lib/sslnil.so"],
1582 },
1583 },
1584}
1585
1586cc_prebuilt_library_shared {
1587 name: "sslnil",
1588 prefer: false,
1589 arch: {
1590 arm64: {
1591 srcs: ["arm64/lib/sslnil.so"],
1592 },
1593 arm: {
1594 srcs: ["arm/lib/sslnil.so"],
1595 },
1596 },
1597}
1598
1599cc_prebuilt_library_shared {
1600 name: "mysdk_sslempty@current",
1601 sdk_member_name: "sslempty",
1602 installable: false,
1603 system_shared_libs: [],
1604 arch: {
1605 arm64: {
1606 srcs: ["arm64/lib/sslempty.so"],
1607 },
1608 arm: {
1609 srcs: ["arm/lib/sslempty.so"],
1610 },
1611 },
1612}
1613
1614cc_prebuilt_library_shared {
1615 name: "sslempty",
1616 prefer: false,
1617 system_shared_libs: [],
1618 arch: {
1619 arm64: {
1620 srcs: ["arm64/lib/sslempty.so"],
1621 },
1622 arm: {
1623 srcs: ["arm/lib/sslempty.so"],
1624 },
1625 },
1626}
1627
1628cc_prebuilt_library_shared {
1629 name: "mysdk_sslnonempty@current",
1630 sdk_member_name: "sslnonempty",
1631 installable: false,
1632 system_shared_libs: ["mysdk_sslnil@current"],
1633 arch: {
1634 arm64: {
1635 srcs: ["arm64/lib/sslnonempty.so"],
1636 },
1637 arm: {
1638 srcs: ["arm/lib/sslnonempty.so"],
1639 },
1640 },
1641}
1642
1643cc_prebuilt_library_shared {
1644 name: "sslnonempty",
1645 prefer: false,
1646 system_shared_libs: ["sslnil"],
1647 arch: {
1648 arm64: {
1649 srcs: ["arm64/lib/sslnonempty.so"],
1650 },
1651 arm: {
1652 srcs: ["arm/lib/sslnonempty.so"],
1653 },
1654 },
1655}
1656
1657sdk_snapshot {
1658 name: "mysdk@current",
1659 native_shared_libs: [
1660 "mysdk_sslnil@current",
1661 "mysdk_sslempty@current",
1662 "mysdk_sslnonempty@current",
1663 ],
1664}
1665`))
1666
1667 result = testSdkWithCc(t, `
1668 sdk {
1669 name: "mysdk",
1670 host_supported: true,
1671 native_shared_libs: ["sslvariants"],
1672 }
1673
1674 cc_library {
1675 name: "sslvariants",
1676 host_supported: true,
1677 target: {
1678 android: {
1679 system_shared_libs: [],
1680 },
1681 },
1682 }
1683 `)
1684
1685 result.CheckSnapshot("mysdk", "",
1686 checkAndroidBpContents(`
1687// This is auto-generated. DO NOT EDIT.
1688
1689cc_prebuilt_library_shared {
1690 name: "mysdk_sslvariants@current",
1691 sdk_member_name: "sslvariants",
1692 host_supported: true,
1693 installable: false,
1694 target: {
1695 android: {
1696 system_shared_libs: [],
1697 },
1698 android_arm64: {
1699 srcs: ["android/arm64/lib/sslvariants.so"],
1700 },
1701 android_arm: {
1702 srcs: ["android/arm/lib/sslvariants.so"],
1703 },
1704 linux_glibc_x86_64: {
1705 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
1706 },
1707 linux_glibc_x86: {
1708 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
1709 },
1710 },
1711}
1712
1713cc_prebuilt_library_shared {
1714 name: "sslvariants",
1715 prefer: false,
1716 host_supported: true,
1717 target: {
1718 android: {
1719 system_shared_libs: [],
1720 },
1721 android_arm64: {
1722 srcs: ["android/arm64/lib/sslvariants.so"],
1723 },
1724 android_arm: {
1725 srcs: ["android/arm/lib/sslvariants.so"],
1726 },
1727 linux_glibc_x86_64: {
1728 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
1729 },
1730 linux_glibc_x86: {
1731 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
1732 },
1733 },
1734}
1735
1736sdk_snapshot {
1737 name: "mysdk@current",
1738 host_supported: true,
1739 native_shared_libs: ["mysdk_sslvariants@current"],
1740}
1741`))
1742}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001743
1744func TestStubsLibrary(t *testing.T) {
1745 result := testSdkWithCc(t, `
1746 sdk {
1747 name: "mysdk",
1748 native_shared_libs: ["stubslib"],
1749 }
1750
1751 cc_library {
1752 name: "stubslib",
1753 stubs: {
1754 symbol_file: "some/where/stubslib.map.txt",
1755 versions: ["1", "2", "3"],
1756 },
1757 }
1758 `)
1759
1760 result.CheckSnapshot("mysdk", "",
1761 checkAndroidBpContents(`
1762// This is auto-generated. DO NOT EDIT.
1763
1764cc_prebuilt_library_shared {
1765 name: "mysdk_stubslib@current",
1766 sdk_member_name: "stubslib",
1767 installable: false,
1768 stubs: {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001769 versions: ["3"],
1770 },
1771 arch: {
1772 arm64: {
1773 srcs: ["arm64/lib/stubslib.so"],
1774 },
1775 arm: {
1776 srcs: ["arm/lib/stubslib.so"],
1777 },
1778 },
1779}
1780
1781cc_prebuilt_library_shared {
1782 name: "stubslib",
1783 prefer: false,
1784 stubs: {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001785 versions: ["3"],
1786 },
1787 arch: {
1788 arm64: {
1789 srcs: ["arm64/lib/stubslib.so"],
1790 },
1791 arm: {
1792 srcs: ["arm/lib/stubslib.so"],
1793 },
1794 },
1795}
1796
1797sdk_snapshot {
1798 name: "mysdk@current",
1799 native_shared_libs: ["mysdk_stubslib@current"],
1800}
1801`))
1802}