blob: c214e75c453fac80e5b82971f40bb3b8344ce257 [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 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100123 linux_glibc: {
124 enabled: true,
125 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100126 linux_glibc_x86_64: {
127 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100128 },
129 },
130}
131
132cc_prebuilt_library_shared {
133 name: "sdkmember",
134 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100135 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100136 host_supported: true,
137 stl: "none",
138 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100139 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100140 host: {
141 enabled: false,
142 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100143 android_arm64: {
144 srcs: ["android/arm64/lib/sdkmember.so"],
145 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100146 linux_glibc: {
147 enabled: true,
148 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100149 linux_glibc_x86_64: {
150 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100151 },
152 },
153}
154
155sdk_snapshot {
156 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100157 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100158 host_supported: true,
159 native_shared_libs: ["mysdk_sdkmember@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100160 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100161 target: {
162 host: {
163 enabled: false,
164 },
165 linux_glibc: {
166 enabled: true,
167 },
168 },
Martin Stjernholm89238f42020-07-10 00:14:03 +0100169}
170`),
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100171 checkAllCopyRules(`
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100172.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
173.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100174`))
175}
176
Paul Duffina80fdec2019-12-03 15:25:00 +0000177func TestBasicSdkWithCc(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000178 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000179 sdk {
180 name: "mysdk",
181 native_shared_libs: ["sdkmember"],
182 }
183
Paul Duffina0843f62019-12-13 19:50:38 +0000184 cc_library_shared {
185 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -0800186 system_shared_libs: [],
Martin Stjernholmcc776012020-07-07 03:22:21 +0100187 stl: "none",
188 apex_available: ["mysdkapex"],
Paul Duffina0843f62019-12-13 19:50:38 +0000189 }
190
Paul Duffina80fdec2019-12-03 15:25:00 +0000191 sdk_snapshot {
192 name: "mysdk@1",
193 native_shared_libs: ["sdkmember_mysdk_1"],
194 }
195
196 sdk_snapshot {
197 name: "mysdk@2",
198 native_shared_libs: ["sdkmember_mysdk_2"],
199 }
200
201 cc_prebuilt_library_shared {
202 name: "sdkmember",
203 srcs: ["libfoo.so"],
204 prefer: false,
205 system_shared_libs: [],
206 stl: "none",
207 }
208
209 cc_prebuilt_library_shared {
210 name: "sdkmember_mysdk_1",
211 sdk_member_name: "sdkmember",
212 srcs: ["libfoo.so"],
213 system_shared_libs: [],
214 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000215 // TODO: remove //apex_available:platform
216 apex_available: [
217 "//apex_available:platform",
218 "myapex",
219 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000220 }
221
222 cc_prebuilt_library_shared {
223 name: "sdkmember_mysdk_2",
224 sdk_member_name: "sdkmember",
225 srcs: ["libfoo.so"],
226 system_shared_libs: [],
227 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000228 // TODO: remove //apex_available:platform
229 apex_available: [
230 "//apex_available:platform",
231 "myapex2",
232 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000233 }
234
235 cc_library_shared {
236 name: "mycpplib",
237 srcs: ["Test.cpp"],
238 shared_libs: ["sdkmember"],
239 system_shared_libs: [],
240 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000241 apex_available: [
242 "myapex",
243 "myapex2",
244 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000245 }
246
247 apex {
248 name: "myapex",
249 native_shared_libs: ["mycpplib"],
250 uses_sdks: ["mysdk@1"],
251 key: "myapex.key",
252 certificate: ":myapex.cert",
253 }
254
255 apex {
256 name: "myapex2",
257 native_shared_libs: ["mycpplib"],
258 uses_sdks: ["mysdk@2"],
259 key: "myapex.key",
260 certificate: ":myapex.cert",
261 }
Martin Stjernholmcc776012020-07-07 03:22:21 +0100262
263 apex {
264 name: "mysdkapex",
265 native_shared_libs: ["sdkmember"],
266 key: "myapex.key",
267 certificate: ":myapex.cert",
268 }
Paul Duffina80fdec2019-12-03 15:25:00 +0000269 `)
270
Colin Crossaede88c2020-08-11 12:17:01 -0700271 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
272 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000273
Colin Crossaede88c2020-08-11 12:17:01 -0700274 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1")
275 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000276
277 // Depending on the uses_sdks value, different libs are linked
278 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
279 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
280}
281
Paul Duffina0843f62019-12-13 19:50:38 +0000282// Make sure the sdk can use host specific cc libraries static/shared and both.
283func TestHostSdkWithCc(t *testing.T) {
284 testSdkWithCc(t, `
285 sdk {
286 name: "mysdk",
287 device_supported: false,
288 host_supported: true,
289 native_shared_libs: ["sdkshared"],
290 native_static_libs: ["sdkstatic"],
291 }
292
293 cc_library_host_shared {
294 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000295 stl: "none",
296 }
297
298 cc_library_host_static {
299 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000300 stl: "none",
301 }
302 `)
303}
304
305// Make sure the sdk can use cc libraries static/shared and both.
306func TestSdkWithCc(t *testing.T) {
307 testSdkWithCc(t, `
308 sdk {
309 name: "mysdk",
310 native_shared_libs: ["sdkshared", "sdkboth1"],
311 native_static_libs: ["sdkstatic", "sdkboth2"],
312 }
313
314 cc_library_shared {
315 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000316 stl: "none",
317 }
318
319 cc_library_static {
320 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000321 stl: "none",
322 }
323
324 cc_library {
325 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000326 stl: "none",
327 }
328
329 cc_library {
330 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000331 stl: "none",
332 }
333 `)
334}
335
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000336func TestSnapshotWithObject(t *testing.T) {
337 result := testSdkWithCc(t, `
338 sdk {
339 name: "mysdk",
340 native_objects: ["crtobj"],
341 }
342
343 cc_object {
344 name: "crtobj",
345 stl: "none",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100346 sanitize: {
347 never: true,
348 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000349 }
350 `)
351
352 result.CheckSnapshot("mysdk", "",
353 checkAndroidBpContents(`
354// This is auto-generated. DO NOT EDIT.
355
356cc_prebuilt_object {
357 name: "mysdk_crtobj@current",
358 sdk_member_name: "crtobj",
Paul Duffind99d9972020-09-29 16:00:55 +0100359 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000360 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100361 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100362 sanitize: {
363 never: true,
364 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000365 arch: {
366 arm64: {
367 srcs: ["arm64/lib/crtobj.o"],
368 },
369 arm: {
370 srcs: ["arm/lib/crtobj.o"],
371 },
372 },
373}
374
375cc_prebuilt_object {
376 name: "crtobj",
377 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100378 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000379 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100380 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100381 sanitize: {
382 never: true,
383 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000384 arch: {
385 arm64: {
386 srcs: ["arm64/lib/crtobj.o"],
387 },
388 arm: {
389 srcs: ["arm/lib/crtobj.o"],
390 },
391 },
392}
393
394sdk_snapshot {
395 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100396 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000397 native_objects: ["mysdk_crtobj@current"],
398}
399`),
400 checkAllCopyRules(`
401.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
402.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
403`),
404 )
405}
406
Paul Duffinc62a5102019-12-11 18:34:15 +0000407func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
408 result := testSdkWithCc(t, `
409 sdk {
410 name: "mysdk",
411 native_shared_libs: ["mynativelib1", "mynativelib2"],
412 }
413
414 cc_library_shared {
415 name: "mynativelib1",
416 srcs: [
417 "Test.cpp",
418 ],
419 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000420 stl: "none",
421 }
422
423 cc_library_shared {
424 name: "mynativelib2",
425 srcs: [
426 "Test.cpp",
427 ],
428 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000429 stl: "none",
430 }
431 `)
432
Paul Duffin1356d8c2020-02-25 19:26:33 +0000433 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000434 checkAllCopyRules(`
435include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800436.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
437.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
438.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
439.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000440`),
441 )
442}
443
Martin Stjernholmb0249572020-09-15 02:32:35 +0100444// Verify that when the shared library has some common and some arch specific
445// properties that the generated snapshot is optimized properly. Substruct
446// handling is tested with the sanitize clauses (but note there's a lot of
447// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000448func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
449 result := testSdkWithCc(t, `
450 sdk {
451 name: "mysdk",
452 native_shared_libs: ["mynativelib"],
453 }
454
455 cc_library_shared {
456 name: "mynativelib",
457 srcs: [
458 "Test.cpp",
459 "aidl/foo/bar/Test.aidl",
460 ],
461 export_include_dirs: ["include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100462 sanitize: {
463 fuzzer: false,
464 integer_overflow: true,
465 diag: { undefined: false },
466 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000467 arch: {
468 arm64: {
469 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100470 sanitize: {
471 hwaddress: true,
472 integer_overflow: false,
473 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000474 },
475 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000476 stl: "none",
477 }
478 `)
479
Paul Duffin1356d8c2020-02-25 19:26:33 +0000480 result.CheckSnapshot("mysdk", "",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000481 checkAndroidBpContents(`
482// This is auto-generated. DO NOT EDIT.
483
484cc_prebuilt_library_shared {
485 name: "mysdk_mynativelib@current",
486 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100487 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000488 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000489 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100490 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000491 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100492 sanitize: {
493 fuzzer: false,
494 diag: {
495 undefined: false,
496 },
497 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000498 arch: {
499 arm64: {
500 srcs: ["arm64/lib/mynativelib.so"],
501 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100502 sanitize: {
503 hwaddress: true,
504 integer_overflow: false,
505 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000506 },
507 arm: {
508 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100509 sanitize: {
510 integer_overflow: true,
511 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000512 },
513 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000514}
515
516cc_prebuilt_library_shared {
517 name: "mynativelib",
518 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100519 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000520 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100521 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000522 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100523 sanitize: {
524 fuzzer: false,
525 diag: {
526 undefined: false,
527 },
528 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000529 arch: {
530 arm64: {
531 srcs: ["arm64/lib/mynativelib.so"],
532 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100533 sanitize: {
534 hwaddress: true,
535 integer_overflow: false,
536 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000537 },
538 arm: {
539 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100540 sanitize: {
541 integer_overflow: true,
542 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000543 },
544 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000545}
546
547sdk_snapshot {
548 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100549 visibility: ["//visibility:public"],
Paul Duffina7cd8c82019-12-11 20:00:57 +0000550 native_shared_libs: ["mysdk_mynativelib@current"],
551}
552`),
553 checkAllCopyRules(`
554include/Test.h -> include/include/Test.h
Martin Stjernholmb0249572020-09-15 02:32:35 +0100555.intermediates/mynativelib/android_arm64_armv8-a_shared_hwasan/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000556arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800557.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000558 )
559}
560
Paul Duffin25ce04b2020-01-16 11:47:25 +0000561func TestSnapshotWithCcBinary(t *testing.T) {
562 result := testSdkWithCc(t, `
563 module_exports {
564 name: "mymodule_exports",
565 native_binaries: ["mynativebinary"],
566 }
567
568 cc_binary {
569 name: "mynativebinary",
570 srcs: [
571 "Test.cpp",
572 ],
573 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000574 }
575 `)
576
Paul Duffin1356d8c2020-02-25 19:26:33 +0000577 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000578 checkAndroidBpContents(`
579// This is auto-generated. DO NOT EDIT.
580
581cc_prebuilt_binary {
582 name: "mymodule_exports_mynativebinary@current",
583 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100584 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000585 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000586 compile_multilib: "both",
587 arch: {
588 arm64: {
589 srcs: ["arm64/bin/mynativebinary"],
590 },
591 arm: {
592 srcs: ["arm/bin/mynativebinary"],
593 },
594 },
595}
596
597cc_prebuilt_binary {
598 name: "mynativebinary",
599 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100600 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000601 compile_multilib: "both",
602 arch: {
603 arm64: {
604 srcs: ["arm64/bin/mynativebinary"],
605 },
606 arm: {
607 srcs: ["arm/bin/mynativebinary"],
608 },
609 },
610}
611
612module_exports_snapshot {
613 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100614 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000615 native_binaries: ["mymodule_exports_mynativebinary@current"],
616}
617`),
618 checkAllCopyRules(`
619.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
620.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
621`),
622 )
623}
624
Paul Duffina04c1072020-03-02 10:16:35 +0000625func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000626 result := testSdkWithCc(t, `
627 module_exports {
628 name: "myexports",
629 device_supported: false,
630 host_supported: true,
631 native_binaries: ["mynativebinary"],
632 target: {
633 windows: {
634 enabled: true,
635 },
636 },
637 }
638
639 cc_binary {
640 name: "mynativebinary",
641 device_supported: false,
642 host_supported: true,
643 srcs: [
644 "Test.cpp",
645 ],
646 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000647 stl: "none",
648 target: {
649 windows: {
650 enabled: true,
651 },
652 },
653 }
654 `)
655
656 result.CheckSnapshot("myexports", "",
657 checkAndroidBpContents(`
658// This is auto-generated. DO NOT EDIT.
659
660cc_prebuilt_binary {
661 name: "myexports_mynativebinary@current",
662 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100663 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000664 device_supported: false,
665 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000666 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100667 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000668 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100669 host: {
670 enabled: false,
671 },
Paul Duffina04c1072020-03-02 10:16:35 +0000672 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100673 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000674 compile_multilib: "both",
675 },
676 linux_glibc_x86_64: {
677 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
678 },
679 linux_glibc_x86: {
680 srcs: ["linux_glibc/x86/bin/mynativebinary"],
681 },
682 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100683 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000684 compile_multilib: "64",
685 },
686 windows_x86_64: {
687 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
688 },
689 },
690}
691
692cc_prebuilt_binary {
693 name: "mynativebinary",
694 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100695 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000696 device_supported: false,
697 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100698 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000699 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100700 host: {
701 enabled: false,
702 },
Paul Duffina04c1072020-03-02 10:16:35 +0000703 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100704 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000705 compile_multilib: "both",
706 },
707 linux_glibc_x86_64: {
708 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
709 },
710 linux_glibc_x86: {
711 srcs: ["linux_glibc/x86/bin/mynativebinary"],
712 },
713 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100714 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000715 compile_multilib: "64",
716 },
717 windows_x86_64: {
718 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
719 },
720 },
721}
722
723module_exports_snapshot {
724 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100725 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000726 device_supported: false,
727 host_supported: true,
728 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000729 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100730 host: {
731 enabled: false,
732 },
733 linux_glibc: {
734 enabled: true,
735 },
Paul Duffin6a7e9532020-03-20 17:50:07 +0000736 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100737 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000738 compile_multilib: "64",
739 },
740 },
Paul Duffina04c1072020-03-02 10:16:35 +0000741}
742`),
743 checkAllCopyRules(`
744.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
745.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
746.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
747`),
748 )
749}
750
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100751func TestSnapshotWithSingleHostOsType(t *testing.T) {
752 ctx, config := testSdkContext(`
753 cc_defaults {
754 name: "mydefaults",
755 device_supported: false,
756 host_supported: true,
757 compile_multilib: "64",
758 target: {
759 host: {
760 enabled: false,
761 },
762 linux_bionic: {
763 enabled: true,
764 },
765 },
766 }
767
768 module_exports {
769 name: "myexports",
770 defaults: ["mydefaults"],
771 native_shared_libs: ["mynativelib"],
772 native_binaries: ["mynativebinary"],
773 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
774 }
775
776 cc_library {
777 name: "mynativelib",
778 defaults: ["mydefaults"],
779 srcs: [
780 "Test.cpp",
781 ],
782 stl: "none",
783 }
784
785 cc_binary {
786 name: "mynativebinary",
787 defaults: ["mydefaults"],
788 srcs: [
789 "Test.cpp",
790 ],
791 stl: "none",
792 }
793 `, ccTestFs, []android.OsType{android.LinuxBionic})
794
795 result := runTests(t, ctx, config)
796
797 result.CheckSnapshot("myexports", "",
798 checkAndroidBpContents(`
799// This is auto-generated. DO NOT EDIT.
800
801cc_prebuilt_binary {
802 name: "myexports_mynativebinary@current",
803 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100804 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100805 device_supported: false,
806 host_supported: true,
807 installable: false,
808 stl: "none",
809 compile_multilib: "64",
810 target: {
811 host: {
812 enabled: false,
813 },
814 linux_bionic: {
815 enabled: true,
816 },
817 linux_bionic_x86_64: {
818 srcs: ["x86_64/bin/mynativebinary"],
819 },
820 },
821}
822
823cc_prebuilt_binary {
824 name: "mynativebinary",
825 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100826 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100827 device_supported: false,
828 host_supported: true,
829 stl: "none",
830 compile_multilib: "64",
831 target: {
832 host: {
833 enabled: false,
834 },
835 linux_bionic: {
836 enabled: true,
837 },
838 linux_bionic_x86_64: {
839 srcs: ["x86_64/bin/mynativebinary"],
840 },
841 },
842}
843
844cc_prebuilt_library_shared {
845 name: "myexports_mynativelib@current",
846 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100847 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100848 device_supported: false,
849 host_supported: true,
850 installable: false,
851 stl: "none",
852 compile_multilib: "64",
853 target: {
854 host: {
855 enabled: false,
856 },
857 linux_bionic: {
858 enabled: true,
859 },
860 linux_bionic_x86_64: {
861 srcs: ["x86_64/lib/mynativelib.so"],
862 },
863 },
864}
865
866cc_prebuilt_library_shared {
867 name: "mynativelib",
868 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100869 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100870 device_supported: false,
871 host_supported: true,
872 stl: "none",
873 compile_multilib: "64",
874 target: {
875 host: {
876 enabled: false,
877 },
878 linux_bionic: {
879 enabled: true,
880 },
881 linux_bionic_x86_64: {
882 srcs: ["x86_64/lib/mynativelib.so"],
883 },
884 },
885}
886
887module_exports_snapshot {
888 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100889 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100890 device_supported: false,
891 host_supported: true,
892 native_binaries: ["myexports_mynativebinary@current"],
893 native_shared_libs: ["myexports_mynativelib@current"],
894 compile_multilib: "64",
895 target: {
896 host: {
897 enabled: false,
898 },
899 linux_bionic: {
900 enabled: true,
901 },
902 },
903}
904`),
905 checkAllCopyRules(`
906.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
907.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
908`),
909 )
910}
911
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100912// Test that we support the necessary flags for the linker binary, which is
913// special in several ways.
914func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100915 result := testSdkWithCc(t, `
916 module_exports {
917 name: "mymodule_exports",
918 host_supported: true,
919 device_supported: false,
920 native_binaries: ["linker"],
921 }
922
923 cc_binary {
924 name: "linker",
925 host_supported: true,
926 static_executable: true,
927 nocrt: true,
928 stl: "none",
929 srcs: [
930 "Test.cpp",
931 ],
932 compile_multilib: "both",
933 }
934 `)
935
936 result.CheckSnapshot("mymodule_exports", "",
937 checkAndroidBpContents(`
938// This is auto-generated. DO NOT EDIT.
939
940cc_prebuilt_binary {
941 name: "mymodule_exports_linker@current",
942 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +0100943 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100944 device_supported: false,
945 host_supported: true,
946 installable: false,
947 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100948 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100949 static_executable: true,
950 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100951 target: {
952 host: {
953 enabled: false,
954 },
955 linux_glibc: {
956 enabled: true,
957 },
958 linux_glibc_x86_64: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100959 srcs: ["x86_64/bin/linker"],
960 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100961 linux_glibc_x86: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100962 srcs: ["x86/bin/linker"],
963 },
964 },
965}
966
967cc_prebuilt_binary {
968 name: "linker",
969 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100970 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100971 device_supported: false,
972 host_supported: true,
973 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100974 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100975 static_executable: true,
976 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100977 target: {
978 host: {
979 enabled: false,
980 },
981 linux_glibc: {
982 enabled: true,
983 },
984 linux_glibc_x86_64: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100985 srcs: ["x86_64/bin/linker"],
986 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100987 linux_glibc_x86: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100988 srcs: ["x86/bin/linker"],
989 },
990 },
991}
992
993module_exports_snapshot {
994 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100995 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100996 device_supported: false,
997 host_supported: true,
998 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100999 target: {
1000 host: {
1001 enabled: false,
1002 },
1003 linux_glibc: {
1004 enabled: true,
1005 },
1006 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001007}
1008`),
1009 checkAllCopyRules(`
1010.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1011.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1012`),
1013 )
1014}
1015
Paul Duffin9ab556f2019-12-11 18:42:17 +00001016func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001017 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001018 sdk {
1019 name: "mysdk",
1020 native_shared_libs: ["mynativelib"],
1021 }
1022
1023 cc_library_shared {
1024 name: "mynativelib",
1025 srcs: [
1026 "Test.cpp",
1027 "aidl/foo/bar/Test.aidl",
1028 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001029 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001030 export_include_dirs: ["include"],
1031 aidl: {
1032 export_aidl_headers: true,
1033 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001034 stl: "none",
1035 }
1036 `)
1037
Paul Duffin1356d8c2020-02-25 19:26:33 +00001038 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001039 checkAndroidBpContents(`
1040// This is auto-generated. DO NOT EDIT.
1041
1042cc_prebuilt_library_shared {
1043 name: "mysdk_mynativelib@current",
1044 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001045 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001046 apex_available: [
1047 "apex1",
1048 "apex2",
1049 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001050 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001051 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001052 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001053 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001054 arch: {
1055 arm64: {
1056 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001057 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001058 },
1059 arm: {
1060 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001061 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001062 },
1063 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001064}
1065
1066cc_prebuilt_library_shared {
1067 name: "mynativelib",
1068 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001069 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001070 apex_available: [
1071 "apex1",
1072 "apex2",
1073 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001074 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001075 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001076 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001077 arch: {
1078 arm64: {
1079 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001080 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001081 },
1082 arm: {
1083 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001084 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001085 },
1086 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001087}
1088
1089sdk_snapshot {
1090 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001091 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001092 native_shared_libs: ["mysdk_mynativelib@current"],
1093}
1094`),
1095 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001096include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001097.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1098.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1099.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1100.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1101.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1102.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1103.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1104.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 +00001105`),
1106 )
1107}
1108
Paul Duffin13f02712020-03-06 12:30:43 +00001109func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1110 result := testSdkWithCc(t, `
1111 sdk {
1112 name: "mysdk",
1113 native_shared_libs: [
1114 "mynativelib",
1115 "myothernativelib",
1116 "mysystemnativelib",
1117 ],
1118 }
1119
1120 cc_library {
1121 name: "mysystemnativelib",
1122 srcs: [
1123 "Test.cpp",
1124 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001125 stl: "none",
1126 }
1127
1128 cc_library_shared {
1129 name: "myothernativelib",
1130 srcs: [
1131 "Test.cpp",
1132 ],
1133 system_shared_libs: [
1134 // A reference to a library that is not an sdk member. Uses libm as that
1135 // is in the default set of modules available to this test and so is available
1136 // both here and also when the generated Android.bp file is tested in
1137 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1138 // handles references to modules that are not sdk members.
1139 "libm",
1140 ],
1141 stl: "none",
1142 }
1143
1144 cc_library {
1145 name: "mynativelib",
1146 srcs: [
1147 "Test.cpp",
1148 ],
1149 shared_libs: [
1150 // A reference to another sdk member.
1151 "myothernativelib",
1152 ],
1153 target: {
1154 android: {
1155 shared: {
1156 shared_libs: [
1157 // A reference to a library that is not an sdk member. The libc library
1158 // is used here to check that the shared_libs property is handled correctly
1159 // in a similar way to how libm is used to check system_shared_libs above.
1160 "libc",
1161 ],
1162 },
1163 },
1164 },
Paul Duffin13f02712020-03-06 12:30:43 +00001165 stl: "none",
1166 }
1167 `)
1168
1169 result.CheckSnapshot("mysdk", "",
1170 checkAndroidBpContents(`
1171// This is auto-generated. DO NOT EDIT.
1172
1173cc_prebuilt_library_shared {
1174 name: "mysdk_mynativelib@current",
1175 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001176 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001177 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001178 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001179 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001180 shared_libs: [
1181 "mysdk_myothernativelib@current",
1182 "libc",
1183 ],
1184 arch: {
1185 arm64: {
1186 srcs: ["arm64/lib/mynativelib.so"],
1187 },
1188 arm: {
1189 srcs: ["arm/lib/mynativelib.so"],
1190 },
1191 },
Paul Duffin13f02712020-03-06 12:30:43 +00001192}
1193
1194cc_prebuilt_library_shared {
1195 name: "mynativelib",
1196 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001197 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001198 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001199 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001200 shared_libs: [
1201 "myothernativelib",
1202 "libc",
1203 ],
1204 arch: {
1205 arm64: {
1206 srcs: ["arm64/lib/mynativelib.so"],
1207 },
1208 arm: {
1209 srcs: ["arm/lib/mynativelib.so"],
1210 },
1211 },
Paul Duffin13f02712020-03-06 12:30:43 +00001212}
1213
1214cc_prebuilt_library_shared {
1215 name: "mysdk_myothernativelib@current",
1216 sdk_member_name: "myothernativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001217 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001218 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001219 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001220 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001221 system_shared_libs: ["libm"],
1222 arch: {
1223 arm64: {
1224 srcs: ["arm64/lib/myothernativelib.so"],
1225 },
1226 arm: {
1227 srcs: ["arm/lib/myothernativelib.so"],
1228 },
1229 },
Paul Duffin13f02712020-03-06 12:30:43 +00001230}
1231
1232cc_prebuilt_library_shared {
1233 name: "myothernativelib",
1234 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001235 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001236 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001237 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001238 system_shared_libs: ["libm"],
1239 arch: {
1240 arm64: {
1241 srcs: ["arm64/lib/myothernativelib.so"],
1242 },
1243 arm: {
1244 srcs: ["arm/lib/myothernativelib.so"],
1245 },
1246 },
Paul Duffin13f02712020-03-06 12:30:43 +00001247}
1248
1249cc_prebuilt_library_shared {
1250 name: "mysdk_mysystemnativelib@current",
1251 sdk_member_name: "mysystemnativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001252 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001253 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001254 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001255 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001256 arch: {
1257 arm64: {
1258 srcs: ["arm64/lib/mysystemnativelib.so"],
1259 },
1260 arm: {
1261 srcs: ["arm/lib/mysystemnativelib.so"],
1262 },
1263 },
Paul Duffin13f02712020-03-06 12:30:43 +00001264}
1265
1266cc_prebuilt_library_shared {
1267 name: "mysystemnativelib",
1268 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001269 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001270 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001271 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001272 arch: {
1273 arm64: {
1274 srcs: ["arm64/lib/mysystemnativelib.so"],
1275 },
1276 arm: {
1277 srcs: ["arm/lib/mysystemnativelib.so"],
1278 },
1279 },
Paul Duffin13f02712020-03-06 12:30:43 +00001280}
1281
1282sdk_snapshot {
1283 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001284 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001285 native_shared_libs: [
1286 "mysdk_mynativelib@current",
1287 "mysdk_myothernativelib@current",
1288 "mysdk_mysystemnativelib@current",
1289 ],
1290}
1291`),
1292 checkAllCopyRules(`
1293.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1294.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1295.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1296.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1297.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1298.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1299`),
1300 )
1301}
1302
Paul Duffin9ab556f2019-12-11 18:42:17 +00001303func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001304 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001305 sdk {
1306 name: "mysdk",
1307 device_supported: false,
1308 host_supported: true,
1309 native_shared_libs: ["mynativelib"],
1310 }
1311
1312 cc_library_shared {
1313 name: "mynativelib",
1314 device_supported: false,
1315 host_supported: true,
1316 srcs: [
1317 "Test.cpp",
1318 "aidl/foo/bar/Test.aidl",
1319 ],
1320 export_include_dirs: ["include"],
1321 aidl: {
1322 export_aidl_headers: true,
1323 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001324 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001325 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001326 }
1327 `)
1328
Paul Duffin1356d8c2020-02-25 19:26:33 +00001329 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001330 checkAndroidBpContents(`
1331// This is auto-generated. DO NOT EDIT.
1332
1333cc_prebuilt_library_shared {
1334 name: "mysdk_mynativelib@current",
1335 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001336 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001337 device_supported: false,
1338 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001339 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001340 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001341 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001342 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001343 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001344 target: {
1345 host: {
1346 enabled: false,
1347 },
1348 linux_glibc: {
1349 enabled: true,
1350 },
1351 linux_glibc_x86_64: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001352 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001353 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001354 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001355 linux_glibc_x86: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001356 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001357 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001358 },
1359 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001360}
1361
1362cc_prebuilt_library_shared {
1363 name: "mynativelib",
1364 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001365 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001366 device_supported: false,
1367 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001368 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001369 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001370 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001371 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001372 target: {
1373 host: {
1374 enabled: false,
1375 },
1376 linux_glibc: {
1377 enabled: true,
1378 },
1379 linux_glibc_x86_64: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001380 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001381 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001382 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001383 linux_glibc_x86: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001384 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001385 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001386 },
1387 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001388}
1389
1390sdk_snapshot {
1391 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001392 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001393 device_supported: false,
1394 host_supported: true,
1395 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001396 target: {
1397 host: {
1398 enabled: false,
1399 },
1400 linux_glibc: {
1401 enabled: true,
1402 },
1403 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001404}
1405`),
1406 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001407include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001408.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001409.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1410.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1411.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1412.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001413.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1414.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1415.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1416`),
1417 )
1418}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001419
Paul Duffina04c1072020-03-02 10:16:35 +00001420func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001421 result := testSdkWithCc(t, `
1422 sdk {
1423 name: "mysdk",
1424 device_supported: false,
1425 host_supported: true,
1426 native_shared_libs: ["mynativelib"],
1427 target: {
1428 windows: {
1429 enabled: true,
1430 },
1431 },
1432 }
1433
1434 cc_library_shared {
1435 name: "mynativelib",
1436 device_supported: false,
1437 host_supported: true,
1438 srcs: [
1439 "Test.cpp",
1440 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001441 stl: "none",
1442 target: {
1443 windows: {
1444 enabled: true,
1445 },
1446 },
1447 }
1448 `)
1449
1450 result.CheckSnapshot("mysdk", "",
1451 checkAndroidBpContents(`
1452// This is auto-generated. DO NOT EDIT.
1453
1454cc_prebuilt_library_shared {
1455 name: "mysdk_mynativelib@current",
1456 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001457 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001458 device_supported: false,
1459 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001460 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001461 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001462 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001463 host: {
1464 enabled: false,
1465 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001466 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001467 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001468 compile_multilib: "both",
1469 },
Paul Duffina04c1072020-03-02 10:16:35 +00001470 linux_glibc_x86_64: {
1471 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1472 },
1473 linux_glibc_x86: {
1474 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1475 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001476 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001477 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001478 compile_multilib: "64",
1479 },
Paul Duffina04c1072020-03-02 10:16:35 +00001480 windows_x86_64: {
1481 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1482 },
1483 },
Paul Duffina04c1072020-03-02 10:16:35 +00001484}
1485
1486cc_prebuilt_library_shared {
1487 name: "mynativelib",
1488 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001489 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001490 device_supported: false,
1491 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001492 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001493 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001494 host: {
1495 enabled: false,
1496 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001497 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001498 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001499 compile_multilib: "both",
1500 },
Paul Duffina04c1072020-03-02 10:16:35 +00001501 linux_glibc_x86_64: {
1502 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1503 },
1504 linux_glibc_x86: {
1505 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1506 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001507 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001508 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001509 compile_multilib: "64",
1510 },
Paul Duffina04c1072020-03-02 10:16:35 +00001511 windows_x86_64: {
1512 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1513 },
1514 },
Paul Duffina04c1072020-03-02 10:16:35 +00001515}
1516
1517sdk_snapshot {
1518 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001519 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001520 device_supported: false,
1521 host_supported: true,
1522 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001523 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001524 host: {
1525 enabled: false,
1526 },
1527 linux_glibc: {
1528 enabled: true,
1529 },
Paul Duffin6a7e9532020-03-20 17:50:07 +00001530 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001531 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001532 compile_multilib: "64",
1533 },
1534 },
Paul Duffina04c1072020-03-02 10:16:35 +00001535}
1536`),
1537 checkAllCopyRules(`
1538.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1539.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1540.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1541`),
1542 )
1543}
1544
Paul Duffin9ab556f2019-12-11 18:42:17 +00001545func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1546 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001547 module_exports {
1548 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001549 native_static_libs: ["mynativelib"],
1550 }
1551
1552 cc_library_static {
1553 name: "mynativelib",
1554 srcs: [
1555 "Test.cpp",
1556 "aidl/foo/bar/Test.aidl",
1557 ],
1558 export_include_dirs: ["include"],
1559 aidl: {
1560 export_aidl_headers: true,
1561 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001562 stl: "none",
1563 }
1564 `)
1565
Paul Duffin1356d8c2020-02-25 19:26:33 +00001566 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001567 checkAndroidBpContents(`
1568// This is auto-generated. DO NOT EDIT.
1569
1570cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001571 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001572 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001573 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001574 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001575 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001576 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001577 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001578 arch: {
1579 arm64: {
1580 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001581 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001582 },
1583 arm: {
1584 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001585 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001586 },
1587 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001588}
1589
1590cc_prebuilt_library_static {
1591 name: "mynativelib",
1592 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001593 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001594 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001595 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001596 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001597 arch: {
1598 arm64: {
1599 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001600 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001601 },
1602 arm: {
1603 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001604 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001605 },
1606 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001607}
1608
Paul Duffine6029182019-12-16 17:43:48 +00001609module_exports_snapshot {
1610 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001611 visibility: ["//visibility:public"],
Paul Duffine6029182019-12-16 17:43:48 +00001612 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001613}
1614`),
1615 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001616include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001617.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1618.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1619.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1620.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1621.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1622.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1623.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1624.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 +00001625`),
1626 )
1627}
1628
1629func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001630 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001631 module_exports {
1632 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001633 device_supported: false,
1634 host_supported: true,
1635 native_static_libs: ["mynativelib"],
1636 }
1637
1638 cc_library_static {
1639 name: "mynativelib",
1640 device_supported: false,
1641 host_supported: true,
1642 srcs: [
1643 "Test.cpp",
1644 "aidl/foo/bar/Test.aidl",
1645 ],
1646 export_include_dirs: ["include"],
1647 aidl: {
1648 export_aidl_headers: true,
1649 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001650 stl: "none",
1651 }
1652 `)
1653
Paul Duffin1356d8c2020-02-25 19:26:33 +00001654 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001655 checkAndroidBpContents(`
1656// This is auto-generated. DO NOT EDIT.
1657
1658cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001659 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001660 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001661 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001662 device_supported: false,
1663 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001664 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001665 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001666 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001667 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001668 target: {
1669 host: {
1670 enabled: false,
1671 },
1672 linux_glibc: {
1673 enabled: true,
1674 },
1675 linux_glibc_x86_64: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001676 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001677 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001678 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001679 linux_glibc_x86: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001680 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001681 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001682 },
1683 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001684}
1685
1686cc_prebuilt_library_static {
1687 name: "mynativelib",
1688 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001689 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001690 device_supported: false,
1691 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001692 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001693 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001694 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001695 target: {
1696 host: {
1697 enabled: false,
1698 },
1699 linux_glibc: {
1700 enabled: true,
1701 },
1702 linux_glibc_x86_64: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001703 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001704 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001705 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001706 linux_glibc_x86: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001707 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001708 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001709 },
1710 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001711}
1712
Paul Duffine6029182019-12-16 17:43:48 +00001713module_exports_snapshot {
1714 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001715 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001716 device_supported: false,
1717 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001718 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001719 target: {
1720 host: {
1721 enabled: false,
1722 },
1723 linux_glibc: {
1724 enabled: true,
1725 },
1726 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001727}
1728`),
1729 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001730include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001731.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001732.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1733.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1734.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1735.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001736.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1737.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1738.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1739`),
1740 )
1741}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001742
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001743func TestSnapshotWithCcLibrary(t *testing.T) {
1744 result := testSdkWithCc(t, `
1745 module_exports {
1746 name: "myexports",
1747 native_libs: ["mynativelib"],
1748 }
1749
1750 cc_library {
1751 name: "mynativelib",
1752 srcs: [
1753 "Test.cpp",
1754 ],
1755 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001756 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001757 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001758 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001759 }
1760 `)
1761
1762 result.CheckSnapshot("myexports", "",
1763 checkAndroidBpContents(`
1764// This is auto-generated. DO NOT EDIT.
1765
1766cc_prebuilt_library {
1767 name: "myexports_mynativelib@current",
1768 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001769 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001770 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001771 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001772 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001773 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001774 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001775 export_include_dirs: ["include/include"],
1776 arch: {
1777 arm64: {
1778 static: {
1779 srcs: ["arm64/lib/mynativelib.a"],
1780 },
1781 shared: {
1782 srcs: ["arm64/lib/mynativelib.so"],
1783 },
1784 },
1785 arm: {
1786 static: {
1787 srcs: ["arm/lib/mynativelib.a"],
1788 },
1789 shared: {
1790 srcs: ["arm/lib/mynativelib.so"],
1791 },
1792 },
1793 },
1794}
1795
1796cc_prebuilt_library {
1797 name: "mynativelib",
1798 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001799 visibility: ["//visibility:public"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001800 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001801 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001802 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001803 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001804 export_include_dirs: ["include/include"],
1805 arch: {
1806 arm64: {
1807 static: {
1808 srcs: ["arm64/lib/mynativelib.a"],
1809 },
1810 shared: {
1811 srcs: ["arm64/lib/mynativelib.so"],
1812 },
1813 },
1814 arm: {
1815 static: {
1816 srcs: ["arm/lib/mynativelib.a"],
1817 },
1818 shared: {
1819 srcs: ["arm/lib/mynativelib.so"],
1820 },
1821 },
1822 },
1823}
1824
1825module_exports_snapshot {
1826 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001827 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001828 native_libs: ["myexports_mynativelib@current"],
1829}
1830`),
1831 checkAllCopyRules(`
1832include/Test.h -> include/include/Test.h
1833.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1834.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1835.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1836.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1837 )
1838}
1839
Paul Duffin13ad94f2020-02-19 16:19:27 +00001840func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001841 result := testSdkWithCc(t, `
1842 module_exports {
1843 name: "myexports",
1844 device_supported: false,
1845 host_supported: true,
1846 target: {
1847 host: {
1848 compile_multilib: "64",
1849 },
1850 },
1851 native_static_libs: ["mynativelib"],
1852 }
1853
1854 cc_library_static {
1855 name: "mynativelib",
1856 device_supported: false,
1857 host_supported: true,
1858 srcs: [
1859 "Test.cpp",
1860 "aidl/foo/bar/Test.aidl",
1861 ],
1862 export_include_dirs: ["include"],
1863 aidl: {
1864 export_aidl_headers: true,
1865 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001866 stl: "none",
1867 }
1868 `)
1869
Paul Duffin1356d8c2020-02-25 19:26:33 +00001870 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001871 checkAndroidBpContents(`
1872// This is auto-generated. DO NOT EDIT.
1873
1874cc_prebuilt_library_static {
1875 name: "myexports_mynativelib@current",
1876 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001877 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001878 device_supported: false,
1879 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001880 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001881 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001882 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001883 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001884 target: {
1885 host: {
1886 enabled: false,
1887 },
1888 linux_glibc: {
1889 enabled: true,
1890 },
1891 linux_glibc_x86_64: {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001892 srcs: ["x86_64/lib/mynativelib.a"],
1893 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1894 },
1895 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001896}
1897
1898cc_prebuilt_library_static {
1899 name: "mynativelib",
1900 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001901 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001902 device_supported: false,
1903 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001904 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001905 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001906 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001907 target: {
1908 host: {
1909 enabled: false,
1910 },
1911 linux_glibc: {
1912 enabled: true,
1913 },
1914 linux_glibc_x86_64: {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001915 srcs: ["x86_64/lib/mynativelib.a"],
1916 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1917 },
1918 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001919}
1920
1921module_exports_snapshot {
1922 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001923 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001924 device_supported: false,
1925 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001926 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001927 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001928 target: {
1929 host: {
1930 enabled: false,
1931 },
1932 linux_glibc: {
1933 enabled: true,
1934 },
1935 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001936}`),
1937 checkAllCopyRules(`
1938include/Test.h -> include/include/Test.h
1939.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1940.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1941.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1942.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1943`),
1944 )
1945}
Paul Duffin91756d22020-02-21 16:29:57 +00001946
1947func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1948 result := testSdkWithCc(t, `
1949 sdk {
1950 name: "mysdk",
1951 native_header_libs: ["mynativeheaders"],
1952 }
1953
1954 cc_library_headers {
1955 name: "mynativeheaders",
1956 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001957 stl: "none",
1958 }
1959 `)
1960
Paul Duffin1356d8c2020-02-25 19:26:33 +00001961 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001962 checkAndroidBpContents(`
1963// This is auto-generated. DO NOT EDIT.
1964
1965cc_prebuilt_library_headers {
1966 name: "mysdk_mynativeheaders@current",
1967 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01001968 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001969 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001970 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001971 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001972}
1973
1974cc_prebuilt_library_headers {
1975 name: "mynativeheaders",
1976 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001977 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001978 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001979 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001980 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001981}
1982
1983sdk_snapshot {
1984 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001985 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001986 native_header_libs: ["mysdk_mynativeheaders@current"],
1987}
1988`),
1989 checkAllCopyRules(`
1990include/Test.h -> include/include/Test.h
1991`),
1992 )
1993}
1994
1995func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001996 result := testSdkWithCc(t, `
1997 sdk {
1998 name: "mysdk",
1999 device_supported: false,
2000 host_supported: true,
2001 native_header_libs: ["mynativeheaders"],
2002 }
2003
2004 cc_library_headers {
2005 name: "mynativeheaders",
2006 device_supported: false,
2007 host_supported: true,
2008 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00002009 stl: "none",
2010 }
2011 `)
2012
Paul Duffin1356d8c2020-02-25 19:26:33 +00002013 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00002014 checkAndroidBpContents(`
2015// This is auto-generated. DO NOT EDIT.
2016
2017cc_prebuilt_library_headers {
2018 name: "mysdk_mynativeheaders@current",
2019 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002020 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002021 device_supported: false,
2022 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002023 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002024 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002025 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002026 target: {
2027 host: {
2028 enabled: false,
2029 },
2030 linux_glibc: {
2031 enabled: true,
2032 },
2033 },
Paul Duffin91756d22020-02-21 16:29:57 +00002034}
2035
2036cc_prebuilt_library_headers {
2037 name: "mynativeheaders",
2038 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002039 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002040 device_supported: false,
2041 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002042 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002043 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002044 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002045 target: {
2046 host: {
2047 enabled: false,
2048 },
2049 linux_glibc: {
2050 enabled: true,
2051 },
2052 },
Paul Duffin91756d22020-02-21 16:29:57 +00002053}
2054
2055sdk_snapshot {
2056 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002057 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002058 device_supported: false,
2059 host_supported: true,
2060 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002061 target: {
2062 host: {
2063 enabled: false,
2064 },
2065 linux_glibc: {
2066 enabled: true,
2067 },
2068 },
Paul Duffin91756d22020-02-21 16:29:57 +00002069}
2070`),
2071 checkAllCopyRules(`
2072include/Test.h -> include/include/Test.h
2073`),
2074 )
2075}
Paul Duffina04c1072020-03-02 10:16:35 +00002076
2077func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00002078 result := testSdkWithCc(t, `
2079 sdk {
2080 name: "mysdk",
2081 host_supported: true,
2082 native_header_libs: ["mynativeheaders"],
2083 }
2084
2085 cc_library_headers {
2086 name: "mynativeheaders",
2087 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002088 stl: "none",
2089 export_system_include_dirs: ["include"],
2090 target: {
2091 android: {
2092 export_include_dirs: ["include-android"],
2093 },
2094 host: {
2095 export_include_dirs: ["include-host"],
2096 },
2097 },
2098 }
2099 `)
2100
2101 result.CheckSnapshot("mysdk", "",
2102 checkAndroidBpContents(`
2103// This is auto-generated. DO NOT EDIT.
2104
2105cc_prebuilt_library_headers {
2106 name: "mysdk_mynativeheaders@current",
2107 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002108 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002109 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002110 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002111 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002112 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002113 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002114 host: {
2115 enabled: false,
2116 },
Paul Duffina04c1072020-03-02 10:16:35 +00002117 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002118 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002119 },
2120 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002121 enabled: true,
Paul Duffined62b9c2020-06-16 16:12:50 +01002122 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002123 },
2124 },
Paul Duffina04c1072020-03-02 10:16:35 +00002125}
2126
2127cc_prebuilt_library_headers {
2128 name: "mynativeheaders",
2129 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002130 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002131 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002132 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002133 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002134 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002135 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002136 host: {
2137 enabled: false,
2138 },
Paul Duffina04c1072020-03-02 10:16:35 +00002139 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002140 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002141 },
2142 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002143 enabled: true,
Paul Duffined62b9c2020-06-16 16:12:50 +01002144 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002145 },
2146 },
Paul Duffina04c1072020-03-02 10:16:35 +00002147}
2148
2149sdk_snapshot {
2150 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002151 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002152 host_supported: true,
2153 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002154 target: {
2155 host: {
2156 enabled: false,
2157 },
2158 linux_glibc: {
2159 enabled: true,
2160 },
2161 },
Paul Duffina04c1072020-03-02 10:16:35 +00002162}
2163`),
2164 checkAllCopyRules(`
Paul Duffined62b9c2020-06-16 16:12:50 +01002165include/Test.h -> common_os/include/include/Test.h
2166include-android/AndroidTest.h -> android/include/include-android/AndroidTest.h
2167include-host/HostTest.h -> linux_glibc/include/include-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002168`),
2169 )
2170}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002171
2172func TestSystemSharedLibPropagation(t *testing.T) {
2173 result := testSdkWithCc(t, `
2174 sdk {
2175 name: "mysdk",
2176 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2177 }
2178
2179 cc_library {
2180 name: "sslnil",
2181 host_supported: true,
2182 }
2183
2184 cc_library {
2185 name: "sslempty",
2186 system_shared_libs: [],
2187 }
2188
2189 cc_library {
2190 name: "sslnonempty",
2191 system_shared_libs: ["sslnil"],
2192 }
2193 `)
2194
2195 result.CheckSnapshot("mysdk", "",
2196 checkAndroidBpContents(`
2197// This is auto-generated. DO NOT EDIT.
2198
2199cc_prebuilt_library_shared {
2200 name: "mysdk_sslnil@current",
2201 sdk_member_name: "sslnil",
Paul Duffind99d9972020-09-29 16:00:55 +01002202 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002203 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002204 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002205 arch: {
2206 arm64: {
2207 srcs: ["arm64/lib/sslnil.so"],
2208 },
2209 arm: {
2210 srcs: ["arm/lib/sslnil.so"],
2211 },
2212 },
2213}
2214
2215cc_prebuilt_library_shared {
2216 name: "sslnil",
2217 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002218 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002219 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002220 arch: {
2221 arm64: {
2222 srcs: ["arm64/lib/sslnil.so"],
2223 },
2224 arm: {
2225 srcs: ["arm/lib/sslnil.so"],
2226 },
2227 },
2228}
2229
2230cc_prebuilt_library_shared {
2231 name: "mysdk_sslempty@current",
2232 sdk_member_name: "sslempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002233 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002234 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002235 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002236 system_shared_libs: [],
2237 arch: {
2238 arm64: {
2239 srcs: ["arm64/lib/sslempty.so"],
2240 },
2241 arm: {
2242 srcs: ["arm/lib/sslempty.so"],
2243 },
2244 },
2245}
2246
2247cc_prebuilt_library_shared {
2248 name: "sslempty",
2249 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002250 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002251 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002252 system_shared_libs: [],
2253 arch: {
2254 arm64: {
2255 srcs: ["arm64/lib/sslempty.so"],
2256 },
2257 arm: {
2258 srcs: ["arm/lib/sslempty.so"],
2259 },
2260 },
2261}
2262
2263cc_prebuilt_library_shared {
2264 name: "mysdk_sslnonempty@current",
2265 sdk_member_name: "sslnonempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002266 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002267 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002268 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002269 system_shared_libs: ["mysdk_sslnil@current"],
2270 arch: {
2271 arm64: {
2272 srcs: ["arm64/lib/sslnonempty.so"],
2273 },
2274 arm: {
2275 srcs: ["arm/lib/sslnonempty.so"],
2276 },
2277 },
2278}
2279
2280cc_prebuilt_library_shared {
2281 name: "sslnonempty",
2282 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002283 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002284 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002285 system_shared_libs: ["sslnil"],
2286 arch: {
2287 arm64: {
2288 srcs: ["arm64/lib/sslnonempty.so"],
2289 },
2290 arm: {
2291 srcs: ["arm/lib/sslnonempty.so"],
2292 },
2293 },
2294}
2295
2296sdk_snapshot {
2297 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002298 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002299 native_shared_libs: [
2300 "mysdk_sslnil@current",
2301 "mysdk_sslempty@current",
2302 "mysdk_sslnonempty@current",
2303 ],
2304}
2305`))
2306
2307 result = testSdkWithCc(t, `
2308 sdk {
2309 name: "mysdk",
2310 host_supported: true,
2311 native_shared_libs: ["sslvariants"],
2312 }
2313
2314 cc_library {
2315 name: "sslvariants",
2316 host_supported: true,
2317 target: {
2318 android: {
2319 system_shared_libs: [],
2320 },
2321 },
2322 }
2323 `)
2324
2325 result.CheckSnapshot("mysdk", "",
2326 checkAndroidBpContents(`
2327// This is auto-generated. DO NOT EDIT.
2328
2329cc_prebuilt_library_shared {
2330 name: "mysdk_sslvariants@current",
2331 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002332 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002333 host_supported: true,
2334 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002335 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002336 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002337 host: {
2338 enabled: false,
2339 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002340 android: {
2341 system_shared_libs: [],
2342 },
2343 android_arm64: {
2344 srcs: ["android/arm64/lib/sslvariants.so"],
2345 },
2346 android_arm: {
2347 srcs: ["android/arm/lib/sslvariants.so"],
2348 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002349 linux_glibc: {
2350 enabled: true,
2351 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002352 linux_glibc_x86_64: {
2353 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2354 },
2355 linux_glibc_x86: {
2356 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2357 },
2358 },
2359}
2360
2361cc_prebuilt_library_shared {
2362 name: "sslvariants",
2363 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002364 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002365 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002366 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002367 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002368 host: {
2369 enabled: false,
2370 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002371 android: {
2372 system_shared_libs: [],
2373 },
2374 android_arm64: {
2375 srcs: ["android/arm64/lib/sslvariants.so"],
2376 },
2377 android_arm: {
2378 srcs: ["android/arm/lib/sslvariants.so"],
2379 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002380 linux_glibc: {
2381 enabled: true,
2382 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002383 linux_glibc_x86_64: {
2384 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2385 },
2386 linux_glibc_x86: {
2387 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2388 },
2389 },
2390}
2391
2392sdk_snapshot {
2393 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002394 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002395 host_supported: true,
2396 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002397 target: {
2398 host: {
2399 enabled: false,
2400 },
2401 linux_glibc: {
2402 enabled: true,
2403 },
2404 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002405}
2406`))
2407}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002408
2409func TestStubsLibrary(t *testing.T) {
2410 result := testSdkWithCc(t, `
2411 sdk {
2412 name: "mysdk",
2413 native_shared_libs: ["stubslib"],
2414 }
2415
2416 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002417 name: "internaldep",
2418 }
2419
2420 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002421 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002422 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002423 stubs: {
2424 symbol_file: "some/where/stubslib.map.txt",
2425 versions: ["1", "2", "3"],
2426 },
2427 }
2428 `)
2429
2430 result.CheckSnapshot("mysdk", "",
2431 checkAndroidBpContents(`
2432// This is auto-generated. DO NOT EDIT.
2433
2434cc_prebuilt_library_shared {
2435 name: "mysdk_stubslib@current",
2436 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002437 visibility: ["//visibility:public"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002438 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002439 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002440 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002441 versions: [
2442 "1",
2443 "2",
2444 "3",
2445 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002446 },
2447 arch: {
2448 arm64: {
2449 srcs: ["arm64/lib/stubslib.so"],
2450 },
2451 arm: {
2452 srcs: ["arm/lib/stubslib.so"],
2453 },
2454 },
2455}
2456
2457cc_prebuilt_library_shared {
2458 name: "stubslib",
2459 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002460 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002461 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002462 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002463 versions: [
2464 "1",
2465 "2",
2466 "3",
2467 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002468 },
2469 arch: {
2470 arm64: {
2471 srcs: ["arm64/lib/stubslib.so"],
2472 },
2473 arm: {
2474 srcs: ["arm/lib/stubslib.so"],
2475 },
2476 },
2477}
2478
2479sdk_snapshot {
2480 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002481 visibility: ["//visibility:public"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002482 native_shared_libs: ["mysdk_stubslib@current"],
2483}
2484`))
2485}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002486
2487func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002488 result := testSdkWithCc(t, `
2489 sdk {
2490 name: "mysdk",
2491 host_supported: true,
2492 native_shared_libs: ["stubslib"],
2493 }
2494
2495 cc_library {
2496 name: "internaldep",
2497 host_supported: true,
2498 }
2499
2500 cc_library {
2501 name: "stubslib",
2502 host_supported: true,
2503 shared_libs: ["internaldep"],
2504 stubs: {
2505 symbol_file: "some/where/stubslib.map.txt",
2506 versions: ["1", "2", "3"],
2507 },
2508 }
2509 `)
2510
2511 result.CheckSnapshot("mysdk", "",
2512 checkAndroidBpContents(`
2513// This is auto-generated. DO NOT EDIT.
2514
2515cc_prebuilt_library_shared {
2516 name: "mysdk_stubslib@current",
2517 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002518 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002519 host_supported: true,
2520 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002521 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002522 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002523 versions: [
2524 "1",
2525 "2",
2526 "3",
2527 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002528 },
2529 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002530 host: {
2531 enabled: false,
2532 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002533 android_arm64: {
2534 srcs: ["android/arm64/lib/stubslib.so"],
2535 },
2536 android_arm: {
2537 srcs: ["android/arm/lib/stubslib.so"],
2538 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002539 linux_glibc: {
2540 enabled: true,
2541 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002542 linux_glibc_x86_64: {
2543 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2544 },
2545 linux_glibc_x86: {
2546 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2547 },
2548 },
2549}
2550
2551cc_prebuilt_library_shared {
2552 name: "stubslib",
2553 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002554 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002555 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002556 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002557 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002558 versions: [
2559 "1",
2560 "2",
2561 "3",
2562 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002563 },
2564 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002565 host: {
2566 enabled: false,
2567 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002568 android_arm64: {
2569 srcs: ["android/arm64/lib/stubslib.so"],
2570 },
2571 android_arm: {
2572 srcs: ["android/arm/lib/stubslib.so"],
2573 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002574 linux_glibc: {
2575 enabled: true,
2576 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002577 linux_glibc_x86_64: {
2578 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2579 },
2580 linux_glibc_x86: {
2581 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2582 },
2583 },
2584}
2585
2586sdk_snapshot {
2587 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002588 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002589 host_supported: true,
2590 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002591 target: {
2592 host: {
2593 enabled: false,
2594 },
2595 linux_glibc: {
2596 enabled: true,
2597 },
2598 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002599}
2600`))
2601}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002602
2603func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002604 result := testSdkWithCc(t, `
2605 sdk {
2606 name: "mysdk",
2607 host_supported: true,
2608 native_shared_libs: ["mylib"],
2609 }
2610
2611 cc_library {
2612 name: "mylib",
2613 host_supported: true,
2614 unique_host_soname: true,
2615 }
2616 `)
2617
2618 result.CheckSnapshot("mysdk", "",
2619 checkAndroidBpContents(`
2620// This is auto-generated. DO NOT EDIT.
2621
2622cc_prebuilt_library_shared {
2623 name: "mysdk_mylib@current",
2624 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002625 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002626 host_supported: true,
2627 installable: false,
2628 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002629 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002630 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002631 host: {
2632 enabled: false,
2633 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002634 android_arm64: {
2635 srcs: ["android/arm64/lib/mylib.so"],
2636 },
2637 android_arm: {
2638 srcs: ["android/arm/lib/mylib.so"],
2639 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002640 linux_glibc: {
2641 enabled: true,
2642 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002643 linux_glibc_x86_64: {
2644 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2645 },
2646 linux_glibc_x86: {
2647 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2648 },
2649 },
2650}
2651
2652cc_prebuilt_library_shared {
2653 name: "mylib",
2654 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002655 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002656 host_supported: true,
2657 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002658 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002659 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002660 host: {
2661 enabled: false,
2662 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002663 android_arm64: {
2664 srcs: ["android/arm64/lib/mylib.so"],
2665 },
2666 android_arm: {
2667 srcs: ["android/arm/lib/mylib.so"],
2668 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002669 linux_glibc: {
2670 enabled: true,
2671 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002672 linux_glibc_x86_64: {
2673 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2674 },
2675 linux_glibc_x86: {
2676 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2677 },
2678 },
2679}
2680
2681sdk_snapshot {
2682 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002683 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002684 host_supported: true,
2685 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002686 target: {
2687 host: {
2688 enabled: false,
2689 },
2690 linux_glibc: {
2691 enabled: true,
2692 },
2693 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002694}
2695`),
2696 checkAllCopyRules(`
2697.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2698.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2699.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2700.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2701`),
2702 )
2703}