blob: 9501d88d7c5051bf51ea7ec73389e0219be6f303 [file] [log] [blame]
Paul Duffina80fdec2019-12-03 15:25:00 +00001// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package sdk
16
17import (
18 "testing"
19
Paul Duffin1356d8c2020-02-25 19:26:33 +000020 "android/soong/android"
Paul Duffina80fdec2019-12-03 15:25:00 +000021 "android/soong/cc"
22)
23
Martin Stjernholm7feceb22020-07-11 04:33:29 +010024var ccTestFs = map[string][]byte{
25 "Test.cpp": nil,
26 "include/Test.h": nil,
27 "include-android/AndroidTest.h": nil,
28 "include-host/HostTest.h": nil,
29 "arm64/include/Arm64Test.h": nil,
30 "libfoo.so": nil,
31 "aidl/foo/bar/Test.aidl": nil,
32 "some/where/stubslib.map.txt": nil,
33}
34
Paul Duffind835daa2019-11-30 17:49:09 +000035func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
36 t.Helper()
Martin Stjernholm7feceb22020-07-11 04:33:29 +010037 return testSdkWithFs(t, bp, ccTestFs)
Paul Duffind835daa2019-11-30 17:49:09 +000038}
39
Paul Duffina80fdec2019-12-03 15:25:00 +000040// Contains tests for SDK members provided by the cc package.
41
Martin Stjernholmcaa47d72020-07-11 04:52:24 +010042func TestSingleDeviceOsAssumption(t *testing.T) {
43 // Mock a module with DeviceSupported() == true.
44 s := &sdk{}
45 android.InitAndroidArchModule(s, android.DeviceSupported, android.MultilibCommon)
46
47 osTypes := s.getPossibleOsTypes()
48 if len(osTypes) != 1 {
49 // The snapshot generation assumes there is a single device OS. If more are
50 // added it might need to disable them by default, like it does for host
51 // OS'es.
52 t.Errorf("expected a single device OS, got %v", osTypes)
53 }
54}
55
Paul Duffina80fdec2019-12-03 15:25:00 +000056func TestSdkIsCompileMultilibBoth(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +000057 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000058 sdk {
59 name: "mysdk",
60 native_shared_libs: ["sdkmember"],
61 }
62
63 cc_library_shared {
64 name: "sdkmember",
65 srcs: ["Test.cpp"],
Paul Duffina80fdec2019-12-03 15:25:00 +000066 stl: "none",
67 }
68 `)
69
Colin Cross7113d202019-11-20 16:39:12 -080070 armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile()
71 arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile()
Paul Duffina80fdec2019-12-03 15:25:00 +000072
73 var inputs []string
Paul Duffin1356d8c2020-02-25 19:26:33 +000074 buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests()
Paul Duffina80fdec2019-12-03 15:25:00 +000075 for _, bp := range buildParams {
76 if bp.Input != nil {
77 inputs = append(inputs, bp.Input.String())
78 }
79 }
80
81 // ensure that both 32/64 outputs are inputs of the sdk snapshot
82 ensureListContains(t, inputs, armOutput.String())
83 ensureListContains(t, inputs, arm64Output.String())
84}
85
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010086func TestSdkCompileMultilibOverride(t *testing.T) {
87 result := testSdkWithCc(t, `
88 sdk {
89 name: "mysdk",
Martin Stjernholm89238f42020-07-10 00:14:03 +010090 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010091 native_shared_libs: ["sdkmember"],
92 compile_multilib: "64",
93 }
94
95 cc_library_shared {
96 name: "sdkmember",
Martin Stjernholm89238f42020-07-10 00:14:03 +010097 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010098 srcs: ["Test.cpp"],
99 stl: "none",
100 compile_multilib: "64",
101 }
102 `)
103
104 result.CheckSnapshot("mysdk", "",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100105 checkAndroidBpContents(`
106// This is auto-generated. DO NOT EDIT.
107
108cc_prebuilt_library_shared {
109 name: "mysdk_sdkmember@current",
110 sdk_member_name: "sdkmember",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100111 host_supported: true,
112 installable: false,
113 stl: "none",
114 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100115 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100116 host: {
117 enabled: false,
118 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100119 android_arm64: {
120 srcs: ["android/arm64/lib/sdkmember.so"],
121 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100122 linux_glibc: {
123 enabled: true,
124 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100125 linux_glibc_x86_64: {
126 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100127 },
128 },
129}
130
131cc_prebuilt_library_shared {
132 name: "sdkmember",
133 prefer: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +0100134 host_supported: true,
135 stl: "none",
136 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100137 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100138 host: {
139 enabled: false,
140 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100141 android_arm64: {
142 srcs: ["android/arm64/lib/sdkmember.so"],
143 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100144 linux_glibc: {
145 enabled: true,
146 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100147 linux_glibc_x86_64: {
148 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100149 },
150 },
151}
152
153sdk_snapshot {
154 name: "mysdk@current",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100155 host_supported: true,
156 native_shared_libs: ["mysdk_sdkmember@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100157 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100158 target: {
159 host: {
160 enabled: false,
161 },
162 linux_glibc: {
163 enabled: true,
164 },
165 },
Martin Stjernholm89238f42020-07-10 00:14:03 +0100166}
167`),
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100168 checkAllCopyRules(`
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100169.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
170.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100171`))
172}
173
Paul Duffina80fdec2019-12-03 15:25:00 +0000174func TestBasicSdkWithCc(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000175 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000176 sdk {
177 name: "mysdk",
178 native_shared_libs: ["sdkmember"],
179 }
180
Paul Duffina0843f62019-12-13 19:50:38 +0000181 cc_library_shared {
182 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -0800183 system_shared_libs: [],
Martin Stjernholmcc776012020-07-07 03:22:21 +0100184 stl: "none",
185 apex_available: ["mysdkapex"],
Paul Duffina0843f62019-12-13 19:50:38 +0000186 }
187
Paul Duffina80fdec2019-12-03 15:25:00 +0000188 sdk_snapshot {
189 name: "mysdk@1",
190 native_shared_libs: ["sdkmember_mysdk_1"],
191 }
192
193 sdk_snapshot {
194 name: "mysdk@2",
195 native_shared_libs: ["sdkmember_mysdk_2"],
196 }
197
198 cc_prebuilt_library_shared {
199 name: "sdkmember",
200 srcs: ["libfoo.so"],
201 prefer: false,
202 system_shared_libs: [],
203 stl: "none",
204 }
205
206 cc_prebuilt_library_shared {
207 name: "sdkmember_mysdk_1",
208 sdk_member_name: "sdkmember",
209 srcs: ["libfoo.so"],
210 system_shared_libs: [],
211 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000212 // TODO: remove //apex_available:platform
213 apex_available: [
214 "//apex_available:platform",
215 "myapex",
216 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000217 }
218
219 cc_prebuilt_library_shared {
220 name: "sdkmember_mysdk_2",
221 sdk_member_name: "sdkmember",
222 srcs: ["libfoo.so"],
223 system_shared_libs: [],
224 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000225 // TODO: remove //apex_available:platform
226 apex_available: [
227 "//apex_available:platform",
228 "myapex2",
229 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000230 }
231
232 cc_library_shared {
233 name: "mycpplib",
234 srcs: ["Test.cpp"],
235 shared_libs: ["sdkmember"],
236 system_shared_libs: [],
237 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000238 apex_available: [
239 "myapex",
240 "myapex2",
241 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000242 }
243
244 apex {
245 name: "myapex",
246 native_shared_libs: ["mycpplib"],
247 uses_sdks: ["mysdk@1"],
248 key: "myapex.key",
249 certificate: ":myapex.cert",
250 }
251
252 apex {
253 name: "myapex2",
254 native_shared_libs: ["mycpplib"],
255 uses_sdks: ["mysdk@2"],
256 key: "myapex.key",
257 certificate: ":myapex.cert",
258 }
Martin Stjernholmcc776012020-07-07 03:22:21 +0100259
260 apex {
261 name: "mysdkapex",
262 native_shared_libs: ["sdkmember"],
263 key: "myapex.key",
264 certificate: ":myapex.cert",
265 }
Paul Duffina80fdec2019-12-03 15:25:00 +0000266 `)
267
Colin Cross7113d202019-11-20 16:39:12 -0800268 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_myapex").Rule("toc").Output
269 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_myapex2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000270
Colin Cross7113d202019-11-20 16:39:12 -0800271 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex")
272 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000273
274 // Depending on the uses_sdks value, different libs are linked
275 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
276 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
277}
278
Paul Duffina0843f62019-12-13 19:50:38 +0000279// Make sure the sdk can use host specific cc libraries static/shared and both.
280func TestHostSdkWithCc(t *testing.T) {
281 testSdkWithCc(t, `
282 sdk {
283 name: "mysdk",
284 device_supported: false,
285 host_supported: true,
286 native_shared_libs: ["sdkshared"],
287 native_static_libs: ["sdkstatic"],
288 }
289
290 cc_library_host_shared {
291 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000292 stl: "none",
293 }
294
295 cc_library_host_static {
296 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000297 stl: "none",
298 }
299 `)
300}
301
302// Make sure the sdk can use cc libraries static/shared and both.
303func TestSdkWithCc(t *testing.T) {
304 testSdkWithCc(t, `
305 sdk {
306 name: "mysdk",
307 native_shared_libs: ["sdkshared", "sdkboth1"],
308 native_static_libs: ["sdkstatic", "sdkboth2"],
309 }
310
311 cc_library_shared {
312 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000313 stl: "none",
314 }
315
316 cc_library_static {
317 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000318 stl: "none",
319 }
320
321 cc_library {
322 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000323 stl: "none",
324 }
325
326 cc_library {
327 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000328 stl: "none",
329 }
330 `)
331}
332
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000333func TestSnapshotWithObject(t *testing.T) {
334 result := testSdkWithCc(t, `
335 sdk {
336 name: "mysdk",
337 native_objects: ["crtobj"],
338 }
339
340 cc_object {
341 name: "crtobj",
342 stl: "none",
343 }
344 `)
345
346 result.CheckSnapshot("mysdk", "",
347 checkAndroidBpContents(`
348// This is auto-generated. DO NOT EDIT.
349
350cc_prebuilt_object {
351 name: "mysdk_crtobj@current",
352 sdk_member_name: "crtobj",
353 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100354 compile_multilib: "both",
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000355 arch: {
356 arm64: {
357 srcs: ["arm64/lib/crtobj.o"],
358 },
359 arm: {
360 srcs: ["arm/lib/crtobj.o"],
361 },
362 },
363}
364
365cc_prebuilt_object {
366 name: "crtobj",
367 prefer: false,
368 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100369 compile_multilib: "both",
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000370 arch: {
371 arm64: {
372 srcs: ["arm64/lib/crtobj.o"],
373 },
374 arm: {
375 srcs: ["arm/lib/crtobj.o"],
376 },
377 },
378}
379
380sdk_snapshot {
381 name: "mysdk@current",
382 native_objects: ["mysdk_crtobj@current"],
383}
384`),
385 checkAllCopyRules(`
386.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
387.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
388`),
389 )
390}
391
Paul Duffinc62a5102019-12-11 18:34:15 +0000392func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
393 result := testSdkWithCc(t, `
394 sdk {
395 name: "mysdk",
396 native_shared_libs: ["mynativelib1", "mynativelib2"],
397 }
398
399 cc_library_shared {
400 name: "mynativelib1",
401 srcs: [
402 "Test.cpp",
403 ],
404 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000405 stl: "none",
406 }
407
408 cc_library_shared {
409 name: "mynativelib2",
410 srcs: [
411 "Test.cpp",
412 ],
413 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000414 stl: "none",
415 }
416 `)
417
Paul Duffin1356d8c2020-02-25 19:26:33 +0000418 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000419 checkAllCopyRules(`
420include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800421.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
422.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
423.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
424.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000425`),
426 )
427}
428
Paul Duffina7cd8c82019-12-11 20:00:57 +0000429// Verify that when the shared library has some common and some arch specific properties that the generated
430// snapshot is optimized properly.
431func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
432 result := testSdkWithCc(t, `
433 sdk {
434 name: "mysdk",
435 native_shared_libs: ["mynativelib"],
436 }
437
438 cc_library_shared {
439 name: "mynativelib",
440 srcs: [
441 "Test.cpp",
442 "aidl/foo/bar/Test.aidl",
443 ],
444 export_include_dirs: ["include"],
445 arch: {
446 arm64: {
447 export_system_include_dirs: ["arm64/include"],
448 },
449 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000450 stl: "none",
451 }
452 `)
453
Paul Duffin1356d8c2020-02-25 19:26:33 +0000454 result.CheckSnapshot("mysdk", "",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000455 checkAndroidBpContents(`
456// This is auto-generated. DO NOT EDIT.
457
458cc_prebuilt_library_shared {
459 name: "mysdk_mynativelib@current",
460 sdk_member_name: "mynativelib",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000461 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000462 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100463 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000464 export_include_dirs: ["include/include"],
465 arch: {
466 arm64: {
467 srcs: ["arm64/lib/mynativelib.so"],
468 export_system_include_dirs: ["arm64/include/arm64/include"],
469 },
470 arm: {
471 srcs: ["arm/lib/mynativelib.so"],
472 },
473 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000474}
475
476cc_prebuilt_library_shared {
477 name: "mynativelib",
478 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000479 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100480 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000481 export_include_dirs: ["include/include"],
482 arch: {
483 arm64: {
484 srcs: ["arm64/lib/mynativelib.so"],
485 export_system_include_dirs: ["arm64/include/arm64/include"],
486 },
487 arm: {
488 srcs: ["arm/lib/mynativelib.so"],
489 },
490 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000491}
492
493sdk_snapshot {
494 name: "mysdk@current",
495 native_shared_libs: ["mysdk_mynativelib@current"],
496}
497`),
498 checkAllCopyRules(`
499include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800500.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000501arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800502.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000503 )
504}
505
Paul Duffin25ce04b2020-01-16 11:47:25 +0000506func TestSnapshotWithCcBinary(t *testing.T) {
507 result := testSdkWithCc(t, `
508 module_exports {
509 name: "mymodule_exports",
510 native_binaries: ["mynativebinary"],
511 }
512
513 cc_binary {
514 name: "mynativebinary",
515 srcs: [
516 "Test.cpp",
517 ],
518 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000519 }
520 `)
521
Paul Duffin1356d8c2020-02-25 19:26:33 +0000522 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000523 checkAndroidBpContents(`
524// This is auto-generated. DO NOT EDIT.
525
526cc_prebuilt_binary {
527 name: "mymodule_exports_mynativebinary@current",
528 sdk_member_name: "mynativebinary",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000529 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000530 compile_multilib: "both",
531 arch: {
532 arm64: {
533 srcs: ["arm64/bin/mynativebinary"],
534 },
535 arm: {
536 srcs: ["arm/bin/mynativebinary"],
537 },
538 },
539}
540
541cc_prebuilt_binary {
542 name: "mynativebinary",
543 prefer: false,
544 compile_multilib: "both",
545 arch: {
546 arm64: {
547 srcs: ["arm64/bin/mynativebinary"],
548 },
549 arm: {
550 srcs: ["arm/bin/mynativebinary"],
551 },
552 },
553}
554
555module_exports_snapshot {
556 name: "mymodule_exports@current",
557 native_binaries: ["mymodule_exports_mynativebinary@current"],
558}
559`),
560 checkAllCopyRules(`
561.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
562.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
563`),
564 )
565}
566
Paul Duffina04c1072020-03-02 10:16:35 +0000567func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000568 result := testSdkWithCc(t, `
569 module_exports {
570 name: "myexports",
571 device_supported: false,
572 host_supported: true,
573 native_binaries: ["mynativebinary"],
574 target: {
575 windows: {
576 enabled: true,
577 },
578 },
579 }
580
581 cc_binary {
582 name: "mynativebinary",
583 device_supported: false,
584 host_supported: true,
585 srcs: [
586 "Test.cpp",
587 ],
588 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000589 stl: "none",
590 target: {
591 windows: {
592 enabled: true,
593 },
594 },
595 }
596 `)
597
598 result.CheckSnapshot("myexports", "",
599 checkAndroidBpContents(`
600// This is auto-generated. DO NOT EDIT.
601
602cc_prebuilt_binary {
603 name: "myexports_mynativebinary@current",
604 sdk_member_name: "mynativebinary",
605 device_supported: false,
606 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000607 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100608 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000609 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100610 host: {
611 enabled: false,
612 },
Paul Duffina04c1072020-03-02 10:16:35 +0000613 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100614 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000615 compile_multilib: "both",
616 },
617 linux_glibc_x86_64: {
618 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
619 },
620 linux_glibc_x86: {
621 srcs: ["linux_glibc/x86/bin/mynativebinary"],
622 },
623 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100624 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000625 compile_multilib: "64",
626 },
627 windows_x86_64: {
628 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
629 },
630 },
631}
632
633cc_prebuilt_binary {
634 name: "mynativebinary",
635 prefer: false,
636 device_supported: false,
637 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100638 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000639 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100640 host: {
641 enabled: false,
642 },
Paul Duffina04c1072020-03-02 10:16:35 +0000643 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100644 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000645 compile_multilib: "both",
646 },
647 linux_glibc_x86_64: {
648 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
649 },
650 linux_glibc_x86: {
651 srcs: ["linux_glibc/x86/bin/mynativebinary"],
652 },
653 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100654 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000655 compile_multilib: "64",
656 },
657 windows_x86_64: {
658 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
659 },
660 },
661}
662
663module_exports_snapshot {
664 name: "myexports@current",
665 device_supported: false,
666 host_supported: true,
667 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000668 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100669 host: {
670 enabled: false,
671 },
672 linux_glibc: {
673 enabled: true,
674 },
Paul Duffin6a7e9532020-03-20 17:50:07 +0000675 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100676 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000677 compile_multilib: "64",
678 },
679 },
Paul Duffina04c1072020-03-02 10:16:35 +0000680}
681`),
682 checkAllCopyRules(`
683.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
684.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
685.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
686`),
687 )
688}
689
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100690func TestSnapshotWithSingleHostOsType(t *testing.T) {
691 ctx, config := testSdkContext(`
692 cc_defaults {
693 name: "mydefaults",
694 device_supported: false,
695 host_supported: true,
696 compile_multilib: "64",
697 target: {
698 host: {
699 enabled: false,
700 },
701 linux_bionic: {
702 enabled: true,
703 },
704 },
705 }
706
707 module_exports {
708 name: "myexports",
709 defaults: ["mydefaults"],
710 native_shared_libs: ["mynativelib"],
711 native_binaries: ["mynativebinary"],
712 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
713 }
714
715 cc_library {
716 name: "mynativelib",
717 defaults: ["mydefaults"],
718 srcs: [
719 "Test.cpp",
720 ],
721 stl: "none",
722 }
723
724 cc_binary {
725 name: "mynativebinary",
726 defaults: ["mydefaults"],
727 srcs: [
728 "Test.cpp",
729 ],
730 stl: "none",
731 }
732 `, ccTestFs, []android.OsType{android.LinuxBionic})
733
734 result := runTests(t, ctx, config)
735
736 result.CheckSnapshot("myexports", "",
737 checkAndroidBpContents(`
738// This is auto-generated. DO NOT EDIT.
739
740cc_prebuilt_binary {
741 name: "myexports_mynativebinary@current",
742 sdk_member_name: "mynativebinary",
743 device_supported: false,
744 host_supported: true,
745 installable: false,
746 stl: "none",
747 compile_multilib: "64",
748 target: {
749 host: {
750 enabled: false,
751 },
752 linux_bionic: {
753 enabled: true,
754 },
755 linux_bionic_x86_64: {
756 srcs: ["x86_64/bin/mynativebinary"],
757 },
758 },
759}
760
761cc_prebuilt_binary {
762 name: "mynativebinary",
763 prefer: false,
764 device_supported: false,
765 host_supported: true,
766 stl: "none",
767 compile_multilib: "64",
768 target: {
769 host: {
770 enabled: false,
771 },
772 linux_bionic: {
773 enabled: true,
774 },
775 linux_bionic_x86_64: {
776 srcs: ["x86_64/bin/mynativebinary"],
777 },
778 },
779}
780
781cc_prebuilt_library_shared {
782 name: "myexports_mynativelib@current",
783 sdk_member_name: "mynativelib",
784 device_supported: false,
785 host_supported: true,
786 installable: false,
787 stl: "none",
788 compile_multilib: "64",
789 target: {
790 host: {
791 enabled: false,
792 },
793 linux_bionic: {
794 enabled: true,
795 },
796 linux_bionic_x86_64: {
797 srcs: ["x86_64/lib/mynativelib.so"],
798 },
799 },
800}
801
802cc_prebuilt_library_shared {
803 name: "mynativelib",
804 prefer: false,
805 device_supported: false,
806 host_supported: true,
807 stl: "none",
808 compile_multilib: "64",
809 target: {
810 host: {
811 enabled: false,
812 },
813 linux_bionic: {
814 enabled: true,
815 },
816 linux_bionic_x86_64: {
817 srcs: ["x86_64/lib/mynativelib.so"],
818 },
819 },
820}
821
822module_exports_snapshot {
823 name: "myexports@current",
824 device_supported: false,
825 host_supported: true,
826 native_binaries: ["myexports_mynativebinary@current"],
827 native_shared_libs: ["myexports_mynativelib@current"],
828 compile_multilib: "64",
829 target: {
830 host: {
831 enabled: false,
832 },
833 linux_bionic: {
834 enabled: true,
835 },
836 },
837}
838`),
839 checkAllCopyRules(`
840.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
841.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
842`),
843 )
844}
845
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100846// Test that we support the necessary flags for the linker binary, which is
847// special in several ways.
848func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100849 result := testSdkWithCc(t, `
850 module_exports {
851 name: "mymodule_exports",
852 host_supported: true,
853 device_supported: false,
854 native_binaries: ["linker"],
855 }
856
857 cc_binary {
858 name: "linker",
859 host_supported: true,
860 static_executable: true,
861 nocrt: true,
862 stl: "none",
863 srcs: [
864 "Test.cpp",
865 ],
866 compile_multilib: "both",
867 }
868 `)
869
870 result.CheckSnapshot("mymodule_exports", "",
871 checkAndroidBpContents(`
872// This is auto-generated. DO NOT EDIT.
873
874cc_prebuilt_binary {
875 name: "mymodule_exports_linker@current",
876 sdk_member_name: "linker",
877 device_supported: false,
878 host_supported: true,
879 installable: false,
880 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100881 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100882 static_executable: true,
883 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100884 target: {
885 host: {
886 enabled: false,
887 },
888 linux_glibc: {
889 enabled: true,
890 },
891 linux_glibc_x86_64: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100892 srcs: ["x86_64/bin/linker"],
893 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100894 linux_glibc_x86: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100895 srcs: ["x86/bin/linker"],
896 },
897 },
898}
899
900cc_prebuilt_binary {
901 name: "linker",
902 prefer: false,
903 device_supported: false,
904 host_supported: true,
905 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100906 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100907 static_executable: true,
908 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100909 target: {
910 host: {
911 enabled: false,
912 },
913 linux_glibc: {
914 enabled: true,
915 },
916 linux_glibc_x86_64: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100917 srcs: ["x86_64/bin/linker"],
918 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100919 linux_glibc_x86: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100920 srcs: ["x86/bin/linker"],
921 },
922 },
923}
924
925module_exports_snapshot {
926 name: "mymodule_exports@current",
927 device_supported: false,
928 host_supported: true,
929 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100930 target: {
931 host: {
932 enabled: false,
933 },
934 linux_glibc: {
935 enabled: true,
936 },
937 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100938}
939`),
940 checkAllCopyRules(`
941.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
942.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
943`),
944 )
945}
946
Paul Duffin9ab556f2019-12-11 18:42:17 +0000947func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000948 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000949 sdk {
950 name: "mysdk",
951 native_shared_libs: ["mynativelib"],
952 }
953
954 cc_library_shared {
955 name: "mynativelib",
956 srcs: [
957 "Test.cpp",
958 "aidl/foo/bar/Test.aidl",
959 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +0000960 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000961 export_include_dirs: ["include"],
962 aidl: {
963 export_aidl_headers: true,
964 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000965 stl: "none",
966 }
967 `)
968
Paul Duffin1356d8c2020-02-25 19:26:33 +0000969 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000970 checkAndroidBpContents(`
971// This is auto-generated. DO NOT EDIT.
972
973cc_prebuilt_library_shared {
974 name: "mysdk_mynativelib@current",
975 sdk_member_name: "mynativelib",
Paul Duffinbefa4b92020-03-04 14:22:45 +0000976 apex_available: [
977 "apex1",
978 "apex2",
979 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000980 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000981 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100982 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000983 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000984 arch: {
985 arm64: {
986 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000987 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000988 },
989 arm: {
990 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000991 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000992 },
993 },
Paul Duffina80fdec2019-12-03 15:25:00 +0000994}
995
996cc_prebuilt_library_shared {
997 name: "mynativelib",
998 prefer: false,
Paul Duffinbefa4b92020-03-04 14:22:45 +0000999 apex_available: [
1000 "apex1",
1001 "apex2",
1002 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001003 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001004 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001005 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001006 arch: {
1007 arm64: {
1008 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001009 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001010 },
1011 arm: {
1012 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001013 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001014 },
1015 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001016}
1017
1018sdk_snapshot {
1019 name: "mysdk@current",
1020 native_shared_libs: ["mysdk_mynativelib@current"],
1021}
1022`),
1023 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001024include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001025.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1026.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1027.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1028.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1029.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1030.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1031.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1032.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 +00001033`),
1034 )
1035}
1036
Paul Duffin13f02712020-03-06 12:30:43 +00001037func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1038 result := testSdkWithCc(t, `
1039 sdk {
1040 name: "mysdk",
1041 native_shared_libs: [
1042 "mynativelib",
1043 "myothernativelib",
1044 "mysystemnativelib",
1045 ],
1046 }
1047
1048 cc_library {
1049 name: "mysystemnativelib",
1050 srcs: [
1051 "Test.cpp",
1052 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001053 stl: "none",
1054 }
1055
1056 cc_library_shared {
1057 name: "myothernativelib",
1058 srcs: [
1059 "Test.cpp",
1060 ],
1061 system_shared_libs: [
1062 // A reference to a library that is not an sdk member. Uses libm as that
1063 // is in the default set of modules available to this test and so is available
1064 // both here and also when the generated Android.bp file is tested in
1065 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1066 // handles references to modules that are not sdk members.
1067 "libm",
1068 ],
1069 stl: "none",
1070 }
1071
1072 cc_library {
1073 name: "mynativelib",
1074 srcs: [
1075 "Test.cpp",
1076 ],
1077 shared_libs: [
1078 // A reference to another sdk member.
1079 "myothernativelib",
1080 ],
1081 target: {
1082 android: {
1083 shared: {
1084 shared_libs: [
1085 // A reference to a library that is not an sdk member. The libc library
1086 // is used here to check that the shared_libs property is handled correctly
1087 // in a similar way to how libm is used to check system_shared_libs above.
1088 "libc",
1089 ],
1090 },
1091 },
1092 },
Paul Duffin13f02712020-03-06 12:30:43 +00001093 stl: "none",
1094 }
1095 `)
1096
1097 result.CheckSnapshot("mysdk", "",
1098 checkAndroidBpContents(`
1099// This is auto-generated. DO NOT EDIT.
1100
1101cc_prebuilt_library_shared {
1102 name: "mysdk_mynativelib@current",
1103 sdk_member_name: "mynativelib",
1104 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001105 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001106 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001107 shared_libs: [
1108 "mysdk_myothernativelib@current",
1109 "libc",
1110 ],
1111 arch: {
1112 arm64: {
1113 srcs: ["arm64/lib/mynativelib.so"],
1114 },
1115 arm: {
1116 srcs: ["arm/lib/mynativelib.so"],
1117 },
1118 },
Paul Duffin13f02712020-03-06 12:30:43 +00001119}
1120
1121cc_prebuilt_library_shared {
1122 name: "mynativelib",
1123 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001124 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001125 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001126 shared_libs: [
1127 "myothernativelib",
1128 "libc",
1129 ],
1130 arch: {
1131 arm64: {
1132 srcs: ["arm64/lib/mynativelib.so"],
1133 },
1134 arm: {
1135 srcs: ["arm/lib/mynativelib.so"],
1136 },
1137 },
Paul Duffin13f02712020-03-06 12:30:43 +00001138}
1139
1140cc_prebuilt_library_shared {
1141 name: "mysdk_myothernativelib@current",
1142 sdk_member_name: "myothernativelib",
1143 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001144 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001145 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001146 system_shared_libs: ["libm"],
1147 arch: {
1148 arm64: {
1149 srcs: ["arm64/lib/myothernativelib.so"],
1150 },
1151 arm: {
1152 srcs: ["arm/lib/myothernativelib.so"],
1153 },
1154 },
Paul Duffin13f02712020-03-06 12:30:43 +00001155}
1156
1157cc_prebuilt_library_shared {
1158 name: "myothernativelib",
1159 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001160 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001161 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001162 system_shared_libs: ["libm"],
1163 arch: {
1164 arm64: {
1165 srcs: ["arm64/lib/myothernativelib.so"],
1166 },
1167 arm: {
1168 srcs: ["arm/lib/myothernativelib.so"],
1169 },
1170 },
Paul Duffin13f02712020-03-06 12:30:43 +00001171}
1172
1173cc_prebuilt_library_shared {
1174 name: "mysdk_mysystemnativelib@current",
1175 sdk_member_name: "mysystemnativelib",
1176 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001177 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001178 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001179 arch: {
1180 arm64: {
1181 srcs: ["arm64/lib/mysystemnativelib.so"],
1182 },
1183 arm: {
1184 srcs: ["arm/lib/mysystemnativelib.so"],
1185 },
1186 },
Paul Duffin13f02712020-03-06 12:30:43 +00001187}
1188
1189cc_prebuilt_library_shared {
1190 name: "mysystemnativelib",
1191 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001192 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001193 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001194 arch: {
1195 arm64: {
1196 srcs: ["arm64/lib/mysystemnativelib.so"],
1197 },
1198 arm: {
1199 srcs: ["arm/lib/mysystemnativelib.so"],
1200 },
1201 },
Paul Duffin13f02712020-03-06 12:30:43 +00001202}
1203
1204sdk_snapshot {
1205 name: "mysdk@current",
1206 native_shared_libs: [
1207 "mysdk_mynativelib@current",
1208 "mysdk_myothernativelib@current",
1209 "mysdk_mysystemnativelib@current",
1210 ],
1211}
1212`),
1213 checkAllCopyRules(`
1214.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1215.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1216.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1217.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1218.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1219.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1220`),
1221 )
1222}
1223
Paul Duffin9ab556f2019-12-11 18:42:17 +00001224func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001225 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001226 sdk {
1227 name: "mysdk",
1228 device_supported: false,
1229 host_supported: true,
1230 native_shared_libs: ["mynativelib"],
1231 }
1232
1233 cc_library_shared {
1234 name: "mynativelib",
1235 device_supported: false,
1236 host_supported: true,
1237 srcs: [
1238 "Test.cpp",
1239 "aidl/foo/bar/Test.aidl",
1240 ],
1241 export_include_dirs: ["include"],
1242 aidl: {
1243 export_aidl_headers: true,
1244 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001245 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001246 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001247 }
1248 `)
1249
Paul Duffin1356d8c2020-02-25 19:26:33 +00001250 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001251 checkAndroidBpContents(`
1252// This is auto-generated. DO NOT EDIT.
1253
1254cc_prebuilt_library_shared {
1255 name: "mysdk_mynativelib@current",
1256 sdk_member_name: "mynativelib",
1257 device_supported: false,
1258 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001259 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001260 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001261 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001262 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001263 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001264 target: {
1265 host: {
1266 enabled: false,
1267 },
1268 linux_glibc: {
1269 enabled: true,
1270 },
1271 linux_glibc_x86_64: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001272 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001273 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001274 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001275 linux_glibc_x86: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001276 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001277 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001278 },
1279 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001280}
1281
1282cc_prebuilt_library_shared {
1283 name: "mynativelib",
1284 prefer: false,
1285 device_supported: false,
1286 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001287 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001288 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001289 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001290 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001291 target: {
1292 host: {
1293 enabled: false,
1294 },
1295 linux_glibc: {
1296 enabled: true,
1297 },
1298 linux_glibc_x86_64: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001299 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001300 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001301 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001302 linux_glibc_x86: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001303 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001304 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001305 },
1306 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001307}
1308
1309sdk_snapshot {
1310 name: "mysdk@current",
1311 device_supported: false,
1312 host_supported: true,
1313 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001314 target: {
1315 host: {
1316 enabled: false,
1317 },
1318 linux_glibc: {
1319 enabled: true,
1320 },
1321 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001322}
1323`),
1324 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001325include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001326.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001327.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1328.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1329.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1330.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001331.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1332.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1333.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1334`),
1335 )
1336}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001337
Paul Duffina04c1072020-03-02 10:16:35 +00001338func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001339 result := testSdkWithCc(t, `
1340 sdk {
1341 name: "mysdk",
1342 device_supported: false,
1343 host_supported: true,
1344 native_shared_libs: ["mynativelib"],
1345 target: {
1346 windows: {
1347 enabled: true,
1348 },
1349 },
1350 }
1351
1352 cc_library_shared {
1353 name: "mynativelib",
1354 device_supported: false,
1355 host_supported: true,
1356 srcs: [
1357 "Test.cpp",
1358 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001359 stl: "none",
1360 target: {
1361 windows: {
1362 enabled: true,
1363 },
1364 },
1365 }
1366 `)
1367
1368 result.CheckSnapshot("mysdk", "",
1369 checkAndroidBpContents(`
1370// This is auto-generated. DO NOT EDIT.
1371
1372cc_prebuilt_library_shared {
1373 name: "mysdk_mynativelib@current",
1374 sdk_member_name: "mynativelib",
1375 device_supported: false,
1376 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001377 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001378 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001379 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001380 host: {
1381 enabled: false,
1382 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001383 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001384 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001385 compile_multilib: "both",
1386 },
Paul Duffina04c1072020-03-02 10:16:35 +00001387 linux_glibc_x86_64: {
1388 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1389 },
1390 linux_glibc_x86: {
1391 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1392 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001393 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001394 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001395 compile_multilib: "64",
1396 },
Paul Duffina04c1072020-03-02 10:16:35 +00001397 windows_x86_64: {
1398 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1399 },
1400 },
Paul Duffina04c1072020-03-02 10:16:35 +00001401}
1402
1403cc_prebuilt_library_shared {
1404 name: "mynativelib",
1405 prefer: false,
1406 device_supported: false,
1407 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001408 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001409 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001410 host: {
1411 enabled: false,
1412 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001413 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001414 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001415 compile_multilib: "both",
1416 },
Paul Duffina04c1072020-03-02 10:16:35 +00001417 linux_glibc_x86_64: {
1418 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1419 },
1420 linux_glibc_x86: {
1421 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1422 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001423 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001424 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001425 compile_multilib: "64",
1426 },
Paul Duffina04c1072020-03-02 10:16:35 +00001427 windows_x86_64: {
1428 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1429 },
1430 },
Paul Duffina04c1072020-03-02 10:16:35 +00001431}
1432
1433sdk_snapshot {
1434 name: "mysdk@current",
1435 device_supported: false,
1436 host_supported: true,
1437 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001438 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001439 host: {
1440 enabled: false,
1441 },
1442 linux_glibc: {
1443 enabled: true,
1444 },
Paul Duffin6a7e9532020-03-20 17:50:07 +00001445 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001446 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001447 compile_multilib: "64",
1448 },
1449 },
Paul Duffina04c1072020-03-02 10:16:35 +00001450}
1451`),
1452 checkAllCopyRules(`
1453.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1454.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1455.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1456`),
1457 )
1458}
1459
Paul Duffin9ab556f2019-12-11 18:42:17 +00001460func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1461 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001462 module_exports {
1463 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001464 native_static_libs: ["mynativelib"],
1465 }
1466
1467 cc_library_static {
1468 name: "mynativelib",
1469 srcs: [
1470 "Test.cpp",
1471 "aidl/foo/bar/Test.aidl",
1472 ],
1473 export_include_dirs: ["include"],
1474 aidl: {
1475 export_aidl_headers: true,
1476 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001477 stl: "none",
1478 }
1479 `)
1480
Paul Duffin1356d8c2020-02-25 19:26:33 +00001481 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001482 checkAndroidBpContents(`
1483// This is auto-generated. DO NOT EDIT.
1484
1485cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001486 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001487 sdk_member_name: "mynativelib",
Paul Duffin0cb37b92020-03-04 14:52:46 +00001488 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001489 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001490 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001491 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001492 arch: {
1493 arm64: {
1494 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001495 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001496 },
1497 arm: {
1498 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001499 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001500 },
1501 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001502}
1503
1504cc_prebuilt_library_static {
1505 name: "mynativelib",
1506 prefer: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001507 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001508 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001509 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001510 arch: {
1511 arm64: {
1512 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001513 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001514 },
1515 arm: {
1516 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001517 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001518 },
1519 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001520}
1521
Paul Duffine6029182019-12-16 17:43:48 +00001522module_exports_snapshot {
1523 name: "myexports@current",
1524 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001525}
1526`),
1527 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001528include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001529.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1530.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1531.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1532.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1533.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1534.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1535.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1536.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 +00001537`),
1538 )
1539}
1540
1541func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001542 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001543 module_exports {
1544 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001545 device_supported: false,
1546 host_supported: true,
1547 native_static_libs: ["mynativelib"],
1548 }
1549
1550 cc_library_static {
1551 name: "mynativelib",
1552 device_supported: false,
1553 host_supported: true,
1554 srcs: [
1555 "Test.cpp",
1556 "aidl/foo/bar/Test.aidl",
1557 ],
1558 export_include_dirs: ["include"],
1559 aidl: {
1560 export_aidl_headers: true,
1561 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001562 stl: "none",
1563 }
1564 `)
1565
Paul Duffin1356d8c2020-02-25 19:26:33 +00001566 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001567 checkAndroidBpContents(`
1568// This is auto-generated. DO NOT EDIT.
1569
1570cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001571 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001572 sdk_member_name: "mynativelib",
1573 device_supported: false,
1574 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001575 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001576 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001577 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001578 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001579 target: {
1580 host: {
1581 enabled: false,
1582 },
1583 linux_glibc: {
1584 enabled: true,
1585 },
1586 linux_glibc_x86_64: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001587 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001588 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001589 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001590 linux_glibc_x86: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001591 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001592 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001593 },
1594 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001595}
1596
1597cc_prebuilt_library_static {
1598 name: "mynativelib",
1599 prefer: false,
1600 device_supported: false,
1601 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001602 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001603 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001604 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001605 target: {
1606 host: {
1607 enabled: false,
1608 },
1609 linux_glibc: {
1610 enabled: true,
1611 },
1612 linux_glibc_x86_64: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001613 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001614 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001615 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001616 linux_glibc_x86: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001617 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001618 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001619 },
1620 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001621}
1622
Paul Duffine6029182019-12-16 17:43:48 +00001623module_exports_snapshot {
1624 name: "myexports@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001625 device_supported: false,
1626 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001627 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001628 target: {
1629 host: {
1630 enabled: false,
1631 },
1632 linux_glibc: {
1633 enabled: true,
1634 },
1635 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001636}
1637`),
1638 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001639include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001640.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001641.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1642.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1643.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1644.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001645.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1646.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1647.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1648`),
1649 )
1650}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001651
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001652func TestSnapshotWithCcLibrary(t *testing.T) {
1653 result := testSdkWithCc(t, `
1654 module_exports {
1655 name: "myexports",
1656 native_libs: ["mynativelib"],
1657 }
1658
1659 cc_library {
1660 name: "mynativelib",
1661 srcs: [
1662 "Test.cpp",
1663 ],
1664 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001665 stl: "none",
1666 }
1667 `)
1668
1669 result.CheckSnapshot("myexports", "",
1670 checkAndroidBpContents(`
1671// This is auto-generated. DO NOT EDIT.
1672
1673cc_prebuilt_library {
1674 name: "myexports_mynativelib@current",
1675 sdk_member_name: "mynativelib",
1676 installable: false,
1677 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001678 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001679 export_include_dirs: ["include/include"],
1680 arch: {
1681 arm64: {
1682 static: {
1683 srcs: ["arm64/lib/mynativelib.a"],
1684 },
1685 shared: {
1686 srcs: ["arm64/lib/mynativelib.so"],
1687 },
1688 },
1689 arm: {
1690 static: {
1691 srcs: ["arm/lib/mynativelib.a"],
1692 },
1693 shared: {
1694 srcs: ["arm/lib/mynativelib.so"],
1695 },
1696 },
1697 },
1698}
1699
1700cc_prebuilt_library {
1701 name: "mynativelib",
1702 prefer: false,
1703 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001704 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001705 export_include_dirs: ["include/include"],
1706 arch: {
1707 arm64: {
1708 static: {
1709 srcs: ["arm64/lib/mynativelib.a"],
1710 },
1711 shared: {
1712 srcs: ["arm64/lib/mynativelib.so"],
1713 },
1714 },
1715 arm: {
1716 static: {
1717 srcs: ["arm/lib/mynativelib.a"],
1718 },
1719 shared: {
1720 srcs: ["arm/lib/mynativelib.so"],
1721 },
1722 },
1723 },
1724}
1725
1726module_exports_snapshot {
1727 name: "myexports@current",
1728 native_libs: ["myexports_mynativelib@current"],
1729}
1730`),
1731 checkAllCopyRules(`
1732include/Test.h -> include/include/Test.h
1733.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1734.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1735.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1736.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1737 )
1738}
1739
Paul Duffin13ad94f2020-02-19 16:19:27 +00001740func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001741 result := testSdkWithCc(t, `
1742 module_exports {
1743 name: "myexports",
1744 device_supported: false,
1745 host_supported: true,
1746 target: {
1747 host: {
1748 compile_multilib: "64",
1749 },
1750 },
1751 native_static_libs: ["mynativelib"],
1752 }
1753
1754 cc_library_static {
1755 name: "mynativelib",
1756 device_supported: false,
1757 host_supported: true,
1758 srcs: [
1759 "Test.cpp",
1760 "aidl/foo/bar/Test.aidl",
1761 ],
1762 export_include_dirs: ["include"],
1763 aidl: {
1764 export_aidl_headers: true,
1765 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001766 stl: "none",
1767 }
1768 `)
1769
Paul Duffin1356d8c2020-02-25 19:26:33 +00001770 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001771 checkAndroidBpContents(`
1772// This is auto-generated. DO NOT EDIT.
1773
1774cc_prebuilt_library_static {
1775 name: "myexports_mynativelib@current",
1776 sdk_member_name: "mynativelib",
1777 device_supported: false,
1778 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001779 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001780 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001781 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001782 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001783 target: {
1784 host: {
1785 enabled: false,
1786 },
1787 linux_glibc: {
1788 enabled: true,
1789 },
1790 linux_glibc_x86_64: {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001791 srcs: ["x86_64/lib/mynativelib.a"],
1792 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1793 },
1794 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001795}
1796
1797cc_prebuilt_library_static {
1798 name: "mynativelib",
1799 prefer: false,
1800 device_supported: false,
1801 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001802 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001803 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001804 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001805 target: {
1806 host: {
1807 enabled: false,
1808 },
1809 linux_glibc: {
1810 enabled: true,
1811 },
1812 linux_glibc_x86_64: {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001813 srcs: ["x86_64/lib/mynativelib.a"],
1814 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1815 },
1816 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001817}
1818
1819module_exports_snapshot {
1820 name: "myexports@current",
1821 device_supported: false,
1822 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001823 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001824 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001825 target: {
1826 host: {
1827 enabled: false,
1828 },
1829 linux_glibc: {
1830 enabled: true,
1831 },
1832 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001833}`),
1834 checkAllCopyRules(`
1835include/Test.h -> include/include/Test.h
1836.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1837.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1838.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1839.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1840`),
1841 )
1842}
Paul Duffin91756d22020-02-21 16:29:57 +00001843
1844func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1845 result := testSdkWithCc(t, `
1846 sdk {
1847 name: "mysdk",
1848 native_header_libs: ["mynativeheaders"],
1849 }
1850
1851 cc_library_headers {
1852 name: "mynativeheaders",
1853 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001854 stl: "none",
1855 }
1856 `)
1857
Paul Duffin1356d8c2020-02-25 19:26:33 +00001858 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001859 checkAndroidBpContents(`
1860// This is auto-generated. DO NOT EDIT.
1861
1862cc_prebuilt_library_headers {
1863 name: "mysdk_mynativeheaders@current",
1864 sdk_member_name: "mynativeheaders",
Paul Duffin91756d22020-02-21 16:29:57 +00001865 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001866 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001867 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001868}
1869
1870cc_prebuilt_library_headers {
1871 name: "mynativeheaders",
1872 prefer: false,
Paul Duffin91756d22020-02-21 16:29:57 +00001873 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001874 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001875 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001876}
1877
1878sdk_snapshot {
1879 name: "mysdk@current",
1880 native_header_libs: ["mysdk_mynativeheaders@current"],
1881}
1882`),
1883 checkAllCopyRules(`
1884include/Test.h -> include/include/Test.h
1885`),
1886 )
1887}
1888
1889func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001890 result := testSdkWithCc(t, `
1891 sdk {
1892 name: "mysdk",
1893 device_supported: false,
1894 host_supported: true,
1895 native_header_libs: ["mynativeheaders"],
1896 }
1897
1898 cc_library_headers {
1899 name: "mynativeheaders",
1900 device_supported: false,
1901 host_supported: true,
1902 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001903 stl: "none",
1904 }
1905 `)
1906
Paul Duffin1356d8c2020-02-25 19:26:33 +00001907 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001908 checkAndroidBpContents(`
1909// This is auto-generated. DO NOT EDIT.
1910
1911cc_prebuilt_library_headers {
1912 name: "mysdk_mynativeheaders@current",
1913 sdk_member_name: "mynativeheaders",
1914 device_supported: false,
1915 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001916 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001917 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001918 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001919 target: {
1920 host: {
1921 enabled: false,
1922 },
1923 linux_glibc: {
1924 enabled: true,
1925 },
1926 },
Paul Duffin91756d22020-02-21 16:29:57 +00001927}
1928
1929cc_prebuilt_library_headers {
1930 name: "mynativeheaders",
1931 prefer: false,
1932 device_supported: false,
1933 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001934 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001935 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001936 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001937 target: {
1938 host: {
1939 enabled: false,
1940 },
1941 linux_glibc: {
1942 enabled: true,
1943 },
1944 },
Paul Duffin91756d22020-02-21 16:29:57 +00001945}
1946
1947sdk_snapshot {
1948 name: "mysdk@current",
1949 device_supported: false,
1950 host_supported: true,
1951 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001952 target: {
1953 host: {
1954 enabled: false,
1955 },
1956 linux_glibc: {
1957 enabled: true,
1958 },
1959 },
Paul Duffin91756d22020-02-21 16:29:57 +00001960}
1961`),
1962 checkAllCopyRules(`
1963include/Test.h -> include/include/Test.h
1964`),
1965 )
1966}
Paul Duffina04c1072020-03-02 10:16:35 +00001967
1968func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001969 result := testSdkWithCc(t, `
1970 sdk {
1971 name: "mysdk",
1972 host_supported: true,
1973 native_header_libs: ["mynativeheaders"],
1974 }
1975
1976 cc_library_headers {
1977 name: "mynativeheaders",
1978 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001979 stl: "none",
1980 export_system_include_dirs: ["include"],
1981 target: {
1982 android: {
1983 export_include_dirs: ["include-android"],
1984 },
1985 host: {
1986 export_include_dirs: ["include-host"],
1987 },
1988 },
1989 }
1990 `)
1991
1992 result.CheckSnapshot("mysdk", "",
1993 checkAndroidBpContents(`
1994// This is auto-generated. DO NOT EDIT.
1995
1996cc_prebuilt_library_headers {
1997 name: "mysdk_mynativeheaders@current",
1998 sdk_member_name: "mynativeheaders",
1999 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002000 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002001 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002002 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002003 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002004 host: {
2005 enabled: false,
2006 },
Paul Duffina04c1072020-03-02 10:16:35 +00002007 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002008 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002009 },
2010 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002011 enabled: true,
Paul Duffined62b9c2020-06-16 16:12:50 +01002012 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002013 },
2014 },
Paul Duffina04c1072020-03-02 10:16:35 +00002015}
2016
2017cc_prebuilt_library_headers {
2018 name: "mynativeheaders",
2019 prefer: false,
2020 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002021 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002022 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002023 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002024 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002025 host: {
2026 enabled: false,
2027 },
Paul Duffina04c1072020-03-02 10:16:35 +00002028 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002029 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002030 },
2031 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002032 enabled: true,
Paul Duffined62b9c2020-06-16 16:12:50 +01002033 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002034 },
2035 },
Paul Duffina04c1072020-03-02 10:16:35 +00002036}
2037
2038sdk_snapshot {
2039 name: "mysdk@current",
2040 host_supported: true,
2041 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002042 target: {
2043 host: {
2044 enabled: false,
2045 },
2046 linux_glibc: {
2047 enabled: true,
2048 },
2049 },
Paul Duffina04c1072020-03-02 10:16:35 +00002050}
2051`),
2052 checkAllCopyRules(`
Paul Duffined62b9c2020-06-16 16:12:50 +01002053include/Test.h -> common_os/include/include/Test.h
2054include-android/AndroidTest.h -> android/include/include-android/AndroidTest.h
2055include-host/HostTest.h -> linux_glibc/include/include-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002056`),
2057 )
2058}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002059
2060func TestSystemSharedLibPropagation(t *testing.T) {
2061 result := testSdkWithCc(t, `
2062 sdk {
2063 name: "mysdk",
2064 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2065 }
2066
2067 cc_library {
2068 name: "sslnil",
2069 host_supported: true,
2070 }
2071
2072 cc_library {
2073 name: "sslempty",
2074 system_shared_libs: [],
2075 }
2076
2077 cc_library {
2078 name: "sslnonempty",
2079 system_shared_libs: ["sslnil"],
2080 }
2081 `)
2082
2083 result.CheckSnapshot("mysdk", "",
2084 checkAndroidBpContents(`
2085// This is auto-generated. DO NOT EDIT.
2086
2087cc_prebuilt_library_shared {
2088 name: "mysdk_sslnil@current",
2089 sdk_member_name: "sslnil",
2090 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002091 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002092 arch: {
2093 arm64: {
2094 srcs: ["arm64/lib/sslnil.so"],
2095 },
2096 arm: {
2097 srcs: ["arm/lib/sslnil.so"],
2098 },
2099 },
2100}
2101
2102cc_prebuilt_library_shared {
2103 name: "sslnil",
2104 prefer: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002105 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002106 arch: {
2107 arm64: {
2108 srcs: ["arm64/lib/sslnil.so"],
2109 },
2110 arm: {
2111 srcs: ["arm/lib/sslnil.so"],
2112 },
2113 },
2114}
2115
2116cc_prebuilt_library_shared {
2117 name: "mysdk_sslempty@current",
2118 sdk_member_name: "sslempty",
2119 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002120 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002121 system_shared_libs: [],
2122 arch: {
2123 arm64: {
2124 srcs: ["arm64/lib/sslempty.so"],
2125 },
2126 arm: {
2127 srcs: ["arm/lib/sslempty.so"],
2128 },
2129 },
2130}
2131
2132cc_prebuilt_library_shared {
2133 name: "sslempty",
2134 prefer: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002135 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002136 system_shared_libs: [],
2137 arch: {
2138 arm64: {
2139 srcs: ["arm64/lib/sslempty.so"],
2140 },
2141 arm: {
2142 srcs: ["arm/lib/sslempty.so"],
2143 },
2144 },
2145}
2146
2147cc_prebuilt_library_shared {
2148 name: "mysdk_sslnonempty@current",
2149 sdk_member_name: "sslnonempty",
2150 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002151 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002152 system_shared_libs: ["mysdk_sslnil@current"],
2153 arch: {
2154 arm64: {
2155 srcs: ["arm64/lib/sslnonempty.so"],
2156 },
2157 arm: {
2158 srcs: ["arm/lib/sslnonempty.so"],
2159 },
2160 },
2161}
2162
2163cc_prebuilt_library_shared {
2164 name: "sslnonempty",
2165 prefer: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002166 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002167 system_shared_libs: ["sslnil"],
2168 arch: {
2169 arm64: {
2170 srcs: ["arm64/lib/sslnonempty.so"],
2171 },
2172 arm: {
2173 srcs: ["arm/lib/sslnonempty.so"],
2174 },
2175 },
2176}
2177
2178sdk_snapshot {
2179 name: "mysdk@current",
2180 native_shared_libs: [
2181 "mysdk_sslnil@current",
2182 "mysdk_sslempty@current",
2183 "mysdk_sslnonempty@current",
2184 ],
2185}
2186`))
2187
2188 result = testSdkWithCc(t, `
2189 sdk {
2190 name: "mysdk",
2191 host_supported: true,
2192 native_shared_libs: ["sslvariants"],
2193 }
2194
2195 cc_library {
2196 name: "sslvariants",
2197 host_supported: true,
2198 target: {
2199 android: {
2200 system_shared_libs: [],
2201 },
2202 },
2203 }
2204 `)
2205
2206 result.CheckSnapshot("mysdk", "",
2207 checkAndroidBpContents(`
2208// This is auto-generated. DO NOT EDIT.
2209
2210cc_prebuilt_library_shared {
2211 name: "mysdk_sslvariants@current",
2212 sdk_member_name: "sslvariants",
2213 host_supported: true,
2214 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002215 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002216 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002217 host: {
2218 enabled: false,
2219 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002220 android: {
2221 system_shared_libs: [],
2222 },
2223 android_arm64: {
2224 srcs: ["android/arm64/lib/sslvariants.so"],
2225 },
2226 android_arm: {
2227 srcs: ["android/arm/lib/sslvariants.so"],
2228 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002229 linux_glibc: {
2230 enabled: true,
2231 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002232 linux_glibc_x86_64: {
2233 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2234 },
2235 linux_glibc_x86: {
2236 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2237 },
2238 },
2239}
2240
2241cc_prebuilt_library_shared {
2242 name: "sslvariants",
2243 prefer: false,
2244 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002245 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002246 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002247 host: {
2248 enabled: false,
2249 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002250 android: {
2251 system_shared_libs: [],
2252 },
2253 android_arm64: {
2254 srcs: ["android/arm64/lib/sslvariants.so"],
2255 },
2256 android_arm: {
2257 srcs: ["android/arm/lib/sslvariants.so"],
2258 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002259 linux_glibc: {
2260 enabled: true,
2261 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002262 linux_glibc_x86_64: {
2263 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2264 },
2265 linux_glibc_x86: {
2266 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2267 },
2268 },
2269}
2270
2271sdk_snapshot {
2272 name: "mysdk@current",
2273 host_supported: true,
2274 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002275 target: {
2276 host: {
2277 enabled: false,
2278 },
2279 linux_glibc: {
2280 enabled: true,
2281 },
2282 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002283}
2284`))
2285}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002286
2287func TestStubsLibrary(t *testing.T) {
2288 result := testSdkWithCc(t, `
2289 sdk {
2290 name: "mysdk",
2291 native_shared_libs: ["stubslib"],
2292 }
2293
2294 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002295 name: "internaldep",
2296 }
2297
2298 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002299 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002300 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002301 stubs: {
2302 symbol_file: "some/where/stubslib.map.txt",
2303 versions: ["1", "2", "3"],
2304 },
2305 }
2306 `)
2307
2308 result.CheckSnapshot("mysdk", "",
2309 checkAndroidBpContents(`
2310// This is auto-generated. DO NOT EDIT.
2311
2312cc_prebuilt_library_shared {
2313 name: "mysdk_stubslib@current",
2314 sdk_member_name: "stubslib",
2315 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002316 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002317 stubs: {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002318 versions: ["3"],
2319 },
2320 arch: {
2321 arm64: {
2322 srcs: ["arm64/lib/stubslib.so"],
2323 },
2324 arm: {
2325 srcs: ["arm/lib/stubslib.so"],
2326 },
2327 },
2328}
2329
2330cc_prebuilt_library_shared {
2331 name: "stubslib",
2332 prefer: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002333 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002334 stubs: {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002335 versions: ["3"],
2336 },
2337 arch: {
2338 arm64: {
2339 srcs: ["arm64/lib/stubslib.so"],
2340 },
2341 arm: {
2342 srcs: ["arm/lib/stubslib.so"],
2343 },
2344 },
2345}
2346
2347sdk_snapshot {
2348 name: "mysdk@current",
2349 native_shared_libs: ["mysdk_stubslib@current"],
2350}
2351`))
2352}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002353
2354func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002355 result := testSdkWithCc(t, `
2356 sdk {
2357 name: "mysdk",
2358 host_supported: true,
2359 native_shared_libs: ["stubslib"],
2360 }
2361
2362 cc_library {
2363 name: "internaldep",
2364 host_supported: true,
2365 }
2366
2367 cc_library {
2368 name: "stubslib",
2369 host_supported: true,
2370 shared_libs: ["internaldep"],
2371 stubs: {
2372 symbol_file: "some/where/stubslib.map.txt",
2373 versions: ["1", "2", "3"],
2374 },
2375 }
2376 `)
2377
2378 result.CheckSnapshot("mysdk", "",
2379 checkAndroidBpContents(`
2380// This is auto-generated. DO NOT EDIT.
2381
2382cc_prebuilt_library_shared {
2383 name: "mysdk_stubslib@current",
2384 sdk_member_name: "stubslib",
2385 host_supported: true,
2386 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002387 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002388 stubs: {
2389 versions: ["3"],
2390 },
2391 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002392 host: {
2393 enabled: false,
2394 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002395 android_arm64: {
2396 srcs: ["android/arm64/lib/stubslib.so"],
2397 },
2398 android_arm: {
2399 srcs: ["android/arm/lib/stubslib.so"],
2400 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002401 linux_glibc: {
2402 enabled: true,
2403 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002404 linux_glibc_x86_64: {
2405 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2406 },
2407 linux_glibc_x86: {
2408 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2409 },
2410 },
2411}
2412
2413cc_prebuilt_library_shared {
2414 name: "stubslib",
2415 prefer: false,
2416 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002417 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002418 stubs: {
2419 versions: ["3"],
2420 },
2421 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002422 host: {
2423 enabled: false,
2424 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002425 android_arm64: {
2426 srcs: ["android/arm64/lib/stubslib.so"],
2427 },
2428 android_arm: {
2429 srcs: ["android/arm/lib/stubslib.so"],
2430 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002431 linux_glibc: {
2432 enabled: true,
2433 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002434 linux_glibc_x86_64: {
2435 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2436 },
2437 linux_glibc_x86: {
2438 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2439 },
2440 },
2441}
2442
2443sdk_snapshot {
2444 name: "mysdk@current",
2445 host_supported: true,
2446 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002447 target: {
2448 host: {
2449 enabled: false,
2450 },
2451 linux_glibc: {
2452 enabled: true,
2453 },
2454 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002455}
2456`))
2457}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002458
2459func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002460 result := testSdkWithCc(t, `
2461 sdk {
2462 name: "mysdk",
2463 host_supported: true,
2464 native_shared_libs: ["mylib"],
2465 }
2466
2467 cc_library {
2468 name: "mylib",
2469 host_supported: true,
2470 unique_host_soname: true,
2471 }
2472 `)
2473
2474 result.CheckSnapshot("mysdk", "",
2475 checkAndroidBpContents(`
2476// This is auto-generated. DO NOT EDIT.
2477
2478cc_prebuilt_library_shared {
2479 name: "mysdk_mylib@current",
2480 sdk_member_name: "mylib",
2481 host_supported: true,
2482 installable: false,
2483 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002484 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002485 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002486 host: {
2487 enabled: false,
2488 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002489 android_arm64: {
2490 srcs: ["android/arm64/lib/mylib.so"],
2491 },
2492 android_arm: {
2493 srcs: ["android/arm/lib/mylib.so"],
2494 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002495 linux_glibc: {
2496 enabled: true,
2497 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002498 linux_glibc_x86_64: {
2499 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2500 },
2501 linux_glibc_x86: {
2502 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2503 },
2504 },
2505}
2506
2507cc_prebuilt_library_shared {
2508 name: "mylib",
2509 prefer: false,
2510 host_supported: true,
2511 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002512 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002513 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002514 host: {
2515 enabled: false,
2516 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002517 android_arm64: {
2518 srcs: ["android/arm64/lib/mylib.so"],
2519 },
2520 android_arm: {
2521 srcs: ["android/arm/lib/mylib.so"],
2522 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002523 linux_glibc: {
2524 enabled: true,
2525 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002526 linux_glibc_x86_64: {
2527 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2528 },
2529 linux_glibc_x86: {
2530 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2531 },
2532 },
2533}
2534
2535sdk_snapshot {
2536 name: "mysdk@current",
2537 host_supported: true,
2538 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002539 target: {
2540 host: {
2541 enabled: false,
2542 },
2543 linux_glibc: {
2544 enabled: true,
2545 },
2546 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002547}
2548`),
2549 checkAllCopyRules(`
2550.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2551.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2552.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2553.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2554`),
2555 )
2556}