blob: 9db816df88306f3e891761b9b7846fef8a0d9dc4 [file] [log] [blame]
Paul Duffina80fdec2019-12-03 15:25:00 +00001// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package sdk
16
17import (
18 "testing"
19
Paul Duffin1356d8c2020-02-25 19:26:33 +000020 "android/soong/android"
Paul Duffina80fdec2019-12-03 15:25:00 +000021 "android/soong/cc"
22)
23
Paul Duffin4a2a29c2021-03-09 22:27:13 +000024var ccTestFs = android.MockFS{
Paul Duffin86b02a72021-02-22 11:50:04 +000025 "Test.cpp": nil,
26 "myinclude/Test.h": nil,
27 "myinclude-android/AndroidTest.h": nil,
28 "myinclude-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,
Martin Stjernholm7feceb22020-07-11 04:33:29 +010033}
34
Paul Duffin4a2a29c2021-03-09 22:27:13 +000035func testSdkWithCc(t *testing.T, bp string) *android.TestResult {
Paul Duffind835daa2019-11-30 17:49:09 +000036 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
Paul Duffin36474d32021-03-12 12:19:43 +0000104 CheckSnapshot(t, result, "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",
Mathew Inwoodf8dcf5e2021-02-16 11:40:16 +0000254 updatable: false,
Paul Duffina80fdec2019-12-03 15:25:00 +0000255 }
256
257 apex {
258 name: "myapex2",
259 native_shared_libs: ["mycpplib"],
260 uses_sdks: ["mysdk@2"],
261 key: "myapex.key",
262 certificate: ":myapex.cert",
Mathew Inwoodf8dcf5e2021-02-16 11:40:16 +0000263 updatable: false,
Paul Duffina80fdec2019-12-03 15:25:00 +0000264 }
Martin Stjernholmcc776012020-07-07 03:22:21 +0100265
266 apex {
267 name: "mysdkapex",
268 native_shared_libs: ["sdkmember"],
269 key: "myapex.key",
270 certificate: ":myapex.cert",
Mathew Inwoodf8dcf5e2021-02-16 11:40:16 +0000271 updatable: false,
Martin Stjernholmcc776012020-07-07 03:22:21 +0100272 }
Paul Duffina80fdec2019-12-03 15:25:00 +0000273 `)
274
Colin Crossaede88c2020-08-11 12:17:01 -0700275 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
276 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000277
Colin Crossaede88c2020-08-11 12:17:01 -0700278 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1")
279 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000280
281 // Depending on the uses_sdks value, different libs are linked
282 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
283 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
284}
285
Paul Duffina0843f62019-12-13 19:50:38 +0000286// Make sure the sdk can use host specific cc libraries static/shared and both.
287func TestHostSdkWithCc(t *testing.T) {
288 testSdkWithCc(t, `
289 sdk {
290 name: "mysdk",
291 device_supported: false,
292 host_supported: true,
293 native_shared_libs: ["sdkshared"],
294 native_static_libs: ["sdkstatic"],
295 }
296
297 cc_library_host_shared {
298 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000299 stl: "none",
300 }
301
302 cc_library_host_static {
303 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000304 stl: "none",
305 }
306 `)
307}
308
309// Make sure the sdk can use cc libraries static/shared and both.
310func TestSdkWithCc(t *testing.T) {
311 testSdkWithCc(t, `
312 sdk {
313 name: "mysdk",
314 native_shared_libs: ["sdkshared", "sdkboth1"],
315 native_static_libs: ["sdkstatic", "sdkboth2"],
316 }
317
318 cc_library_shared {
319 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000320 stl: "none",
321 }
322
323 cc_library_static {
324 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000325 stl: "none",
326 }
327
328 cc_library {
329 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000330 stl: "none",
331 }
332
333 cc_library {
334 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000335 stl: "none",
336 }
337 `)
338}
339
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000340func TestSnapshotWithObject(t *testing.T) {
341 result := testSdkWithCc(t, `
342 sdk {
343 name: "mysdk",
344 native_objects: ["crtobj"],
345 }
346
347 cc_object {
348 name: "crtobj",
349 stl: "none",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100350 sanitize: {
351 never: true,
352 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000353 }
354 `)
355
Paul Duffin36474d32021-03-12 12:19:43 +0000356 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000357 checkUnversionedAndroidBpContents(`
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000358// This is auto-generated. DO NOT EDIT.
359
360cc_prebuilt_object {
Paul Duffin75b902a2021-02-22 12:13:13 +0000361 name: "crtobj",
362 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100363 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000364 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000365 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100366 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100367 sanitize: {
368 never: true,
369 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000370 arch: {
371 arm64: {
372 srcs: ["arm64/lib/crtobj.o"],
373 },
374 arm: {
375 srcs: ["arm/lib/crtobj.o"],
376 },
377 },
378}
Paul Duffin75b902a2021-02-22 12:13:13 +0000379`),
380 // Make sure that the generated sdk_snapshot uses the native_objects property.
381 checkVersionedAndroidBpContents(`
382// This is auto-generated. DO NOT EDIT.
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000383
384cc_prebuilt_object {
Paul Duffin75b902a2021-02-22 12:13:13 +0000385 name: "mysdk_crtobj@current",
386 sdk_member_name: "crtobj",
Paul Duffind99d9972020-09-29 16:00:55 +0100387 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000388 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000389 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100390 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100391 sanitize: {
392 never: true,
393 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000394 arch: {
395 arm64: {
396 srcs: ["arm64/lib/crtobj.o"],
397 },
398 arm: {
399 srcs: ["arm/lib/crtobj.o"],
400 },
401 },
402}
403
404sdk_snapshot {
405 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100406 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000407 native_objects: ["mysdk_crtobj@current"],
408}
409`),
410 checkAllCopyRules(`
411.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
412.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
413`),
414 )
415}
416
Paul Duffinc62a5102019-12-11 18:34:15 +0000417func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
418 result := testSdkWithCc(t, `
419 sdk {
420 name: "mysdk",
421 native_shared_libs: ["mynativelib1", "mynativelib2"],
422 }
423
424 cc_library_shared {
425 name: "mynativelib1",
426 srcs: [
427 "Test.cpp",
428 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000429 export_include_dirs: ["myinclude"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000430 stl: "none",
431 }
432
433 cc_library_shared {
434 name: "mynativelib2",
435 srcs: [
436 "Test.cpp",
437 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000438 export_include_dirs: ["myinclude"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000439 stl: "none",
440 }
441 `)
442
Paul Duffin36474d32021-03-12 12:19:43 +0000443 CheckSnapshot(t, result, "mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000444 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000445myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800446.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
447.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
448.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
449.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000450`),
451 )
452}
453
Paul Duffina43f9272021-02-17 10:55:25 +0000454func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
455 result := testSdkWithCc(t, `
456 sdk {
457 name: "mysdk",
458 native_shared_libs: ["mynativelib"],
459 }
460
461 cc_library_shared {
462 name: "mynativelib",
463 srcs: [
464 "Test.cpp",
465 ],
466 generated_headers: [
467 "generated_foo",
468 ],
469 export_generated_headers: [
470 "generated_foo",
471 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000472 export_include_dirs: ["myinclude"],
Paul Duffina43f9272021-02-17 10:55:25 +0000473 stl: "none",
474 }
475
476 genrule {
477 name: "generated_foo",
478 cmd: "generate-foo",
479 out: [
480 "generated_foo/protos/foo/bar.h",
481 ],
482 export_include_dirs: [
483 ".",
484 "protos",
485 ],
486 }
487 `)
488
Paul Duffin36474d32021-03-12 12:19:43 +0000489 CheckSnapshot(t, result, "mysdk", "",
Paul Duffina43f9272021-02-17 10:55:25 +0000490 checkUnversionedAndroidBpContents(`
491// This is auto-generated. DO NOT EDIT.
492
493cc_prebuilt_library_shared {
494 name: "mynativelib",
495 prefer: false,
496 visibility: ["//visibility:public"],
497 apex_available: ["//apex_available:platform"],
498 stl: "none",
499 compile_multilib: "both",
Paul Duffin7a7d0672021-02-17 12:17:40 +0000500 export_include_dirs: [
501 "include/myinclude",
502 "include_gen/generated_foo/gen",
503 "include_gen/generated_foo/gen/protos",
504 ],
Paul Duffina43f9272021-02-17 10:55:25 +0000505 arch: {
506 arm64: {
507 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffina43f9272021-02-17 10:55:25 +0000508 },
509 arm: {
510 srcs: ["arm/lib/mynativelib.so"],
Paul Duffina43f9272021-02-17 10:55:25 +0000511 },
512 },
513}
514`),
515 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000516myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin7a7d0672021-02-17 12:17:40 +0000517.intermediates/generated_foo/gen/generated_foo/protos/foo/bar.h -> include_gen/generated_foo/gen/generated_foo/protos/foo/bar.h
Paul Duffina43f9272021-02-17 10:55:25 +0000518.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina43f9272021-02-17 10:55:25 +0000519.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
Paul Duffina43f9272021-02-17 10:55:25 +0000520`),
521 )
522}
523
Martin Stjernholmb0249572020-09-15 02:32:35 +0100524// Verify that when the shared library has some common and some arch specific
525// properties that the generated snapshot is optimized properly. Substruct
526// handling is tested with the sanitize clauses (but note there's a lot of
527// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000528func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
529 result := testSdkWithCc(t, `
530 sdk {
531 name: "mysdk",
532 native_shared_libs: ["mynativelib"],
533 }
534
535 cc_library_shared {
536 name: "mynativelib",
537 srcs: [
538 "Test.cpp",
539 "aidl/foo/bar/Test.aidl",
540 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000541 export_include_dirs: ["myinclude"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100542 sanitize: {
543 fuzzer: false,
544 integer_overflow: true,
545 diag: { undefined: false },
546 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000547 arch: {
548 arm64: {
549 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100550 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100551 integer_overflow: false,
552 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000553 },
554 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000555 stl: "none",
556 }
557 `)
558
Paul Duffin36474d32021-03-12 12:19:43 +0000559 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000560 checkUnversionedAndroidBpContents(`
Paul Duffina7cd8c82019-12-11 20:00:57 +0000561// This is auto-generated. DO NOT EDIT.
562
563cc_prebuilt_library_shared {
Paul Duffina7cd8c82019-12-11 20:00:57 +0000564 name: "mynativelib",
565 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100566 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000567 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000568 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100569 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +0000570 export_include_dirs: ["include/myinclude"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100571 sanitize: {
572 fuzzer: false,
573 diag: {
574 undefined: false,
575 },
576 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000577 arch: {
578 arm64: {
579 srcs: ["arm64/lib/mynativelib.so"],
580 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100581 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100582 integer_overflow: false,
583 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000584 },
585 arm: {
586 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100587 sanitize: {
588 integer_overflow: true,
589 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000590 },
591 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000592}
Paul Duffina7cd8c82019-12-11 20:00:57 +0000593`),
594 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000595myinclude/Test.h -> include/myinclude/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +0000596.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000597arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800598.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000599 )
600}
601
Paul Duffin25ce04b2020-01-16 11:47:25 +0000602func TestSnapshotWithCcBinary(t *testing.T) {
603 result := testSdkWithCc(t, `
604 module_exports {
605 name: "mymodule_exports",
606 native_binaries: ["mynativebinary"],
607 }
608
609 cc_binary {
610 name: "mynativebinary",
611 srcs: [
612 "Test.cpp",
613 ],
614 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000615 }
616 `)
617
Paul Duffin36474d32021-03-12 12:19:43 +0000618 CheckSnapshot(t, result, "mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000619 checkUnversionedAndroidBpContents(`
Paul Duffin25ce04b2020-01-16 11:47:25 +0000620// This is auto-generated. DO NOT EDIT.
621
622cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000623 name: "mynativebinary",
624 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100625 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000626 apex_available: ["//apex_available:platform"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000627 compile_multilib: "both",
628 arch: {
629 arm64: {
630 srcs: ["arm64/bin/mynativebinary"],
631 },
632 arm: {
633 srcs: ["arm/bin/mynativebinary"],
634 },
635 },
636}
Paul Duffin75b902a2021-02-22 12:13:13 +0000637`),
638 // Make sure that the generated sdk_snapshot uses the native_binaries property.
639 checkVersionedAndroidBpContents(`
640// This is auto-generated. DO NOT EDIT.
Paul Duffin25ce04b2020-01-16 11:47:25 +0000641
642cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000643 name: "mymodule_exports_mynativebinary@current",
644 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100645 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000646 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +0000647 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000648 compile_multilib: "both",
649 arch: {
650 arm64: {
651 srcs: ["arm64/bin/mynativebinary"],
652 },
653 arm: {
654 srcs: ["arm/bin/mynativebinary"],
655 },
656 },
657}
658
659module_exports_snapshot {
660 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100661 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000662 native_binaries: ["mymodule_exports_mynativebinary@current"],
663}
664`),
665 checkAllCopyRules(`
666.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
667.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
668`),
669 )
670}
671
Paul Duffina04c1072020-03-02 10:16:35 +0000672func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000673 result := testSdkWithCc(t, `
674 module_exports {
675 name: "myexports",
676 device_supported: false,
677 host_supported: true,
678 native_binaries: ["mynativebinary"],
679 target: {
680 windows: {
681 enabled: true,
682 },
683 },
684 }
685
686 cc_binary {
687 name: "mynativebinary",
688 device_supported: false,
689 host_supported: true,
690 srcs: [
691 "Test.cpp",
692 ],
693 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000694 stl: "none",
695 target: {
696 windows: {
697 enabled: true,
698 },
699 },
700 }
701 `)
702
Paul Duffin36474d32021-03-12 12:19:43 +0000703 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000704 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +0000705// This is auto-generated. DO NOT EDIT.
706
707cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000708 name: "mynativebinary",
709 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100710 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000711 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000712 device_supported: false,
713 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100714 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000715 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100716 host: {
717 enabled: false,
718 },
Paul Duffina04c1072020-03-02 10:16:35 +0000719 linux_glibc: {
720 compile_multilib: "both",
721 },
722 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900723 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000724 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
725 },
726 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900727 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000728 srcs: ["linux_glibc/x86/bin/mynativebinary"],
729 },
730 windows: {
731 compile_multilib: "64",
732 },
733 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900734 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000735 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
736 },
737 },
738}
Paul Duffin75b902a2021-02-22 12:13:13 +0000739`),
740 checkVersionedAndroidBpContents(`
741// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +0000742
743cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000744 name: "myexports_mynativebinary@current",
745 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100746 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000747 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000748 device_supported: false,
749 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +0000750 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100751 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000752 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100753 host: {
754 enabled: false,
755 },
Paul Duffina04c1072020-03-02 10:16:35 +0000756 linux_glibc: {
757 compile_multilib: "both",
758 },
759 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900760 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000761 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
762 },
763 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900764 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000765 srcs: ["linux_glibc/x86/bin/mynativebinary"],
766 },
767 windows: {
768 compile_multilib: "64",
769 },
770 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900771 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000772 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
773 },
774 },
775}
776
777module_exports_snapshot {
778 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100779 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000780 device_supported: false,
781 host_supported: true,
782 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000783 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900784 windows: {
785 compile_multilib: "64",
786 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100787 host: {
788 enabled: false,
789 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900790 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100791 enabled: true,
792 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900793 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100794 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +0900795 },
796 windows_x86_64: {
797 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000798 },
799 },
Paul Duffina04c1072020-03-02 10:16:35 +0000800}
801`),
802 checkAllCopyRules(`
803.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
804.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
805.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
806`),
807 )
808}
809
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100810func TestSnapshotWithSingleHostOsType(t *testing.T) {
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000811 result := sdkFixtureFactory.Extend(
812 ccTestFs.AddToFixture(),
813 cc.PrepareForTestOnLinuxBionic,
814 android.FixtureModifyConfig(func(config android.Config) {
815 config.Targets[android.LinuxBionic] = []android.Target{
816 {android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", false},
817 }
818 }),
819 ).RunTestWithBp(t, `
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100820 cc_defaults {
821 name: "mydefaults",
822 device_supported: false,
823 host_supported: true,
824 compile_multilib: "64",
825 target: {
826 host: {
827 enabled: false,
828 },
829 linux_bionic: {
830 enabled: true,
831 },
832 },
833 }
834
835 module_exports {
836 name: "myexports",
837 defaults: ["mydefaults"],
838 native_shared_libs: ["mynativelib"],
839 native_binaries: ["mynativebinary"],
840 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
841 }
842
843 cc_library {
844 name: "mynativelib",
845 defaults: ["mydefaults"],
846 srcs: [
847 "Test.cpp",
848 ],
849 stl: "none",
850 }
851
852 cc_binary {
853 name: "mynativebinary",
854 defaults: ["mydefaults"],
855 srcs: [
856 "Test.cpp",
857 ],
858 stl: "none",
859 }
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000860 `)
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100861
Paul Duffin36474d32021-03-12 12:19:43 +0000862 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000863 checkUnversionedAndroidBpContents(`
864// This is auto-generated. DO NOT EDIT.
865
866cc_prebuilt_binary {
867 name: "mynativebinary",
868 prefer: false,
869 visibility: ["//visibility:public"],
870 apex_available: ["//apex_available:platform"],
871 device_supported: false,
872 host_supported: true,
873 stl: "none",
874 compile_multilib: "64",
875 target: {
876 host: {
877 enabled: false,
878 },
879 linux_bionic_x86_64: {
880 enabled: true,
881 srcs: ["x86_64/bin/mynativebinary"],
882 },
883 },
884}
885
886cc_prebuilt_library_shared {
887 name: "mynativelib",
888 prefer: false,
889 visibility: ["//visibility:public"],
890 apex_available: ["//apex_available:platform"],
891 device_supported: false,
892 host_supported: true,
893 stl: "none",
894 compile_multilib: "64",
895 target: {
896 host: {
897 enabled: false,
898 },
899 linux_bionic_x86_64: {
900 enabled: true,
901 srcs: ["x86_64/lib/mynativelib.so"],
902 },
903 },
904}
905`),
906 checkVersionedAndroidBpContents(`
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100907// This is auto-generated. DO NOT EDIT.
908
909cc_prebuilt_binary {
910 name: "myexports_mynativebinary@current",
911 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100912 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000913 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100914 device_supported: false,
915 host_supported: true,
916 installable: false,
917 stl: "none",
918 compile_multilib: "64",
919 target: {
920 host: {
921 enabled: false,
922 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100923 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900924 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100925 srcs: ["x86_64/bin/mynativebinary"],
926 },
927 },
928}
929
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100930cc_prebuilt_library_shared {
931 name: "myexports_mynativelib@current",
932 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100933 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000934 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100935 device_supported: false,
936 host_supported: true,
937 installable: false,
938 stl: "none",
939 compile_multilib: "64",
940 target: {
941 host: {
942 enabled: false,
943 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100944 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900945 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100946 srcs: ["x86_64/lib/mynativelib.so"],
947 },
948 },
949}
950
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100951module_exports_snapshot {
952 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100953 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100954 device_supported: false,
955 host_supported: true,
956 native_binaries: ["myexports_mynativebinary@current"],
957 native_shared_libs: ["myexports_mynativelib@current"],
958 compile_multilib: "64",
959 target: {
960 host: {
961 enabled: false,
962 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900963 linux_bionic_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100964 enabled: true,
965 },
966 },
967}
968`),
969 checkAllCopyRules(`
970.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
971.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
972`),
973 )
974}
975
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100976// Test that we support the necessary flags for the linker binary, which is
977// special in several ways.
978func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100979 result := testSdkWithCc(t, `
980 module_exports {
981 name: "mymodule_exports",
982 host_supported: true,
983 device_supported: false,
984 native_binaries: ["linker"],
985 }
986
987 cc_binary {
988 name: "linker",
989 host_supported: true,
990 static_executable: true,
991 nocrt: true,
992 stl: "none",
993 srcs: [
994 "Test.cpp",
995 ],
996 compile_multilib: "both",
997 }
998 `)
999
Paul Duffin36474d32021-03-12 12:19:43 +00001000 CheckSnapshot(t, result, "mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001001 checkUnversionedAndroidBpContents(`
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001002// This is auto-generated. DO NOT EDIT.
1003
1004cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +00001005 name: "linker",
1006 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001007 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001008 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001009 device_supported: false,
1010 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001011 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001012 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001013 static_executable: true,
1014 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001015 target: {
1016 host: {
1017 enabled: false,
1018 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001019 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001020 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001021 srcs: ["x86_64/bin/linker"],
1022 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001023 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001024 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001025 srcs: ["x86/bin/linker"],
1026 },
1027 },
1028}
Paul Duffin75b902a2021-02-22 12:13:13 +00001029`),
1030 checkVersionedAndroidBpContents(`
1031// This is auto-generated. DO NOT EDIT.
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001032
1033cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +00001034 name: "mymodule_exports_linker@current",
1035 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +01001036 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001037 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001038 device_supported: false,
1039 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001040 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001041 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001042 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001043 static_executable: true,
1044 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001045 target: {
1046 host: {
1047 enabled: false,
1048 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001049 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001050 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001051 srcs: ["x86_64/bin/linker"],
1052 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001053 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001054 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001055 srcs: ["x86/bin/linker"],
1056 },
1057 },
1058}
1059
1060module_exports_snapshot {
1061 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001062 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001063 device_supported: false,
1064 host_supported: true,
1065 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001066 target: {
1067 host: {
1068 enabled: false,
1069 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001070 linux_glibc_x86_64: {
1071 enabled: true,
1072 },
1073 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001074 enabled: true,
1075 },
1076 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001077}
1078`),
1079 checkAllCopyRules(`
1080.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1081.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1082`),
1083 )
1084}
1085
Paul Duffin9ab556f2019-12-11 18:42:17 +00001086func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001087 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001088 sdk {
1089 name: "mysdk",
1090 native_shared_libs: ["mynativelib"],
1091 }
1092
1093 cc_library_shared {
1094 name: "mynativelib",
1095 srcs: [
1096 "Test.cpp",
1097 "aidl/foo/bar/Test.aidl",
1098 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001099 apex_available: ["apex1", "apex2"],
Paul Duffin86b02a72021-02-22 11:50:04 +00001100 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001101 aidl: {
1102 export_aidl_headers: true,
1103 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001104 stl: "none",
1105 }
1106 `)
1107
Paul Duffin36474d32021-03-12 12:19:43 +00001108 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001109 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001110// This is auto-generated. DO NOT EDIT.
1111
1112cc_prebuilt_library_shared {
Paul Duffina80fdec2019-12-03 15:25:00 +00001113 name: "mynativelib",
1114 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001115 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001116 apex_available: [
1117 "apex1",
1118 "apex2",
1119 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001120 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001121 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001122 export_include_dirs: ["include/myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001123 arch: {
1124 arm64: {
1125 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001126 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001127 },
1128 arm: {
1129 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001130 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001131 },
1132 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001133}
Paul Duffina80fdec2019-12-03 15:25:00 +00001134`),
1135 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001136myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001137.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001138.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h
1139.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h
1140.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h
Colin Cross7113d202019-11-20 16:39:12 -08001141.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001142.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h
1143.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h
1144.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BpTest.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001145`),
1146 )
1147}
1148
Paul Duffin13f02712020-03-06 12:30:43 +00001149func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1150 result := testSdkWithCc(t, `
1151 sdk {
1152 name: "mysdk",
1153 native_shared_libs: [
1154 "mynativelib",
1155 "myothernativelib",
1156 "mysystemnativelib",
1157 ],
1158 }
1159
1160 cc_library {
1161 name: "mysystemnativelib",
1162 srcs: [
1163 "Test.cpp",
1164 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001165 stl: "none",
1166 }
1167
1168 cc_library_shared {
1169 name: "myothernativelib",
1170 srcs: [
1171 "Test.cpp",
1172 ],
1173 system_shared_libs: [
1174 // A reference to a library that is not an sdk member. Uses libm as that
1175 // is in the default set of modules available to this test and so is available
1176 // both here and also when the generated Android.bp file is tested in
1177 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1178 // handles references to modules that are not sdk members.
1179 "libm",
1180 ],
1181 stl: "none",
1182 }
1183
1184 cc_library {
1185 name: "mynativelib",
1186 srcs: [
1187 "Test.cpp",
1188 ],
1189 shared_libs: [
1190 // A reference to another sdk member.
1191 "myothernativelib",
1192 ],
1193 target: {
1194 android: {
1195 shared: {
1196 shared_libs: [
1197 // A reference to a library that is not an sdk member. The libc library
1198 // is used here to check that the shared_libs property is handled correctly
1199 // in a similar way to how libm is used to check system_shared_libs above.
1200 "libc",
1201 ],
1202 },
1203 },
1204 },
Paul Duffin13f02712020-03-06 12:30:43 +00001205 stl: "none",
1206 }
1207 `)
1208
Paul Duffin36474d32021-03-12 12:19:43 +00001209 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001210 checkUnversionedAndroidBpContents(`
Paul Duffin13f02712020-03-06 12:30:43 +00001211// This is auto-generated. DO NOT EDIT.
1212
1213cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001214 name: "mynativelib",
1215 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001216 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001217 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001218 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001219 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001220 shared_libs: [
1221 "myothernativelib",
1222 "libc",
1223 ],
1224 arch: {
1225 arm64: {
1226 srcs: ["arm64/lib/mynativelib.so"],
1227 },
1228 arm: {
1229 srcs: ["arm/lib/mynativelib.so"],
1230 },
1231 },
Paul Duffin13f02712020-03-06 12:30:43 +00001232}
1233
1234cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001235 name: "myothernativelib",
1236 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001237 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001238 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001239 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001240 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001241 system_shared_libs: ["libm"],
1242 arch: {
1243 arm64: {
1244 srcs: ["arm64/lib/myothernativelib.so"],
1245 },
1246 arm: {
1247 srcs: ["arm/lib/myothernativelib.so"],
1248 },
1249 },
Paul Duffin13f02712020-03-06 12:30:43 +00001250}
1251
1252cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001253 name: "mysystemnativelib",
1254 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001255 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001256 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001257 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001258 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001259 arch: {
1260 arm64: {
1261 srcs: ["arm64/lib/mysystemnativelib.so"],
1262 },
1263 arm: {
1264 srcs: ["arm/lib/mysystemnativelib.so"],
1265 },
1266 },
Paul Duffin13f02712020-03-06 12:30:43 +00001267}
Paul Duffin13f02712020-03-06 12:30:43 +00001268`),
1269 checkAllCopyRules(`
1270.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1271.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1272.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1273.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1274.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1275.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1276`),
1277 )
1278}
1279
Paul Duffin9ab556f2019-12-11 18:42:17 +00001280func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001281 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001282 sdk {
1283 name: "mysdk",
1284 device_supported: false,
1285 host_supported: true,
1286 native_shared_libs: ["mynativelib"],
1287 }
1288
1289 cc_library_shared {
1290 name: "mynativelib",
1291 device_supported: false,
1292 host_supported: true,
1293 srcs: [
1294 "Test.cpp",
1295 "aidl/foo/bar/Test.aidl",
1296 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001297 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001298 aidl: {
1299 export_aidl_headers: true,
1300 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001301 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001302 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001303 }
1304 `)
1305
Paul Duffin36474d32021-03-12 12:19:43 +00001306 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001307 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001308// This is auto-generated. DO NOT EDIT.
1309
1310cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001311 name: "mynativelib",
1312 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001313 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001314 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001315 device_supported: false,
1316 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001317 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001318 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001319 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001320 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001321 target: {
1322 host: {
1323 enabled: false,
1324 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001325 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001326 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001327 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001328 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001329 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001330 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001331 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001332 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001333 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001334 },
1335 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001336}
Paul Duffin75b902a2021-02-22 12:13:13 +00001337`),
1338 checkVersionedAndroidBpContents(`
1339// This is auto-generated. DO NOT EDIT.
Paul Duffina80fdec2019-12-03 15:25:00 +00001340
1341cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001342 name: "mysdk_mynativelib@current",
1343 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001344 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001345 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001346 device_supported: false,
1347 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001348 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001349 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001350 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001351 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001352 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001353 target: {
1354 host: {
1355 enabled: false,
1356 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001357 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001358 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001359 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001360 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001361 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001362 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001363 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001364 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001365 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001366 },
1367 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001368}
1369
1370sdk_snapshot {
1371 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001372 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001373 device_supported: false,
1374 host_supported: true,
1375 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001376 target: {
1377 host: {
1378 enabled: false,
1379 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001380 linux_glibc_x86_64: {
1381 enabled: true,
1382 },
1383 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001384 enabled: true,
1385 },
1386 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001387}
1388`),
1389 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001390myinclude/Test.h -> include/myinclude/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001391.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001392.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h
1393.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h
1394.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001395.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001396.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h
1397.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h
1398.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001399`),
1400 )
1401}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001402
Paul Duffina04c1072020-03-02 10:16:35 +00001403func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001404 result := testSdkWithCc(t, `
1405 sdk {
1406 name: "mysdk",
1407 device_supported: false,
1408 host_supported: true,
1409 native_shared_libs: ["mynativelib"],
1410 target: {
1411 windows: {
1412 enabled: true,
1413 },
1414 },
1415 }
1416
1417 cc_library_shared {
1418 name: "mynativelib",
1419 device_supported: false,
1420 host_supported: true,
1421 srcs: [
1422 "Test.cpp",
1423 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001424 stl: "none",
1425 target: {
1426 windows: {
1427 enabled: true,
1428 },
1429 },
1430 }
1431 `)
1432
Paul Duffin36474d32021-03-12 12:19:43 +00001433 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001434 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00001435// This is auto-generated. DO NOT EDIT.
1436
1437cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001438 name: "mynativelib",
1439 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001440 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001441 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001442 device_supported: false,
1443 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001444 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001445 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001446 host: {
1447 enabled: false,
1448 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001449 linux_glibc: {
1450 compile_multilib: "both",
1451 },
Paul Duffina04c1072020-03-02 10:16:35 +00001452 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001453 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001454 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1455 },
1456 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001457 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001458 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1459 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001460 windows: {
1461 compile_multilib: "64",
1462 },
Paul Duffina04c1072020-03-02 10:16:35 +00001463 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001464 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001465 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1466 },
1467 },
Paul Duffina04c1072020-03-02 10:16:35 +00001468}
Paul Duffin75b902a2021-02-22 12:13:13 +00001469`),
1470 checkVersionedAndroidBpContents(`
1471// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00001472
1473cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001474 name: "mysdk_mynativelib@current",
1475 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001476 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001477 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001478 device_supported: false,
1479 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001480 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001481 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001482 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001483 host: {
1484 enabled: false,
1485 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001486 linux_glibc: {
1487 compile_multilib: "both",
1488 },
Paul Duffina04c1072020-03-02 10:16:35 +00001489 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001490 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001491 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1492 },
1493 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001494 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001495 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1496 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001497 windows: {
1498 compile_multilib: "64",
1499 },
Paul Duffina04c1072020-03-02 10:16:35 +00001500 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001501 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001502 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1503 },
1504 },
Paul Duffina04c1072020-03-02 10:16:35 +00001505}
1506
1507sdk_snapshot {
1508 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001509 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001510 device_supported: false,
1511 host_supported: true,
1512 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001513 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001514 windows: {
1515 compile_multilib: "64",
1516 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001517 host: {
1518 enabled: false,
1519 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001520 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001521 enabled: true,
1522 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001523 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001524 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +09001525 },
1526 windows_x86_64: {
1527 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001528 },
1529 },
Paul Duffina04c1072020-03-02 10:16:35 +00001530}
1531`),
1532 checkAllCopyRules(`
1533.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1534.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1535.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1536`),
1537 )
1538}
1539
Paul Duffin9ab556f2019-12-11 18:42:17 +00001540func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1541 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001542 module_exports {
1543 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001544 native_static_libs: ["mynativelib"],
1545 }
1546
1547 cc_library_static {
1548 name: "mynativelib",
1549 srcs: [
1550 "Test.cpp",
1551 "aidl/foo/bar/Test.aidl",
1552 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001553 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001554 aidl: {
1555 export_aidl_headers: true,
1556 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001557 stl: "none",
1558 }
1559 `)
1560
Paul Duffin36474d32021-03-12 12:19:43 +00001561 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001562 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001563// This is auto-generated. DO NOT EDIT.
1564
1565cc_prebuilt_library_static {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001566 name: "mynativelib",
1567 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001568 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001569 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001570 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001571 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001572 export_include_dirs: ["include/myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001573 arch: {
1574 arm64: {
1575 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001576 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001577 },
1578 arm: {
1579 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001580 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001581 },
1582 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001583}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001584`),
1585 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001586myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001587.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001588.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h
1589.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h
1590.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h
Colin Cross7113d202019-11-20 16:39:12 -08001591.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001592.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h
1593.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h
1594.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BpTest.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001595`),
1596 )
1597}
1598
1599func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001600 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001601 module_exports {
1602 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001603 device_supported: false,
1604 host_supported: true,
1605 native_static_libs: ["mynativelib"],
1606 }
1607
1608 cc_library_static {
1609 name: "mynativelib",
1610 device_supported: false,
1611 host_supported: true,
1612 srcs: [
1613 "Test.cpp",
1614 "aidl/foo/bar/Test.aidl",
1615 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001616 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001617 aidl: {
1618 export_aidl_headers: true,
1619 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001620 stl: "none",
1621 }
1622 `)
1623
Paul Duffin36474d32021-03-12 12:19:43 +00001624 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001625 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001626// This is auto-generated. DO NOT EDIT.
1627
1628cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001629 name: "mynativelib",
1630 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001631 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001632 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001633 device_supported: false,
1634 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001635 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001636 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001637 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001638 target: {
1639 host: {
1640 enabled: false,
1641 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001642 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001643 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001644 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001645 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001646 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001647 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001648 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001649 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001650 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001651 },
1652 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001653}
Paul Duffin75b902a2021-02-22 12:13:13 +00001654`),
1655 checkVersionedAndroidBpContents(`
1656// This is auto-generated. DO NOT EDIT.
Paul Duffin9ab556f2019-12-11 18:42:17 +00001657
1658cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001659 name: "myexports_mynativelib@current",
1660 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001661 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001662 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001663 device_supported: false,
1664 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001665 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001666 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001667 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001668 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001669 target: {
1670 host: {
1671 enabled: false,
1672 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001673 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001674 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001675 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001676 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001677 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001678 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001679 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001680 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001681 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001682 },
1683 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001684}
1685
Paul Duffine6029182019-12-16 17:43:48 +00001686module_exports_snapshot {
1687 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001688 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001689 device_supported: false,
1690 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001691 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001692 target: {
1693 host: {
1694 enabled: false,
1695 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001696 linux_glibc_x86_64: {
1697 enabled: true,
1698 },
1699 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001700 enabled: true,
1701 },
1702 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001703}
1704`),
1705 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001706myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001707.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001708.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h
1709.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h
1710.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001711.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001712.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h
1713.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h
1714.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001715`),
1716 )
1717}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001718
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001719func TestSnapshotWithCcLibrary(t *testing.T) {
1720 result := testSdkWithCc(t, `
1721 module_exports {
1722 name: "myexports",
1723 native_libs: ["mynativelib"],
1724 }
1725
1726 cc_library {
1727 name: "mynativelib",
1728 srcs: [
1729 "Test.cpp",
1730 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001731 export_include_dirs: ["myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001732 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001733 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001734 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001735 }
1736 `)
1737
Paul Duffin36474d32021-03-12 12:19:43 +00001738 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001739 checkUnversionedAndroidBpContents(`
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001740// This is auto-generated. DO NOT EDIT.
1741
1742cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001743 name: "mynativelib",
1744 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001745 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001746 apex_available: ["//apex_available:platform"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001747 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001748 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001749 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001750 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001751 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001752 arch: {
1753 arm64: {
1754 static: {
1755 srcs: ["arm64/lib/mynativelib.a"],
1756 },
1757 shared: {
1758 srcs: ["arm64/lib/mynativelib.so"],
1759 },
1760 },
1761 arm: {
1762 static: {
1763 srcs: ["arm/lib/mynativelib.a"],
1764 },
1765 shared: {
1766 srcs: ["arm/lib/mynativelib.so"],
1767 },
1768 },
1769 },
1770}
Paul Duffin75b902a2021-02-22 12:13:13 +00001771`),
1772 // Make sure that the generated sdk_snapshot uses the native_libs property.
1773 checkVersionedAndroidBpContents(`
1774// This is auto-generated. DO NOT EDIT.
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001775
1776cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001777 name: "myexports_mynativelib@current",
1778 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001779 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001780 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +00001781 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001782 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001783 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001784 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001785 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001786 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001787 arch: {
1788 arm64: {
1789 static: {
1790 srcs: ["arm64/lib/mynativelib.a"],
1791 },
1792 shared: {
1793 srcs: ["arm64/lib/mynativelib.so"],
1794 },
1795 },
1796 arm: {
1797 static: {
1798 srcs: ["arm/lib/mynativelib.a"],
1799 },
1800 shared: {
1801 srcs: ["arm/lib/mynativelib.so"],
1802 },
1803 },
1804 },
1805}
1806
1807module_exports_snapshot {
1808 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001809 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001810 native_libs: ["myexports_mynativelib@current"],
1811}
1812`),
1813 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001814myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001815.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1816.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1817.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1818.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1819 )
1820}
1821
Paul Duffin13ad94f2020-02-19 16:19:27 +00001822func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001823 result := testSdkWithCc(t, `
1824 module_exports {
1825 name: "myexports",
1826 device_supported: false,
1827 host_supported: true,
1828 target: {
1829 host: {
1830 compile_multilib: "64",
1831 },
1832 },
1833 native_static_libs: ["mynativelib"],
1834 }
1835
1836 cc_library_static {
1837 name: "mynativelib",
1838 device_supported: false,
1839 host_supported: true,
1840 srcs: [
1841 "Test.cpp",
1842 "aidl/foo/bar/Test.aidl",
1843 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001844 export_include_dirs: ["myinclude"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001845 aidl: {
1846 export_aidl_headers: true,
1847 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001848 stl: "none",
1849 }
1850 `)
1851
Paul Duffin36474d32021-03-12 12:19:43 +00001852 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001853 checkUnversionedAndroidBpContents(`
Paul Duffin13ad94f2020-02-19 16:19:27 +00001854// This is auto-generated. DO NOT EDIT.
1855
1856cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001857 name: "mynativelib",
1858 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001859 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001860 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001861 device_supported: false,
1862 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001863 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001864 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001865 export_include_dirs: [
1866 "include/myinclude",
1867 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1868 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001869 target: {
1870 host: {
1871 enabled: false,
1872 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001873 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001874 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001875 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001876 },
1877 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001878}
Paul Duffin75b902a2021-02-22 12:13:13 +00001879`),
1880 checkVersionedAndroidBpContents(`
1881// This is auto-generated. DO NOT EDIT.
Paul Duffin13ad94f2020-02-19 16:19:27 +00001882
1883cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001884 name: "myexports_mynativelib@current",
1885 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001886 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001887 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001888 device_supported: false,
1889 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001890 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001891 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001892 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001893 export_include_dirs: [
1894 "include/myinclude",
1895 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1896 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001897 target: {
1898 host: {
1899 enabled: false,
1900 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001901 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001902 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001903 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001904 },
1905 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001906}
1907
1908module_exports_snapshot {
1909 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001910 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001911 device_supported: false,
1912 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001913 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001914 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001915 target: {
1916 host: {
1917 enabled: false,
1918 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001919 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001920 enabled: true,
1921 },
1922 },
Paul Duffin75b902a2021-02-22 12:13:13 +00001923}
1924`),
Paul Duffin13ad94f2020-02-19 16:19:27 +00001925 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001926myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin7a7d0672021-02-17 12:17:40 +00001927.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h
1928.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h
1929.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h
Paul Duffin13ad94f2020-02-19 16:19:27 +00001930.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin13ad94f2020-02-19 16:19:27 +00001931`),
1932 )
1933}
Paul Duffin91756d22020-02-21 16:29:57 +00001934
1935func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1936 result := testSdkWithCc(t, `
1937 sdk {
1938 name: "mysdk",
1939 native_header_libs: ["mynativeheaders"],
1940 }
1941
1942 cc_library_headers {
1943 name: "mynativeheaders",
Paul Duffin86b02a72021-02-22 11:50:04 +00001944 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001945 stl: "none",
1946 }
1947 `)
1948
Paul Duffin36474d32021-03-12 12:19:43 +00001949 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001950 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001951// This is auto-generated. DO NOT EDIT.
1952
1953cc_prebuilt_library_headers {
Paul Duffin91756d22020-02-21 16:29:57 +00001954 name: "mynativeheaders",
1955 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001956 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001957 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00001958 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001959 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001960 export_include_dirs: ["include/myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001961}
Paul Duffin91756d22020-02-21 16:29:57 +00001962`),
1963 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001964myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00001965`),
1966 )
1967}
1968
1969func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001970 result := testSdkWithCc(t, `
1971 sdk {
1972 name: "mysdk",
1973 device_supported: false,
1974 host_supported: true,
1975 native_header_libs: ["mynativeheaders"],
1976 }
1977
1978 cc_library_headers {
1979 name: "mynativeheaders",
1980 device_supported: false,
1981 host_supported: true,
Paul Duffin86b02a72021-02-22 11:50:04 +00001982 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001983 stl: "none",
1984 }
1985 `)
1986
Paul Duffin36474d32021-03-12 12:19:43 +00001987 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001988 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001989// This is auto-generated. DO NOT EDIT.
1990
1991cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00001992 name: "mynativeheaders",
1993 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001994 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001995 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00001996 device_supported: false,
1997 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00001998 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001999 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002000 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002001 target: {
2002 host: {
2003 enabled: false,
2004 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002005 linux_glibc_x86_64: {
2006 enabled: true,
2007 },
2008 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002009 enabled: true,
2010 },
2011 },
Paul Duffin91756d22020-02-21 16:29:57 +00002012}
Paul Duffin75b902a2021-02-22 12:13:13 +00002013`),
2014 checkVersionedAndroidBpContents(`
2015// This is auto-generated. DO NOT EDIT.
Paul Duffin91756d22020-02-21 16:29:57 +00002016
2017cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002018 name: "mysdk_mynativeheaders@current",
2019 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002020 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002021 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002022 device_supported: false,
2023 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002024 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002025 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002026 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002027 target: {
2028 host: {
2029 enabled: false,
2030 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002031 linux_glibc_x86_64: {
2032 enabled: true,
2033 },
2034 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002035 enabled: true,
2036 },
2037 },
Paul Duffin91756d22020-02-21 16:29:57 +00002038}
2039
2040sdk_snapshot {
2041 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002042 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002043 device_supported: false,
2044 host_supported: true,
2045 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002046 target: {
2047 host: {
2048 enabled: false,
2049 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002050 linux_glibc_x86_64: {
2051 enabled: true,
2052 },
2053 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002054 enabled: true,
2055 },
2056 },
Paul Duffin91756d22020-02-21 16:29:57 +00002057}
2058`),
2059 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002060myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00002061`),
2062 )
2063}
Paul Duffina04c1072020-03-02 10:16:35 +00002064
2065func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00002066 result := testSdkWithCc(t, `
2067 sdk {
2068 name: "mysdk",
2069 host_supported: true,
2070 native_header_libs: ["mynativeheaders"],
2071 }
2072
2073 cc_library_headers {
2074 name: "mynativeheaders",
2075 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002076 stl: "none",
Paul Duffin86b02a72021-02-22 11:50:04 +00002077 export_system_include_dirs: ["myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002078 target: {
2079 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002080 export_include_dirs: ["myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002081 },
2082 host: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002083 export_include_dirs: ["myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002084 },
2085 },
2086 }
2087 `)
2088
Paul Duffin36474d32021-03-12 12:19:43 +00002089 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002090 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00002091// This is auto-generated. DO NOT EDIT.
2092
2093cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002094 name: "mynativeheaders",
2095 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002096 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002097 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002098 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002099 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002100 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002101 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002102 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002103 host: {
2104 enabled: false,
2105 },
Paul Duffina04c1072020-03-02 10:16:35 +00002106 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002107 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002108 },
2109 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002110 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002111 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002112 linux_glibc_x86_64: {
2113 enabled: true,
2114 },
2115 linux_glibc_x86: {
2116 enabled: true,
2117 },
Paul Duffina04c1072020-03-02 10:16:35 +00002118 },
Paul Duffina04c1072020-03-02 10:16:35 +00002119}
Paul Duffin75b902a2021-02-22 12:13:13 +00002120`),
Paul Duffin75b902a2021-02-22 12:13:13 +00002121 checkVersionedAndroidBpContents(`
2122// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00002123
2124cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002125 name: "mysdk_mynativeheaders@current",
2126 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002127 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002128 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002129 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002130 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002131 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002132 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002133 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002134 host: {
2135 enabled: false,
2136 },
Paul Duffina04c1072020-03-02 10:16:35 +00002137 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002138 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002139 },
2140 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002141 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002142 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002143 linux_glibc_x86_64: {
2144 enabled: true,
2145 },
2146 linux_glibc_x86: {
2147 enabled: true,
2148 },
Paul Duffina04c1072020-03-02 10:16:35 +00002149 },
Paul Duffina04c1072020-03-02 10:16:35 +00002150}
2151
2152sdk_snapshot {
2153 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002154 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002155 host_supported: true,
2156 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002157 target: {
2158 host: {
2159 enabled: false,
2160 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002161 linux_glibc_x86_64: {
2162 enabled: true,
2163 },
2164 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002165 enabled: true,
2166 },
2167 },
Paul Duffina04c1072020-03-02 10:16:35 +00002168}
2169`),
2170 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002171myinclude/Test.h -> common_os/include/myinclude/Test.h
2172myinclude-android/AndroidTest.h -> android/include/myinclude-android/AndroidTest.h
2173myinclude-host/HostTest.h -> linux_glibc/include/myinclude-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002174`),
2175 )
2176}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002177
2178func TestSystemSharedLibPropagation(t *testing.T) {
2179 result := testSdkWithCc(t, `
2180 sdk {
2181 name: "mysdk",
2182 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2183 }
2184
2185 cc_library {
2186 name: "sslnil",
2187 host_supported: true,
2188 }
2189
2190 cc_library {
2191 name: "sslempty",
2192 system_shared_libs: [],
2193 }
2194
2195 cc_library {
2196 name: "sslnonempty",
2197 system_shared_libs: ["sslnil"],
2198 }
2199 `)
2200
Paul Duffin36474d32021-03-12 12:19:43 +00002201 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002202 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002203// This is auto-generated. DO NOT EDIT.
2204
2205cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002206 name: "sslnil",
2207 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002208 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002209 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002210 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002211 arch: {
2212 arm64: {
2213 srcs: ["arm64/lib/sslnil.so"],
2214 },
2215 arm: {
2216 srcs: ["arm/lib/sslnil.so"],
2217 },
2218 },
2219}
2220
2221cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002222 name: "sslempty",
2223 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002224 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002225 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002226 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002227 system_shared_libs: [],
2228 arch: {
2229 arm64: {
2230 srcs: ["arm64/lib/sslempty.so"],
2231 },
2232 arm: {
2233 srcs: ["arm/lib/sslempty.so"],
2234 },
2235 },
2236}
2237
2238cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002239 name: "sslnonempty",
2240 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002241 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002242 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002243 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002244 system_shared_libs: ["sslnil"],
2245 arch: {
2246 arm64: {
2247 srcs: ["arm64/lib/sslnonempty.so"],
2248 },
2249 arm: {
2250 srcs: ["arm/lib/sslnonempty.so"],
2251 },
2252 },
2253}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002254`))
2255
2256 result = testSdkWithCc(t, `
2257 sdk {
2258 name: "mysdk",
2259 host_supported: true,
2260 native_shared_libs: ["sslvariants"],
2261 }
2262
2263 cc_library {
2264 name: "sslvariants",
2265 host_supported: true,
2266 target: {
2267 android: {
2268 system_shared_libs: [],
2269 },
2270 },
2271 }
2272 `)
2273
Paul Duffin36474d32021-03-12 12:19:43 +00002274 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002275 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002276// This is auto-generated. DO NOT EDIT.
2277
2278cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002279 name: "sslvariants",
2280 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002281 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002282 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002283 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002284 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002285 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002286 host: {
2287 enabled: false,
2288 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002289 android: {
2290 system_shared_libs: [],
2291 },
2292 android_arm64: {
2293 srcs: ["android/arm64/lib/sslvariants.so"],
2294 },
2295 android_arm: {
2296 srcs: ["android/arm/lib/sslvariants.so"],
2297 },
2298 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002299 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002300 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2301 },
2302 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002303 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002304 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2305 },
2306 },
2307}
Paul Duffin75b902a2021-02-22 12:13:13 +00002308`),
2309 checkVersionedAndroidBpContents(`
2310// This is auto-generated. DO NOT EDIT.
Martin Stjernholm10566a02020-03-24 01:19:52 +00002311
2312cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002313 name: "mysdk_sslvariants@current",
2314 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002315 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002316 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002317 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002318 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002319 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002320 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002321 host: {
2322 enabled: false,
2323 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002324 android: {
2325 system_shared_libs: [],
2326 },
2327 android_arm64: {
2328 srcs: ["android/arm64/lib/sslvariants.so"],
2329 },
2330 android_arm: {
2331 srcs: ["android/arm/lib/sslvariants.so"],
2332 },
2333 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002334 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002335 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2336 },
2337 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002338 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002339 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2340 },
2341 },
2342}
2343
2344sdk_snapshot {
2345 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002346 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002347 host_supported: true,
2348 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002349 target: {
2350 host: {
2351 enabled: false,
2352 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002353 linux_glibc_x86_64: {
2354 enabled: true,
2355 },
2356 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002357 enabled: true,
2358 },
2359 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002360}
2361`))
2362}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002363
2364func TestStubsLibrary(t *testing.T) {
2365 result := testSdkWithCc(t, `
2366 sdk {
2367 name: "mysdk",
2368 native_shared_libs: ["stubslib"],
2369 }
2370
2371 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002372 name: "internaldep",
2373 }
2374
2375 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002376 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002377 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002378 stubs: {
2379 symbol_file: "some/where/stubslib.map.txt",
2380 versions: ["1", "2", "3"],
2381 },
2382 }
2383 `)
2384
Paul Duffin36474d32021-03-12 12:19:43 +00002385 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002386 checkUnversionedAndroidBpContents(`
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002387// This is auto-generated. DO NOT EDIT.
2388
2389cc_prebuilt_library_shared {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002390 name: "stubslib",
2391 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002392 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002393 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002394 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002395 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002396 versions: [
2397 "1",
2398 "2",
2399 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002400 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002401 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002402 },
2403 arch: {
2404 arm64: {
2405 srcs: ["arm64/lib/stubslib.so"],
2406 },
2407 arm: {
2408 srcs: ["arm/lib/stubslib.so"],
2409 },
2410 },
2411}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002412`))
2413}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002414
2415func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002416 result := testSdkWithCc(t, `
2417 sdk {
2418 name: "mysdk",
2419 host_supported: true,
2420 native_shared_libs: ["stubslib"],
2421 }
2422
2423 cc_library {
2424 name: "internaldep",
2425 host_supported: true,
2426 }
2427
2428 cc_library {
2429 name: "stubslib",
2430 host_supported: true,
2431 shared_libs: ["internaldep"],
2432 stubs: {
2433 symbol_file: "some/where/stubslib.map.txt",
2434 versions: ["1", "2", "3"],
2435 },
2436 }
2437 `)
2438
Paul Duffin36474d32021-03-12 12:19:43 +00002439 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002440 checkUnversionedAndroidBpContents(`
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002441// This is auto-generated. DO NOT EDIT.
2442
2443cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002444 name: "stubslib",
2445 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002446 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002447 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002448 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002449 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002450 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002451 versions: [
2452 "1",
2453 "2",
2454 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002455 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002456 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002457 },
2458 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002459 host: {
2460 enabled: false,
2461 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002462 android_arm64: {
2463 srcs: ["android/arm64/lib/stubslib.so"],
2464 },
2465 android_arm: {
2466 srcs: ["android/arm/lib/stubslib.so"],
2467 },
2468 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002469 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002470 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2471 },
2472 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002473 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002474 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2475 },
2476 },
2477}
Paul Duffin75b902a2021-02-22 12:13:13 +00002478`),
2479 checkVersionedAndroidBpContents(`
2480// This is auto-generated. DO NOT EDIT.
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002481
2482cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002483 name: "mysdk_stubslib@current",
2484 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002485 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002486 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002487 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002488 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002489 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002490 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002491 versions: [
2492 "1",
2493 "2",
2494 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002495 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002496 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002497 },
2498 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002499 host: {
2500 enabled: false,
2501 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002502 android_arm64: {
2503 srcs: ["android/arm64/lib/stubslib.so"],
2504 },
2505 android_arm: {
2506 srcs: ["android/arm/lib/stubslib.so"],
2507 },
2508 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002509 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002510 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2511 },
2512 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002513 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002514 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2515 },
2516 },
2517}
2518
2519sdk_snapshot {
2520 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002521 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002522 host_supported: true,
2523 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002524 target: {
2525 host: {
2526 enabled: false,
2527 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002528 linux_glibc_x86_64: {
2529 enabled: true,
2530 },
2531 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002532 enabled: true,
2533 },
2534 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002535}
2536`))
2537}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002538
2539func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002540 result := testSdkWithCc(t, `
2541 sdk {
2542 name: "mysdk",
2543 host_supported: true,
2544 native_shared_libs: ["mylib"],
2545 }
2546
2547 cc_library {
2548 name: "mylib",
2549 host_supported: true,
2550 unique_host_soname: true,
2551 }
2552 `)
2553
Paul Duffin36474d32021-03-12 12:19:43 +00002554 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002555 checkUnversionedAndroidBpContents(`
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002556// This is auto-generated. DO NOT EDIT.
2557
2558cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002559 name: "mylib",
2560 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002561 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002562 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002563 host_supported: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002564 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002565 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002566 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002567 host: {
2568 enabled: false,
2569 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002570 android_arm64: {
2571 srcs: ["android/arm64/lib/mylib.so"],
2572 },
2573 android_arm: {
2574 srcs: ["android/arm/lib/mylib.so"],
2575 },
2576 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002577 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002578 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2579 },
2580 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002581 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002582 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2583 },
2584 },
2585}
Paul Duffin75b902a2021-02-22 12:13:13 +00002586`),
2587 checkVersionedAndroidBpContents(`
2588// This is auto-generated. DO NOT EDIT.
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002589
2590cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002591 name: "mysdk_mylib@current",
2592 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002593 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002594 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002595 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002596 installable: false,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002597 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002598 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002599 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002600 host: {
2601 enabled: false,
2602 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002603 android_arm64: {
2604 srcs: ["android/arm64/lib/mylib.so"],
2605 },
2606 android_arm: {
2607 srcs: ["android/arm/lib/mylib.so"],
2608 },
2609 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002610 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002611 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2612 },
2613 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002614 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002615 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2616 },
2617 },
2618}
2619
2620sdk_snapshot {
2621 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002622 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002623 host_supported: true,
2624 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002625 target: {
2626 host: {
2627 enabled: false,
2628 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002629 linux_glibc_x86_64: {
2630 enabled: true,
2631 },
2632 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002633 enabled: true,
2634 },
2635 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002636}
2637`),
2638 checkAllCopyRules(`
2639.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2640.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2641.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2642.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2643`),
2644 )
2645}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002646
2647func TestNoSanitizerMembers(t *testing.T) {
2648 result := testSdkWithCc(t, `
2649 sdk {
2650 name: "mysdk",
2651 native_shared_libs: ["mynativelib"],
2652 }
2653
2654 cc_library_shared {
2655 name: "mynativelib",
2656 srcs: ["Test.cpp"],
Paul Duffin86b02a72021-02-22 11:50:04 +00002657 export_include_dirs: ["myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002658 arch: {
2659 arm64: {
2660 export_system_include_dirs: ["arm64/include"],
2661 sanitize: {
2662 hwaddress: true,
2663 },
2664 },
2665 },
2666 }
2667 `)
2668
Paul Duffin36474d32021-03-12 12:19:43 +00002669 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002670 checkUnversionedAndroidBpContents(`
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002671// This is auto-generated. DO NOT EDIT.
2672
2673cc_prebuilt_library_shared {
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002674 name: "mynativelib",
2675 prefer: false,
2676 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002677 apex_available: ["//apex_available:platform"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002678 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002679 export_include_dirs: ["include/myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002680 arch: {
2681 arm64: {
2682 export_system_include_dirs: ["arm64/include/arm64/include"],
2683 },
2684 arm: {
2685 srcs: ["arm/lib/mynativelib.so"],
2686 },
2687 },
2688}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002689`),
2690 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002691myinclude/Test.h -> include/myinclude/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002692arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
2693.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
2694 )
2695}