blob: ac3c336cd52e2a0f1147a50f6eb460bc30fca09f [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", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000105 checkUnversionedAndroidBpContents(`
Martin Stjernholm89238f42020-07-10 00:14:03 +0100106// This is auto-generated. DO NOT EDIT.
107
108cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +0000109 name: "sdkmember",
110 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100111 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000112 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100113 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +0100114 stl: "none",
115 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100116 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100117 host: {
118 enabled: false,
119 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100120 android_arm64: {
121 srcs: ["android/arm64/lib/sdkmember.so"],
122 },
123 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900124 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100125 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100126 },
127 },
128}
Paul Duffin75b902a2021-02-22 12:13:13 +0000129`),
130 checkVersionedAndroidBpContents(`
131// This is auto-generated. DO NOT EDIT.
Martin Stjernholm89238f42020-07-10 00:14:03 +0100132
133cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +0000134 name: "mysdk_sdkmember@current",
135 sdk_member_name: "sdkmember",
Paul Duffind99d9972020-09-29 16:00:55 +0100136 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000137 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100138 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +0000139 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +0100140 stl: "none",
141 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100142 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100143 host: {
144 enabled: false,
145 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100146 android_arm64: {
147 srcs: ["android/arm64/lib/sdkmember.so"],
148 },
149 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900150 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100151 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100152 },
153 },
154}
155
156sdk_snapshot {
157 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100158 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100159 host_supported: true,
160 native_shared_libs: ["mysdk_sdkmember@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100161 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100162 target: {
163 host: {
164 enabled: false,
165 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900166 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100167 enabled: true,
168 },
169 },
Martin Stjernholm89238f42020-07-10 00:14:03 +0100170}
171`),
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100172 checkAllCopyRules(`
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100173.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
174.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100175`))
176}
177
Paul Duffina80fdec2019-12-03 15:25:00 +0000178func TestBasicSdkWithCc(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000179 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000180 sdk {
181 name: "mysdk",
182 native_shared_libs: ["sdkmember"],
183 }
184
Paul Duffina0843f62019-12-13 19:50:38 +0000185 cc_library_shared {
186 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -0800187 system_shared_libs: [],
Martin Stjernholmcc776012020-07-07 03:22:21 +0100188 stl: "none",
189 apex_available: ["mysdkapex"],
Paul Duffina0843f62019-12-13 19:50:38 +0000190 }
191
Paul Duffina80fdec2019-12-03 15:25:00 +0000192 sdk_snapshot {
193 name: "mysdk@1",
194 native_shared_libs: ["sdkmember_mysdk_1"],
195 }
196
197 sdk_snapshot {
198 name: "mysdk@2",
199 native_shared_libs: ["sdkmember_mysdk_2"],
200 }
201
202 cc_prebuilt_library_shared {
203 name: "sdkmember",
204 srcs: ["libfoo.so"],
205 prefer: false,
206 system_shared_libs: [],
207 stl: "none",
208 }
209
210 cc_prebuilt_library_shared {
211 name: "sdkmember_mysdk_1",
212 sdk_member_name: "sdkmember",
213 srcs: ["libfoo.so"],
214 system_shared_libs: [],
215 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000216 // TODO: remove //apex_available:platform
217 apex_available: [
218 "//apex_available:platform",
219 "myapex",
220 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000221 }
222
223 cc_prebuilt_library_shared {
224 name: "sdkmember_mysdk_2",
225 sdk_member_name: "sdkmember",
226 srcs: ["libfoo.so"],
227 system_shared_libs: [],
228 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000229 // TODO: remove //apex_available:platform
230 apex_available: [
231 "//apex_available:platform",
232 "myapex2",
233 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000234 }
235
236 cc_library_shared {
237 name: "mycpplib",
238 srcs: ["Test.cpp"],
239 shared_libs: ["sdkmember"],
240 system_shared_libs: [],
241 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000242 apex_available: [
243 "myapex",
244 "myapex2",
245 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000246 }
247
248 apex {
249 name: "myapex",
250 native_shared_libs: ["mycpplib"],
251 uses_sdks: ["mysdk@1"],
252 key: "myapex.key",
253 certificate: ":myapex.cert",
254 }
255
256 apex {
257 name: "myapex2",
258 native_shared_libs: ["mycpplib"],
259 uses_sdks: ["mysdk@2"],
260 key: "myapex.key",
261 certificate: ":myapex.cert",
262 }
Martin Stjernholmcc776012020-07-07 03:22:21 +0100263
264 apex {
265 name: "mysdkapex",
266 native_shared_libs: ["sdkmember"],
267 key: "myapex.key",
268 certificate: ":myapex.cert",
269 }
Paul Duffina80fdec2019-12-03 15:25:00 +0000270 `)
271
Colin Crossaede88c2020-08-11 12:17:01 -0700272 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
273 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000274
Colin Crossaede88c2020-08-11 12:17:01 -0700275 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1")
276 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000277
278 // Depending on the uses_sdks value, different libs are linked
279 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
280 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
281}
282
Paul Duffina0843f62019-12-13 19:50:38 +0000283// Make sure the sdk can use host specific cc libraries static/shared and both.
284func TestHostSdkWithCc(t *testing.T) {
285 testSdkWithCc(t, `
286 sdk {
287 name: "mysdk",
288 device_supported: false,
289 host_supported: true,
290 native_shared_libs: ["sdkshared"],
291 native_static_libs: ["sdkstatic"],
292 }
293
294 cc_library_host_shared {
295 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000296 stl: "none",
297 }
298
299 cc_library_host_static {
300 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000301 stl: "none",
302 }
303 `)
304}
305
306// Make sure the sdk can use cc libraries static/shared and both.
307func TestSdkWithCc(t *testing.T) {
308 testSdkWithCc(t, `
309 sdk {
310 name: "mysdk",
311 native_shared_libs: ["sdkshared", "sdkboth1"],
312 native_static_libs: ["sdkstatic", "sdkboth2"],
313 }
314
315 cc_library_shared {
316 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000317 stl: "none",
318 }
319
320 cc_library_static {
321 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000322 stl: "none",
323 }
324
325 cc_library {
326 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000327 stl: "none",
328 }
329
330 cc_library {
331 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000332 stl: "none",
333 }
334 `)
335}
336
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000337func TestSnapshotWithObject(t *testing.T) {
338 result := testSdkWithCc(t, `
339 sdk {
340 name: "mysdk",
341 native_objects: ["crtobj"],
342 }
343
344 cc_object {
345 name: "crtobj",
346 stl: "none",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100347 sanitize: {
348 never: true,
349 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000350 }
351 `)
352
353 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000354 checkUnversionedAndroidBpContents(`
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000355// This is auto-generated. DO NOT EDIT.
356
357cc_prebuilt_object {
Paul Duffin75b902a2021-02-22 12:13:13 +0000358 name: "crtobj",
359 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100360 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000361 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000362 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100363 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100364 sanitize: {
365 never: true,
366 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000367 arch: {
368 arm64: {
369 srcs: ["arm64/lib/crtobj.o"],
370 },
371 arm: {
372 srcs: ["arm/lib/crtobj.o"],
373 },
374 },
375}
Paul Duffin75b902a2021-02-22 12:13:13 +0000376`),
377 // Make sure that the generated sdk_snapshot uses the native_objects property.
378 checkVersionedAndroidBpContents(`
379// This is auto-generated. DO NOT EDIT.
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000380
381cc_prebuilt_object {
Paul Duffin75b902a2021-02-22 12:13:13 +0000382 name: "mysdk_crtobj@current",
383 sdk_member_name: "crtobj",
Paul Duffind99d9972020-09-29 16:00:55 +0100384 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000385 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000386 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100387 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100388 sanitize: {
389 never: true,
390 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000391 arch: {
392 arm64: {
393 srcs: ["arm64/lib/crtobj.o"],
394 },
395 arm: {
396 srcs: ["arm/lib/crtobj.o"],
397 },
398 },
399}
400
401sdk_snapshot {
402 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100403 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000404 native_objects: ["mysdk_crtobj@current"],
405}
406`),
407 checkAllCopyRules(`
408.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
409.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
410`),
411 )
412}
413
Paul Duffinc62a5102019-12-11 18:34:15 +0000414func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
415 result := testSdkWithCc(t, `
416 sdk {
417 name: "mysdk",
418 native_shared_libs: ["mynativelib1", "mynativelib2"],
419 }
420
421 cc_library_shared {
422 name: "mynativelib1",
423 srcs: [
424 "Test.cpp",
425 ],
426 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000427 stl: "none",
428 }
429
430 cc_library_shared {
431 name: "mynativelib2",
432 srcs: [
433 "Test.cpp",
434 ],
435 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000436 stl: "none",
437 }
438 `)
439
Paul Duffin1356d8c2020-02-25 19:26:33 +0000440 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000441 checkAllCopyRules(`
442include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800443.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
444.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
445.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
446.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000447`),
448 )
449}
450
Martin Stjernholmb0249572020-09-15 02:32:35 +0100451// Verify that when the shared library has some common and some arch specific
452// properties that the generated snapshot is optimized properly. Substruct
453// handling is tested with the sanitize clauses (but note there's a lot of
454// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000455func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
456 result := testSdkWithCc(t, `
457 sdk {
458 name: "mysdk",
459 native_shared_libs: ["mynativelib"],
460 }
461
462 cc_library_shared {
463 name: "mynativelib",
464 srcs: [
465 "Test.cpp",
466 "aidl/foo/bar/Test.aidl",
467 ],
468 export_include_dirs: ["include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100469 sanitize: {
470 fuzzer: false,
471 integer_overflow: true,
472 diag: { undefined: false },
473 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000474 arch: {
475 arm64: {
476 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100477 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100478 integer_overflow: false,
479 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000480 },
481 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000482 stl: "none",
483 }
484 `)
485
Paul Duffin1356d8c2020-02-25 19:26:33 +0000486 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000487 checkUnversionedAndroidBpContents(`
Paul Duffina7cd8c82019-12-11 20:00:57 +0000488// This is auto-generated. DO NOT EDIT.
489
490cc_prebuilt_library_shared {
Paul Duffina7cd8c82019-12-11 20:00:57 +0000491 name: "mynativelib",
492 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100493 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000494 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000495 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100496 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000497 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100498 sanitize: {
499 fuzzer: false,
500 diag: {
501 undefined: false,
502 },
503 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000504 arch: {
505 arm64: {
506 srcs: ["arm64/lib/mynativelib.so"],
507 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100508 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100509 integer_overflow: false,
510 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000511 },
512 arm: {
513 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100514 sanitize: {
515 integer_overflow: true,
516 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000517 },
518 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000519}
Paul Duffina7cd8c82019-12-11 20:00:57 +0000520`),
521 checkAllCopyRules(`
522include/Test.h -> include/include/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +0000523.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000524arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800525.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000526 )
527}
528
Paul Duffin25ce04b2020-01-16 11:47:25 +0000529func TestSnapshotWithCcBinary(t *testing.T) {
530 result := testSdkWithCc(t, `
531 module_exports {
532 name: "mymodule_exports",
533 native_binaries: ["mynativebinary"],
534 }
535
536 cc_binary {
537 name: "mynativebinary",
538 srcs: [
539 "Test.cpp",
540 ],
541 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000542 }
543 `)
544
Paul Duffin1356d8c2020-02-25 19:26:33 +0000545 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000546 checkUnversionedAndroidBpContents(`
Paul Duffin25ce04b2020-01-16 11:47:25 +0000547// This is auto-generated. DO NOT EDIT.
548
549cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000550 name: "mynativebinary",
551 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100552 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000553 apex_available: ["//apex_available:platform"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000554 compile_multilib: "both",
555 arch: {
556 arm64: {
557 srcs: ["arm64/bin/mynativebinary"],
558 },
559 arm: {
560 srcs: ["arm/bin/mynativebinary"],
561 },
562 },
563}
Paul Duffin75b902a2021-02-22 12:13:13 +0000564`),
565 // Make sure that the generated sdk_snapshot uses the native_binaries property.
566 checkVersionedAndroidBpContents(`
567// This is auto-generated. DO NOT EDIT.
Paul Duffin25ce04b2020-01-16 11:47:25 +0000568
569cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000570 name: "mymodule_exports_mynativebinary@current",
571 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100572 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000573 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +0000574 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000575 compile_multilib: "both",
576 arch: {
577 arm64: {
578 srcs: ["arm64/bin/mynativebinary"],
579 },
580 arm: {
581 srcs: ["arm/bin/mynativebinary"],
582 },
583 },
584}
585
586module_exports_snapshot {
587 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100588 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000589 native_binaries: ["mymodule_exports_mynativebinary@current"],
590}
591`),
592 checkAllCopyRules(`
593.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
594.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
595`),
596 )
597}
598
Paul Duffina04c1072020-03-02 10:16:35 +0000599func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000600 result := testSdkWithCc(t, `
601 module_exports {
602 name: "myexports",
603 device_supported: false,
604 host_supported: true,
605 native_binaries: ["mynativebinary"],
606 target: {
607 windows: {
608 enabled: true,
609 },
610 },
611 }
612
613 cc_binary {
614 name: "mynativebinary",
615 device_supported: false,
616 host_supported: true,
617 srcs: [
618 "Test.cpp",
619 ],
620 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000621 stl: "none",
622 target: {
623 windows: {
624 enabled: true,
625 },
626 },
627 }
628 `)
629
630 result.CheckSnapshot("myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000631 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +0000632// This is auto-generated. DO NOT EDIT.
633
634cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000635 name: "mynativebinary",
636 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100637 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000638 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000639 device_supported: false,
640 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100641 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000642 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100643 host: {
644 enabled: false,
645 },
Paul Duffina04c1072020-03-02 10:16:35 +0000646 linux_glibc: {
647 compile_multilib: "both",
648 },
649 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900650 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000651 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
652 },
653 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900654 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000655 srcs: ["linux_glibc/x86/bin/mynativebinary"],
656 },
657 windows: {
658 compile_multilib: "64",
659 },
660 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900661 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000662 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
663 },
664 },
665}
Paul Duffin75b902a2021-02-22 12:13:13 +0000666`),
667 checkVersionedAndroidBpContents(`
668// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +0000669
670cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000671 name: "myexports_mynativebinary@current",
672 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100673 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000674 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000675 device_supported: false,
676 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +0000677 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100678 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000679 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100680 host: {
681 enabled: false,
682 },
Paul Duffina04c1072020-03-02 10:16:35 +0000683 linux_glibc: {
684 compile_multilib: "both",
685 },
686 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900687 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000688 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
689 },
690 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900691 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000692 srcs: ["linux_glibc/x86/bin/mynativebinary"],
693 },
694 windows: {
695 compile_multilib: "64",
696 },
697 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900698 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000699 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
700 },
701 },
702}
703
704module_exports_snapshot {
705 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100706 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000707 device_supported: false,
708 host_supported: true,
709 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000710 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900711 windows: {
712 compile_multilib: "64",
713 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100714 host: {
715 enabled: false,
716 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900717 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100718 enabled: true,
719 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900720 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100721 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +0900722 },
723 windows_x86_64: {
724 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000725 },
726 },
Paul Duffina04c1072020-03-02 10:16:35 +0000727}
728`),
729 checkAllCopyRules(`
730.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
731.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
732.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
733`),
734 )
735}
736
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100737func TestSnapshotWithSingleHostOsType(t *testing.T) {
738 ctx, config := testSdkContext(`
739 cc_defaults {
740 name: "mydefaults",
741 device_supported: false,
742 host_supported: true,
743 compile_multilib: "64",
744 target: {
745 host: {
746 enabled: false,
747 },
748 linux_bionic: {
749 enabled: true,
750 },
751 },
752 }
753
754 module_exports {
755 name: "myexports",
756 defaults: ["mydefaults"],
757 native_shared_libs: ["mynativelib"],
758 native_binaries: ["mynativebinary"],
759 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
760 }
761
762 cc_library {
763 name: "mynativelib",
764 defaults: ["mydefaults"],
765 srcs: [
766 "Test.cpp",
767 ],
768 stl: "none",
769 }
770
771 cc_binary {
772 name: "mynativebinary",
773 defaults: ["mydefaults"],
774 srcs: [
775 "Test.cpp",
776 ],
777 stl: "none",
778 }
779 `, ccTestFs, []android.OsType{android.LinuxBionic})
780
781 result := runTests(t, ctx, config)
782
783 result.CheckSnapshot("myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000784 checkUnversionedAndroidBpContents(`
785// This is auto-generated. DO NOT EDIT.
786
787cc_prebuilt_binary {
788 name: "mynativebinary",
789 prefer: false,
790 visibility: ["//visibility:public"],
791 apex_available: ["//apex_available:platform"],
792 device_supported: false,
793 host_supported: true,
794 stl: "none",
795 compile_multilib: "64",
796 target: {
797 host: {
798 enabled: false,
799 },
800 linux_bionic_x86_64: {
801 enabled: true,
802 srcs: ["x86_64/bin/mynativebinary"],
803 },
804 },
805}
806
807cc_prebuilt_library_shared {
808 name: "mynativelib",
809 prefer: false,
810 visibility: ["//visibility:public"],
811 apex_available: ["//apex_available:platform"],
812 device_supported: false,
813 host_supported: true,
814 stl: "none",
815 compile_multilib: "64",
816 target: {
817 host: {
818 enabled: false,
819 },
820 linux_bionic_x86_64: {
821 enabled: true,
822 srcs: ["x86_64/lib/mynativelib.so"],
823 },
824 },
825}
826`),
827 checkVersionedAndroidBpContents(`
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100828// This is auto-generated. DO NOT EDIT.
829
830cc_prebuilt_binary {
831 name: "myexports_mynativebinary@current",
832 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100833 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000834 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100835 device_supported: false,
836 host_supported: true,
837 installable: false,
838 stl: "none",
839 compile_multilib: "64",
840 target: {
841 host: {
842 enabled: false,
843 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100844 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900845 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100846 srcs: ["x86_64/bin/mynativebinary"],
847 },
848 },
849}
850
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100851cc_prebuilt_library_shared {
852 name: "myexports_mynativelib@current",
853 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100854 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000855 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100856 device_supported: false,
857 host_supported: true,
858 installable: false,
859 stl: "none",
860 compile_multilib: "64",
861 target: {
862 host: {
863 enabled: false,
864 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100865 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900866 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100867 srcs: ["x86_64/lib/mynativelib.so"],
868 },
869 },
870}
871
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100872module_exports_snapshot {
873 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100874 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100875 device_supported: false,
876 host_supported: true,
877 native_binaries: ["myexports_mynativebinary@current"],
878 native_shared_libs: ["myexports_mynativelib@current"],
879 compile_multilib: "64",
880 target: {
881 host: {
882 enabled: false,
883 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900884 linux_bionic_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100885 enabled: true,
886 },
887 },
888}
889`),
890 checkAllCopyRules(`
891.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
892.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
893`),
894 )
895}
896
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100897// Test that we support the necessary flags for the linker binary, which is
898// special in several ways.
899func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100900 result := testSdkWithCc(t, `
901 module_exports {
902 name: "mymodule_exports",
903 host_supported: true,
904 device_supported: false,
905 native_binaries: ["linker"],
906 }
907
908 cc_binary {
909 name: "linker",
910 host_supported: true,
911 static_executable: true,
912 nocrt: true,
913 stl: "none",
914 srcs: [
915 "Test.cpp",
916 ],
917 compile_multilib: "both",
918 }
919 `)
920
921 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000922 checkUnversionedAndroidBpContents(`
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100923// This is auto-generated. DO NOT EDIT.
924
925cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000926 name: "linker",
927 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100928 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000929 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100930 device_supported: false,
931 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100932 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100933 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100934 static_executable: true,
935 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100936 target: {
937 host: {
938 enabled: false,
939 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100940 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900941 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100942 srcs: ["x86_64/bin/linker"],
943 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100944 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900945 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100946 srcs: ["x86/bin/linker"],
947 },
948 },
949}
Paul Duffin75b902a2021-02-22 12:13:13 +0000950`),
951 checkVersionedAndroidBpContents(`
952// This is auto-generated. DO NOT EDIT.
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100953
954cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000955 name: "mymodule_exports_linker@current",
956 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +0100957 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000958 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100959 device_supported: false,
960 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +0000961 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100962 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100963 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100964 static_executable: true,
965 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100966 target: {
967 host: {
968 enabled: false,
969 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100970 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900971 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100972 srcs: ["x86_64/bin/linker"],
973 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100974 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900975 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100976 srcs: ["x86/bin/linker"],
977 },
978 },
979}
980
981module_exports_snapshot {
982 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100983 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100984 device_supported: false,
985 host_supported: true,
986 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100987 target: {
988 host: {
989 enabled: false,
990 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900991 linux_glibc_x86_64: {
992 enabled: true,
993 },
994 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100995 enabled: true,
996 },
997 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100998}
999`),
1000 checkAllCopyRules(`
1001.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1002.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1003`),
1004 )
1005}
1006
Paul Duffin9ab556f2019-12-11 18:42:17 +00001007func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001008 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001009 sdk {
1010 name: "mysdk",
1011 native_shared_libs: ["mynativelib"],
1012 }
1013
1014 cc_library_shared {
1015 name: "mynativelib",
1016 srcs: [
1017 "Test.cpp",
1018 "aidl/foo/bar/Test.aidl",
1019 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001020 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001021 export_include_dirs: ["include"],
1022 aidl: {
1023 export_aidl_headers: true,
1024 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001025 stl: "none",
1026 }
1027 `)
1028
Paul Duffin1356d8c2020-02-25 19:26:33 +00001029 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001030 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001031// This is auto-generated. DO NOT EDIT.
1032
1033cc_prebuilt_library_shared {
Paul Duffina80fdec2019-12-03 15:25:00 +00001034 name: "mynativelib",
1035 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001036 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001037 apex_available: [
1038 "apex1",
1039 "apex2",
1040 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001041 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001042 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001043 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001044 arch: {
1045 arm64: {
1046 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001047 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001048 },
1049 arm: {
1050 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001051 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001052 },
1053 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001054}
Paul Duffina80fdec2019-12-03 15:25:00 +00001055`),
1056 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001057include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001058.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1059.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1060.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1061.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1062.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1063.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1064.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1065.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 +00001066`),
1067 )
1068}
1069
Paul Duffin13f02712020-03-06 12:30:43 +00001070func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1071 result := testSdkWithCc(t, `
1072 sdk {
1073 name: "mysdk",
1074 native_shared_libs: [
1075 "mynativelib",
1076 "myothernativelib",
1077 "mysystemnativelib",
1078 ],
1079 }
1080
1081 cc_library {
1082 name: "mysystemnativelib",
1083 srcs: [
1084 "Test.cpp",
1085 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001086 stl: "none",
1087 }
1088
1089 cc_library_shared {
1090 name: "myothernativelib",
1091 srcs: [
1092 "Test.cpp",
1093 ],
1094 system_shared_libs: [
1095 // A reference to a library that is not an sdk member. Uses libm as that
1096 // is in the default set of modules available to this test and so is available
1097 // both here and also when the generated Android.bp file is tested in
1098 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1099 // handles references to modules that are not sdk members.
1100 "libm",
1101 ],
1102 stl: "none",
1103 }
1104
1105 cc_library {
1106 name: "mynativelib",
1107 srcs: [
1108 "Test.cpp",
1109 ],
1110 shared_libs: [
1111 // A reference to another sdk member.
1112 "myothernativelib",
1113 ],
1114 target: {
1115 android: {
1116 shared: {
1117 shared_libs: [
1118 // A reference to a library that is not an sdk member. The libc library
1119 // is used here to check that the shared_libs property is handled correctly
1120 // in a similar way to how libm is used to check system_shared_libs above.
1121 "libc",
1122 ],
1123 },
1124 },
1125 },
Paul Duffin13f02712020-03-06 12:30:43 +00001126 stl: "none",
1127 }
1128 `)
1129
1130 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001131 checkUnversionedAndroidBpContents(`
Paul Duffin13f02712020-03-06 12:30:43 +00001132// This is auto-generated. DO NOT EDIT.
1133
1134cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001135 name: "mynativelib",
1136 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001137 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001138 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001139 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001140 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001141 shared_libs: [
1142 "myothernativelib",
1143 "libc",
1144 ],
1145 arch: {
1146 arm64: {
1147 srcs: ["arm64/lib/mynativelib.so"],
1148 },
1149 arm: {
1150 srcs: ["arm/lib/mynativelib.so"],
1151 },
1152 },
Paul Duffin13f02712020-03-06 12:30:43 +00001153}
1154
1155cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001156 name: "myothernativelib",
1157 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001158 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001159 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001160 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001161 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001162 system_shared_libs: ["libm"],
1163 arch: {
1164 arm64: {
1165 srcs: ["arm64/lib/myothernativelib.so"],
1166 },
1167 arm: {
1168 srcs: ["arm/lib/myothernativelib.so"],
1169 },
1170 },
Paul Duffin13f02712020-03-06 12:30:43 +00001171}
1172
1173cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001174 name: "mysystemnativelib",
1175 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001176 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001177 apex_available: ["//apex_available:platform"],
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 arch: {
1181 arm64: {
1182 srcs: ["arm64/lib/mysystemnativelib.so"],
1183 },
1184 arm: {
1185 srcs: ["arm/lib/mysystemnativelib.so"],
1186 },
1187 },
Paul Duffin13f02712020-03-06 12:30:43 +00001188}
Paul Duffin13f02712020-03-06 12:30:43 +00001189`),
1190 checkAllCopyRules(`
1191.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1192.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1193.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1194.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1195.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1196.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1197`),
1198 )
1199}
1200
Paul Duffin9ab556f2019-12-11 18:42:17 +00001201func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001202 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001203 sdk {
1204 name: "mysdk",
1205 device_supported: false,
1206 host_supported: true,
1207 native_shared_libs: ["mynativelib"],
1208 }
1209
1210 cc_library_shared {
1211 name: "mynativelib",
1212 device_supported: false,
1213 host_supported: true,
1214 srcs: [
1215 "Test.cpp",
1216 "aidl/foo/bar/Test.aidl",
1217 ],
1218 export_include_dirs: ["include"],
1219 aidl: {
1220 export_aidl_headers: true,
1221 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001222 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001223 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001224 }
1225 `)
1226
Paul Duffin1356d8c2020-02-25 19:26:33 +00001227 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001228 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001229// This is auto-generated. DO NOT EDIT.
1230
1231cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001232 name: "mynativelib",
1233 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001234 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001235 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001236 device_supported: false,
1237 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001238 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001239 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001240 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001241 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001242 target: {
1243 host: {
1244 enabled: false,
1245 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001246 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001247 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001248 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001249 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001250 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001251 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001252 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001253 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001254 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001255 },
1256 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001257}
Paul Duffin75b902a2021-02-22 12:13:13 +00001258`),
1259 checkVersionedAndroidBpContents(`
1260// This is auto-generated. DO NOT EDIT.
Paul Duffina80fdec2019-12-03 15:25:00 +00001261
1262cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001263 name: "mysdk_mynativelib@current",
1264 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001265 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001266 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001267 device_supported: false,
1268 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001269 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001270 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001271 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001272 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001273 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001274 target: {
1275 host: {
1276 enabled: false,
1277 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001278 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001279 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001280 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001281 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001282 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001283 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001284 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001285 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001286 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001287 },
1288 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001289}
1290
1291sdk_snapshot {
1292 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001293 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001294 device_supported: false,
1295 host_supported: true,
1296 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001297 target: {
1298 host: {
1299 enabled: false,
1300 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001301 linux_glibc_x86_64: {
1302 enabled: true,
1303 },
1304 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001305 enabled: true,
1306 },
1307 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001308}
1309`),
1310 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001311include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001312.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001313.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1314.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1315.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1316.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001317.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1318.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1319.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1320`),
1321 )
1322}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001323
Paul Duffina04c1072020-03-02 10:16:35 +00001324func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001325 result := testSdkWithCc(t, `
1326 sdk {
1327 name: "mysdk",
1328 device_supported: false,
1329 host_supported: true,
1330 native_shared_libs: ["mynativelib"],
1331 target: {
1332 windows: {
1333 enabled: true,
1334 },
1335 },
1336 }
1337
1338 cc_library_shared {
1339 name: "mynativelib",
1340 device_supported: false,
1341 host_supported: true,
1342 srcs: [
1343 "Test.cpp",
1344 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001345 stl: "none",
1346 target: {
1347 windows: {
1348 enabled: true,
1349 },
1350 },
1351 }
1352 `)
1353
1354 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001355 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00001356// This is auto-generated. DO NOT EDIT.
1357
1358cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001359 name: "mynativelib",
1360 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001361 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001362 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001363 device_supported: false,
1364 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001365 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001366 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001367 host: {
1368 enabled: false,
1369 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001370 linux_glibc: {
1371 compile_multilib: "both",
1372 },
Paul Duffina04c1072020-03-02 10:16:35 +00001373 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001374 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001375 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1376 },
1377 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001378 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001379 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1380 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001381 windows: {
1382 compile_multilib: "64",
1383 },
Paul Duffina04c1072020-03-02 10:16:35 +00001384 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001385 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001386 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1387 },
1388 },
Paul Duffina04c1072020-03-02 10:16:35 +00001389}
Paul Duffin75b902a2021-02-22 12:13:13 +00001390`),
1391 checkVersionedAndroidBpContents(`
1392// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00001393
1394cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001395 name: "mysdk_mynativelib@current",
1396 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001397 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001398 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001399 device_supported: false,
1400 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001401 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001402 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001403 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001404 host: {
1405 enabled: false,
1406 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001407 linux_glibc: {
1408 compile_multilib: "both",
1409 },
Paul Duffina04c1072020-03-02 10:16:35 +00001410 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001411 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001412 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1413 },
1414 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001415 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001416 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1417 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001418 windows: {
1419 compile_multilib: "64",
1420 },
Paul Duffina04c1072020-03-02 10:16:35 +00001421 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001422 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001423 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1424 },
1425 },
Paul Duffina04c1072020-03-02 10:16:35 +00001426}
1427
1428sdk_snapshot {
1429 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001430 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001431 device_supported: false,
1432 host_supported: true,
1433 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001434 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001435 windows: {
1436 compile_multilib: "64",
1437 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001438 host: {
1439 enabled: false,
1440 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001441 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001442 enabled: true,
1443 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001444 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001445 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +09001446 },
1447 windows_x86_64: {
1448 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001449 },
1450 },
Paul Duffina04c1072020-03-02 10:16:35 +00001451}
1452`),
1453 checkAllCopyRules(`
1454.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1455.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1456.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1457`),
1458 )
1459}
1460
Paul Duffin9ab556f2019-12-11 18:42:17 +00001461func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1462 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001463 module_exports {
1464 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001465 native_static_libs: ["mynativelib"],
1466 }
1467
1468 cc_library_static {
1469 name: "mynativelib",
1470 srcs: [
1471 "Test.cpp",
1472 "aidl/foo/bar/Test.aidl",
1473 ],
1474 export_include_dirs: ["include"],
1475 aidl: {
1476 export_aidl_headers: true,
1477 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001478 stl: "none",
1479 }
1480 `)
1481
Paul Duffin1356d8c2020-02-25 19:26:33 +00001482 result.CheckSnapshot("myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001483 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001484// This is auto-generated. DO NOT EDIT.
1485
1486cc_prebuilt_library_static {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001487 name: "mynativelib",
1488 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001489 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001490 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001491 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001492 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001493 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001494 arch: {
1495 arm64: {
1496 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001497 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001498 },
1499 arm: {
1500 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001501 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001502 },
1503 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001504}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001505`),
1506 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001507include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001508.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1509.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1510.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1511.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1512.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1513.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1514.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1515.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 +00001516`),
1517 )
1518}
1519
1520func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001521 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001522 module_exports {
1523 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001524 device_supported: false,
1525 host_supported: true,
1526 native_static_libs: ["mynativelib"],
1527 }
1528
1529 cc_library_static {
1530 name: "mynativelib",
1531 device_supported: false,
1532 host_supported: true,
1533 srcs: [
1534 "Test.cpp",
1535 "aidl/foo/bar/Test.aidl",
1536 ],
1537 export_include_dirs: ["include"],
1538 aidl: {
1539 export_aidl_headers: true,
1540 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001541 stl: "none",
1542 }
1543 `)
1544
Paul Duffin1356d8c2020-02-25 19:26:33 +00001545 result.CheckSnapshot("myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001546 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001547// This is auto-generated. DO NOT EDIT.
1548
1549cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001550 name: "mynativelib",
1551 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001552 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001553 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001554 device_supported: false,
1555 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001556 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001557 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001558 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001559 target: {
1560 host: {
1561 enabled: false,
1562 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001563 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001564 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001565 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001566 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001567 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001568 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001569 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001570 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001571 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001572 },
1573 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001574}
Paul Duffin75b902a2021-02-22 12:13:13 +00001575`),
1576 checkVersionedAndroidBpContents(`
1577// This is auto-generated. DO NOT EDIT.
Paul Duffin9ab556f2019-12-11 18:42:17 +00001578
1579cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001580 name: "myexports_mynativelib@current",
1581 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001582 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001583 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001584 device_supported: false,
1585 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001586 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001587 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001588 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001589 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001590 target: {
1591 host: {
1592 enabled: false,
1593 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001594 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001595 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001596 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001597 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001598 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001599 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001600 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001601 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001602 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001603 },
1604 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001605}
1606
Paul Duffine6029182019-12-16 17:43:48 +00001607module_exports_snapshot {
1608 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001609 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001610 device_supported: false,
1611 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001612 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001613 target: {
1614 host: {
1615 enabled: false,
1616 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001617 linux_glibc_x86_64: {
1618 enabled: true,
1619 },
1620 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001621 enabled: true,
1622 },
1623 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001624}
1625`),
1626 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001627include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001628.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001629.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1630.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1631.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1632.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001633.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1634.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1635.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1636`),
1637 )
1638}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001639
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001640func TestSnapshotWithCcLibrary(t *testing.T) {
1641 result := testSdkWithCc(t, `
1642 module_exports {
1643 name: "myexports",
1644 native_libs: ["mynativelib"],
1645 }
1646
1647 cc_library {
1648 name: "mynativelib",
1649 srcs: [
1650 "Test.cpp",
1651 ],
1652 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001653 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001654 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001655 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001656 }
1657 `)
1658
1659 result.CheckSnapshot("myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001660 checkUnversionedAndroidBpContents(`
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001661// This is auto-generated. DO NOT EDIT.
1662
1663cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001664 name: "mynativelib",
1665 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001666 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001667 apex_available: ["//apex_available:platform"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001668 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001669 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001670 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001671 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001672 export_include_dirs: ["include/include"],
1673 arch: {
1674 arm64: {
1675 static: {
1676 srcs: ["arm64/lib/mynativelib.a"],
1677 },
1678 shared: {
1679 srcs: ["arm64/lib/mynativelib.so"],
1680 },
1681 },
1682 arm: {
1683 static: {
1684 srcs: ["arm/lib/mynativelib.a"],
1685 },
1686 shared: {
1687 srcs: ["arm/lib/mynativelib.so"],
1688 },
1689 },
1690 },
1691}
Paul Duffin75b902a2021-02-22 12:13:13 +00001692`),
1693 // Make sure that the generated sdk_snapshot uses the native_libs property.
1694 checkVersionedAndroidBpContents(`
1695// This is auto-generated. DO NOT EDIT.
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001696
1697cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001698 name: "myexports_mynativelib@current",
1699 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001700 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001701 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +00001702 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001703 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001704 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001705 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001706 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001707 export_include_dirs: ["include/include"],
1708 arch: {
1709 arm64: {
1710 static: {
1711 srcs: ["arm64/lib/mynativelib.a"],
1712 },
1713 shared: {
1714 srcs: ["arm64/lib/mynativelib.so"],
1715 },
1716 },
1717 arm: {
1718 static: {
1719 srcs: ["arm/lib/mynativelib.a"],
1720 },
1721 shared: {
1722 srcs: ["arm/lib/mynativelib.so"],
1723 },
1724 },
1725 },
1726}
1727
1728module_exports_snapshot {
1729 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001730 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001731 native_libs: ["myexports_mynativelib@current"],
1732}
1733`),
1734 checkAllCopyRules(`
1735include/Test.h -> include/include/Test.h
1736.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1737.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1738.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1739.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1740 )
1741}
1742
Paul Duffin13ad94f2020-02-19 16:19:27 +00001743func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001744 result := testSdkWithCc(t, `
1745 module_exports {
1746 name: "myexports",
1747 device_supported: false,
1748 host_supported: true,
1749 target: {
1750 host: {
1751 compile_multilib: "64",
1752 },
1753 },
1754 native_static_libs: ["mynativelib"],
1755 }
1756
1757 cc_library_static {
1758 name: "mynativelib",
1759 device_supported: false,
1760 host_supported: true,
1761 srcs: [
1762 "Test.cpp",
1763 "aidl/foo/bar/Test.aidl",
1764 ],
1765 export_include_dirs: ["include"],
1766 aidl: {
1767 export_aidl_headers: true,
1768 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001769 stl: "none",
1770 }
1771 `)
1772
Paul Duffin1356d8c2020-02-25 19:26:33 +00001773 result.CheckSnapshot("myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001774 checkUnversionedAndroidBpContents(`
Paul Duffin13ad94f2020-02-19 16:19:27 +00001775// This is auto-generated. DO NOT EDIT.
1776
1777cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001778 name: "mynativelib",
1779 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001780 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001781 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001782 device_supported: false,
1783 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001784 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001785 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001786 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001787 target: {
1788 host: {
1789 enabled: false,
1790 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001791 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001792 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001793 srcs: ["x86_64/lib/mynativelib.a"],
1794 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1795 },
1796 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001797}
Paul Duffin75b902a2021-02-22 12:13:13 +00001798`),
1799 checkVersionedAndroidBpContents(`
1800// This is auto-generated. DO NOT EDIT.
Paul Duffin13ad94f2020-02-19 16:19:27 +00001801
1802cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001803 name: "myexports_mynativelib@current",
1804 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001805 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001806 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001807 device_supported: false,
1808 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001809 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001810 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001811 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001812 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001813 target: {
1814 host: {
1815 enabled: false,
1816 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001817 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001818 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001819 srcs: ["x86_64/lib/mynativelib.a"],
1820 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1821 },
1822 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001823}
1824
1825module_exports_snapshot {
1826 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001827 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001828 device_supported: false,
1829 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001830 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001831 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001832 target: {
1833 host: {
1834 enabled: false,
1835 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001836 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001837 enabled: true,
1838 },
1839 },
Paul Duffin75b902a2021-02-22 12:13:13 +00001840}
1841`),
Paul Duffin13ad94f2020-02-19 16:19:27 +00001842 checkAllCopyRules(`
1843include/Test.h -> include/include/Test.h
1844.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1845.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1846.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1847.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1848`),
1849 )
1850}
Paul Duffin91756d22020-02-21 16:29:57 +00001851
1852func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1853 result := testSdkWithCc(t, `
1854 sdk {
1855 name: "mysdk",
1856 native_header_libs: ["mynativeheaders"],
1857 }
1858
1859 cc_library_headers {
1860 name: "mynativeheaders",
1861 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001862 stl: "none",
1863 }
1864 `)
1865
Paul Duffin1356d8c2020-02-25 19:26:33 +00001866 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001867 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001868// This is auto-generated. DO NOT EDIT.
1869
1870cc_prebuilt_library_headers {
Paul Duffin91756d22020-02-21 16:29:57 +00001871 name: "mynativeheaders",
1872 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001873 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001874 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00001875 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001876 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001877 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001878}
Paul Duffin91756d22020-02-21 16:29:57 +00001879`),
1880 checkAllCopyRules(`
1881include/Test.h -> include/include/Test.h
1882`),
1883 )
1884}
1885
1886func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001887 result := testSdkWithCc(t, `
1888 sdk {
1889 name: "mysdk",
1890 device_supported: false,
1891 host_supported: true,
1892 native_header_libs: ["mynativeheaders"],
1893 }
1894
1895 cc_library_headers {
1896 name: "mynativeheaders",
1897 device_supported: false,
1898 host_supported: true,
1899 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001900 stl: "none",
1901 }
1902 `)
1903
Paul Duffin1356d8c2020-02-25 19:26:33 +00001904 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001905 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001906// This is auto-generated. DO NOT EDIT.
1907
1908cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00001909 name: "mynativeheaders",
1910 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001911 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001912 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00001913 device_supported: false,
1914 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001915 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001916 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001917 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001918 target: {
1919 host: {
1920 enabled: false,
1921 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001922 linux_glibc_x86_64: {
1923 enabled: true,
1924 },
1925 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001926 enabled: true,
1927 },
1928 },
Paul Duffin91756d22020-02-21 16:29:57 +00001929}
Paul Duffin75b902a2021-02-22 12:13:13 +00001930`),
1931 checkVersionedAndroidBpContents(`
1932// This is auto-generated. DO NOT EDIT.
Paul Duffin91756d22020-02-21 16:29:57 +00001933
1934cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00001935 name: "mysdk_mynativeheaders@current",
1936 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01001937 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001938 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00001939 device_supported: false,
1940 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001941 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001942 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001943 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001944 target: {
1945 host: {
1946 enabled: false,
1947 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001948 linux_glibc_x86_64: {
1949 enabled: true,
1950 },
1951 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001952 enabled: true,
1953 },
1954 },
Paul Duffin91756d22020-02-21 16:29:57 +00001955}
1956
1957sdk_snapshot {
1958 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001959 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001960 device_supported: false,
1961 host_supported: true,
1962 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001963 target: {
1964 host: {
1965 enabled: false,
1966 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001967 linux_glibc_x86_64: {
1968 enabled: true,
1969 },
1970 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001971 enabled: true,
1972 },
1973 },
Paul Duffin91756d22020-02-21 16:29:57 +00001974}
1975`),
1976 checkAllCopyRules(`
1977include/Test.h -> include/include/Test.h
1978`),
1979 )
1980}
Paul Duffina04c1072020-03-02 10:16:35 +00001981
1982func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001983 result := testSdkWithCc(t, `
1984 sdk {
1985 name: "mysdk",
1986 host_supported: true,
1987 native_header_libs: ["mynativeheaders"],
1988 }
1989
1990 cc_library_headers {
1991 name: "mynativeheaders",
1992 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001993 stl: "none",
1994 export_system_include_dirs: ["include"],
1995 target: {
1996 android: {
1997 export_include_dirs: ["include-android"],
1998 },
1999 host: {
2000 export_include_dirs: ["include-host"],
2001 },
2002 },
2003 }
2004 `)
2005
2006 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002007 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00002008// This is auto-generated. DO NOT EDIT.
2009
2010cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002011 name: "mynativeheaders",
2012 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002013 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002014 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002015 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002016 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002017 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002018 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002019 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002020 host: {
2021 enabled: false,
2022 },
Paul Duffina04c1072020-03-02 10:16:35 +00002023 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002024 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002025 },
2026 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002027 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002028 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002029 linux_glibc_x86_64: {
2030 enabled: true,
2031 },
2032 linux_glibc_x86: {
2033 enabled: true,
2034 },
Paul Duffina04c1072020-03-02 10:16:35 +00002035 },
Paul Duffina04c1072020-03-02 10:16:35 +00002036}
Paul Duffin75b902a2021-02-22 12:13:13 +00002037`),
2038 // Verifi
2039 checkVersionedAndroidBpContents(`
2040// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00002041
2042cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002043 name: "mysdk_mynativeheaders@current",
2044 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002045 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002046 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002047 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002048 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002049 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002050 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002051 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002052 host: {
2053 enabled: false,
2054 },
Paul Duffina04c1072020-03-02 10:16:35 +00002055 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002056 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002057 },
2058 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002059 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002060 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002061 linux_glibc_x86_64: {
2062 enabled: true,
2063 },
2064 linux_glibc_x86: {
2065 enabled: true,
2066 },
Paul Duffina04c1072020-03-02 10:16:35 +00002067 },
Paul Duffina04c1072020-03-02 10:16:35 +00002068}
2069
2070sdk_snapshot {
2071 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002072 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002073 host_supported: true,
2074 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002075 target: {
2076 host: {
2077 enabled: false,
2078 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002079 linux_glibc_x86_64: {
2080 enabled: true,
2081 },
2082 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002083 enabled: true,
2084 },
2085 },
Paul Duffina04c1072020-03-02 10:16:35 +00002086}
2087`),
2088 checkAllCopyRules(`
Paul Duffined62b9c2020-06-16 16:12:50 +01002089include/Test.h -> common_os/include/include/Test.h
2090include-android/AndroidTest.h -> android/include/include-android/AndroidTest.h
2091include-host/HostTest.h -> linux_glibc/include/include-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002092`),
2093 )
2094}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002095
2096func TestSystemSharedLibPropagation(t *testing.T) {
2097 result := testSdkWithCc(t, `
2098 sdk {
2099 name: "mysdk",
2100 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2101 }
2102
2103 cc_library {
2104 name: "sslnil",
2105 host_supported: true,
2106 }
2107
2108 cc_library {
2109 name: "sslempty",
2110 system_shared_libs: [],
2111 }
2112
2113 cc_library {
2114 name: "sslnonempty",
2115 system_shared_libs: ["sslnil"],
2116 }
2117 `)
2118
2119 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002120 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002121// This is auto-generated. DO NOT EDIT.
2122
2123cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002124 name: "sslnil",
2125 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002126 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002127 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002128 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002129 arch: {
2130 arm64: {
2131 srcs: ["arm64/lib/sslnil.so"],
2132 },
2133 arm: {
2134 srcs: ["arm/lib/sslnil.so"],
2135 },
2136 },
2137}
2138
2139cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002140 name: "sslempty",
2141 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002142 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002143 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002144 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002145 system_shared_libs: [],
2146 arch: {
2147 arm64: {
2148 srcs: ["arm64/lib/sslempty.so"],
2149 },
2150 arm: {
2151 srcs: ["arm/lib/sslempty.so"],
2152 },
2153 },
2154}
2155
2156cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002157 name: "sslnonempty",
2158 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002159 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002160 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002161 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002162 system_shared_libs: ["sslnil"],
2163 arch: {
2164 arm64: {
2165 srcs: ["arm64/lib/sslnonempty.so"],
2166 },
2167 arm: {
2168 srcs: ["arm/lib/sslnonempty.so"],
2169 },
2170 },
2171}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002172`))
2173
2174 result = testSdkWithCc(t, `
2175 sdk {
2176 name: "mysdk",
2177 host_supported: true,
2178 native_shared_libs: ["sslvariants"],
2179 }
2180
2181 cc_library {
2182 name: "sslvariants",
2183 host_supported: true,
2184 target: {
2185 android: {
2186 system_shared_libs: [],
2187 },
2188 },
2189 }
2190 `)
2191
2192 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002193 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002194// This is auto-generated. DO NOT EDIT.
2195
2196cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002197 name: "sslvariants",
2198 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002199 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002200 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002201 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002202 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002203 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002204 host: {
2205 enabled: false,
2206 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002207 android: {
2208 system_shared_libs: [],
2209 },
2210 android_arm64: {
2211 srcs: ["android/arm64/lib/sslvariants.so"],
2212 },
2213 android_arm: {
2214 srcs: ["android/arm/lib/sslvariants.so"],
2215 },
2216 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002217 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002218 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2219 },
2220 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002221 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002222 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2223 },
2224 },
2225}
Paul Duffin75b902a2021-02-22 12:13:13 +00002226`),
2227 checkVersionedAndroidBpContents(`
2228// This is auto-generated. DO NOT EDIT.
Martin Stjernholm10566a02020-03-24 01:19:52 +00002229
2230cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002231 name: "mysdk_sslvariants@current",
2232 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002233 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002234 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002235 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002236 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002237 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002238 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002239 host: {
2240 enabled: false,
2241 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002242 android: {
2243 system_shared_libs: [],
2244 },
2245 android_arm64: {
2246 srcs: ["android/arm64/lib/sslvariants.so"],
2247 },
2248 android_arm: {
2249 srcs: ["android/arm/lib/sslvariants.so"],
2250 },
2251 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002252 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002253 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2254 },
2255 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002256 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002257 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2258 },
2259 },
2260}
2261
2262sdk_snapshot {
2263 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002264 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002265 host_supported: true,
2266 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002267 target: {
2268 host: {
2269 enabled: false,
2270 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002271 linux_glibc_x86_64: {
2272 enabled: true,
2273 },
2274 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002275 enabled: true,
2276 },
2277 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002278}
2279`))
2280}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002281
2282func TestStubsLibrary(t *testing.T) {
2283 result := testSdkWithCc(t, `
2284 sdk {
2285 name: "mysdk",
2286 native_shared_libs: ["stubslib"],
2287 }
2288
2289 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002290 name: "internaldep",
2291 }
2292
2293 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002294 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002295 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002296 stubs: {
2297 symbol_file: "some/where/stubslib.map.txt",
2298 versions: ["1", "2", "3"],
2299 },
2300 }
2301 `)
2302
2303 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002304 checkUnversionedAndroidBpContents(`
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002305// This is auto-generated. DO NOT EDIT.
2306
2307cc_prebuilt_library_shared {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002308 name: "stubslib",
2309 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002310 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002311 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002312 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002313 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002314 versions: [
2315 "1",
2316 "2",
2317 "3",
2318 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002319 },
2320 arch: {
2321 arm64: {
2322 srcs: ["arm64/lib/stubslib.so"],
2323 },
2324 arm: {
2325 srcs: ["arm/lib/stubslib.so"],
2326 },
2327 },
2328}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002329`))
2330}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002331
2332func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002333 result := testSdkWithCc(t, `
2334 sdk {
2335 name: "mysdk",
2336 host_supported: true,
2337 native_shared_libs: ["stubslib"],
2338 }
2339
2340 cc_library {
2341 name: "internaldep",
2342 host_supported: true,
2343 }
2344
2345 cc_library {
2346 name: "stubslib",
2347 host_supported: true,
2348 shared_libs: ["internaldep"],
2349 stubs: {
2350 symbol_file: "some/where/stubslib.map.txt",
2351 versions: ["1", "2", "3"],
2352 },
2353 }
2354 `)
2355
2356 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002357 checkUnversionedAndroidBpContents(`
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002358// This is auto-generated. DO NOT EDIT.
2359
2360cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002361 name: "stubslib",
2362 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002363 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002364 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002365 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002366 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002367 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002368 versions: [
2369 "1",
2370 "2",
2371 "3",
2372 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002373 },
2374 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002375 host: {
2376 enabled: false,
2377 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002378 android_arm64: {
2379 srcs: ["android/arm64/lib/stubslib.so"],
2380 },
2381 android_arm: {
2382 srcs: ["android/arm/lib/stubslib.so"],
2383 },
2384 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002385 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002386 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2387 },
2388 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002389 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002390 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2391 },
2392 },
2393}
Paul Duffin75b902a2021-02-22 12:13:13 +00002394`),
2395 checkVersionedAndroidBpContents(`
2396// This is auto-generated. DO NOT EDIT.
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002397
2398cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002399 name: "mysdk_stubslib@current",
2400 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002401 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002402 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002403 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002404 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002405 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002406 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002407 versions: [
2408 "1",
2409 "2",
2410 "3",
2411 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002412 },
2413 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002414 host: {
2415 enabled: false,
2416 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002417 android_arm64: {
2418 srcs: ["android/arm64/lib/stubslib.so"],
2419 },
2420 android_arm: {
2421 srcs: ["android/arm/lib/stubslib.so"],
2422 },
2423 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002424 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002425 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2426 },
2427 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002428 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002429 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2430 },
2431 },
2432}
2433
2434sdk_snapshot {
2435 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002436 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002437 host_supported: true,
2438 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002439 target: {
2440 host: {
2441 enabled: false,
2442 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002443 linux_glibc_x86_64: {
2444 enabled: true,
2445 },
2446 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002447 enabled: true,
2448 },
2449 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002450}
2451`))
2452}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002453
2454func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002455 result := testSdkWithCc(t, `
2456 sdk {
2457 name: "mysdk",
2458 host_supported: true,
2459 native_shared_libs: ["mylib"],
2460 }
2461
2462 cc_library {
2463 name: "mylib",
2464 host_supported: true,
2465 unique_host_soname: true,
2466 }
2467 `)
2468
2469 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002470 checkUnversionedAndroidBpContents(`
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002471// This is auto-generated. DO NOT EDIT.
2472
2473cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002474 name: "mylib",
2475 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002476 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002477 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002478 host_supported: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002479 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002480 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002481 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002482 host: {
2483 enabled: false,
2484 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002485 android_arm64: {
2486 srcs: ["android/arm64/lib/mylib.so"],
2487 },
2488 android_arm: {
2489 srcs: ["android/arm/lib/mylib.so"],
2490 },
2491 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002492 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002493 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2494 },
2495 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002496 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002497 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2498 },
2499 },
2500}
Paul Duffin75b902a2021-02-22 12:13:13 +00002501`),
2502 checkVersionedAndroidBpContents(`
2503// This is auto-generated. DO NOT EDIT.
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002504
2505cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002506 name: "mysdk_mylib@current",
2507 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002508 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002509 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002510 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002511 installable: false,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002512 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002513 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002514 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002515 host: {
2516 enabled: false,
2517 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002518 android_arm64: {
2519 srcs: ["android/arm64/lib/mylib.so"],
2520 },
2521 android_arm: {
2522 srcs: ["android/arm/lib/mylib.so"],
2523 },
2524 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002525 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002526 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2527 },
2528 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002529 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002530 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2531 },
2532 },
2533}
2534
2535sdk_snapshot {
2536 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002537 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002538 host_supported: true,
2539 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002540 target: {
2541 host: {
2542 enabled: false,
2543 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002544 linux_glibc_x86_64: {
2545 enabled: true,
2546 },
2547 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002548 enabled: true,
2549 },
2550 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002551}
2552`),
2553 checkAllCopyRules(`
2554.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2555.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2556.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2557.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2558`),
2559 )
2560}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002561
2562func TestNoSanitizerMembers(t *testing.T) {
2563 result := testSdkWithCc(t, `
2564 sdk {
2565 name: "mysdk",
2566 native_shared_libs: ["mynativelib"],
2567 }
2568
2569 cc_library_shared {
2570 name: "mynativelib",
2571 srcs: ["Test.cpp"],
2572 export_include_dirs: ["include"],
2573 arch: {
2574 arm64: {
2575 export_system_include_dirs: ["arm64/include"],
2576 sanitize: {
2577 hwaddress: true,
2578 },
2579 },
2580 },
2581 }
2582 `)
2583
2584 result.CheckSnapshot("mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002585 checkUnversionedAndroidBpContents(`
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002586// This is auto-generated. DO NOT EDIT.
2587
2588cc_prebuilt_library_shared {
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002589 name: "mynativelib",
2590 prefer: false,
2591 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002592 apex_available: ["//apex_available:platform"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002593 compile_multilib: "both",
2594 export_include_dirs: ["include/include"],
2595 arch: {
2596 arm64: {
2597 export_system_include_dirs: ["arm64/include/arm64/include"],
2598 },
2599 arm: {
2600 srcs: ["arm/lib/mynativelib.so"],
2601 },
2602 },
2603}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002604`),
2605 checkAllCopyRules(`
2606include/Test.h -> include/include/Test.h
2607arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
2608.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
2609 )
2610}