blob: 2b0fd3c93ca0fcc1516c7de5c4a76c1e909403c7 [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",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000300 installable: false,
Paul Duffina7cd8c82019-12-11 20:00:57 +0000301 export_include_dirs: ["include/include"],
302 arch: {
303 arm64: {
304 srcs: ["arm64/lib/mynativelib.so"],
305 export_system_include_dirs: ["arm64/include/arm64/include"],
306 },
307 arm: {
308 srcs: ["arm/lib/mynativelib.so"],
309 },
310 },
311 stl: "none",
312 system_shared_libs: [],
313}
314
315cc_prebuilt_library_shared {
316 name: "mynativelib",
317 prefer: false,
318 export_include_dirs: ["include/include"],
319 arch: {
320 arm64: {
321 srcs: ["arm64/lib/mynativelib.so"],
322 export_system_include_dirs: ["arm64/include/arm64/include"],
323 },
324 arm: {
325 srcs: ["arm/lib/mynativelib.so"],
326 },
327 },
328 stl: "none",
329 system_shared_libs: [],
330}
331
332sdk_snapshot {
333 name: "mysdk@current",
334 native_shared_libs: ["mysdk_mynativelib@current"],
335}
336`),
337 checkAllCopyRules(`
338include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800339.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000340arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800341.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000342 )
343}
344
Paul Duffin25ce04b2020-01-16 11:47:25 +0000345func TestSnapshotWithCcBinary(t *testing.T) {
346 result := testSdkWithCc(t, `
347 module_exports {
348 name: "mymodule_exports",
349 native_binaries: ["mynativebinary"],
350 }
351
352 cc_binary {
353 name: "mynativebinary",
354 srcs: [
355 "Test.cpp",
356 ],
357 compile_multilib: "both",
358 system_shared_libs: [],
359 stl: "none",
360 }
361 `)
362
Paul Duffin1356d8c2020-02-25 19:26:33 +0000363 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000364 checkAndroidBpContents(`
365// This is auto-generated. DO NOT EDIT.
366
367cc_prebuilt_binary {
368 name: "mymodule_exports_mynativebinary@current",
369 sdk_member_name: "mynativebinary",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000370 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000371 compile_multilib: "both",
372 arch: {
373 arm64: {
374 srcs: ["arm64/bin/mynativebinary"],
375 },
376 arm: {
377 srcs: ["arm/bin/mynativebinary"],
378 },
379 },
380}
381
382cc_prebuilt_binary {
383 name: "mynativebinary",
384 prefer: false,
385 compile_multilib: "both",
386 arch: {
387 arm64: {
388 srcs: ["arm64/bin/mynativebinary"],
389 },
390 arm: {
391 srcs: ["arm/bin/mynativebinary"],
392 },
393 },
394}
395
396module_exports_snapshot {
397 name: "mymodule_exports@current",
398 native_binaries: ["mymodule_exports_mynativebinary@current"],
399}
400`),
401 checkAllCopyRules(`
402.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
403.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
404`),
405 )
406}
407
Paul Duffina04c1072020-03-02 10:16:35 +0000408func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
409 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
410 SkipIfNotLinux(t)
411
412 result := testSdkWithCc(t, `
413 module_exports {
414 name: "myexports",
415 device_supported: false,
416 host_supported: true,
417 native_binaries: ["mynativebinary"],
418 target: {
419 windows: {
420 enabled: true,
421 },
422 },
423 }
424
425 cc_binary {
426 name: "mynativebinary",
427 device_supported: false,
428 host_supported: true,
429 srcs: [
430 "Test.cpp",
431 ],
432 compile_multilib: "both",
433 system_shared_libs: [],
434 stl: "none",
435 target: {
436 windows: {
437 enabled: true,
438 },
439 },
440 }
441 `)
442
443 result.CheckSnapshot("myexports", "",
444 checkAndroidBpContents(`
445// This is auto-generated. DO NOT EDIT.
446
447cc_prebuilt_binary {
448 name: "myexports_mynativebinary@current",
449 sdk_member_name: "mynativebinary",
450 device_supported: false,
451 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000452 installable: false,
Paul Duffina04c1072020-03-02 10:16:35 +0000453 target: {
454 linux_glibc: {
455 compile_multilib: "both",
456 },
457 linux_glibc_x86_64: {
458 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
459 },
460 linux_glibc_x86: {
461 srcs: ["linux_glibc/x86/bin/mynativebinary"],
462 },
463 windows: {
464 compile_multilib: "64",
465 },
466 windows_x86_64: {
467 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
468 },
469 },
470}
471
472cc_prebuilt_binary {
473 name: "mynativebinary",
474 prefer: false,
475 device_supported: false,
476 host_supported: true,
477 target: {
478 linux_glibc: {
479 compile_multilib: "both",
480 },
481 linux_glibc_x86_64: {
482 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
483 },
484 linux_glibc_x86: {
485 srcs: ["linux_glibc/x86/bin/mynativebinary"],
486 },
487 windows: {
488 compile_multilib: "64",
489 },
490 windows_x86_64: {
491 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
492 },
493 },
494}
495
496module_exports_snapshot {
497 name: "myexports@current",
498 device_supported: false,
499 host_supported: true,
500 native_binaries: ["myexports_mynativebinary@current"],
501}
502`),
503 checkAllCopyRules(`
504.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
505.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
506.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
507`),
508 )
509}
510
Paul Duffin9ab556f2019-12-11 18:42:17 +0000511func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000512 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000513 sdk {
514 name: "mysdk",
515 native_shared_libs: ["mynativelib"],
516 }
517
518 cc_library_shared {
519 name: "mynativelib",
520 srcs: [
521 "Test.cpp",
522 "aidl/foo/bar/Test.aidl",
523 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +0000524 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000525 export_include_dirs: ["include"],
526 aidl: {
527 export_aidl_headers: true,
528 },
529 system_shared_libs: [],
530 stl: "none",
531 }
532 `)
533
Paul Duffin1356d8c2020-02-25 19:26:33 +0000534 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000535 checkAndroidBpContents(`
536// This is auto-generated. DO NOT EDIT.
537
538cc_prebuilt_library_shared {
539 name: "mysdk_mynativelib@current",
540 sdk_member_name: "mynativelib",
Paul Duffinbefa4b92020-03-04 14:22:45 +0000541 apex_available: [
542 "apex1",
543 "apex2",
544 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000545 installable: false,
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000546 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000547 arch: {
548 arm64: {
549 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000550 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000551 },
552 arm: {
553 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000554 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000555 },
556 },
557 stl: "none",
558 system_shared_libs: [],
559}
560
561cc_prebuilt_library_shared {
562 name: "mynativelib",
563 prefer: false,
Paul Duffinbefa4b92020-03-04 14:22:45 +0000564 apex_available: [
565 "apex1",
566 "apex2",
567 ],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000568 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000569 arch: {
570 arm64: {
571 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000572 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000573 },
574 arm: {
575 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000576 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000577 },
578 },
579 stl: "none",
580 system_shared_libs: [],
581}
582
583sdk_snapshot {
584 name: "mysdk@current",
585 native_shared_libs: ["mysdk_mynativelib@current"],
586}
587`),
588 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000589include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800590.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
591.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
592.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
593.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
594.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
595.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
596.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
597.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 +0000598`),
599 )
600}
601
Paul Duffin9ab556f2019-12-11 18:42:17 +0000602func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina80fdec2019-12-03 15:25:00 +0000603 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
604 SkipIfNotLinux(t)
605
Paul Duffind835daa2019-11-30 17:49:09 +0000606 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000607 sdk {
608 name: "mysdk",
609 device_supported: false,
610 host_supported: true,
611 native_shared_libs: ["mynativelib"],
612 }
613
614 cc_library_shared {
615 name: "mynativelib",
616 device_supported: false,
617 host_supported: true,
618 srcs: [
619 "Test.cpp",
620 "aidl/foo/bar/Test.aidl",
621 ],
622 export_include_dirs: ["include"],
623 aidl: {
624 export_aidl_headers: true,
625 },
626 system_shared_libs: [],
627 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +0000628 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +0000629 }
630 `)
631
Paul Duffin1356d8c2020-02-25 19:26:33 +0000632 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +0000633 checkAndroidBpContents(`
634// This is auto-generated. DO NOT EDIT.
635
636cc_prebuilt_library_shared {
637 name: "mysdk_mynativelib@current",
638 sdk_member_name: "mynativelib",
639 device_supported: false,
640 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000641 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +0000642 sdk_version: "minimum",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000643 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000644 arch: {
645 x86_64: {
646 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000647 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000648 },
649 x86: {
650 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000651 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000652 },
653 },
654 stl: "none",
655 system_shared_libs: [],
656}
657
658cc_prebuilt_library_shared {
659 name: "mynativelib",
660 prefer: false,
661 device_supported: false,
662 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +0000663 sdk_version: "minimum",
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000664 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000665 arch: {
666 x86_64: {
667 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000668 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000669 },
670 x86: {
671 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000672 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000673 },
674 },
675 stl: "none",
676 system_shared_libs: [],
677}
678
679sdk_snapshot {
680 name: "mysdk@current",
681 device_supported: false,
682 host_supported: true,
683 native_shared_libs: ["mysdk_mynativelib@current"],
684}
685`),
686 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000687include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +0000688.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +0000689.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
690.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
691.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
692.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +0000693.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
694.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
695.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
696`),
697 )
698}
Paul Duffin9ab556f2019-12-11 18:42:17 +0000699
Paul Duffina04c1072020-03-02 10:16:35 +0000700func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
701 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
702 SkipIfNotLinux(t)
703
704 result := testSdkWithCc(t, `
705 sdk {
706 name: "mysdk",
707 device_supported: false,
708 host_supported: true,
709 native_shared_libs: ["mynativelib"],
710 target: {
711 windows: {
712 enabled: true,
713 },
714 },
715 }
716
717 cc_library_shared {
718 name: "mynativelib",
719 device_supported: false,
720 host_supported: true,
721 srcs: [
722 "Test.cpp",
723 ],
724 system_shared_libs: [],
725 stl: "none",
726 target: {
727 windows: {
728 enabled: true,
729 },
730 },
731 }
732 `)
733
734 result.CheckSnapshot("mysdk", "",
735 checkAndroidBpContents(`
736// This is auto-generated. DO NOT EDIT.
737
738cc_prebuilt_library_shared {
739 name: "mysdk_mynativelib@current",
740 sdk_member_name: "mynativelib",
741 device_supported: false,
742 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000743 installable: false,
Paul Duffina04c1072020-03-02 10:16:35 +0000744 target: {
745 linux_glibc_x86_64: {
746 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
747 },
748 linux_glibc_x86: {
749 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
750 },
751 windows_x86_64: {
752 srcs: ["windows/x86_64/lib/mynativelib.dll"],
753 },
754 },
755 stl: "none",
756 system_shared_libs: [],
757}
758
759cc_prebuilt_library_shared {
760 name: "mynativelib",
761 prefer: false,
762 device_supported: false,
763 host_supported: true,
764 target: {
765 linux_glibc_x86_64: {
766 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
767 },
768 linux_glibc_x86: {
769 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
770 },
771 windows_x86_64: {
772 srcs: ["windows/x86_64/lib/mynativelib.dll"],
773 },
774 },
775 stl: "none",
776 system_shared_libs: [],
777}
778
779sdk_snapshot {
780 name: "mysdk@current",
781 device_supported: false,
782 host_supported: true,
783 native_shared_libs: ["mysdk_mynativelib@current"],
784}
785`),
786 checkAllCopyRules(`
787.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
788.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
789.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
790`),
791 )
792}
793
Paul Duffin9ab556f2019-12-11 18:42:17 +0000794func TestSnapshotWithCcStaticLibrary(t *testing.T) {
795 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +0000796 module_exports {
797 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000798 native_static_libs: ["mynativelib"],
799 }
800
801 cc_library_static {
802 name: "mynativelib",
803 srcs: [
804 "Test.cpp",
805 "aidl/foo/bar/Test.aidl",
806 ],
807 export_include_dirs: ["include"],
808 aidl: {
809 export_aidl_headers: true,
810 },
811 system_shared_libs: [],
812 stl: "none",
813 }
814 `)
815
Paul Duffin1356d8c2020-02-25 19:26:33 +0000816 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000817 checkAndroidBpContents(`
818// This is auto-generated. DO NOT EDIT.
819
820cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +0000821 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000822 sdk_member_name: "mynativelib",
Paul Duffin0cb37b92020-03-04 14:52:46 +0000823 installable: false,
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000824 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000825 arch: {
826 arm64: {
827 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000828 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000829 },
830 arm: {
831 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000832 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000833 },
834 },
835 stl: "none",
836 system_shared_libs: [],
837}
838
839cc_prebuilt_library_static {
840 name: "mynativelib",
841 prefer: false,
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000842 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000843 arch: {
844 arm64: {
845 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000846 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000847 },
848 arm: {
849 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000850 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000851 },
852 },
853 stl: "none",
854 system_shared_libs: [],
855}
856
Paul Duffine6029182019-12-16 17:43:48 +0000857module_exports_snapshot {
858 name: "myexports@current",
859 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000860}
861`),
862 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000863include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800864.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
865.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
866.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
867.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
868.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
869.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
870.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
871.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 +0000872`),
873 )
874}
875
876func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
877 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
878 SkipIfNotLinux(t)
879
880 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +0000881 module_exports {
882 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000883 device_supported: false,
884 host_supported: true,
885 native_static_libs: ["mynativelib"],
886 }
887
888 cc_library_static {
889 name: "mynativelib",
890 device_supported: false,
891 host_supported: true,
892 srcs: [
893 "Test.cpp",
894 "aidl/foo/bar/Test.aidl",
895 ],
896 export_include_dirs: ["include"],
897 aidl: {
898 export_aidl_headers: true,
899 },
900 system_shared_libs: [],
901 stl: "none",
902 }
903 `)
904
Paul Duffin1356d8c2020-02-25 19:26:33 +0000905 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000906 checkAndroidBpContents(`
907// This is auto-generated. DO NOT EDIT.
908
909cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +0000910 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000911 sdk_member_name: "mynativelib",
912 device_supported: false,
913 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000914 installable: false,
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000915 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000916 arch: {
917 x86_64: {
918 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000919 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000920 },
921 x86: {
922 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000923 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000924 },
925 },
926 stl: "none",
927 system_shared_libs: [],
928}
929
930cc_prebuilt_library_static {
931 name: "mynativelib",
932 prefer: false,
933 device_supported: false,
934 host_supported: true,
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000935 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000936 arch: {
937 x86_64: {
938 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000939 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000940 },
941 x86: {
942 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000943 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000944 },
945 },
946 stl: "none",
947 system_shared_libs: [],
948}
949
Paul Duffine6029182019-12-16 17:43:48 +0000950module_exports_snapshot {
951 name: "myexports@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +0000952 device_supported: false,
953 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +0000954 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +0000955}
956`),
957 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +0000958include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +0000959.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +0000960.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
961.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
962.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
963.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +0000964.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
965.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
966.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
967`),
968 )
969}
Paul Duffin13ad94f2020-02-19 16:19:27 +0000970
971func TestHostSnapshotWithMultiLib64(t *testing.T) {
972 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
973 SkipIfNotLinux(t)
974
975 result := testSdkWithCc(t, `
976 module_exports {
977 name: "myexports",
978 device_supported: false,
979 host_supported: true,
980 target: {
981 host: {
982 compile_multilib: "64",
983 },
984 },
985 native_static_libs: ["mynativelib"],
986 }
987
988 cc_library_static {
989 name: "mynativelib",
990 device_supported: false,
991 host_supported: true,
992 srcs: [
993 "Test.cpp",
994 "aidl/foo/bar/Test.aidl",
995 ],
996 export_include_dirs: ["include"],
997 aidl: {
998 export_aidl_headers: true,
999 },
1000 system_shared_libs: [],
1001 stl: "none",
1002 }
1003 `)
1004
Paul Duffin1356d8c2020-02-25 19:26:33 +00001005 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001006 checkAndroidBpContents(`
1007// This is auto-generated. DO NOT EDIT.
1008
1009cc_prebuilt_library_static {
1010 name: "myexports_mynativelib@current",
1011 sdk_member_name: "mynativelib",
1012 device_supported: false,
1013 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001014 installable: false,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001015 export_include_dirs: ["include/include"],
1016 arch: {
1017 x86_64: {
1018 srcs: ["x86_64/lib/mynativelib.a"],
1019 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1020 },
1021 },
1022 stl: "none",
1023 system_shared_libs: [],
1024}
1025
1026cc_prebuilt_library_static {
1027 name: "mynativelib",
1028 prefer: false,
1029 device_supported: false,
1030 host_supported: true,
1031 export_include_dirs: ["include/include"],
1032 arch: {
1033 x86_64: {
1034 srcs: ["x86_64/lib/mynativelib.a"],
1035 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1036 },
1037 },
1038 stl: "none",
1039 system_shared_libs: [],
1040}
1041
1042module_exports_snapshot {
1043 name: "myexports@current",
1044 device_supported: false,
1045 host_supported: true,
1046 target: {
1047 host: {
1048 compile_multilib: "64",
1049 },
1050 },
1051 native_static_libs: ["myexports_mynativelib@current"],
1052}`),
1053 checkAllCopyRules(`
1054include/Test.h -> include/include/Test.h
1055.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1056.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1057.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1058.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1059`),
1060 )
1061}
Paul Duffin91756d22020-02-21 16:29:57 +00001062
1063func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1064 result := testSdkWithCc(t, `
1065 sdk {
1066 name: "mysdk",
1067 native_header_libs: ["mynativeheaders"],
1068 }
1069
1070 cc_library_headers {
1071 name: "mynativeheaders",
1072 export_include_dirs: ["include"],
1073 system_shared_libs: [],
1074 stl: "none",
1075 }
1076 `)
1077
Paul Duffin1356d8c2020-02-25 19:26:33 +00001078 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001079 checkAndroidBpContents(`
1080// This is auto-generated. DO NOT EDIT.
1081
1082cc_prebuilt_library_headers {
1083 name: "mysdk_mynativeheaders@current",
1084 sdk_member_name: "mynativeheaders",
1085 export_include_dirs: ["include/include"],
1086 stl: "none",
1087 system_shared_libs: [],
1088}
1089
1090cc_prebuilt_library_headers {
1091 name: "mynativeheaders",
1092 prefer: false,
1093 export_include_dirs: ["include/include"],
1094 stl: "none",
1095 system_shared_libs: [],
1096}
1097
1098sdk_snapshot {
1099 name: "mysdk@current",
1100 native_header_libs: ["mysdk_mynativeheaders@current"],
1101}
1102`),
1103 checkAllCopyRules(`
1104include/Test.h -> include/include/Test.h
1105`),
1106 )
1107}
1108
1109func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
1110 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1111 SkipIfNotLinux(t)
1112
1113 result := testSdkWithCc(t, `
1114 sdk {
1115 name: "mysdk",
1116 device_supported: false,
1117 host_supported: true,
1118 native_header_libs: ["mynativeheaders"],
1119 }
1120
1121 cc_library_headers {
1122 name: "mynativeheaders",
1123 device_supported: false,
1124 host_supported: true,
1125 export_include_dirs: ["include"],
1126 system_shared_libs: [],
1127 stl: "none",
1128 }
1129 `)
1130
Paul Duffin1356d8c2020-02-25 19:26:33 +00001131 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001132 checkAndroidBpContents(`
1133// This is auto-generated. DO NOT EDIT.
1134
1135cc_prebuilt_library_headers {
1136 name: "mysdk_mynativeheaders@current",
1137 sdk_member_name: "mynativeheaders",
1138 device_supported: false,
1139 host_supported: true,
1140 export_include_dirs: ["include/include"],
1141 stl: "none",
1142 system_shared_libs: [],
1143}
1144
1145cc_prebuilt_library_headers {
1146 name: "mynativeheaders",
1147 prefer: false,
1148 device_supported: false,
1149 host_supported: true,
1150 export_include_dirs: ["include/include"],
1151 stl: "none",
1152 system_shared_libs: [],
1153}
1154
1155sdk_snapshot {
1156 name: "mysdk@current",
1157 device_supported: false,
1158 host_supported: true,
1159 native_header_libs: ["mysdk_mynativeheaders@current"],
1160}
1161`),
1162 checkAllCopyRules(`
1163include/Test.h -> include/include/Test.h
1164`),
1165 )
1166}
Paul Duffina04c1072020-03-02 10:16:35 +00001167
1168func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
1169 // b/145598135 - Generating host snapshots for anything other than linux is not supported.
1170 SkipIfNotLinux(t)
1171
1172 result := testSdkWithCc(t, `
1173 sdk {
1174 name: "mysdk",
1175 host_supported: true,
1176 native_header_libs: ["mynativeheaders"],
1177 }
1178
1179 cc_library_headers {
1180 name: "mynativeheaders",
1181 host_supported: true,
1182 system_shared_libs: [],
1183 stl: "none",
1184 export_system_include_dirs: ["include"],
1185 target: {
1186 android: {
1187 export_include_dirs: ["include-android"],
1188 },
1189 host: {
1190 export_include_dirs: ["include-host"],
1191 },
1192 },
1193 }
1194 `)
1195
1196 result.CheckSnapshot("mysdk", "",
1197 checkAndroidBpContents(`
1198// This is auto-generated. DO NOT EDIT.
1199
1200cc_prebuilt_library_headers {
1201 name: "mysdk_mynativeheaders@current",
1202 sdk_member_name: "mynativeheaders",
1203 host_supported: true,
1204 export_system_include_dirs: ["include/include"],
1205 target: {
1206 android: {
1207 export_include_dirs: ["include/include-android"],
1208 },
1209 linux_glibc: {
1210 export_include_dirs: ["include/include-host"],
1211 },
1212 },
1213 stl: "none",
1214 system_shared_libs: [],
1215}
1216
1217cc_prebuilt_library_headers {
1218 name: "mynativeheaders",
1219 prefer: false,
1220 host_supported: true,
1221 export_system_include_dirs: ["include/include"],
1222 target: {
1223 android: {
1224 export_include_dirs: ["include/include-android"],
1225 },
1226 linux_glibc: {
1227 export_include_dirs: ["include/include-host"],
1228 },
1229 },
1230 stl: "none",
1231 system_shared_libs: [],
1232}
1233
1234sdk_snapshot {
1235 name: "mysdk@current",
1236 host_supported: true,
1237 native_header_libs: ["mysdk_mynativeheaders@current"],
1238}
1239`),
1240 checkAllCopyRules(`
1241include/Test.h -> include/include/Test.h
1242include-android/AndroidTest.h -> include/include-android/AndroidTest.h
1243include-host/HostTest.h -> include/include-host/HostTest.h
1244`),
1245 )
1246}