blob: 11bc90238383fcb046b4cbca6c479ccf978a6efc [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,
Paul Duffind835daa2019-11-30 17:49:09 +000035 }
36 return testSdkWithFs(t, bp, fs)
37}
38
Paul Duffina80fdec2019-12-03 15:25:00 +000039// Contains tests for SDK members provided by the cc package.
40
41func TestSdkIsCompileMultilibBoth(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +000042 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000043 sdk {
44 name: "mysdk",
45 native_shared_libs: ["sdkmember"],
46 }
47
48 cc_library_shared {
49 name: "sdkmember",
50 srcs: ["Test.cpp"],
51 system_shared_libs: [],
52 stl: "none",
53 }
54 `)
55
Colin Cross7113d202019-11-20 16:39:12 -080056 armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile()
57 arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile()
Paul Duffina80fdec2019-12-03 15:25:00 +000058
59 var inputs []string
Paul Duffin1356d8c2020-02-25 19:26:33 +000060 buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests()
Paul Duffina80fdec2019-12-03 15:25:00 +000061 for _, bp := range buildParams {
62 if bp.Input != nil {
63 inputs = append(inputs, bp.Input.String())
64 }
65 }
66
67 // ensure that both 32/64 outputs are inputs of the sdk snapshot
68 ensureListContains(t, inputs, armOutput.String())
69 ensureListContains(t, inputs, arm64Output.String())
70}
71
72func TestBasicSdkWithCc(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +000073 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000074 sdk {
75 name: "mysdk",
76 native_shared_libs: ["sdkmember"],
77 }
78
Paul Duffina0843f62019-12-13 19:50:38 +000079 cc_library_shared {
80 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -080081 system_shared_libs: [],
Paul Duffina0843f62019-12-13 19:50:38 +000082 }
83
Paul Duffina80fdec2019-12-03 15:25:00 +000084 sdk_snapshot {
85 name: "mysdk@1",
86 native_shared_libs: ["sdkmember_mysdk_1"],
87 }
88
89 sdk_snapshot {
90 name: "mysdk@2",
91 native_shared_libs: ["sdkmember_mysdk_2"],
92 }
93
94 cc_prebuilt_library_shared {
95 name: "sdkmember",
96 srcs: ["libfoo.so"],
97 prefer: false,
98 system_shared_libs: [],
99 stl: "none",
100 }
101
102 cc_prebuilt_library_shared {
103 name: "sdkmember_mysdk_1",
104 sdk_member_name: "sdkmember",
105 srcs: ["libfoo.so"],
106 system_shared_libs: [],
107 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000108 // TODO: remove //apex_available:platform
109 apex_available: [
110 "//apex_available:platform",
111 "myapex",
112 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000113 }
114
115 cc_prebuilt_library_shared {
116 name: "sdkmember_mysdk_2",
117 sdk_member_name: "sdkmember",
118 srcs: ["libfoo.so"],
119 system_shared_libs: [],
120 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000121 // TODO: remove //apex_available:platform
122 apex_available: [
123 "//apex_available:platform",
124 "myapex2",
125 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000126 }
127
128 cc_library_shared {
129 name: "mycpplib",
130 srcs: ["Test.cpp"],
131 shared_libs: ["sdkmember"],
132 system_shared_libs: [],
133 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000134 apex_available: [
135 "myapex",
136 "myapex2",
137 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000138 }
139
140 apex {
141 name: "myapex",
142 native_shared_libs: ["mycpplib"],
143 uses_sdks: ["mysdk@1"],
144 key: "myapex.key",
145 certificate: ":myapex.cert",
146 }
147
148 apex {
149 name: "myapex2",
150 native_shared_libs: ["mycpplib"],
151 uses_sdks: ["mysdk@2"],
152 key: "myapex.key",
153 certificate: ":myapex.cert",
154 }
155 `)
156
Colin Cross7113d202019-11-20 16:39:12 -0800157 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_myapex").Rule("toc").Output
158 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_myapex2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000159
Colin Cross7113d202019-11-20 16:39:12 -0800160 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex")
161 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000162
163 // Depending on the uses_sdks value, different libs are linked
164 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
165 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
166}
167
Paul Duffina0843f62019-12-13 19:50:38 +0000168// Make sure the sdk can use host specific cc libraries static/shared and both.
169func TestHostSdkWithCc(t *testing.T) {
170 testSdkWithCc(t, `
171 sdk {
172 name: "mysdk",
173 device_supported: false,
174 host_supported: true,
175 native_shared_libs: ["sdkshared"],
176 native_static_libs: ["sdkstatic"],
177 }
178
179 cc_library_host_shared {
180 name: "sdkshared",
181 system_shared_libs: [],
182 stl: "none",
183 }
184
185 cc_library_host_static {
186 name: "sdkstatic",
187 system_shared_libs: [],
188 stl: "none",
189 }
190 `)
191}
192
193// Make sure the sdk can use cc libraries static/shared and both.
194func TestSdkWithCc(t *testing.T) {
195 testSdkWithCc(t, `
196 sdk {
197 name: "mysdk",
198 native_shared_libs: ["sdkshared", "sdkboth1"],
199 native_static_libs: ["sdkstatic", "sdkboth2"],
200 }
201
202 cc_library_shared {
203 name: "sdkshared",
204 system_shared_libs: [],
205 stl: "none",
206 }
207
208 cc_library_static {
209 name: "sdkstatic",
210 system_shared_libs: [],
211 stl: "none",
212 }
213
214 cc_library {
215 name: "sdkboth1",
216 system_shared_libs: [],
217 stl: "none",
218 }
219
220 cc_library {
221 name: "sdkboth2",
222 system_shared_libs: [],
223 stl: "none",
224 }
225 `)
226}
227
Paul Duffinc62a5102019-12-11 18:34:15 +0000228func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
229 result := testSdkWithCc(t, `
230 sdk {
231 name: "mysdk",
232 native_shared_libs: ["mynativelib1", "mynativelib2"],
233 }
234
235 cc_library_shared {
236 name: "mynativelib1",
237 srcs: [
238 "Test.cpp",
239 ],
240 export_include_dirs: ["include"],
241 system_shared_libs: [],
242 stl: "none",
243 }
244
245 cc_library_shared {
246 name: "mynativelib2",
247 srcs: [
248 "Test.cpp",
249 ],
250 export_include_dirs: ["include"],
251 system_shared_libs: [],
252 stl: "none",
253 }
254 `)
255
Paul Duffin1356d8c2020-02-25 19:26:33 +0000256 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000257 checkAllCopyRules(`
258include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800259.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
260.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
261.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
262.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000263`),
264 )
265}
266
Paul Duffina7cd8c82019-12-11 20:00:57 +0000267// Verify that when the shared library has some common and some arch specific properties that the generated
268// snapshot is optimized properly.
269func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
270 result := testSdkWithCc(t, `
271 sdk {
272 name: "mysdk",
273 native_shared_libs: ["mynativelib"],
274 }
275
276 cc_library_shared {
277 name: "mynativelib",
278 srcs: [
279 "Test.cpp",
280 "aidl/foo/bar/Test.aidl",
281 ],
282 export_include_dirs: ["include"],
283 arch: {
284 arm64: {
285 export_system_include_dirs: ["arm64/include"],
286 },
287 },
288 system_shared_libs: [],
289 stl: "none",
290 }
291 `)
292
Paul Duffin1356d8c2020-02-25 19:26:33 +0000293 result.CheckSnapshot("mysdk", "",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000294 checkAndroidBpContents(`
295// This is auto-generated. DO NOT EDIT.
296
297cc_prebuilt_library_shared {
298 name: "mysdk_mynativelib@current",
299 sdk_member_name: "mynativelib",
300 export_include_dirs: ["include/include"],
301 arch: {
302 arm64: {
303 srcs: ["arm64/lib/mynativelib.so"],
304 export_system_include_dirs: ["arm64/include/arm64/include"],
305 },
306 arm: {
307 srcs: ["arm/lib/mynativelib.so"],
308 },
309 },
310 stl: "none",
311 system_shared_libs: [],
312}
313
314cc_prebuilt_library_shared {
315 name: "mynativelib",
316 prefer: false,
317 export_include_dirs: ["include/include"],
318 arch: {
319 arm64: {
320 srcs: ["arm64/lib/mynativelib.so"],
321 export_system_include_dirs: ["arm64/include/arm64/include"],
322 },
323 arm: {
324 srcs: ["arm/lib/mynativelib.so"],
325 },
326 },
327 stl: "none",
328 system_shared_libs: [],
329}
330
331sdk_snapshot {
332 name: "mysdk@current",
333 native_shared_libs: ["mysdk_mynativelib@current"],
334}
335`),
336 checkAllCopyRules(`
337include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800338.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000339arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800340.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000341 )
342}
343
Paul Duffin25ce04b2020-01-16 11:47:25 +0000344func TestSnapshotWithCcBinary(t *testing.T) {
345 result := testSdkWithCc(t, `
346 module_exports {
347 name: "mymodule_exports",
348 native_binaries: ["mynativebinary"],
349 }
350
351 cc_binary {
352 name: "mynativebinary",
353 srcs: [
354 "Test.cpp",
355 ],
356 compile_multilib: "both",
357 system_shared_libs: [],
358 stl: "none",
359 }
360 `)
361
Paul Duffin1356d8c2020-02-25 19:26:33 +0000362 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000363 checkAndroidBpContents(`
364// This is auto-generated. DO NOT EDIT.
365
366cc_prebuilt_binary {
367 name: "mymodule_exports_mynativebinary@current",
368 sdk_member_name: "mynativebinary",
369 compile_multilib: "both",
370 arch: {
371 arm64: {
372 srcs: ["arm64/bin/mynativebinary"],
373 },
374 arm: {
375 srcs: ["arm/bin/mynativebinary"],
376 },
377 },
378}
379
380cc_prebuilt_binary {
381 name: "mynativebinary",
382 prefer: false,
383 compile_multilib: "both",
384 arch: {
385 arm64: {
386 srcs: ["arm64/bin/mynativebinary"],
387 },
388 arm: {
389 srcs: ["arm/bin/mynativebinary"],
390 },
391 },
392}
393
394module_exports_snapshot {
395 name: "mymodule_exports@current",
396 native_binaries: ["mymodule_exports_mynativebinary@current"],
397}
398`),
399 checkAllCopyRules(`
400.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
401.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
402`),
403 )
404}
405
Paul Duffina04c1072020-03-02 10:16:35 +0000406func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
407 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
408 SkipIfNotLinux(t)
409
410 result := testSdkWithCc(t, `
411 module_exports {
412 name: "myexports",
413 device_supported: false,
414 host_supported: true,
415 native_binaries: ["mynativebinary"],
416 target: {
417 windows: {
418 enabled: true,
419 },
420 },
421 }
422
423 cc_binary {
424 name: "mynativebinary",
425 device_supported: false,
426 host_supported: true,
427 srcs: [
428 "Test.cpp",
429 ],
430 compile_multilib: "both",
431 system_shared_libs: [],
432 stl: "none",
433 target: {
434 windows: {
435 enabled: true,
436 },
437 },
438 }
439 `)
440
441 result.CheckSnapshot("myexports", "",
442 checkAndroidBpContents(`
443// This is auto-generated. DO NOT EDIT.
444
445cc_prebuilt_binary {
446 name: "myexports_mynativebinary@current",
447 sdk_member_name: "mynativebinary",
448 device_supported: false,
449 host_supported: true,
450 target: {
451 linux_glibc: {
452 compile_multilib: "both",
453 },
454 linux_glibc_x86_64: {
455 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
456 },
457 linux_glibc_x86: {
458 srcs: ["linux_glibc/x86/bin/mynativebinary"],
459 },
460 windows: {
461 compile_multilib: "64",
462 },
463 windows_x86_64: {
464 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
465 },
466 },
467}
468
469cc_prebuilt_binary {
470 name: "mynativebinary",
471 prefer: false,
472 device_supported: false,
473 host_supported: true,
474 target: {
475 linux_glibc: {
476 compile_multilib: "both",
477 },
478 linux_glibc_x86_64: {
479 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
480 },
481 linux_glibc_x86: {
482 srcs: ["linux_glibc/x86/bin/mynativebinary"],
483 },
484 windows: {
485 compile_multilib: "64",
486 },
487 windows_x86_64: {
488 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
489 },
490 },
491}
492
493module_exports_snapshot {
494 name: "myexports@current",
495 device_supported: false,
496 host_supported: true,
497 native_binaries: ["myexports_mynativebinary@current"],
498}
499`),
500 checkAllCopyRules(`
501.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
502.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
503.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
504`),
505 )
506}
507
Paul Duffin9ab556f2019-12-11 18:42:17 +0000508func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000509 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000510 sdk {
511 name: "mysdk",
512 native_shared_libs: ["mynativelib"],
513 }
514
515 cc_library_shared {
516 name: "mynativelib",
517 srcs: [
518 "Test.cpp",
519 "aidl/foo/bar/Test.aidl",
520 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +0000521 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000522 export_include_dirs: ["include"],
523 aidl: {
524 export_aidl_headers: true,
525 },
526 system_shared_libs: [],
527 stl: "none",
528 }
529 `)
530
Paul Duffin1356d8c2020-02-25 19:26:33 +0000531 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000532 checkAndroidBpContents(`
533// This is auto-generated. DO NOT EDIT.
534
535cc_prebuilt_library_shared {
536 name: "mysdk_mynativelib@current",
537 sdk_member_name: "mynativelib",
Paul Duffinbefa4b92020-03-04 14:22:45 +0000538 apex_available: [
539 "apex1",
540 "apex2",
541 ],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000542 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000543 arch: {
544 arm64: {
545 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000546 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000547 },
548 arm: {
549 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000550 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000551 },
552 },
553 stl: "none",
554 system_shared_libs: [],
555}
556
557cc_prebuilt_library_shared {
558 name: "mynativelib",
559 prefer: false,
Paul Duffinbefa4b92020-03-04 14:22:45 +0000560 apex_available: [
561 "apex1",
562 "apex2",
563 ],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000564 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000565 arch: {
566 arm64: {
567 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000568 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000569 },
570 arm: {
571 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000572 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000573 },
574 },
575 stl: "none",
576 system_shared_libs: [],
577}
578
579sdk_snapshot {
580 name: "mysdk@current",
581 native_shared_libs: ["mysdk_mynativelib@current"],
582}
583`),
584 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000585include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800586.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
587.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
588.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
589.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
590.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
591.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
592.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
593.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 +0000594`),
595 )
596}
597
Paul Duffin9ab556f2019-12-11 18:42:17 +0000598func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina80fdec2019-12-03 15:25:00 +0000599 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
600 SkipIfNotLinux(t)
601
Paul Duffind835daa2019-11-30 17:49:09 +0000602 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000603 sdk {
604 name: "mysdk",
605 device_supported: false,
606 host_supported: true,
607 native_shared_libs: ["mynativelib"],
608 }
609
610 cc_library_shared {
611 name: "mynativelib",
612 device_supported: false,
613 host_supported: true,
614 srcs: [
615 "Test.cpp",
616 "aidl/foo/bar/Test.aidl",
617 ],
618 export_include_dirs: ["include"],
619 aidl: {
620 export_aidl_headers: true,
621 },
622 system_shared_libs: [],
623 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +0000624 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +0000625 }
626 `)
627
Paul Duffin1356d8c2020-02-25 19:26:33 +0000628 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000629 checkAndroidBpContents(`
630// This is auto-generated. DO NOT EDIT.
631
632cc_prebuilt_library_shared {
633 name: "mysdk_mynativelib@current",
634 sdk_member_name: "mynativelib",
635 device_supported: false,
636 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +0000637 sdk_version: "minimum",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000638 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000639 arch: {
640 x86_64: {
641 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000642 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000643 },
644 x86: {
645 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000646 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000647 },
648 },
649 stl: "none",
650 system_shared_libs: [],
651}
652
653cc_prebuilt_library_shared {
654 name: "mynativelib",
655 prefer: false,
656 device_supported: false,
657 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +0000658 sdk_version: "minimum",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000659 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000660 arch: {
661 x86_64: {
662 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000663 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000664 },
665 x86: {
666 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000667 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000668 },
669 },
670 stl: "none",
671 system_shared_libs: [],
672}
673
674sdk_snapshot {
675 name: "mysdk@current",
676 device_supported: false,
677 host_supported: true,
678 native_shared_libs: ["mysdk_mynativelib@current"],
679}
680`),
681 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000682include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +0000683.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +0000684.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
685.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
686.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
687.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +0000688.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
689.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
690.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
691`),
692 )
693}
Paul Duffin9ab556f2019-12-11 18:42:17 +0000694
Paul Duffina04c1072020-03-02 10:16:35 +0000695func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
696 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
697 SkipIfNotLinux(t)
698
699 result := testSdkWithCc(t, `
700 sdk {
701 name: "mysdk",
702 device_supported: false,
703 host_supported: true,
704 native_shared_libs: ["mynativelib"],
705 target: {
706 windows: {
707 enabled: true,
708 },
709 },
710 }
711
712 cc_library_shared {
713 name: "mynativelib",
714 device_supported: false,
715 host_supported: true,
716 srcs: [
717 "Test.cpp",
718 ],
719 system_shared_libs: [],
720 stl: "none",
721 target: {
722 windows: {
723 enabled: true,
724 },
725 },
726 }
727 `)
728
729 result.CheckSnapshot("mysdk", "",
730 checkAndroidBpContents(`
731// This is auto-generated. DO NOT EDIT.
732
733cc_prebuilt_library_shared {
734 name: "mysdk_mynativelib@current",
735 sdk_member_name: "mynativelib",
736 device_supported: false,
737 host_supported: true,
738 target: {
739 linux_glibc_x86_64: {
740 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
741 },
742 linux_glibc_x86: {
743 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
744 },
745 windows_x86_64: {
746 srcs: ["windows/x86_64/lib/mynativelib.dll"],
747 },
748 },
749 stl: "none",
750 system_shared_libs: [],
751}
752
753cc_prebuilt_library_shared {
754 name: "mynativelib",
755 prefer: false,
756 device_supported: false,
757 host_supported: true,
758 target: {
759 linux_glibc_x86_64: {
760 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
761 },
762 linux_glibc_x86: {
763 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
764 },
765 windows_x86_64: {
766 srcs: ["windows/x86_64/lib/mynativelib.dll"],
767 },
768 },
769 stl: "none",
770 system_shared_libs: [],
771}
772
773sdk_snapshot {
774 name: "mysdk@current",
775 device_supported: false,
776 host_supported: true,
777 native_shared_libs: ["mysdk_mynativelib@current"],
778}
779`),
780 checkAllCopyRules(`
781.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
782.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
783.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
784`),
785 )
786}
787
Paul Duffin9ab556f2019-12-11 18:42:17 +0000788func TestSnapshotWithCcStaticLibrary(t *testing.T) {
789 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +0000790 module_exports {
791 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000792 native_static_libs: ["mynativelib"],
793 }
794
795 cc_library_static {
796 name: "mynativelib",
797 srcs: [
798 "Test.cpp",
799 "aidl/foo/bar/Test.aidl",
800 ],
801 export_include_dirs: ["include"],
802 aidl: {
803 export_aidl_headers: true,
804 },
805 system_shared_libs: [],
806 stl: "none",
807 }
808 `)
809
Paul Duffin1356d8c2020-02-25 19:26:33 +0000810 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000811 checkAndroidBpContents(`
812// This is auto-generated. DO NOT EDIT.
813
814cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +0000815 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000816 sdk_member_name: "mynativelib",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000817 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000818 arch: {
819 arm64: {
820 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000821 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000822 },
823 arm: {
824 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000825 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000826 },
827 },
828 stl: "none",
829 system_shared_libs: [],
830}
831
832cc_prebuilt_library_static {
833 name: "mynativelib",
834 prefer: false,
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000835 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000836 arch: {
837 arm64: {
838 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000839 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000840 },
841 arm: {
842 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000843 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000844 },
845 },
846 stl: "none",
847 system_shared_libs: [],
848}
849
Paul Duffine6029182019-12-16 17:43:48 +0000850module_exports_snapshot {
851 name: "myexports@current",
852 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000853}
854`),
855 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000856include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800857.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
858.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
859.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
860.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
861.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
862.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
863.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
864.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 +0000865`),
866 )
867}
868
869func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
870 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
871 SkipIfNotLinux(t)
872
873 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +0000874 module_exports {
875 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000876 device_supported: false,
877 host_supported: true,
878 native_static_libs: ["mynativelib"],
879 }
880
881 cc_library_static {
882 name: "mynativelib",
883 device_supported: false,
884 host_supported: true,
885 srcs: [
886 "Test.cpp",
887 "aidl/foo/bar/Test.aidl",
888 ],
889 export_include_dirs: ["include"],
890 aidl: {
891 export_aidl_headers: true,
892 },
893 system_shared_libs: [],
894 stl: "none",
895 }
896 `)
897
Paul Duffin1356d8c2020-02-25 19:26:33 +0000898 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000899 checkAndroidBpContents(`
900// This is auto-generated. DO NOT EDIT.
901
902cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +0000903 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000904 sdk_member_name: "mynativelib",
905 device_supported: false,
906 host_supported: true,
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000907 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000908 arch: {
909 x86_64: {
910 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000911 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000912 },
913 x86: {
914 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000915 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000916 },
917 },
918 stl: "none",
919 system_shared_libs: [],
920}
921
922cc_prebuilt_library_static {
923 name: "mynativelib",
924 prefer: false,
925 device_supported: false,
926 host_supported: true,
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000927 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000928 arch: {
929 x86_64: {
930 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000931 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000932 },
933 x86: {
934 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000935 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000936 },
937 },
938 stl: "none",
939 system_shared_libs: [],
940}
941
Paul Duffine6029182019-12-16 17:43:48 +0000942module_exports_snapshot {
943 name: "myexports@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000944 device_supported: false,
945 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +0000946 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000947}
948`),
949 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000950include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +0000951.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +0000952.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
953.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
954.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
955.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +0000956.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
957.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
958.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
959`),
960 )
961}
Paul Duffin13ad94f2020-02-19 16:19:27 +0000962
963func TestHostSnapshotWithMultiLib64(t *testing.T) {
964 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
965 SkipIfNotLinux(t)
966
967 result := testSdkWithCc(t, `
968 module_exports {
969 name: "myexports",
970 device_supported: false,
971 host_supported: true,
972 target: {
973 host: {
974 compile_multilib: "64",
975 },
976 },
977 native_static_libs: ["mynativelib"],
978 }
979
980 cc_library_static {
981 name: "mynativelib",
982 device_supported: false,
983 host_supported: true,
984 srcs: [
985 "Test.cpp",
986 "aidl/foo/bar/Test.aidl",
987 ],
988 export_include_dirs: ["include"],
989 aidl: {
990 export_aidl_headers: true,
991 },
992 system_shared_libs: [],
993 stl: "none",
994 }
995 `)
996
Paul Duffin1356d8c2020-02-25 19:26:33 +0000997 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +0000998 checkAndroidBpContents(`
999// This is auto-generated. DO NOT EDIT.
1000
1001cc_prebuilt_library_static {
1002 name: "myexports_mynativelib@current",
1003 sdk_member_name: "mynativelib",
1004 device_supported: false,
1005 host_supported: true,
1006 export_include_dirs: ["include/include"],
1007 arch: {
1008 x86_64: {
1009 srcs: ["x86_64/lib/mynativelib.a"],
1010 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1011 },
1012 },
1013 stl: "none",
1014 system_shared_libs: [],
1015}
1016
1017cc_prebuilt_library_static {
1018 name: "mynativelib",
1019 prefer: false,
1020 device_supported: false,
1021 host_supported: true,
1022 export_include_dirs: ["include/include"],
1023 arch: {
1024 x86_64: {
1025 srcs: ["x86_64/lib/mynativelib.a"],
1026 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1027 },
1028 },
1029 stl: "none",
1030 system_shared_libs: [],
1031}
1032
1033module_exports_snapshot {
1034 name: "myexports@current",
1035 device_supported: false,
1036 host_supported: true,
1037 target: {
1038 host: {
1039 compile_multilib: "64",
1040 },
1041 },
1042 native_static_libs: ["myexports_mynativelib@current"],
1043}`),
1044 checkAllCopyRules(`
1045include/Test.h -> include/include/Test.h
1046.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1047.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1048.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1049.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1050`),
1051 )
1052}
Paul Duffin91756d22020-02-21 16:29:57 +00001053
1054func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1055 result := testSdkWithCc(t, `
1056 sdk {
1057 name: "mysdk",
1058 native_header_libs: ["mynativeheaders"],
1059 }
1060
1061 cc_library_headers {
1062 name: "mynativeheaders",
1063 export_include_dirs: ["include"],
1064 system_shared_libs: [],
1065 stl: "none",
1066 }
1067 `)
1068
Paul Duffin1356d8c2020-02-25 19:26:33 +00001069 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001070 checkAndroidBpContents(`
1071// This is auto-generated. DO NOT EDIT.
1072
1073cc_prebuilt_library_headers {
1074 name: "mysdk_mynativeheaders@current",
1075 sdk_member_name: "mynativeheaders",
1076 export_include_dirs: ["include/include"],
1077 stl: "none",
1078 system_shared_libs: [],
1079}
1080
1081cc_prebuilt_library_headers {
1082 name: "mynativeheaders",
1083 prefer: false,
1084 export_include_dirs: ["include/include"],
1085 stl: "none",
1086 system_shared_libs: [],
1087}
1088
1089sdk_snapshot {
1090 name: "mysdk@current",
1091 native_header_libs: ["mysdk_mynativeheaders@current"],
1092}
1093`),
1094 checkAllCopyRules(`
1095include/Test.h -> include/include/Test.h
1096`),
1097 )
1098}
1099
1100func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
1101 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1102 SkipIfNotLinux(t)
1103
1104 result := testSdkWithCc(t, `
1105 sdk {
1106 name: "mysdk",
1107 device_supported: false,
1108 host_supported: true,
1109 native_header_libs: ["mynativeheaders"],
1110 }
1111
1112 cc_library_headers {
1113 name: "mynativeheaders",
1114 device_supported: false,
1115 host_supported: true,
1116 export_include_dirs: ["include"],
1117 system_shared_libs: [],
1118 stl: "none",
1119 }
1120 `)
1121
Paul Duffin1356d8c2020-02-25 19:26:33 +00001122 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001123 checkAndroidBpContents(`
1124// This is auto-generated. DO NOT EDIT.
1125
1126cc_prebuilt_library_headers {
1127 name: "mysdk_mynativeheaders@current",
1128 sdk_member_name: "mynativeheaders",
1129 device_supported: false,
1130 host_supported: true,
1131 export_include_dirs: ["include/include"],
1132 stl: "none",
1133 system_shared_libs: [],
1134}
1135
1136cc_prebuilt_library_headers {
1137 name: "mynativeheaders",
1138 prefer: false,
1139 device_supported: false,
1140 host_supported: true,
1141 export_include_dirs: ["include/include"],
1142 stl: "none",
1143 system_shared_libs: [],
1144}
1145
1146sdk_snapshot {
1147 name: "mysdk@current",
1148 device_supported: false,
1149 host_supported: true,
1150 native_header_libs: ["mysdk_mynativeheaders@current"],
1151}
1152`),
1153 checkAllCopyRules(`
1154include/Test.h -> include/include/Test.h
1155`),
1156 )
1157}
Paul Duffina04c1072020-03-02 10:16:35 +00001158
1159func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
1160 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1161 SkipIfNotLinux(t)
1162
1163 result := testSdkWithCc(t, `
1164 sdk {
1165 name: "mysdk",
1166 host_supported: true,
1167 native_header_libs: ["mynativeheaders"],
1168 }
1169
1170 cc_library_headers {
1171 name: "mynativeheaders",
1172 host_supported: true,
1173 system_shared_libs: [],
1174 stl: "none",
1175 export_system_include_dirs: ["include"],
1176 target: {
1177 android: {
1178 export_include_dirs: ["include-android"],
1179 },
1180 host: {
1181 export_include_dirs: ["include-host"],
1182 },
1183 },
1184 }
1185 `)
1186
1187 result.CheckSnapshot("mysdk", "",
1188 checkAndroidBpContents(`
1189// This is auto-generated. DO NOT EDIT.
1190
1191cc_prebuilt_library_headers {
1192 name: "mysdk_mynativeheaders@current",
1193 sdk_member_name: "mynativeheaders",
1194 host_supported: true,
1195 export_system_include_dirs: ["include/include"],
1196 target: {
1197 android: {
1198 export_include_dirs: ["include/include-android"],
1199 },
1200 linux_glibc: {
1201 export_include_dirs: ["include/include-host"],
1202 },
1203 },
1204 stl: "none",
1205 system_shared_libs: [],
1206}
1207
1208cc_prebuilt_library_headers {
1209 name: "mynativeheaders",
1210 prefer: false,
1211 host_supported: true,
1212 export_system_include_dirs: ["include/include"],
1213 target: {
1214 android: {
1215 export_include_dirs: ["include/include-android"],
1216 },
1217 linux_glibc: {
1218 export_include_dirs: ["include/include-host"],
1219 },
1220 },
1221 stl: "none",
1222 system_shared_libs: [],
1223}
1224
1225sdk_snapshot {
1226 name: "mysdk@current",
1227 host_supported: true,
1228 native_header_libs: ["mysdk_mynativeheaders@current"],
1229}
1230`),
1231 checkAllCopyRules(`
1232include/Test.h -> include/include/Test.h
1233include-android/AndroidTest.h -> include/include-android/AndroidTest.h
1234include-host/HostTest.h -> include/include-host/HostTest.h
1235`),
1236 )
1237}