blob: c1813ecd016630899a1b5a096813e72fb2efaaa0 [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",
Paul Duffind99d9972020-09-29 16:00:55 +0100111 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100112 host_supported: true,
113 installable: false,
114 stl: "none",
115 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100116 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100117 host: {
118 enabled: false,
119 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100120 android_arm64: {
121 srcs: ["android/arm64/lib/sdkmember.so"],
122 },
123 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900124 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100125 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100126 },
127 },
128}
129
130cc_prebuilt_library_shared {
131 name: "sdkmember",
132 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100133 visibility: ["//visibility:public"],
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 },
144 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900145 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100146 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100147 },
148 },
149}
150
151sdk_snapshot {
152 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100153 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100154 host_supported: true,
155 native_shared_libs: ["mysdk_sdkmember@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100156 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100157 target: {
158 host: {
159 enabled: false,
160 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900161 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100162 enabled: true,
163 },
164 },
Martin Stjernholm89238f42020-07-10 00:14:03 +0100165}
166`),
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100167 checkAllCopyRules(`
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100168.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
169.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100170`))
171}
172
Paul Duffina80fdec2019-12-03 15:25:00 +0000173func TestBasicSdkWithCc(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000174 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000175 sdk {
176 name: "mysdk",
177 native_shared_libs: ["sdkmember"],
178 }
179
Paul Duffina0843f62019-12-13 19:50:38 +0000180 cc_library_shared {
181 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -0800182 system_shared_libs: [],
Martin Stjernholmcc776012020-07-07 03:22:21 +0100183 stl: "none",
184 apex_available: ["mysdkapex"],
Paul Duffina0843f62019-12-13 19:50:38 +0000185 }
186
Paul Duffina80fdec2019-12-03 15:25:00 +0000187 sdk_snapshot {
188 name: "mysdk@1",
189 native_shared_libs: ["sdkmember_mysdk_1"],
190 }
191
192 sdk_snapshot {
193 name: "mysdk@2",
194 native_shared_libs: ["sdkmember_mysdk_2"],
195 }
196
197 cc_prebuilt_library_shared {
198 name: "sdkmember",
199 srcs: ["libfoo.so"],
200 prefer: false,
201 system_shared_libs: [],
202 stl: "none",
203 }
204
205 cc_prebuilt_library_shared {
206 name: "sdkmember_mysdk_1",
207 sdk_member_name: "sdkmember",
208 srcs: ["libfoo.so"],
209 system_shared_libs: [],
210 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000211 // TODO: remove //apex_available:platform
212 apex_available: [
213 "//apex_available:platform",
214 "myapex",
215 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000216 }
217
218 cc_prebuilt_library_shared {
219 name: "sdkmember_mysdk_2",
220 sdk_member_name: "sdkmember",
221 srcs: ["libfoo.so"],
222 system_shared_libs: [],
223 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000224 // TODO: remove //apex_available:platform
225 apex_available: [
226 "//apex_available:platform",
227 "myapex2",
228 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000229 }
230
231 cc_library_shared {
232 name: "mycpplib",
233 srcs: ["Test.cpp"],
234 shared_libs: ["sdkmember"],
235 system_shared_libs: [],
236 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000237 apex_available: [
238 "myapex",
239 "myapex2",
240 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000241 }
242
243 apex {
244 name: "myapex",
245 native_shared_libs: ["mycpplib"],
246 uses_sdks: ["mysdk@1"],
247 key: "myapex.key",
248 certificate: ":myapex.cert",
249 }
250
251 apex {
252 name: "myapex2",
253 native_shared_libs: ["mycpplib"],
254 uses_sdks: ["mysdk@2"],
255 key: "myapex.key",
256 certificate: ":myapex.cert",
257 }
Martin Stjernholmcc776012020-07-07 03:22:21 +0100258
259 apex {
260 name: "mysdkapex",
261 native_shared_libs: ["sdkmember"],
262 key: "myapex.key",
263 certificate: ":myapex.cert",
264 }
Paul Duffina80fdec2019-12-03 15:25:00 +0000265 `)
266
Colin Crossaede88c2020-08-11 12:17:01 -0700267 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
268 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000269
Colin Crossaede88c2020-08-11 12:17:01 -0700270 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1")
271 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000272
273 // Depending on the uses_sdks value, different libs are linked
274 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
275 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
276}
277
Paul Duffina0843f62019-12-13 19:50:38 +0000278// Make sure the sdk can use host specific cc libraries static/shared and both.
279func TestHostSdkWithCc(t *testing.T) {
280 testSdkWithCc(t, `
281 sdk {
282 name: "mysdk",
283 device_supported: false,
284 host_supported: true,
285 native_shared_libs: ["sdkshared"],
286 native_static_libs: ["sdkstatic"],
287 }
288
289 cc_library_host_shared {
290 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000291 stl: "none",
292 }
293
294 cc_library_host_static {
295 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000296 stl: "none",
297 }
298 `)
299}
300
301// Make sure the sdk can use cc libraries static/shared and both.
302func TestSdkWithCc(t *testing.T) {
303 testSdkWithCc(t, `
304 sdk {
305 name: "mysdk",
306 native_shared_libs: ["sdkshared", "sdkboth1"],
307 native_static_libs: ["sdkstatic", "sdkboth2"],
308 }
309
310 cc_library_shared {
311 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000312 stl: "none",
313 }
314
315 cc_library_static {
316 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000317 stl: "none",
318 }
319
320 cc_library {
321 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000322 stl: "none",
323 }
324
325 cc_library {
326 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000327 stl: "none",
328 }
329 `)
330}
331
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000332func TestSnapshotWithObject(t *testing.T) {
333 result := testSdkWithCc(t, `
334 sdk {
335 name: "mysdk",
336 native_objects: ["crtobj"],
337 }
338
339 cc_object {
340 name: "crtobj",
341 stl: "none",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100342 sanitize: {
343 never: true,
344 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000345 }
346 `)
347
348 result.CheckSnapshot("mysdk", "",
349 checkAndroidBpContents(`
350// This is auto-generated. DO NOT EDIT.
351
352cc_prebuilt_object {
353 name: "mysdk_crtobj@current",
354 sdk_member_name: "crtobj",
Paul Duffind99d9972020-09-29 16:00:55 +0100355 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000356 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100357 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100358 sanitize: {
359 never: true,
360 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000361 arch: {
362 arm64: {
363 srcs: ["arm64/lib/crtobj.o"],
364 },
365 arm: {
366 srcs: ["arm/lib/crtobj.o"],
367 },
368 },
369}
370
371cc_prebuilt_object {
372 name: "crtobj",
373 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100374 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000375 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100376 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100377 sanitize: {
378 never: true,
379 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000380 arch: {
381 arm64: {
382 srcs: ["arm64/lib/crtobj.o"],
383 },
384 arm: {
385 srcs: ["arm/lib/crtobj.o"],
386 },
387 },
388}
389
390sdk_snapshot {
391 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100392 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000393 native_objects: ["mysdk_crtobj@current"],
394}
395`),
396 checkAllCopyRules(`
397.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
398.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
399`),
400 )
401}
402
Paul Duffinc62a5102019-12-11 18:34:15 +0000403func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
404 result := testSdkWithCc(t, `
405 sdk {
406 name: "mysdk",
407 native_shared_libs: ["mynativelib1", "mynativelib2"],
408 }
409
410 cc_library_shared {
411 name: "mynativelib1",
412 srcs: [
413 "Test.cpp",
414 ],
415 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000416 stl: "none",
417 }
418
419 cc_library_shared {
420 name: "mynativelib2",
421 srcs: [
422 "Test.cpp",
423 ],
424 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000425 stl: "none",
426 }
427 `)
428
Paul Duffin1356d8c2020-02-25 19:26:33 +0000429 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000430 checkAllCopyRules(`
431include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800432.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
433.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
434.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
435.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000436`),
437 )
438}
439
Martin Stjernholmb0249572020-09-15 02:32:35 +0100440// Verify that when the shared library has some common and some arch specific
441// properties that the generated snapshot is optimized properly. Substruct
442// handling is tested with the sanitize clauses (but note there's a lot of
443// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000444func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
445 result := testSdkWithCc(t, `
446 sdk {
447 name: "mysdk",
448 native_shared_libs: ["mynativelib"],
449 }
450
451 cc_library_shared {
452 name: "mynativelib",
453 srcs: [
454 "Test.cpp",
455 "aidl/foo/bar/Test.aidl",
456 ],
457 export_include_dirs: ["include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100458 sanitize: {
459 fuzzer: false,
460 integer_overflow: true,
461 diag: { undefined: false },
462 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000463 arch: {
464 arm64: {
465 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100466 sanitize: {
467 hwaddress: true,
468 integer_overflow: false,
469 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000470 },
471 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000472 stl: "none",
473 }
474 `)
475
Paul Duffin1356d8c2020-02-25 19:26:33 +0000476 result.CheckSnapshot("mysdk", "",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000477 checkAndroidBpContents(`
478// This is auto-generated. DO NOT EDIT.
479
480cc_prebuilt_library_shared {
481 name: "mysdk_mynativelib@current",
482 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100483 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000484 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000485 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100486 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000487 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100488 sanitize: {
489 fuzzer: false,
490 diag: {
491 undefined: false,
492 },
493 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000494 arch: {
495 arm64: {
496 srcs: ["arm64/lib/mynativelib.so"],
497 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100498 sanitize: {
499 hwaddress: true,
500 integer_overflow: false,
501 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000502 },
503 arm: {
504 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100505 sanitize: {
506 integer_overflow: true,
507 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000508 },
509 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000510}
511
512cc_prebuilt_library_shared {
513 name: "mynativelib",
514 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100515 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000516 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100517 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000518 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100519 sanitize: {
520 fuzzer: false,
521 diag: {
522 undefined: false,
523 },
524 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000525 arch: {
526 arm64: {
527 srcs: ["arm64/lib/mynativelib.so"],
528 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100529 sanitize: {
530 hwaddress: true,
531 integer_overflow: false,
532 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000533 },
534 arm: {
535 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100536 sanitize: {
537 integer_overflow: true,
538 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000539 },
540 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000541}
542
543sdk_snapshot {
544 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100545 visibility: ["//visibility:public"],
Paul Duffina7cd8c82019-12-11 20:00:57 +0000546 native_shared_libs: ["mysdk_mynativelib@current"],
547}
548`),
549 checkAllCopyRules(`
550include/Test.h -> include/include/Test.h
Martin Stjernholmb0249572020-09-15 02:32:35 +0100551.intermediates/mynativelib/android_arm64_armv8-a_shared_hwasan/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000552arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800553.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000554 )
555}
556
Paul Duffin25ce04b2020-01-16 11:47:25 +0000557func TestSnapshotWithCcBinary(t *testing.T) {
558 result := testSdkWithCc(t, `
559 module_exports {
560 name: "mymodule_exports",
561 native_binaries: ["mynativebinary"],
562 }
563
564 cc_binary {
565 name: "mynativebinary",
566 srcs: [
567 "Test.cpp",
568 ],
569 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000570 }
571 `)
572
Paul Duffin1356d8c2020-02-25 19:26:33 +0000573 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000574 checkAndroidBpContents(`
575// This is auto-generated. DO NOT EDIT.
576
577cc_prebuilt_binary {
578 name: "mymodule_exports_mynativebinary@current",
579 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100580 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000581 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000582 compile_multilib: "both",
583 arch: {
584 arm64: {
585 srcs: ["arm64/bin/mynativebinary"],
586 },
587 arm: {
588 srcs: ["arm/bin/mynativebinary"],
589 },
590 },
591}
592
593cc_prebuilt_binary {
594 name: "mynativebinary",
595 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100596 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000597 compile_multilib: "both",
598 arch: {
599 arm64: {
600 srcs: ["arm64/bin/mynativebinary"],
601 },
602 arm: {
603 srcs: ["arm/bin/mynativebinary"],
604 },
605 },
606}
607
608module_exports_snapshot {
609 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100610 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000611 native_binaries: ["mymodule_exports_mynativebinary@current"],
612}
613`),
614 checkAllCopyRules(`
615.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
616.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
617`),
618 )
619}
620
Paul Duffina04c1072020-03-02 10:16:35 +0000621func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000622 result := testSdkWithCc(t, `
623 module_exports {
624 name: "myexports",
625 device_supported: false,
626 host_supported: true,
627 native_binaries: ["mynativebinary"],
628 target: {
629 windows: {
630 enabled: true,
631 },
632 },
633 }
634
635 cc_binary {
636 name: "mynativebinary",
637 device_supported: false,
638 host_supported: true,
639 srcs: [
640 "Test.cpp",
641 ],
642 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000643 stl: "none",
644 target: {
645 windows: {
646 enabled: true,
647 },
648 },
649 }
650 `)
651
652 result.CheckSnapshot("myexports", "",
653 checkAndroidBpContents(`
654// This is auto-generated. DO NOT EDIT.
655
656cc_prebuilt_binary {
657 name: "myexports_mynativebinary@current",
658 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100659 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000660 device_supported: false,
661 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000662 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100663 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000664 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100665 host: {
666 enabled: false,
667 },
Paul Duffina04c1072020-03-02 10:16:35 +0000668 linux_glibc: {
669 compile_multilib: "both",
670 },
671 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900672 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000673 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
674 },
675 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900676 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000677 srcs: ["linux_glibc/x86/bin/mynativebinary"],
678 },
679 windows: {
680 compile_multilib: "64",
681 },
682 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900683 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000684 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
685 },
686 },
687}
688
689cc_prebuilt_binary {
690 name: "mynativebinary",
691 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100692 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000693 device_supported: false,
694 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100695 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000696 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100697 host: {
698 enabled: false,
699 },
Paul Duffina04c1072020-03-02 10:16:35 +0000700 linux_glibc: {
701 compile_multilib: "both",
702 },
703 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900704 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000705 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
706 },
707 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900708 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000709 srcs: ["linux_glibc/x86/bin/mynativebinary"],
710 },
711 windows: {
712 compile_multilib: "64",
713 },
714 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900715 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000716 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
717 },
718 },
719}
720
721module_exports_snapshot {
722 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100723 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000724 device_supported: false,
725 host_supported: true,
726 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000727 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900728 windows: {
729 compile_multilib: "64",
730 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100731 host: {
732 enabled: false,
733 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900734 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100735 enabled: true,
736 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900737 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100738 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +0900739 },
740 windows_x86_64: {
741 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000742 },
743 },
Paul Duffina04c1072020-03-02 10:16:35 +0000744}
745`),
746 checkAllCopyRules(`
747.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
748.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
749.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
750`),
751 )
752}
753
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100754func TestSnapshotWithSingleHostOsType(t *testing.T) {
755 ctx, config := testSdkContext(`
756 cc_defaults {
757 name: "mydefaults",
758 device_supported: false,
759 host_supported: true,
760 compile_multilib: "64",
761 target: {
762 host: {
763 enabled: false,
764 },
765 linux_bionic: {
766 enabled: true,
767 },
768 },
769 }
770
771 module_exports {
772 name: "myexports",
773 defaults: ["mydefaults"],
774 native_shared_libs: ["mynativelib"],
775 native_binaries: ["mynativebinary"],
776 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
777 }
778
779 cc_library {
780 name: "mynativelib",
781 defaults: ["mydefaults"],
782 srcs: [
783 "Test.cpp",
784 ],
785 stl: "none",
786 }
787
788 cc_binary {
789 name: "mynativebinary",
790 defaults: ["mydefaults"],
791 srcs: [
792 "Test.cpp",
793 ],
794 stl: "none",
795 }
796 `, ccTestFs, []android.OsType{android.LinuxBionic})
797
798 result := runTests(t, ctx, config)
799
800 result.CheckSnapshot("myexports", "",
801 checkAndroidBpContents(`
802// This is auto-generated. DO NOT EDIT.
803
804cc_prebuilt_binary {
805 name: "myexports_mynativebinary@current",
806 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100807 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100808 device_supported: false,
809 host_supported: true,
810 installable: false,
811 stl: "none",
812 compile_multilib: "64",
813 target: {
814 host: {
815 enabled: false,
816 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100817 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900818 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100819 srcs: ["x86_64/bin/mynativebinary"],
820 },
821 },
822}
823
824cc_prebuilt_binary {
825 name: "mynativebinary",
826 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100827 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100828 device_supported: false,
829 host_supported: true,
830 stl: "none",
831 compile_multilib: "64",
832 target: {
833 host: {
834 enabled: false,
835 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100836 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900837 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100838 srcs: ["x86_64/bin/mynativebinary"],
839 },
840 },
841}
842
843cc_prebuilt_library_shared {
844 name: "myexports_mynativelib@current",
845 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100846 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100847 device_supported: false,
848 host_supported: true,
849 installable: false,
850 stl: "none",
851 compile_multilib: "64",
852 target: {
853 host: {
854 enabled: false,
855 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100856 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900857 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100858 srcs: ["x86_64/lib/mynativelib.so"],
859 },
860 },
861}
862
863cc_prebuilt_library_shared {
864 name: "mynativelib",
865 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100866 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100867 device_supported: false,
868 host_supported: true,
869 stl: "none",
870 compile_multilib: "64",
871 target: {
872 host: {
873 enabled: false,
874 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100875 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900876 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100877 srcs: ["x86_64/lib/mynativelib.so"],
878 },
879 },
880}
881
882module_exports_snapshot {
883 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100884 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100885 device_supported: false,
886 host_supported: true,
887 native_binaries: ["myexports_mynativebinary@current"],
888 native_shared_libs: ["myexports_mynativelib@current"],
889 compile_multilib: "64",
890 target: {
891 host: {
892 enabled: false,
893 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900894 linux_bionic_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100895 enabled: true,
896 },
897 },
898}
899`),
900 checkAllCopyRules(`
901.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
902.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
903`),
904 )
905}
906
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100907// Test that we support the necessary flags for the linker binary, which is
908// special in several ways.
909func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100910 result := testSdkWithCc(t, `
911 module_exports {
912 name: "mymodule_exports",
913 host_supported: true,
914 device_supported: false,
915 native_binaries: ["linker"],
916 }
917
918 cc_binary {
919 name: "linker",
920 host_supported: true,
921 static_executable: true,
922 nocrt: true,
923 stl: "none",
924 srcs: [
925 "Test.cpp",
926 ],
927 compile_multilib: "both",
928 }
929 `)
930
931 result.CheckSnapshot("mymodule_exports", "",
932 checkAndroidBpContents(`
933// This is auto-generated. DO NOT EDIT.
934
935cc_prebuilt_binary {
936 name: "mymodule_exports_linker@current",
937 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +0100938 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100939 device_supported: false,
940 host_supported: true,
941 installable: false,
942 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100943 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100944 static_executable: true,
945 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100946 target: {
947 host: {
948 enabled: false,
949 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100950 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900951 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100952 srcs: ["x86_64/bin/linker"],
953 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100954 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900955 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100956 srcs: ["x86/bin/linker"],
957 },
958 },
959}
960
961cc_prebuilt_binary {
962 name: "linker",
963 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100964 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100965 device_supported: false,
966 host_supported: true,
967 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100968 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100969 static_executable: true,
970 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100971 target: {
972 host: {
973 enabled: false,
974 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100975 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900976 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100977 srcs: ["x86_64/bin/linker"],
978 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100979 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900980 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100981 srcs: ["x86/bin/linker"],
982 },
983 },
984}
985
986module_exports_snapshot {
987 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100988 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100989 device_supported: false,
990 host_supported: true,
991 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100992 target: {
993 host: {
994 enabled: false,
995 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900996 linux_glibc_x86_64: {
997 enabled: true,
998 },
999 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001000 enabled: true,
1001 },
1002 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001003}
1004`),
1005 checkAllCopyRules(`
1006.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1007.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1008`),
1009 )
1010}
1011
Paul Duffin9ab556f2019-12-11 18:42:17 +00001012func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001013 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001014 sdk {
1015 name: "mysdk",
1016 native_shared_libs: ["mynativelib"],
1017 }
1018
1019 cc_library_shared {
1020 name: "mynativelib",
1021 srcs: [
1022 "Test.cpp",
1023 "aidl/foo/bar/Test.aidl",
1024 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001025 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001026 export_include_dirs: ["include"],
1027 aidl: {
1028 export_aidl_headers: true,
1029 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001030 stl: "none",
1031 }
1032 `)
1033
Paul Duffin1356d8c2020-02-25 19:26:33 +00001034 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001035 checkAndroidBpContents(`
1036// This is auto-generated. DO NOT EDIT.
1037
1038cc_prebuilt_library_shared {
1039 name: "mysdk_mynativelib@current",
1040 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001041 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001042 apex_available: [
1043 "apex1",
1044 "apex2",
1045 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001046 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001047 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001048 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001049 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001050 arch: {
1051 arm64: {
1052 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001053 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001054 },
1055 arm: {
1056 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001057 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001058 },
1059 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001060}
1061
1062cc_prebuilt_library_shared {
1063 name: "mynativelib",
1064 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001065 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001066 apex_available: [
1067 "apex1",
1068 "apex2",
1069 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001070 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001071 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001072 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001073 arch: {
1074 arm64: {
1075 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001076 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001077 },
1078 arm: {
1079 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001080 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001081 },
1082 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001083}
1084
1085sdk_snapshot {
1086 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001087 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001088 native_shared_libs: ["mysdk_mynativelib@current"],
1089}
1090`),
1091 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001092include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001093.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1094.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1095.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1096.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1097.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1098.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1099.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1100.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 +00001101`),
1102 )
1103}
1104
Paul Duffin13f02712020-03-06 12:30:43 +00001105func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1106 result := testSdkWithCc(t, `
1107 sdk {
1108 name: "mysdk",
1109 native_shared_libs: [
1110 "mynativelib",
1111 "myothernativelib",
1112 "mysystemnativelib",
1113 ],
1114 }
1115
1116 cc_library {
1117 name: "mysystemnativelib",
1118 srcs: [
1119 "Test.cpp",
1120 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001121 stl: "none",
1122 }
1123
1124 cc_library_shared {
1125 name: "myothernativelib",
1126 srcs: [
1127 "Test.cpp",
1128 ],
1129 system_shared_libs: [
1130 // A reference to a library that is not an sdk member. Uses libm as that
1131 // is in the default set of modules available to this test and so is available
1132 // both here and also when the generated Android.bp file is tested in
1133 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1134 // handles references to modules that are not sdk members.
1135 "libm",
1136 ],
1137 stl: "none",
1138 }
1139
1140 cc_library {
1141 name: "mynativelib",
1142 srcs: [
1143 "Test.cpp",
1144 ],
1145 shared_libs: [
1146 // A reference to another sdk member.
1147 "myothernativelib",
1148 ],
1149 target: {
1150 android: {
1151 shared: {
1152 shared_libs: [
1153 // A reference to a library that is not an sdk member. The libc library
1154 // is used here to check that the shared_libs property is handled correctly
1155 // in a similar way to how libm is used to check system_shared_libs above.
1156 "libc",
1157 ],
1158 },
1159 },
1160 },
Paul Duffin13f02712020-03-06 12:30:43 +00001161 stl: "none",
1162 }
1163 `)
1164
1165 result.CheckSnapshot("mysdk", "",
1166 checkAndroidBpContents(`
1167// This is auto-generated. DO NOT EDIT.
1168
1169cc_prebuilt_library_shared {
1170 name: "mysdk_mynativelib@current",
1171 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001172 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001173 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001174 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001175 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001176 shared_libs: [
1177 "mysdk_myothernativelib@current",
1178 "libc",
1179 ],
1180 arch: {
1181 arm64: {
1182 srcs: ["arm64/lib/mynativelib.so"],
1183 },
1184 arm: {
1185 srcs: ["arm/lib/mynativelib.so"],
1186 },
1187 },
Paul Duffin13f02712020-03-06 12:30:43 +00001188}
1189
1190cc_prebuilt_library_shared {
1191 name: "mynativelib",
1192 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001193 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001194 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001195 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001196 shared_libs: [
1197 "myothernativelib",
1198 "libc",
1199 ],
1200 arch: {
1201 arm64: {
1202 srcs: ["arm64/lib/mynativelib.so"],
1203 },
1204 arm: {
1205 srcs: ["arm/lib/mynativelib.so"],
1206 },
1207 },
Paul Duffin13f02712020-03-06 12:30:43 +00001208}
1209
1210cc_prebuilt_library_shared {
1211 name: "mysdk_myothernativelib@current",
1212 sdk_member_name: "myothernativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001213 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001214 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001215 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001216 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001217 system_shared_libs: ["libm"],
1218 arch: {
1219 arm64: {
1220 srcs: ["arm64/lib/myothernativelib.so"],
1221 },
1222 arm: {
1223 srcs: ["arm/lib/myothernativelib.so"],
1224 },
1225 },
Paul Duffin13f02712020-03-06 12:30:43 +00001226}
1227
1228cc_prebuilt_library_shared {
1229 name: "myothernativelib",
1230 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001231 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001232 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001233 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001234 system_shared_libs: ["libm"],
1235 arch: {
1236 arm64: {
1237 srcs: ["arm64/lib/myothernativelib.so"],
1238 },
1239 arm: {
1240 srcs: ["arm/lib/myothernativelib.so"],
1241 },
1242 },
Paul Duffin13f02712020-03-06 12:30:43 +00001243}
1244
1245cc_prebuilt_library_shared {
1246 name: "mysdk_mysystemnativelib@current",
1247 sdk_member_name: "mysystemnativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001248 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001249 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001250 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001251 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001252 arch: {
1253 arm64: {
1254 srcs: ["arm64/lib/mysystemnativelib.so"],
1255 },
1256 arm: {
1257 srcs: ["arm/lib/mysystemnativelib.so"],
1258 },
1259 },
Paul Duffin13f02712020-03-06 12:30:43 +00001260}
1261
1262cc_prebuilt_library_shared {
1263 name: "mysystemnativelib",
1264 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001265 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001266 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001267 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001268 arch: {
1269 arm64: {
1270 srcs: ["arm64/lib/mysystemnativelib.so"],
1271 },
1272 arm: {
1273 srcs: ["arm/lib/mysystemnativelib.so"],
1274 },
1275 },
Paul Duffin13f02712020-03-06 12:30:43 +00001276}
1277
1278sdk_snapshot {
1279 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001280 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001281 native_shared_libs: [
1282 "mysdk_mynativelib@current",
1283 "mysdk_myothernativelib@current",
1284 "mysdk_mysystemnativelib@current",
1285 ],
1286}
1287`),
1288 checkAllCopyRules(`
1289.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1290.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1291.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1292.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1293.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1294.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1295`),
1296 )
1297}
1298
Paul Duffin9ab556f2019-12-11 18:42:17 +00001299func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001300 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001301 sdk {
1302 name: "mysdk",
1303 device_supported: false,
1304 host_supported: true,
1305 native_shared_libs: ["mynativelib"],
1306 }
1307
1308 cc_library_shared {
1309 name: "mynativelib",
1310 device_supported: false,
1311 host_supported: true,
1312 srcs: [
1313 "Test.cpp",
1314 "aidl/foo/bar/Test.aidl",
1315 ],
1316 export_include_dirs: ["include"],
1317 aidl: {
1318 export_aidl_headers: true,
1319 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001320 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001321 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001322 }
1323 `)
1324
Paul Duffin1356d8c2020-02-25 19:26:33 +00001325 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001326 checkAndroidBpContents(`
1327// This is auto-generated. DO NOT EDIT.
1328
1329cc_prebuilt_library_shared {
1330 name: "mysdk_mynativelib@current",
1331 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001332 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001333 device_supported: false,
1334 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001335 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001336 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001337 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001338 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001339 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001340 target: {
1341 host: {
1342 enabled: false,
1343 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001344 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001345 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001346 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001347 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001348 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001349 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001350 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001351 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001352 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001353 },
1354 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001355}
1356
1357cc_prebuilt_library_shared {
1358 name: "mynativelib",
1359 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001360 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001361 device_supported: false,
1362 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001363 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001364 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001365 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001366 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001367 target: {
1368 host: {
1369 enabled: false,
1370 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001371 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001372 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001373 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001374 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001375 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001376 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001377 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001378 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001379 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001380 },
1381 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001382}
1383
1384sdk_snapshot {
1385 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001386 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001387 device_supported: false,
1388 host_supported: true,
1389 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001390 target: {
1391 host: {
1392 enabled: false,
1393 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001394 linux_glibc_x86_64: {
1395 enabled: true,
1396 },
1397 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001398 enabled: true,
1399 },
1400 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001401}
1402`),
1403 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001404include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001405.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001406.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1407.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1408.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1409.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001410.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1411.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1412.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1413`),
1414 )
1415}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001416
Paul Duffina04c1072020-03-02 10:16:35 +00001417func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001418 result := testSdkWithCc(t, `
1419 sdk {
1420 name: "mysdk",
1421 device_supported: false,
1422 host_supported: true,
1423 native_shared_libs: ["mynativelib"],
1424 target: {
1425 windows: {
1426 enabled: true,
1427 },
1428 },
1429 }
1430
1431 cc_library_shared {
1432 name: "mynativelib",
1433 device_supported: false,
1434 host_supported: true,
1435 srcs: [
1436 "Test.cpp",
1437 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001438 stl: "none",
1439 target: {
1440 windows: {
1441 enabled: true,
1442 },
1443 },
1444 }
1445 `)
1446
1447 result.CheckSnapshot("mysdk", "",
1448 checkAndroidBpContents(`
1449// This is auto-generated. DO NOT EDIT.
1450
1451cc_prebuilt_library_shared {
1452 name: "mysdk_mynativelib@current",
1453 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001454 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001455 device_supported: false,
1456 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001457 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001458 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001459 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001460 host: {
1461 enabled: false,
1462 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001463 linux_glibc: {
1464 compile_multilib: "both",
1465 },
Paul Duffina04c1072020-03-02 10:16:35 +00001466 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001467 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001468 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1469 },
1470 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001471 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001472 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1473 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001474 windows: {
1475 compile_multilib: "64",
1476 },
Paul Duffina04c1072020-03-02 10:16:35 +00001477 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001478 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001479 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1480 },
1481 },
Paul Duffina04c1072020-03-02 10:16:35 +00001482}
1483
1484cc_prebuilt_library_shared {
1485 name: "mynativelib",
1486 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001487 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001488 device_supported: false,
1489 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001490 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001491 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001492 host: {
1493 enabled: false,
1494 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001495 linux_glibc: {
1496 compile_multilib: "both",
1497 },
Paul Duffina04c1072020-03-02 10:16:35 +00001498 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001499 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001500 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1501 },
1502 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001503 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001504 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1505 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001506 windows: {
1507 compile_multilib: "64",
1508 },
Paul Duffina04c1072020-03-02 10:16:35 +00001509 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001510 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001511 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1512 },
1513 },
Paul Duffina04c1072020-03-02 10:16:35 +00001514}
1515
1516sdk_snapshot {
1517 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001518 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001519 device_supported: false,
1520 host_supported: true,
1521 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001522 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001523 windows: {
1524 compile_multilib: "64",
1525 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001526 host: {
1527 enabled: false,
1528 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001529 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001530 enabled: true,
1531 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001532 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001533 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +09001534 },
1535 windows_x86_64: {
1536 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001537 },
1538 },
Paul Duffina04c1072020-03-02 10:16:35 +00001539}
1540`),
1541 checkAllCopyRules(`
1542.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1543.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1544.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1545`),
1546 )
1547}
1548
Paul Duffin9ab556f2019-12-11 18:42:17 +00001549func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1550 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001551 module_exports {
1552 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001553 native_static_libs: ["mynativelib"],
1554 }
1555
1556 cc_library_static {
1557 name: "mynativelib",
1558 srcs: [
1559 "Test.cpp",
1560 "aidl/foo/bar/Test.aidl",
1561 ],
1562 export_include_dirs: ["include"],
1563 aidl: {
1564 export_aidl_headers: true,
1565 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001566 stl: "none",
1567 }
1568 `)
1569
Paul Duffin1356d8c2020-02-25 19:26:33 +00001570 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001571 checkAndroidBpContents(`
1572// This is auto-generated. DO NOT EDIT.
1573
1574cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001575 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001576 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001577 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001578 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001579 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001580 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001581 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001582 arch: {
1583 arm64: {
1584 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001585 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001586 },
1587 arm: {
1588 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001589 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001590 },
1591 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001592}
1593
1594cc_prebuilt_library_static {
1595 name: "mynativelib",
1596 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001597 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001598 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001599 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001600 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001601 arch: {
1602 arm64: {
1603 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001604 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001605 },
1606 arm: {
1607 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001608 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001609 },
1610 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001611}
1612
Paul Duffine6029182019-12-16 17:43:48 +00001613module_exports_snapshot {
1614 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001615 visibility: ["//visibility:public"],
Paul Duffine6029182019-12-16 17:43:48 +00001616 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001617}
1618`),
1619 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001620include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001621.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1622.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1623.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1624.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1625.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1626.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1627.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1628.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 +00001629`),
1630 )
1631}
1632
1633func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001634 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001635 module_exports {
1636 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001637 device_supported: false,
1638 host_supported: true,
1639 native_static_libs: ["mynativelib"],
1640 }
1641
1642 cc_library_static {
1643 name: "mynativelib",
1644 device_supported: false,
1645 host_supported: true,
1646 srcs: [
1647 "Test.cpp",
1648 "aidl/foo/bar/Test.aidl",
1649 ],
1650 export_include_dirs: ["include"],
1651 aidl: {
1652 export_aidl_headers: true,
1653 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001654 stl: "none",
1655 }
1656 `)
1657
Paul Duffin1356d8c2020-02-25 19:26:33 +00001658 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001659 checkAndroidBpContents(`
1660// This is auto-generated. DO NOT EDIT.
1661
1662cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001663 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001664 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001665 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001666 device_supported: false,
1667 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001668 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001669 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001670 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001671 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001672 target: {
1673 host: {
1674 enabled: false,
1675 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001676 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001677 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001678 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001679 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001680 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001681 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001682 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001683 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001684 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001685 },
1686 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001687}
1688
1689cc_prebuilt_library_static {
1690 name: "mynativelib",
1691 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001692 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001693 device_supported: false,
1694 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001695 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001696 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001697 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001698 target: {
1699 host: {
1700 enabled: false,
1701 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001702 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001703 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001704 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001705 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001706 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001707 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001708 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001709 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001710 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001711 },
1712 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001713}
1714
Paul Duffine6029182019-12-16 17:43:48 +00001715module_exports_snapshot {
1716 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001717 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001718 device_supported: false,
1719 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001720 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001721 target: {
1722 host: {
1723 enabled: false,
1724 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001725 linux_glibc_x86_64: {
1726 enabled: true,
1727 },
1728 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001729 enabled: true,
1730 },
1731 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001732}
1733`),
1734 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001735include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001736.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001737.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1738.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1739.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1740.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001741.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1742.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1743.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1744`),
1745 )
1746}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001747
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001748func TestSnapshotWithCcLibrary(t *testing.T) {
1749 result := testSdkWithCc(t, `
1750 module_exports {
1751 name: "myexports",
1752 native_libs: ["mynativelib"],
1753 }
1754
1755 cc_library {
1756 name: "mynativelib",
1757 srcs: [
1758 "Test.cpp",
1759 ],
1760 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001761 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001762 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001763 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001764 }
1765 `)
1766
1767 result.CheckSnapshot("myexports", "",
1768 checkAndroidBpContents(`
1769// This is auto-generated. DO NOT EDIT.
1770
1771cc_prebuilt_library {
1772 name: "myexports_mynativelib@current",
1773 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001774 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001775 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001776 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001777 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001778 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001779 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001780 export_include_dirs: ["include/include"],
1781 arch: {
1782 arm64: {
1783 static: {
1784 srcs: ["arm64/lib/mynativelib.a"],
1785 },
1786 shared: {
1787 srcs: ["arm64/lib/mynativelib.so"],
1788 },
1789 },
1790 arm: {
1791 static: {
1792 srcs: ["arm/lib/mynativelib.a"],
1793 },
1794 shared: {
1795 srcs: ["arm/lib/mynativelib.so"],
1796 },
1797 },
1798 },
1799}
1800
1801cc_prebuilt_library {
1802 name: "mynativelib",
1803 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001804 visibility: ["//visibility:public"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001805 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001806 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001807 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001808 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001809 export_include_dirs: ["include/include"],
1810 arch: {
1811 arm64: {
1812 static: {
1813 srcs: ["arm64/lib/mynativelib.a"],
1814 },
1815 shared: {
1816 srcs: ["arm64/lib/mynativelib.so"],
1817 },
1818 },
1819 arm: {
1820 static: {
1821 srcs: ["arm/lib/mynativelib.a"],
1822 },
1823 shared: {
1824 srcs: ["arm/lib/mynativelib.so"],
1825 },
1826 },
1827 },
1828}
1829
1830module_exports_snapshot {
1831 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001832 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001833 native_libs: ["myexports_mynativelib@current"],
1834}
1835`),
1836 checkAllCopyRules(`
1837include/Test.h -> include/include/Test.h
1838.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1839.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1840.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1841.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1842 )
1843}
1844
Paul Duffin13ad94f2020-02-19 16:19:27 +00001845func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001846 result := testSdkWithCc(t, `
1847 module_exports {
1848 name: "myexports",
1849 device_supported: false,
1850 host_supported: true,
1851 target: {
1852 host: {
1853 compile_multilib: "64",
1854 },
1855 },
1856 native_static_libs: ["mynativelib"],
1857 }
1858
1859 cc_library_static {
1860 name: "mynativelib",
1861 device_supported: false,
1862 host_supported: true,
1863 srcs: [
1864 "Test.cpp",
1865 "aidl/foo/bar/Test.aidl",
1866 ],
1867 export_include_dirs: ["include"],
1868 aidl: {
1869 export_aidl_headers: true,
1870 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001871 stl: "none",
1872 }
1873 `)
1874
Paul Duffin1356d8c2020-02-25 19:26:33 +00001875 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001876 checkAndroidBpContents(`
1877// This is auto-generated. DO NOT EDIT.
1878
1879cc_prebuilt_library_static {
1880 name: "myexports_mynativelib@current",
1881 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001882 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001883 device_supported: false,
1884 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001885 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001886 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001887 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001888 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001889 target: {
1890 host: {
1891 enabled: false,
1892 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001893 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001894 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001895 srcs: ["x86_64/lib/mynativelib.a"],
1896 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1897 },
1898 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001899}
1900
1901cc_prebuilt_library_static {
1902 name: "mynativelib",
1903 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001904 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001905 device_supported: false,
1906 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001907 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001908 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001909 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001910 target: {
1911 host: {
1912 enabled: false,
1913 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001914 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001915 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001916 srcs: ["x86_64/lib/mynativelib.a"],
1917 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1918 },
1919 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001920}
1921
1922module_exports_snapshot {
1923 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001924 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001925 device_supported: false,
1926 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001927 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001928 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001929 target: {
1930 host: {
1931 enabled: false,
1932 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001933 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001934 enabled: true,
1935 },
1936 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001937}`),
1938 checkAllCopyRules(`
1939include/Test.h -> include/include/Test.h
1940.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1941.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1942.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1943.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1944`),
1945 )
1946}
Paul Duffin91756d22020-02-21 16:29:57 +00001947
1948func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1949 result := testSdkWithCc(t, `
1950 sdk {
1951 name: "mysdk",
1952 native_header_libs: ["mynativeheaders"],
1953 }
1954
1955 cc_library_headers {
1956 name: "mynativeheaders",
1957 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001958 stl: "none",
1959 }
1960 `)
1961
Paul Duffin1356d8c2020-02-25 19:26:33 +00001962 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001963 checkAndroidBpContents(`
1964// This is auto-generated. DO NOT EDIT.
1965
1966cc_prebuilt_library_headers {
1967 name: "mysdk_mynativeheaders@current",
1968 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01001969 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001970 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001971 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001972 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001973}
1974
1975cc_prebuilt_library_headers {
1976 name: "mynativeheaders",
1977 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001978 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001979 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001980 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001981 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001982}
1983
1984sdk_snapshot {
1985 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001986 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001987 native_header_libs: ["mysdk_mynativeheaders@current"],
1988}
1989`),
1990 checkAllCopyRules(`
1991include/Test.h -> include/include/Test.h
1992`),
1993 )
1994}
1995
1996func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001997 result := testSdkWithCc(t, `
1998 sdk {
1999 name: "mysdk",
2000 device_supported: false,
2001 host_supported: true,
2002 native_header_libs: ["mynativeheaders"],
2003 }
2004
2005 cc_library_headers {
2006 name: "mynativeheaders",
2007 device_supported: false,
2008 host_supported: true,
2009 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00002010 stl: "none",
2011 }
2012 `)
2013
Paul Duffin1356d8c2020-02-25 19:26:33 +00002014 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00002015 checkAndroidBpContents(`
2016// This is auto-generated. DO NOT EDIT.
2017
2018cc_prebuilt_library_headers {
2019 name: "mysdk_mynativeheaders@current",
2020 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002021 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002022 device_supported: false,
2023 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002024 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002025 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002026 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002027 target: {
2028 host: {
2029 enabled: false,
2030 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002031 linux_glibc_x86_64: {
2032 enabled: true,
2033 },
2034 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002035 enabled: true,
2036 },
2037 },
Paul Duffin91756d22020-02-21 16:29:57 +00002038}
2039
2040cc_prebuilt_library_headers {
2041 name: "mynativeheaders",
2042 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002043 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002044 device_supported: false,
2045 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002046 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002047 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002048 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002049 target: {
2050 host: {
2051 enabled: false,
2052 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002053 linux_glibc_x86_64: {
2054 enabled: true,
2055 },
2056 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002057 enabled: true,
2058 },
2059 },
Paul Duffin91756d22020-02-21 16:29:57 +00002060}
2061
2062sdk_snapshot {
2063 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002064 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002065 device_supported: false,
2066 host_supported: true,
2067 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002068 target: {
2069 host: {
2070 enabled: false,
2071 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002072 linux_glibc_x86_64: {
2073 enabled: true,
2074 },
2075 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002076 enabled: true,
2077 },
2078 },
Paul Duffin91756d22020-02-21 16:29:57 +00002079}
2080`),
2081 checkAllCopyRules(`
2082include/Test.h -> include/include/Test.h
2083`),
2084 )
2085}
Paul Duffina04c1072020-03-02 10:16:35 +00002086
2087func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00002088 result := testSdkWithCc(t, `
2089 sdk {
2090 name: "mysdk",
2091 host_supported: true,
2092 native_header_libs: ["mynativeheaders"],
2093 }
2094
2095 cc_library_headers {
2096 name: "mynativeheaders",
2097 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002098 stl: "none",
2099 export_system_include_dirs: ["include"],
2100 target: {
2101 android: {
2102 export_include_dirs: ["include-android"],
2103 },
2104 host: {
2105 export_include_dirs: ["include-host"],
2106 },
2107 },
2108 }
2109 `)
2110
2111 result.CheckSnapshot("mysdk", "",
2112 checkAndroidBpContents(`
2113// This is auto-generated. DO NOT EDIT.
2114
2115cc_prebuilt_library_headers {
2116 name: "mysdk_mynativeheaders@current",
2117 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002118 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002119 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002120 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002121 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002122 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002123 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002124 host: {
2125 enabled: false,
2126 },
Paul Duffina04c1072020-03-02 10:16:35 +00002127 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002128 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002129 },
2130 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002131 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002132 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002133 linux_glibc_x86_64: {
2134 enabled: true,
2135 },
2136 linux_glibc_x86: {
2137 enabled: true,
2138 },
Paul Duffina04c1072020-03-02 10:16:35 +00002139 },
Paul Duffina04c1072020-03-02 10:16:35 +00002140}
2141
2142cc_prebuilt_library_headers {
2143 name: "mynativeheaders",
2144 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002145 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002146 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002147 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002148 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002149 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002150 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002151 host: {
2152 enabled: false,
2153 },
Paul Duffina04c1072020-03-02 10:16:35 +00002154 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002155 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002156 },
2157 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002158 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002159 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002160 linux_glibc_x86_64: {
2161 enabled: true,
2162 },
2163 linux_glibc_x86: {
2164 enabled: true,
2165 },
Paul Duffina04c1072020-03-02 10:16:35 +00002166 },
Paul Duffina04c1072020-03-02 10:16:35 +00002167}
2168
2169sdk_snapshot {
2170 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002171 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002172 host_supported: true,
2173 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002174 target: {
2175 host: {
2176 enabled: false,
2177 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002178 linux_glibc_x86_64: {
2179 enabled: true,
2180 },
2181 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002182 enabled: true,
2183 },
2184 },
Paul Duffina04c1072020-03-02 10:16:35 +00002185}
2186`),
2187 checkAllCopyRules(`
Paul Duffined62b9c2020-06-16 16:12:50 +01002188include/Test.h -> common_os/include/include/Test.h
2189include-android/AndroidTest.h -> android/include/include-android/AndroidTest.h
2190include-host/HostTest.h -> linux_glibc/include/include-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002191`),
2192 )
2193}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002194
2195func TestSystemSharedLibPropagation(t *testing.T) {
2196 result := testSdkWithCc(t, `
2197 sdk {
2198 name: "mysdk",
2199 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2200 }
2201
2202 cc_library {
2203 name: "sslnil",
2204 host_supported: true,
2205 }
2206
2207 cc_library {
2208 name: "sslempty",
2209 system_shared_libs: [],
2210 }
2211
2212 cc_library {
2213 name: "sslnonempty",
2214 system_shared_libs: ["sslnil"],
2215 }
2216 `)
2217
2218 result.CheckSnapshot("mysdk", "",
2219 checkAndroidBpContents(`
2220// This is auto-generated. DO NOT EDIT.
2221
2222cc_prebuilt_library_shared {
2223 name: "mysdk_sslnil@current",
2224 sdk_member_name: "sslnil",
Paul Duffind99d9972020-09-29 16:00:55 +01002225 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002226 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002227 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002228 arch: {
2229 arm64: {
2230 srcs: ["arm64/lib/sslnil.so"],
2231 },
2232 arm: {
2233 srcs: ["arm/lib/sslnil.so"],
2234 },
2235 },
2236}
2237
2238cc_prebuilt_library_shared {
2239 name: "sslnil",
2240 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002241 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002242 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002243 arch: {
2244 arm64: {
2245 srcs: ["arm64/lib/sslnil.so"],
2246 },
2247 arm: {
2248 srcs: ["arm/lib/sslnil.so"],
2249 },
2250 },
2251}
2252
2253cc_prebuilt_library_shared {
2254 name: "mysdk_sslempty@current",
2255 sdk_member_name: "sslempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002256 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002257 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002258 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002259 system_shared_libs: [],
2260 arch: {
2261 arm64: {
2262 srcs: ["arm64/lib/sslempty.so"],
2263 },
2264 arm: {
2265 srcs: ["arm/lib/sslempty.so"],
2266 },
2267 },
2268}
2269
2270cc_prebuilt_library_shared {
2271 name: "sslempty",
2272 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002273 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002274 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002275 system_shared_libs: [],
2276 arch: {
2277 arm64: {
2278 srcs: ["arm64/lib/sslempty.so"],
2279 },
2280 arm: {
2281 srcs: ["arm/lib/sslempty.so"],
2282 },
2283 },
2284}
2285
2286cc_prebuilt_library_shared {
2287 name: "mysdk_sslnonempty@current",
2288 sdk_member_name: "sslnonempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002289 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002290 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002291 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002292 system_shared_libs: ["mysdk_sslnil@current"],
2293 arch: {
2294 arm64: {
2295 srcs: ["arm64/lib/sslnonempty.so"],
2296 },
2297 arm: {
2298 srcs: ["arm/lib/sslnonempty.so"],
2299 },
2300 },
2301}
2302
2303cc_prebuilt_library_shared {
2304 name: "sslnonempty",
2305 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002306 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002307 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002308 system_shared_libs: ["sslnil"],
2309 arch: {
2310 arm64: {
2311 srcs: ["arm64/lib/sslnonempty.so"],
2312 },
2313 arm: {
2314 srcs: ["arm/lib/sslnonempty.so"],
2315 },
2316 },
2317}
2318
2319sdk_snapshot {
2320 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002321 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002322 native_shared_libs: [
2323 "mysdk_sslnil@current",
2324 "mysdk_sslempty@current",
2325 "mysdk_sslnonempty@current",
2326 ],
2327}
2328`))
2329
2330 result = testSdkWithCc(t, `
2331 sdk {
2332 name: "mysdk",
2333 host_supported: true,
2334 native_shared_libs: ["sslvariants"],
2335 }
2336
2337 cc_library {
2338 name: "sslvariants",
2339 host_supported: true,
2340 target: {
2341 android: {
2342 system_shared_libs: [],
2343 },
2344 },
2345 }
2346 `)
2347
2348 result.CheckSnapshot("mysdk", "",
2349 checkAndroidBpContents(`
2350// This is auto-generated. DO NOT EDIT.
2351
2352cc_prebuilt_library_shared {
2353 name: "mysdk_sslvariants@current",
2354 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002355 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002356 host_supported: true,
2357 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002358 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002359 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002360 host: {
2361 enabled: false,
2362 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002363 android: {
2364 system_shared_libs: [],
2365 },
2366 android_arm64: {
2367 srcs: ["android/arm64/lib/sslvariants.so"],
2368 },
2369 android_arm: {
2370 srcs: ["android/arm/lib/sslvariants.so"],
2371 },
2372 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002373 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002374 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2375 },
2376 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002377 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002378 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2379 },
2380 },
2381}
2382
2383cc_prebuilt_library_shared {
2384 name: "sslvariants",
2385 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002386 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002387 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002388 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002389 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002390 host: {
2391 enabled: false,
2392 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002393 android: {
2394 system_shared_libs: [],
2395 },
2396 android_arm64: {
2397 srcs: ["android/arm64/lib/sslvariants.so"],
2398 },
2399 android_arm: {
2400 srcs: ["android/arm/lib/sslvariants.so"],
2401 },
2402 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002403 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002404 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2405 },
2406 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002407 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002408 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2409 },
2410 },
2411}
2412
2413sdk_snapshot {
2414 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002415 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002416 host_supported: true,
2417 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002418 target: {
2419 host: {
2420 enabled: false,
2421 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002422 linux_glibc_x86_64: {
2423 enabled: true,
2424 },
2425 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002426 enabled: true,
2427 },
2428 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002429}
2430`))
2431}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002432
2433func TestStubsLibrary(t *testing.T) {
2434 result := testSdkWithCc(t, `
2435 sdk {
2436 name: "mysdk",
2437 native_shared_libs: ["stubslib"],
2438 }
2439
2440 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002441 name: "internaldep",
2442 }
2443
2444 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002445 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002446 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002447 stubs: {
2448 symbol_file: "some/where/stubslib.map.txt",
2449 versions: ["1", "2", "3"],
2450 },
2451 }
2452 `)
2453
2454 result.CheckSnapshot("mysdk", "",
2455 checkAndroidBpContents(`
2456// This is auto-generated. DO NOT EDIT.
2457
2458cc_prebuilt_library_shared {
2459 name: "mysdk_stubslib@current",
2460 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002461 visibility: ["//visibility:public"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002462 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002463 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002464 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002465 versions: [
2466 "1",
2467 "2",
2468 "3",
2469 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002470 },
2471 arch: {
2472 arm64: {
2473 srcs: ["arm64/lib/stubslib.so"],
2474 },
2475 arm: {
2476 srcs: ["arm/lib/stubslib.so"],
2477 },
2478 },
2479}
2480
2481cc_prebuilt_library_shared {
2482 name: "stubslib",
2483 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002484 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002485 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002486 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002487 versions: [
2488 "1",
2489 "2",
2490 "3",
2491 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002492 },
2493 arch: {
2494 arm64: {
2495 srcs: ["arm64/lib/stubslib.so"],
2496 },
2497 arm: {
2498 srcs: ["arm/lib/stubslib.so"],
2499 },
2500 },
2501}
2502
2503sdk_snapshot {
2504 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002505 visibility: ["//visibility:public"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002506 native_shared_libs: ["mysdk_stubslib@current"],
2507}
2508`))
2509}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002510
2511func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002512 result := testSdkWithCc(t, `
2513 sdk {
2514 name: "mysdk",
2515 host_supported: true,
2516 native_shared_libs: ["stubslib"],
2517 }
2518
2519 cc_library {
2520 name: "internaldep",
2521 host_supported: true,
2522 }
2523
2524 cc_library {
2525 name: "stubslib",
2526 host_supported: true,
2527 shared_libs: ["internaldep"],
2528 stubs: {
2529 symbol_file: "some/where/stubslib.map.txt",
2530 versions: ["1", "2", "3"],
2531 },
2532 }
2533 `)
2534
2535 result.CheckSnapshot("mysdk", "",
2536 checkAndroidBpContents(`
2537// This is auto-generated. DO NOT EDIT.
2538
2539cc_prebuilt_library_shared {
2540 name: "mysdk_stubslib@current",
2541 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002542 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002543 host_supported: true,
2544 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002545 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002546 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002547 versions: [
2548 "1",
2549 "2",
2550 "3",
2551 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002552 },
2553 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002554 host: {
2555 enabled: false,
2556 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002557 android_arm64: {
2558 srcs: ["android/arm64/lib/stubslib.so"],
2559 },
2560 android_arm: {
2561 srcs: ["android/arm/lib/stubslib.so"],
2562 },
2563 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002564 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002565 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2566 },
2567 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002568 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002569 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2570 },
2571 },
2572}
2573
2574cc_prebuilt_library_shared {
2575 name: "stubslib",
2576 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002577 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002578 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002579 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002580 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002581 versions: [
2582 "1",
2583 "2",
2584 "3",
2585 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002586 },
2587 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002588 host: {
2589 enabled: false,
2590 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002591 android_arm64: {
2592 srcs: ["android/arm64/lib/stubslib.so"],
2593 },
2594 android_arm: {
2595 srcs: ["android/arm/lib/stubslib.so"],
2596 },
2597 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002598 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002599 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2600 },
2601 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002602 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002603 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2604 },
2605 },
2606}
2607
2608sdk_snapshot {
2609 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002610 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002611 host_supported: true,
2612 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002613 target: {
2614 host: {
2615 enabled: false,
2616 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002617 linux_glibc_x86_64: {
2618 enabled: true,
2619 },
2620 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002621 enabled: true,
2622 },
2623 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002624}
2625`))
2626}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002627
2628func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002629 result := testSdkWithCc(t, `
2630 sdk {
2631 name: "mysdk",
2632 host_supported: true,
2633 native_shared_libs: ["mylib"],
2634 }
2635
2636 cc_library {
2637 name: "mylib",
2638 host_supported: true,
2639 unique_host_soname: true,
2640 }
2641 `)
2642
2643 result.CheckSnapshot("mysdk", "",
2644 checkAndroidBpContents(`
2645// This is auto-generated. DO NOT EDIT.
2646
2647cc_prebuilt_library_shared {
2648 name: "mysdk_mylib@current",
2649 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002650 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002651 host_supported: true,
2652 installable: false,
2653 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002654 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002655 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002656 host: {
2657 enabled: false,
2658 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002659 android_arm64: {
2660 srcs: ["android/arm64/lib/mylib.so"],
2661 },
2662 android_arm: {
2663 srcs: ["android/arm/lib/mylib.so"],
2664 },
2665 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002666 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002667 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2668 },
2669 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002670 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002671 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2672 },
2673 },
2674}
2675
2676cc_prebuilt_library_shared {
2677 name: "mylib",
2678 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002679 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002680 host_supported: true,
2681 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002682 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002683 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002684 host: {
2685 enabled: false,
2686 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002687 android_arm64: {
2688 srcs: ["android/arm64/lib/mylib.so"],
2689 },
2690 android_arm: {
2691 srcs: ["android/arm/lib/mylib.so"],
2692 },
2693 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002694 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002695 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2696 },
2697 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002698 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002699 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2700 },
2701 },
2702}
2703
2704sdk_snapshot {
2705 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002706 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002707 host_supported: true,
2708 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002709 target: {
2710 host: {
2711 enabled: false,
2712 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002713 linux_glibc_x86_64: {
2714 enabled: true,
2715 },
2716 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002717 enabled: true,
2718 },
2719 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002720}
2721`),
2722 checkAllCopyRules(`
2723.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2724.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2725.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2726.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2727`),
2728 )
2729}