blob: 2dd23c737224761d4ed8907ab817bf003d1ca525 [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
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010072func TestSdkCompileMultilibOverride(t *testing.T) {
73 result := testSdkWithCc(t, `
74 sdk {
75 name: "mysdk",
76 native_shared_libs: ["sdkmember"],
77 compile_multilib: "64",
78 }
79
80 cc_library_shared {
81 name: "sdkmember",
82 srcs: ["Test.cpp"],
83 stl: "none",
84 compile_multilib: "64",
85 }
86 `)
87
88 result.CheckSnapshot("mysdk", "",
89 checkAllCopyRules(`
Charles Chen29936ae2020-07-15 04:01:45 +000090.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> arm64/lib/sdkmember.so
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010091`))
92}
93
Paul Duffina80fdec2019-12-03 15:25:00 +000094func TestBasicSdkWithCc(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +000095 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000096 sdk {
97 name: "mysdk",
98 native_shared_libs: ["sdkmember"],
99 }
100
Paul Duffina0843f62019-12-13 19:50:38 +0000101 cc_library_shared {
102 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -0800103 system_shared_libs: [],
Martin Stjernholmcc776012020-07-07 03:22:21 +0100104 stl: "none",
105 apex_available: ["mysdkapex"],
Paul Duffina0843f62019-12-13 19:50:38 +0000106 }
107
Paul Duffina80fdec2019-12-03 15:25:00 +0000108 sdk_snapshot {
109 name: "mysdk@1",
110 native_shared_libs: ["sdkmember_mysdk_1"],
111 }
112
113 sdk_snapshot {
114 name: "mysdk@2",
115 native_shared_libs: ["sdkmember_mysdk_2"],
116 }
117
118 cc_prebuilt_library_shared {
119 name: "sdkmember",
120 srcs: ["libfoo.so"],
121 prefer: false,
122 system_shared_libs: [],
123 stl: "none",
124 }
125
126 cc_prebuilt_library_shared {
127 name: "sdkmember_mysdk_1",
128 sdk_member_name: "sdkmember",
129 srcs: ["libfoo.so"],
130 system_shared_libs: [],
131 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000132 // TODO: remove //apex_available:platform
133 apex_available: [
134 "//apex_available:platform",
135 "myapex",
136 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000137 }
138
139 cc_prebuilt_library_shared {
140 name: "sdkmember_mysdk_2",
141 sdk_member_name: "sdkmember",
142 srcs: ["libfoo.so"],
143 system_shared_libs: [],
144 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000145 // TODO: remove //apex_available:platform
146 apex_available: [
147 "//apex_available:platform",
148 "myapex2",
149 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000150 }
151
152 cc_library_shared {
153 name: "mycpplib",
154 srcs: ["Test.cpp"],
155 shared_libs: ["sdkmember"],
156 system_shared_libs: [],
157 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000158 apex_available: [
159 "myapex",
160 "myapex2",
161 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000162 }
163
164 apex {
165 name: "myapex",
166 native_shared_libs: ["mycpplib"],
167 uses_sdks: ["mysdk@1"],
168 key: "myapex.key",
169 certificate: ":myapex.cert",
170 }
171
172 apex {
173 name: "myapex2",
174 native_shared_libs: ["mycpplib"],
175 uses_sdks: ["mysdk@2"],
176 key: "myapex.key",
177 certificate: ":myapex.cert",
178 }
Martin Stjernholmcc776012020-07-07 03:22:21 +0100179
180 apex {
181 name: "mysdkapex",
182 native_shared_libs: ["sdkmember"],
183 key: "myapex.key",
184 certificate: ":myapex.cert",
185 }
Paul Duffina80fdec2019-12-03 15:25:00 +0000186 `)
187
Colin Cross7113d202019-11-20 16:39:12 -0800188 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_myapex").Rule("toc").Output
189 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_myapex2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000190
Colin Cross7113d202019-11-20 16:39:12 -0800191 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex")
192 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000193
194 // Depending on the uses_sdks value, different libs are linked
195 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
196 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
197}
198
Paul Duffina0843f62019-12-13 19:50:38 +0000199// Make sure the sdk can use host specific cc libraries static/shared and both.
200func TestHostSdkWithCc(t *testing.T) {
201 testSdkWithCc(t, `
202 sdk {
203 name: "mysdk",
204 device_supported: false,
205 host_supported: true,
206 native_shared_libs: ["sdkshared"],
207 native_static_libs: ["sdkstatic"],
208 }
209
210 cc_library_host_shared {
211 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000212 stl: "none",
213 }
214
215 cc_library_host_static {
216 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000217 stl: "none",
218 }
219 `)
220}
221
222// Make sure the sdk can use cc libraries static/shared and both.
223func TestSdkWithCc(t *testing.T) {
224 testSdkWithCc(t, `
225 sdk {
226 name: "mysdk",
227 native_shared_libs: ["sdkshared", "sdkboth1"],
228 native_static_libs: ["sdkstatic", "sdkboth2"],
229 }
230
231 cc_library_shared {
232 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000233 stl: "none",
234 }
235
236 cc_library_static {
237 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000238 stl: "none",
239 }
240
241 cc_library {
242 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000243 stl: "none",
244 }
245
246 cc_library {
247 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000248 stl: "none",
249 }
250 `)
251}
252
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000253func TestSnapshotWithObject(t *testing.T) {
254 result := testSdkWithCc(t, `
255 sdk {
256 name: "mysdk",
257 native_objects: ["crtobj"],
258 }
259
260 cc_object {
261 name: "crtobj",
262 stl: "none",
263 }
264 `)
265
266 result.CheckSnapshot("mysdk", "",
267 checkAndroidBpContents(`
268// This is auto-generated. DO NOT EDIT.
269
270cc_prebuilt_object {
271 name: "mysdk_crtobj@current",
272 sdk_member_name: "crtobj",
273 stl: "none",
274 arch: {
275 arm64: {
276 srcs: ["arm64/lib/crtobj.o"],
277 },
278 arm: {
279 srcs: ["arm/lib/crtobj.o"],
280 },
281 },
282}
283
284cc_prebuilt_object {
285 name: "crtobj",
286 prefer: false,
287 stl: "none",
288 arch: {
289 arm64: {
290 srcs: ["arm64/lib/crtobj.o"],
291 },
292 arm: {
293 srcs: ["arm/lib/crtobj.o"],
294 },
295 },
296}
297
298sdk_snapshot {
299 name: "mysdk@current",
300 native_objects: ["mysdk_crtobj@current"],
301}
302`),
303 checkAllCopyRules(`
304.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
305.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
306`),
307 )
308}
309
Paul Duffinc62a5102019-12-11 18:34:15 +0000310func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
311 result := testSdkWithCc(t, `
312 sdk {
313 name: "mysdk",
314 native_shared_libs: ["mynativelib1", "mynativelib2"],
315 }
316
317 cc_library_shared {
318 name: "mynativelib1",
319 srcs: [
320 "Test.cpp",
321 ],
322 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000323 stl: "none",
324 }
325
326 cc_library_shared {
327 name: "mynativelib2",
328 srcs: [
329 "Test.cpp",
330 ],
331 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000332 stl: "none",
333 }
334 `)
335
Paul Duffin1356d8c2020-02-25 19:26:33 +0000336 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000337 checkAllCopyRules(`
338include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800339.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
340.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
341.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
342.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000343`),
344 )
345}
346
Paul Duffina7cd8c82019-12-11 20:00:57 +0000347// Verify that when the shared library has some common and some arch specific properties that the generated
348// snapshot is optimized properly.
349func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
350 result := testSdkWithCc(t, `
351 sdk {
352 name: "mysdk",
353 native_shared_libs: ["mynativelib"],
354 }
355
356 cc_library_shared {
357 name: "mynativelib",
358 srcs: [
359 "Test.cpp",
360 "aidl/foo/bar/Test.aidl",
361 ],
362 export_include_dirs: ["include"],
363 arch: {
364 arm64: {
365 export_system_include_dirs: ["arm64/include"],
366 },
367 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000368 stl: "none",
369 }
370 `)
371
Paul Duffin1356d8c2020-02-25 19:26:33 +0000372 result.CheckSnapshot("mysdk", "",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000373 checkAndroidBpContents(`
374// This is auto-generated. DO NOT EDIT.
375
376cc_prebuilt_library_shared {
377 name: "mysdk_mynativelib@current",
378 sdk_member_name: "mynativelib",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000379 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000380 stl: "none",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000381 export_include_dirs: ["include/include"],
382 arch: {
383 arm64: {
384 srcs: ["arm64/lib/mynativelib.so"],
385 export_system_include_dirs: ["arm64/include/arm64/include"],
386 },
387 arm: {
388 srcs: ["arm/lib/mynativelib.so"],
389 },
390 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000391}
392
393cc_prebuilt_library_shared {
394 name: "mynativelib",
395 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000396 stl: "none",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000397 export_include_dirs: ["include/include"],
398 arch: {
399 arm64: {
400 srcs: ["arm64/lib/mynativelib.so"],
401 export_system_include_dirs: ["arm64/include/arm64/include"],
402 },
403 arm: {
404 srcs: ["arm/lib/mynativelib.so"],
405 },
406 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000407}
408
409sdk_snapshot {
410 name: "mysdk@current",
411 native_shared_libs: ["mysdk_mynativelib@current"],
412}
413`),
414 checkAllCopyRules(`
415include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800416.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000417arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800418.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000419 )
420}
421
Paul Duffin25ce04b2020-01-16 11:47:25 +0000422func TestSnapshotWithCcBinary(t *testing.T) {
423 result := testSdkWithCc(t, `
424 module_exports {
425 name: "mymodule_exports",
426 native_binaries: ["mynativebinary"],
427 }
428
429 cc_binary {
430 name: "mynativebinary",
431 srcs: [
432 "Test.cpp",
433 ],
434 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000435 }
436 `)
437
Paul Duffin1356d8c2020-02-25 19:26:33 +0000438 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000439 checkAndroidBpContents(`
440// This is auto-generated. DO NOT EDIT.
441
442cc_prebuilt_binary {
443 name: "mymodule_exports_mynativebinary@current",
444 sdk_member_name: "mynativebinary",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000445 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000446 compile_multilib: "both",
447 arch: {
448 arm64: {
449 srcs: ["arm64/bin/mynativebinary"],
450 },
451 arm: {
452 srcs: ["arm/bin/mynativebinary"],
453 },
454 },
455}
456
457cc_prebuilt_binary {
458 name: "mynativebinary",
459 prefer: false,
460 compile_multilib: "both",
461 arch: {
462 arm64: {
463 srcs: ["arm64/bin/mynativebinary"],
464 },
465 arm: {
466 srcs: ["arm/bin/mynativebinary"],
467 },
468 },
469}
470
471module_exports_snapshot {
472 name: "mymodule_exports@current",
473 native_binaries: ["mymodule_exports_mynativebinary@current"],
474}
475`),
476 checkAllCopyRules(`
477.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
478.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
479`),
480 )
481}
482
Paul Duffina04c1072020-03-02 10:16:35 +0000483func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000484 result := testSdkWithCc(t, `
485 module_exports {
486 name: "myexports",
487 device_supported: false,
488 host_supported: true,
489 native_binaries: ["mynativebinary"],
490 target: {
491 windows: {
492 enabled: true,
493 },
494 },
495 }
496
497 cc_binary {
498 name: "mynativebinary",
499 device_supported: false,
500 host_supported: true,
501 srcs: [
502 "Test.cpp",
503 ],
504 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000505 stl: "none",
506 target: {
507 windows: {
508 enabled: true,
509 },
510 },
511 }
512 `)
513
514 result.CheckSnapshot("myexports", "",
515 checkAndroidBpContents(`
516// This is auto-generated. DO NOT EDIT.
517
518cc_prebuilt_binary {
519 name: "myexports_mynativebinary@current",
520 sdk_member_name: "mynativebinary",
521 device_supported: false,
522 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000523 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100524 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000525 target: {
526 linux_glibc: {
527 compile_multilib: "both",
528 },
529 linux_glibc_x86_64: {
530 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
531 },
532 linux_glibc_x86: {
533 srcs: ["linux_glibc/x86/bin/mynativebinary"],
534 },
535 windows: {
536 compile_multilib: "64",
537 },
538 windows_x86_64: {
539 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
540 },
541 },
542}
543
544cc_prebuilt_binary {
545 name: "mynativebinary",
546 prefer: false,
547 device_supported: false,
548 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100549 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000550 target: {
551 linux_glibc: {
552 compile_multilib: "both",
553 },
554 linux_glibc_x86_64: {
555 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
556 },
557 linux_glibc_x86: {
558 srcs: ["linux_glibc/x86/bin/mynativebinary"],
559 },
560 windows: {
561 compile_multilib: "64",
562 },
563 windows_x86_64: {
564 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
565 },
566 },
567}
568
569module_exports_snapshot {
570 name: "myexports@current",
571 device_supported: false,
572 host_supported: true,
573 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000574 target: {
575 windows: {
576 compile_multilib: "64",
577 },
578 },
Paul Duffina04c1072020-03-02 10:16:35 +0000579}
580`),
581 checkAllCopyRules(`
582.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
583.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
584.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
585`),
586 )
587}
588
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100589// Test that we support the necessary flags for the linker binary, which is
590// special in several ways.
591func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100592 result := testSdkWithCc(t, `
593 module_exports {
594 name: "mymodule_exports",
595 host_supported: true,
596 device_supported: false,
597 native_binaries: ["linker"],
598 }
599
600 cc_binary {
601 name: "linker",
602 host_supported: true,
603 static_executable: true,
604 nocrt: true,
605 stl: "none",
606 srcs: [
607 "Test.cpp",
608 ],
609 compile_multilib: "both",
610 }
611 `)
612
613 result.CheckSnapshot("mymodule_exports", "",
614 checkAndroidBpContents(`
615// This is auto-generated. DO NOT EDIT.
616
617cc_prebuilt_binary {
618 name: "mymodule_exports_linker@current",
619 sdk_member_name: "linker",
620 device_supported: false,
621 host_supported: true,
622 installable: false,
623 stl: "none",
624 static_executable: true,
625 nocrt: true,
Charles Chen29936ae2020-07-15 04:01:45 +0000626 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100627 arch: {
628 x86_64: {
629 srcs: ["x86_64/bin/linker"],
630 },
631 x86: {
632 srcs: ["x86/bin/linker"],
633 },
634 },
635}
636
637cc_prebuilt_binary {
638 name: "linker",
639 prefer: false,
640 device_supported: false,
641 host_supported: true,
642 stl: "none",
643 static_executable: true,
644 nocrt: true,
Charles Chen29936ae2020-07-15 04:01:45 +0000645 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100646 arch: {
647 x86_64: {
648 srcs: ["x86_64/bin/linker"],
649 },
650 x86: {
651 srcs: ["x86/bin/linker"],
652 },
653 },
654}
655
656module_exports_snapshot {
657 name: "mymodule_exports@current",
658 device_supported: false,
659 host_supported: true,
660 native_binaries: ["mymodule_exports_linker@current"],
661}
662`),
663 checkAllCopyRules(`
664.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
665.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
666`),
667 )
668}
669
Paul Duffin9ab556f2019-12-11 18:42:17 +0000670func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000671 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000672 sdk {
673 name: "mysdk",
674 native_shared_libs: ["mynativelib"],
675 }
676
677 cc_library_shared {
678 name: "mynativelib",
679 srcs: [
680 "Test.cpp",
681 "aidl/foo/bar/Test.aidl",
682 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +0000683 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000684 export_include_dirs: ["include"],
685 aidl: {
686 export_aidl_headers: true,
687 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000688 stl: "none",
689 }
690 `)
691
Paul Duffin1356d8c2020-02-25 19:26:33 +0000692 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000693 checkAndroidBpContents(`
694// This is auto-generated. DO NOT EDIT.
695
696cc_prebuilt_library_shared {
697 name: "mysdk_mynativelib@current",
698 sdk_member_name: "mynativelib",
Paul Duffinbefa4b92020-03-04 14:22:45 +0000699 apex_available: [
700 "apex1",
701 "apex2",
702 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000703 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000704 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000705 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000706 arch: {
707 arm64: {
708 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000709 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000710 },
711 arm: {
712 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000713 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000714 },
715 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000716}
717
718cc_prebuilt_library_shared {
719 name: "mynativelib",
720 prefer: false,
Paul Duffinbefa4b92020-03-04 14:22:45 +0000721 apex_available: [
722 "apex1",
723 "apex2",
724 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000725 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000726 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000727 arch: {
728 arm64: {
729 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000730 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000731 },
732 arm: {
733 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000734 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000735 },
736 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000737}
738
739sdk_snapshot {
740 name: "mysdk@current",
741 native_shared_libs: ["mysdk_mynativelib@current"],
742}
743`),
744 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000745include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800746.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
747.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
748.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
749.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
750.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
751.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
752.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
753.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 +0000754`),
755 )
756}
757
Paul Duffin13f02712020-03-06 12:30:43 +0000758func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
759 result := testSdkWithCc(t, `
760 sdk {
761 name: "mysdk",
762 native_shared_libs: [
763 "mynativelib",
764 "myothernativelib",
765 "mysystemnativelib",
766 ],
767 }
768
769 cc_library {
770 name: "mysystemnativelib",
771 srcs: [
772 "Test.cpp",
773 ],
Paul Duffin13f02712020-03-06 12:30:43 +0000774 stl: "none",
775 }
776
777 cc_library_shared {
778 name: "myothernativelib",
779 srcs: [
780 "Test.cpp",
781 ],
782 system_shared_libs: [
783 // A reference to a library that is not an sdk member. Uses libm as that
784 // is in the default set of modules available to this test and so is available
785 // both here and also when the generated Android.bp file is tested in
786 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
787 // handles references to modules that are not sdk members.
788 "libm",
789 ],
790 stl: "none",
791 }
792
793 cc_library {
794 name: "mynativelib",
795 srcs: [
796 "Test.cpp",
797 ],
798 shared_libs: [
799 // A reference to another sdk member.
800 "myothernativelib",
801 ],
802 target: {
803 android: {
804 shared: {
805 shared_libs: [
806 // A reference to a library that is not an sdk member. The libc library
807 // is used here to check that the shared_libs property is handled correctly
808 // in a similar way to how libm is used to check system_shared_libs above.
809 "libc",
810 ],
811 },
812 },
813 },
Paul Duffin13f02712020-03-06 12:30:43 +0000814 stl: "none",
815 }
816 `)
817
818 result.CheckSnapshot("mysdk", "",
819 checkAndroidBpContents(`
820// This is auto-generated. DO NOT EDIT.
821
822cc_prebuilt_library_shared {
823 name: "mysdk_mynativelib@current",
824 sdk_member_name: "mynativelib",
825 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000826 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000827 shared_libs: [
828 "mysdk_myothernativelib@current",
829 "libc",
830 ],
831 arch: {
832 arm64: {
833 srcs: ["arm64/lib/mynativelib.so"],
834 },
835 arm: {
836 srcs: ["arm/lib/mynativelib.so"],
837 },
838 },
Paul Duffin13f02712020-03-06 12:30:43 +0000839}
840
841cc_prebuilt_library_shared {
842 name: "mynativelib",
843 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000844 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000845 shared_libs: [
846 "myothernativelib",
847 "libc",
848 ],
849 arch: {
850 arm64: {
851 srcs: ["arm64/lib/mynativelib.so"],
852 },
853 arm: {
854 srcs: ["arm/lib/mynativelib.so"],
855 },
856 },
Paul Duffin13f02712020-03-06 12:30:43 +0000857}
858
859cc_prebuilt_library_shared {
860 name: "mysdk_myothernativelib@current",
861 sdk_member_name: "myothernativelib",
862 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000863 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000864 system_shared_libs: ["libm"],
865 arch: {
866 arm64: {
867 srcs: ["arm64/lib/myothernativelib.so"],
868 },
869 arm: {
870 srcs: ["arm/lib/myothernativelib.so"],
871 },
872 },
Paul Duffin13f02712020-03-06 12:30:43 +0000873}
874
875cc_prebuilt_library_shared {
876 name: "myothernativelib",
877 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000878 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000879 system_shared_libs: ["libm"],
880 arch: {
881 arm64: {
882 srcs: ["arm64/lib/myothernativelib.so"],
883 },
884 arm: {
885 srcs: ["arm/lib/myothernativelib.so"],
886 },
887 },
Paul Duffin13f02712020-03-06 12:30:43 +0000888}
889
890cc_prebuilt_library_shared {
891 name: "mysdk_mysystemnativelib@current",
892 sdk_member_name: "mysystemnativelib",
893 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000894 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000895 arch: {
896 arm64: {
897 srcs: ["arm64/lib/mysystemnativelib.so"],
898 },
899 arm: {
900 srcs: ["arm/lib/mysystemnativelib.so"],
901 },
902 },
Paul Duffin13f02712020-03-06 12:30:43 +0000903}
904
905cc_prebuilt_library_shared {
906 name: "mysystemnativelib",
907 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000908 stl: "none",
Paul Duffin13f02712020-03-06 12:30:43 +0000909 arch: {
910 arm64: {
911 srcs: ["arm64/lib/mysystemnativelib.so"],
912 },
913 arm: {
914 srcs: ["arm/lib/mysystemnativelib.so"],
915 },
916 },
Paul Duffin13f02712020-03-06 12:30:43 +0000917}
918
919sdk_snapshot {
920 name: "mysdk@current",
921 native_shared_libs: [
922 "mysdk_mynativelib@current",
923 "mysdk_myothernativelib@current",
924 "mysdk_mysystemnativelib@current",
925 ],
926}
927`),
928 checkAllCopyRules(`
929.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
930.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
931.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
932.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
933.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
934.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
935`),
936 )
937}
938
Paul Duffin9ab556f2019-12-11 18:42:17 +0000939func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000940 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000941 sdk {
942 name: "mysdk",
943 device_supported: false,
944 host_supported: true,
945 native_shared_libs: ["mynativelib"],
946 }
947
948 cc_library_shared {
949 name: "mynativelib",
950 device_supported: false,
951 host_supported: true,
952 srcs: [
953 "Test.cpp",
954 "aidl/foo/bar/Test.aidl",
955 ],
956 export_include_dirs: ["include"],
957 aidl: {
958 export_aidl_headers: true,
959 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000960 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +0000961 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +0000962 }
963 `)
964
Paul Duffin1356d8c2020-02-25 19:26:33 +0000965 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000966 checkAndroidBpContents(`
967// This is auto-generated. DO NOT EDIT.
968
969cc_prebuilt_library_shared {
970 name: "mysdk_mynativelib@current",
971 sdk_member_name: "mynativelib",
972 device_supported: false,
973 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000974 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +0000975 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +0000976 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000977 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000978 arch: {
979 x86_64: {
980 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000981 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000982 },
983 x86: {
984 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000985 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000986 },
987 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000988}
989
990cc_prebuilt_library_shared {
991 name: "mynativelib",
992 prefer: false,
993 device_supported: false,
994 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +0000995 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +0000996 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000997 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000998 arch: {
999 x86_64: {
1000 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001001 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001002 },
1003 x86: {
1004 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001005 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001006 },
1007 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001008}
1009
1010sdk_snapshot {
1011 name: "mysdk@current",
1012 device_supported: false,
1013 host_supported: true,
1014 native_shared_libs: ["mysdk_mynativelib@current"],
1015}
1016`),
1017 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001018include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001019.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001020.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1021.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1022.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1023.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001024.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1025.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1026.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1027`),
1028 )
1029}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001030
Paul Duffina04c1072020-03-02 10:16:35 +00001031func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001032 result := testSdkWithCc(t, `
1033 sdk {
1034 name: "mysdk",
1035 device_supported: false,
1036 host_supported: true,
1037 native_shared_libs: ["mynativelib"],
1038 target: {
1039 windows: {
1040 enabled: true,
1041 },
1042 },
1043 }
1044
1045 cc_library_shared {
1046 name: "mynativelib",
1047 device_supported: false,
1048 host_supported: true,
1049 srcs: [
1050 "Test.cpp",
1051 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001052 stl: "none",
1053 target: {
1054 windows: {
1055 enabled: true,
1056 },
1057 },
1058 }
1059 `)
1060
1061 result.CheckSnapshot("mysdk", "",
1062 checkAndroidBpContents(`
1063// This is auto-generated. DO NOT EDIT.
1064
1065cc_prebuilt_library_shared {
1066 name: "mysdk_mynativelib@current",
1067 sdk_member_name: "mynativelib",
1068 device_supported: false,
1069 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001070 installable: false,
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
1085cc_prebuilt_library_shared {
1086 name: "mynativelib",
1087 prefer: false,
1088 device_supported: false,
1089 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001090 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001091 target: {
1092 linux_glibc_x86_64: {
1093 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1094 },
1095 linux_glibc_x86: {
1096 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1097 },
1098 windows_x86_64: {
1099 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1100 },
1101 },
Paul Duffina04c1072020-03-02 10:16:35 +00001102}
1103
1104sdk_snapshot {
1105 name: "mysdk@current",
1106 device_supported: false,
1107 host_supported: true,
1108 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001109 target: {
1110 windows: {
1111 compile_multilib: "64",
1112 },
1113 },
Paul Duffina04c1072020-03-02 10:16:35 +00001114}
1115`),
1116 checkAllCopyRules(`
1117.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1118.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1119.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1120`),
1121 )
1122}
1123
Paul Duffin9ab556f2019-12-11 18:42:17 +00001124func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1125 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001126 module_exports {
1127 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001128 native_static_libs: ["mynativelib"],
1129 }
1130
1131 cc_library_static {
1132 name: "mynativelib",
1133 srcs: [
1134 "Test.cpp",
1135 "aidl/foo/bar/Test.aidl",
1136 ],
1137 export_include_dirs: ["include"],
1138 aidl: {
1139 export_aidl_headers: true,
1140 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001141 stl: "none",
1142 }
1143 `)
1144
Paul Duffin1356d8c2020-02-25 19:26:33 +00001145 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001146 checkAndroidBpContents(`
1147// This is auto-generated. DO NOT EDIT.
1148
1149cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001150 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001151 sdk_member_name: "mynativelib",
Paul Duffin0cb37b92020-03-04 14:52:46 +00001152 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001153 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001154 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001155 arch: {
1156 arm64: {
1157 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001158 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001159 },
1160 arm: {
1161 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001162 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001163 },
1164 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001165}
1166
1167cc_prebuilt_library_static {
1168 name: "mynativelib",
1169 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001170 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001171 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001172 arch: {
1173 arm64: {
1174 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001175 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001176 },
1177 arm: {
1178 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001179 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001180 },
1181 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001182}
1183
Paul Duffine6029182019-12-16 17:43:48 +00001184module_exports_snapshot {
1185 name: "myexports@current",
1186 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001187}
1188`),
1189 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001190include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001191.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1192.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1193.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1194.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1195.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1196.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1197.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1198.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 +00001199`),
1200 )
1201}
1202
1203func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001204 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001205 module_exports {
1206 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001207 device_supported: false,
1208 host_supported: true,
1209 native_static_libs: ["mynativelib"],
1210 }
1211
1212 cc_library_static {
1213 name: "mynativelib",
1214 device_supported: false,
1215 host_supported: true,
1216 srcs: [
1217 "Test.cpp",
1218 "aidl/foo/bar/Test.aidl",
1219 ],
1220 export_include_dirs: ["include"],
1221 aidl: {
1222 export_aidl_headers: true,
1223 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001224 stl: "none",
1225 }
1226 `)
1227
Paul Duffin1356d8c2020-02-25 19:26:33 +00001228 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001229 checkAndroidBpContents(`
1230// This is auto-generated. DO NOT EDIT.
1231
1232cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001233 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001234 sdk_member_name: "mynativelib",
1235 device_supported: false,
1236 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001237 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001238 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001239 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001240 arch: {
1241 x86_64: {
1242 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001243 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001244 },
1245 x86: {
1246 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001247 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001248 },
1249 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001250}
1251
1252cc_prebuilt_library_static {
1253 name: "mynativelib",
1254 prefer: false,
1255 device_supported: false,
1256 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001257 stl: "none",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001258 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001259 arch: {
1260 x86_64: {
1261 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001262 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001263 },
1264 x86: {
1265 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001266 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001267 },
1268 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001269}
1270
Paul Duffine6029182019-12-16 17:43:48 +00001271module_exports_snapshot {
1272 name: "myexports@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001273 device_supported: false,
1274 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001275 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001276}
1277`),
1278 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001279include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001280.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001281.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1282.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1283.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1284.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001285.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1286.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1287.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1288`),
1289 )
1290}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001291
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001292func TestSnapshotWithCcLibrary(t *testing.T) {
1293 result := testSdkWithCc(t, `
1294 module_exports {
1295 name: "myexports",
1296 native_libs: ["mynativelib"],
1297 }
1298
1299 cc_library {
1300 name: "mynativelib",
1301 srcs: [
1302 "Test.cpp",
1303 ],
1304 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001305 stl: "none",
1306 }
1307 `)
1308
1309 result.CheckSnapshot("myexports", "",
1310 checkAndroidBpContents(`
1311// This is auto-generated. DO NOT EDIT.
1312
1313cc_prebuilt_library {
1314 name: "myexports_mynativelib@current",
1315 sdk_member_name: "mynativelib",
1316 installable: false,
1317 stl: "none",
1318 export_include_dirs: ["include/include"],
1319 arch: {
1320 arm64: {
1321 static: {
1322 srcs: ["arm64/lib/mynativelib.a"],
1323 },
1324 shared: {
1325 srcs: ["arm64/lib/mynativelib.so"],
1326 },
1327 },
1328 arm: {
1329 static: {
1330 srcs: ["arm/lib/mynativelib.a"],
1331 },
1332 shared: {
1333 srcs: ["arm/lib/mynativelib.so"],
1334 },
1335 },
1336 },
1337}
1338
1339cc_prebuilt_library {
1340 name: "mynativelib",
1341 prefer: false,
1342 stl: "none",
1343 export_include_dirs: ["include/include"],
1344 arch: {
1345 arm64: {
1346 static: {
1347 srcs: ["arm64/lib/mynativelib.a"],
1348 },
1349 shared: {
1350 srcs: ["arm64/lib/mynativelib.so"],
1351 },
1352 },
1353 arm: {
1354 static: {
1355 srcs: ["arm/lib/mynativelib.a"],
1356 },
1357 shared: {
1358 srcs: ["arm/lib/mynativelib.so"],
1359 },
1360 },
1361 },
1362}
1363
1364module_exports_snapshot {
1365 name: "myexports@current",
1366 native_libs: ["myexports_mynativelib@current"],
1367}
1368`),
1369 checkAllCopyRules(`
1370include/Test.h -> include/include/Test.h
1371.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1372.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1373.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1374.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1375 )
1376}
1377
Paul Duffin13ad94f2020-02-19 16:19:27 +00001378func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001379 result := testSdkWithCc(t, `
1380 module_exports {
1381 name: "myexports",
1382 device_supported: false,
1383 host_supported: true,
1384 target: {
1385 host: {
1386 compile_multilib: "64",
1387 },
1388 },
1389 native_static_libs: ["mynativelib"],
1390 }
1391
1392 cc_library_static {
1393 name: "mynativelib",
1394 device_supported: false,
1395 host_supported: true,
1396 srcs: [
1397 "Test.cpp",
1398 "aidl/foo/bar/Test.aidl",
1399 ],
1400 export_include_dirs: ["include"],
1401 aidl: {
1402 export_aidl_headers: true,
1403 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001404 stl: "none",
1405 }
1406 `)
1407
Paul Duffin1356d8c2020-02-25 19:26:33 +00001408 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001409 checkAndroidBpContents(`
1410// This is auto-generated. DO NOT EDIT.
1411
1412cc_prebuilt_library_static {
1413 name: "myexports_mynativelib@current",
1414 sdk_member_name: "mynativelib",
1415 device_supported: false,
1416 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001417 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001418 stl: "none",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001419 export_include_dirs: ["include/include"],
1420 arch: {
1421 x86_64: {
1422 srcs: ["x86_64/lib/mynativelib.a"],
1423 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1424 },
1425 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001426}
1427
1428cc_prebuilt_library_static {
1429 name: "mynativelib",
1430 prefer: false,
1431 device_supported: false,
1432 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001433 stl: "none",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001434 export_include_dirs: ["include/include"],
1435 arch: {
1436 x86_64: {
1437 srcs: ["x86_64/lib/mynativelib.a"],
1438 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1439 },
1440 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001441}
1442
1443module_exports_snapshot {
1444 name: "myexports@current",
1445 device_supported: false,
1446 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001447 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001448 target: {
Paul Duffin6a7e9532020-03-20 17:50:07 +00001449 linux_glibc: {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001450 compile_multilib: "64",
1451 },
1452 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001453}`),
1454 checkAllCopyRules(`
1455include/Test.h -> include/include/Test.h
1456.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1457.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1458.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1459.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1460`),
1461 )
1462}
Paul Duffin91756d22020-02-21 16:29:57 +00001463
1464func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1465 result := testSdkWithCc(t, `
1466 sdk {
1467 name: "mysdk",
1468 native_header_libs: ["mynativeheaders"],
1469 }
1470
1471 cc_library_headers {
1472 name: "mynativeheaders",
1473 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001474 stl: "none",
1475 }
1476 `)
1477
Paul Duffin1356d8c2020-02-25 19:26:33 +00001478 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001479 checkAndroidBpContents(`
1480// This is auto-generated. DO NOT EDIT.
1481
1482cc_prebuilt_library_headers {
1483 name: "mysdk_mynativeheaders@current",
1484 sdk_member_name: "mynativeheaders",
Paul Duffin91756d22020-02-21 16:29:57 +00001485 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001486 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001487}
1488
1489cc_prebuilt_library_headers {
1490 name: "mynativeheaders",
1491 prefer: false,
Paul Duffin91756d22020-02-21 16:29:57 +00001492 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001493 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001494}
1495
1496sdk_snapshot {
1497 name: "mysdk@current",
1498 native_header_libs: ["mysdk_mynativeheaders@current"],
1499}
1500`),
1501 checkAllCopyRules(`
1502include/Test.h -> include/include/Test.h
1503`),
1504 )
1505}
1506
1507func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001508 result := testSdkWithCc(t, `
1509 sdk {
1510 name: "mysdk",
1511 device_supported: false,
1512 host_supported: true,
1513 native_header_libs: ["mynativeheaders"],
1514 }
1515
1516 cc_library_headers {
1517 name: "mynativeheaders",
1518 device_supported: false,
1519 host_supported: true,
1520 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001521 stl: "none",
1522 }
1523 `)
1524
Paul Duffin1356d8c2020-02-25 19:26:33 +00001525 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001526 checkAndroidBpContents(`
1527// This is auto-generated. DO NOT EDIT.
1528
1529cc_prebuilt_library_headers {
1530 name: "mysdk_mynativeheaders@current",
1531 sdk_member_name: "mynativeheaders",
1532 device_supported: false,
1533 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001534 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001535 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001536}
1537
1538cc_prebuilt_library_headers {
1539 name: "mynativeheaders",
1540 prefer: false,
1541 device_supported: false,
1542 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001543 stl: "none",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001544 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001545}
1546
1547sdk_snapshot {
1548 name: "mysdk@current",
1549 device_supported: false,
1550 host_supported: true,
1551 native_header_libs: ["mysdk_mynativeheaders@current"],
1552}
1553`),
1554 checkAllCopyRules(`
1555include/Test.h -> include/include/Test.h
1556`),
1557 )
1558}
Paul Duffina04c1072020-03-02 10:16:35 +00001559
1560func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001561 result := testSdkWithCc(t, `
1562 sdk {
1563 name: "mysdk",
1564 host_supported: true,
1565 native_header_libs: ["mynativeheaders"],
1566 }
1567
1568 cc_library_headers {
1569 name: "mynativeheaders",
1570 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001571 stl: "none",
1572 export_system_include_dirs: ["include"],
1573 target: {
1574 android: {
1575 export_include_dirs: ["include-android"],
1576 },
1577 host: {
1578 export_include_dirs: ["include-host"],
1579 },
1580 },
1581 }
1582 `)
1583
1584 result.CheckSnapshot("mysdk", "",
1585 checkAndroidBpContents(`
1586// This is auto-generated. DO NOT EDIT.
1587
1588cc_prebuilt_library_headers {
1589 name: "mysdk_mynativeheaders@current",
1590 sdk_member_name: "mynativeheaders",
1591 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001592 stl: "none",
Paul Duffined62b9c2020-06-16 16:12:50 +01001593 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00001594 target: {
1595 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01001596 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00001597 },
1598 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01001599 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00001600 },
1601 },
Paul Duffina04c1072020-03-02 10:16:35 +00001602}
1603
1604cc_prebuilt_library_headers {
1605 name: "mynativeheaders",
1606 prefer: false,
1607 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001608 stl: "none",
Paul Duffined62b9c2020-06-16 16:12:50 +01001609 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00001610 target: {
1611 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01001612 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00001613 },
1614 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01001615 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00001616 },
1617 },
Paul Duffina04c1072020-03-02 10:16:35 +00001618}
1619
1620sdk_snapshot {
1621 name: "mysdk@current",
1622 host_supported: true,
1623 native_header_libs: ["mysdk_mynativeheaders@current"],
1624}
1625`),
1626 checkAllCopyRules(`
Paul Duffined62b9c2020-06-16 16:12:50 +01001627include/Test.h -> common_os/include/include/Test.h
1628include-android/AndroidTest.h -> android/include/include-android/AndroidTest.h
1629include-host/HostTest.h -> linux_glibc/include/include-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00001630`),
1631 )
1632}
Martin Stjernholm10566a02020-03-24 01:19:52 +00001633
1634func TestSystemSharedLibPropagation(t *testing.T) {
1635 result := testSdkWithCc(t, `
1636 sdk {
1637 name: "mysdk",
1638 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
1639 }
1640
1641 cc_library {
1642 name: "sslnil",
1643 host_supported: true,
1644 }
1645
1646 cc_library {
1647 name: "sslempty",
1648 system_shared_libs: [],
1649 }
1650
1651 cc_library {
1652 name: "sslnonempty",
1653 system_shared_libs: ["sslnil"],
1654 }
1655 `)
1656
1657 result.CheckSnapshot("mysdk", "",
1658 checkAndroidBpContents(`
1659// This is auto-generated. DO NOT EDIT.
1660
1661cc_prebuilt_library_shared {
1662 name: "mysdk_sslnil@current",
1663 sdk_member_name: "sslnil",
1664 installable: false,
1665 arch: {
1666 arm64: {
1667 srcs: ["arm64/lib/sslnil.so"],
1668 },
1669 arm: {
1670 srcs: ["arm/lib/sslnil.so"],
1671 },
1672 },
1673}
1674
1675cc_prebuilt_library_shared {
1676 name: "sslnil",
1677 prefer: false,
1678 arch: {
1679 arm64: {
1680 srcs: ["arm64/lib/sslnil.so"],
1681 },
1682 arm: {
1683 srcs: ["arm/lib/sslnil.so"],
1684 },
1685 },
1686}
1687
1688cc_prebuilt_library_shared {
1689 name: "mysdk_sslempty@current",
1690 sdk_member_name: "sslempty",
1691 installable: false,
1692 system_shared_libs: [],
1693 arch: {
1694 arm64: {
1695 srcs: ["arm64/lib/sslempty.so"],
1696 },
1697 arm: {
1698 srcs: ["arm/lib/sslempty.so"],
1699 },
1700 },
1701}
1702
1703cc_prebuilt_library_shared {
1704 name: "sslempty",
1705 prefer: false,
1706 system_shared_libs: [],
1707 arch: {
1708 arm64: {
1709 srcs: ["arm64/lib/sslempty.so"],
1710 },
1711 arm: {
1712 srcs: ["arm/lib/sslempty.so"],
1713 },
1714 },
1715}
1716
1717cc_prebuilt_library_shared {
1718 name: "mysdk_sslnonempty@current",
1719 sdk_member_name: "sslnonempty",
1720 installable: false,
1721 system_shared_libs: ["mysdk_sslnil@current"],
1722 arch: {
1723 arm64: {
1724 srcs: ["arm64/lib/sslnonempty.so"],
1725 },
1726 arm: {
1727 srcs: ["arm/lib/sslnonempty.so"],
1728 },
1729 },
1730}
1731
1732cc_prebuilt_library_shared {
1733 name: "sslnonempty",
1734 prefer: false,
1735 system_shared_libs: ["sslnil"],
1736 arch: {
1737 arm64: {
1738 srcs: ["arm64/lib/sslnonempty.so"],
1739 },
1740 arm: {
1741 srcs: ["arm/lib/sslnonempty.so"],
1742 },
1743 },
1744}
1745
1746sdk_snapshot {
1747 name: "mysdk@current",
1748 native_shared_libs: [
1749 "mysdk_sslnil@current",
1750 "mysdk_sslempty@current",
1751 "mysdk_sslnonempty@current",
1752 ],
1753}
1754`))
1755
1756 result = testSdkWithCc(t, `
1757 sdk {
1758 name: "mysdk",
1759 host_supported: true,
1760 native_shared_libs: ["sslvariants"],
1761 }
1762
1763 cc_library {
1764 name: "sslvariants",
1765 host_supported: true,
1766 target: {
1767 android: {
1768 system_shared_libs: [],
1769 },
1770 },
1771 }
1772 `)
1773
1774 result.CheckSnapshot("mysdk", "",
1775 checkAndroidBpContents(`
1776// This is auto-generated. DO NOT EDIT.
1777
1778cc_prebuilt_library_shared {
1779 name: "mysdk_sslvariants@current",
1780 sdk_member_name: "sslvariants",
1781 host_supported: true,
1782 installable: false,
1783 target: {
1784 android: {
1785 system_shared_libs: [],
1786 },
1787 android_arm64: {
1788 srcs: ["android/arm64/lib/sslvariants.so"],
1789 },
1790 android_arm: {
1791 srcs: ["android/arm/lib/sslvariants.so"],
1792 },
1793 linux_glibc_x86_64: {
1794 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
1795 },
1796 linux_glibc_x86: {
1797 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
1798 },
1799 },
1800}
1801
1802cc_prebuilt_library_shared {
1803 name: "sslvariants",
1804 prefer: false,
1805 host_supported: true,
1806 target: {
1807 android: {
1808 system_shared_libs: [],
1809 },
1810 android_arm64: {
1811 srcs: ["android/arm64/lib/sslvariants.so"],
1812 },
1813 android_arm: {
1814 srcs: ["android/arm/lib/sslvariants.so"],
1815 },
1816 linux_glibc_x86_64: {
1817 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
1818 },
1819 linux_glibc_x86: {
1820 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
1821 },
1822 },
1823}
1824
1825sdk_snapshot {
1826 name: "mysdk@current",
1827 host_supported: true,
1828 native_shared_libs: ["mysdk_sslvariants@current"],
1829}
1830`))
1831}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001832
1833func TestStubsLibrary(t *testing.T) {
1834 result := testSdkWithCc(t, `
1835 sdk {
1836 name: "mysdk",
1837 native_shared_libs: ["stubslib"],
1838 }
1839
1840 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01001841 name: "internaldep",
1842 }
1843
1844 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001845 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01001846 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001847 stubs: {
1848 symbol_file: "some/where/stubslib.map.txt",
1849 versions: ["1", "2", "3"],
1850 },
1851 }
1852 `)
1853
1854 result.CheckSnapshot("mysdk", "",
1855 checkAndroidBpContents(`
1856// This is auto-generated. DO NOT EDIT.
1857
1858cc_prebuilt_library_shared {
1859 name: "mysdk_stubslib@current",
1860 sdk_member_name: "stubslib",
1861 installable: false,
1862 stubs: {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001863 versions: ["3"],
1864 },
1865 arch: {
1866 arm64: {
1867 srcs: ["arm64/lib/stubslib.so"],
1868 },
1869 arm: {
1870 srcs: ["arm/lib/stubslib.so"],
1871 },
1872 },
1873}
1874
1875cc_prebuilt_library_shared {
1876 name: "stubslib",
1877 prefer: false,
1878 stubs: {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01001879 versions: ["3"],
1880 },
1881 arch: {
1882 arm64: {
1883 srcs: ["arm64/lib/stubslib.so"],
1884 },
1885 arm: {
1886 srcs: ["arm/lib/stubslib.so"],
1887 },
1888 },
1889}
1890
1891sdk_snapshot {
1892 name: "mysdk@current",
1893 native_shared_libs: ["mysdk_stubslib@current"],
1894}
1895`))
1896}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01001897
1898func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01001899 result := testSdkWithCc(t, `
1900 sdk {
1901 name: "mysdk",
1902 host_supported: true,
1903 native_shared_libs: ["stubslib"],
1904 }
1905
1906 cc_library {
1907 name: "internaldep",
1908 host_supported: true,
1909 }
1910
1911 cc_library {
1912 name: "stubslib",
1913 host_supported: true,
1914 shared_libs: ["internaldep"],
1915 stubs: {
1916 symbol_file: "some/where/stubslib.map.txt",
1917 versions: ["1", "2", "3"],
1918 },
1919 }
1920 `)
1921
1922 result.CheckSnapshot("mysdk", "",
1923 checkAndroidBpContents(`
1924// This is auto-generated. DO NOT EDIT.
1925
1926cc_prebuilt_library_shared {
1927 name: "mysdk_stubslib@current",
1928 sdk_member_name: "stubslib",
1929 host_supported: true,
1930 installable: false,
1931 stubs: {
1932 versions: ["3"],
1933 },
1934 target: {
1935 android_arm64: {
1936 srcs: ["android/arm64/lib/stubslib.so"],
1937 },
1938 android_arm: {
1939 srcs: ["android/arm/lib/stubslib.so"],
1940 },
1941 linux_glibc_x86_64: {
1942 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
1943 },
1944 linux_glibc_x86: {
1945 srcs: ["linux_glibc/x86/lib/stubslib.so"],
1946 },
1947 },
1948}
1949
1950cc_prebuilt_library_shared {
1951 name: "stubslib",
1952 prefer: false,
1953 host_supported: true,
1954 stubs: {
1955 versions: ["3"],
1956 },
1957 target: {
1958 android_arm64: {
1959 srcs: ["android/arm64/lib/stubslib.so"],
1960 },
1961 android_arm: {
1962 srcs: ["android/arm/lib/stubslib.so"],
1963 },
1964 linux_glibc_x86_64: {
1965 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
1966 },
1967 linux_glibc_x86: {
1968 srcs: ["linux_glibc/x86/lib/stubslib.so"],
1969 },
1970 },
1971}
1972
1973sdk_snapshot {
1974 name: "mysdk@current",
1975 host_supported: true,
1976 native_shared_libs: ["mysdk_stubslib@current"],
1977}
1978`))
1979}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01001980
1981func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01001982 result := testSdkWithCc(t, `
1983 sdk {
1984 name: "mysdk",
1985 host_supported: true,
1986 native_shared_libs: ["mylib"],
1987 }
1988
1989 cc_library {
1990 name: "mylib",
1991 host_supported: true,
1992 unique_host_soname: true,
1993 }
1994 `)
1995
1996 result.CheckSnapshot("mysdk", "",
1997 checkAndroidBpContents(`
1998// This is auto-generated. DO NOT EDIT.
1999
2000cc_prebuilt_library_shared {
2001 name: "mysdk_mylib@current",
2002 sdk_member_name: "mylib",
2003 host_supported: true,
2004 installable: false,
2005 unique_host_soname: true,
2006 target: {
2007 android_arm64: {
2008 srcs: ["android/arm64/lib/mylib.so"],
2009 },
2010 android_arm: {
2011 srcs: ["android/arm/lib/mylib.so"],
2012 },
2013 linux_glibc_x86_64: {
2014 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2015 },
2016 linux_glibc_x86: {
2017 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2018 },
2019 },
2020}
2021
2022cc_prebuilt_library_shared {
2023 name: "mylib",
2024 prefer: false,
2025 host_supported: true,
2026 unique_host_soname: true,
2027 target: {
2028 android_arm64: {
2029 srcs: ["android/arm64/lib/mylib.so"],
2030 },
2031 android_arm: {
2032 srcs: ["android/arm/lib/mylib.so"],
2033 },
2034 linux_glibc_x86_64: {
2035 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2036 },
2037 linux_glibc_x86: {
2038 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2039 },
2040 },
2041}
2042
2043sdk_snapshot {
2044 name: "mysdk@current",
2045 host_supported: true,
2046 native_shared_libs: ["mysdk_mylib@current"],
2047}
2048`),
2049 checkAllCopyRules(`
2050.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2051.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2052.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2053.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2054`),
2055 )
2056}