blob: 6c02bf755bc39198976f8df3767ce58014122c7d [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 Duffin89648f92021-03-20 00:36:55 +0000811 result := android.GroupFixturePreparers(
812 prepareForSdkTest,
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000813 ccTestFs.AddToFixture(),
814 cc.PrepareForTestOnLinuxBionic,
815 android.FixtureModifyConfig(func(config android.Config) {
816 config.Targets[android.LinuxBionic] = []android.Target{
817 {android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", false},
818 }
819 }),
820 ).RunTestWithBp(t, `
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100821 cc_defaults {
822 name: "mydefaults",
823 device_supported: false,
824 host_supported: true,
825 compile_multilib: "64",
826 target: {
827 host: {
828 enabled: false,
829 },
830 linux_bionic: {
831 enabled: true,
832 },
833 },
834 }
835
836 module_exports {
837 name: "myexports",
838 defaults: ["mydefaults"],
839 native_shared_libs: ["mynativelib"],
840 native_binaries: ["mynativebinary"],
841 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
842 }
843
844 cc_library {
845 name: "mynativelib",
846 defaults: ["mydefaults"],
847 srcs: [
848 "Test.cpp",
849 ],
850 stl: "none",
851 }
852
853 cc_binary {
854 name: "mynativebinary",
855 defaults: ["mydefaults"],
856 srcs: [
857 "Test.cpp",
858 ],
859 stl: "none",
860 }
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000861 `)
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100862
Paul Duffin36474d32021-03-12 12:19:43 +0000863 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000864 checkUnversionedAndroidBpContents(`
865// This is auto-generated. DO NOT EDIT.
866
867cc_prebuilt_binary {
868 name: "mynativebinary",
869 prefer: false,
870 visibility: ["//visibility:public"],
871 apex_available: ["//apex_available:platform"],
872 device_supported: false,
873 host_supported: true,
874 stl: "none",
875 compile_multilib: "64",
876 target: {
877 host: {
878 enabled: false,
879 },
880 linux_bionic_x86_64: {
881 enabled: true,
882 srcs: ["x86_64/bin/mynativebinary"],
883 },
884 },
885}
886
887cc_prebuilt_library_shared {
888 name: "mynativelib",
889 prefer: false,
890 visibility: ["//visibility:public"],
891 apex_available: ["//apex_available:platform"],
892 device_supported: false,
893 host_supported: true,
894 stl: "none",
895 compile_multilib: "64",
896 target: {
897 host: {
898 enabled: false,
899 },
900 linux_bionic_x86_64: {
901 enabled: true,
902 srcs: ["x86_64/lib/mynativelib.so"],
903 },
904 },
905}
906`),
907 checkVersionedAndroidBpContents(`
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100908// This is auto-generated. DO NOT EDIT.
909
910cc_prebuilt_binary {
911 name: "myexports_mynativebinary@current",
912 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100913 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000914 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100915 device_supported: false,
916 host_supported: true,
917 installable: false,
918 stl: "none",
919 compile_multilib: "64",
920 target: {
921 host: {
922 enabled: false,
923 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100924 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900925 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100926 srcs: ["x86_64/bin/mynativebinary"],
927 },
928 },
929}
930
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100931cc_prebuilt_library_shared {
932 name: "myexports_mynativelib@current",
933 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100934 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000935 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100936 device_supported: false,
937 host_supported: true,
938 installable: false,
939 stl: "none",
940 compile_multilib: "64",
941 target: {
942 host: {
943 enabled: false,
944 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100945 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900946 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100947 srcs: ["x86_64/lib/mynativelib.so"],
948 },
949 },
950}
951
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100952module_exports_snapshot {
953 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100954 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100955 device_supported: false,
956 host_supported: true,
957 native_binaries: ["myexports_mynativebinary@current"],
958 native_shared_libs: ["myexports_mynativelib@current"],
959 compile_multilib: "64",
960 target: {
961 host: {
962 enabled: false,
963 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900964 linux_bionic_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100965 enabled: true,
966 },
967 },
968}
969`),
970 checkAllCopyRules(`
971.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
972.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
973`),
974 )
975}
976
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100977// Test that we support the necessary flags for the linker binary, which is
978// special in several ways.
979func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100980 result := testSdkWithCc(t, `
981 module_exports {
982 name: "mymodule_exports",
983 host_supported: true,
984 device_supported: false,
985 native_binaries: ["linker"],
986 }
987
988 cc_binary {
989 name: "linker",
990 host_supported: true,
991 static_executable: true,
992 nocrt: true,
993 stl: "none",
994 srcs: [
995 "Test.cpp",
996 ],
997 compile_multilib: "both",
998 }
999 `)
1000
Paul Duffin36474d32021-03-12 12:19:43 +00001001 CheckSnapshot(t, result, "mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001002 checkUnversionedAndroidBpContents(`
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001003// This is auto-generated. DO NOT EDIT.
1004
1005cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +00001006 name: "linker",
1007 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001008 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001009 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001010 device_supported: false,
1011 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001012 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001013 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001014 static_executable: true,
1015 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001016 target: {
1017 host: {
1018 enabled: false,
1019 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001020 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001021 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001022 srcs: ["x86_64/bin/linker"],
1023 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001024 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001025 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001026 srcs: ["x86/bin/linker"],
1027 },
1028 },
1029}
Paul Duffin75b902a2021-02-22 12:13:13 +00001030`),
1031 checkVersionedAndroidBpContents(`
1032// This is auto-generated. DO NOT EDIT.
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001033
1034cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +00001035 name: "mymodule_exports_linker@current",
1036 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +01001037 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001038 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001039 device_supported: false,
1040 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001041 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001042 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001043 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001044 static_executable: true,
1045 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001046 target: {
1047 host: {
1048 enabled: false,
1049 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001050 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001051 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001052 srcs: ["x86_64/bin/linker"],
1053 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001054 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001055 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001056 srcs: ["x86/bin/linker"],
1057 },
1058 },
1059}
1060
1061module_exports_snapshot {
1062 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001063 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001064 device_supported: false,
1065 host_supported: true,
1066 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001067 target: {
1068 host: {
1069 enabled: false,
1070 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001071 linux_glibc_x86_64: {
1072 enabled: true,
1073 },
1074 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001075 enabled: true,
1076 },
1077 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001078}
1079`),
1080 checkAllCopyRules(`
1081.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1082.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1083`),
1084 )
1085}
1086
Paul Duffin9ab556f2019-12-11 18:42:17 +00001087func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001088 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001089 sdk {
1090 name: "mysdk",
1091 native_shared_libs: ["mynativelib"],
1092 }
1093
1094 cc_library_shared {
1095 name: "mynativelib",
1096 srcs: [
1097 "Test.cpp",
1098 "aidl/foo/bar/Test.aidl",
1099 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001100 apex_available: ["apex1", "apex2"],
Paul Duffin86b02a72021-02-22 11:50:04 +00001101 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001102 aidl: {
1103 export_aidl_headers: true,
1104 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001105 stl: "none",
1106 }
1107 `)
1108
Paul Duffin36474d32021-03-12 12:19:43 +00001109 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001110 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001111// This is auto-generated. DO NOT EDIT.
1112
1113cc_prebuilt_library_shared {
Paul Duffina80fdec2019-12-03 15:25:00 +00001114 name: "mynativelib",
1115 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001116 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001117 apex_available: [
1118 "apex1",
1119 "apex2",
1120 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001121 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001122 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001123 export_include_dirs: ["include/myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001124 arch: {
1125 arm64: {
1126 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001127 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001128 },
1129 arm: {
1130 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001131 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001132 },
1133 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001134}
Paul Duffina80fdec2019-12-03 15:25:00 +00001135`),
1136 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001137myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001138.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001139.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
1140.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
1141.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 -08001142.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001143.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
1144.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
1145.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 +00001146`),
1147 )
1148}
1149
Paul Duffin13f02712020-03-06 12:30:43 +00001150func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1151 result := testSdkWithCc(t, `
1152 sdk {
1153 name: "mysdk",
1154 native_shared_libs: [
1155 "mynativelib",
1156 "myothernativelib",
1157 "mysystemnativelib",
1158 ],
1159 }
1160
1161 cc_library {
1162 name: "mysystemnativelib",
1163 srcs: [
1164 "Test.cpp",
1165 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001166 stl: "none",
1167 }
1168
1169 cc_library_shared {
1170 name: "myothernativelib",
1171 srcs: [
1172 "Test.cpp",
1173 ],
1174 system_shared_libs: [
1175 // A reference to a library that is not an sdk member. Uses libm as that
1176 // is in the default set of modules available to this test and so is available
1177 // both here and also when the generated Android.bp file is tested in
1178 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1179 // handles references to modules that are not sdk members.
1180 "libm",
1181 ],
1182 stl: "none",
1183 }
1184
1185 cc_library {
1186 name: "mynativelib",
1187 srcs: [
1188 "Test.cpp",
1189 ],
1190 shared_libs: [
1191 // A reference to another sdk member.
1192 "myothernativelib",
1193 ],
1194 target: {
1195 android: {
1196 shared: {
1197 shared_libs: [
1198 // A reference to a library that is not an sdk member. The libc library
1199 // is used here to check that the shared_libs property is handled correctly
1200 // in a similar way to how libm is used to check system_shared_libs above.
1201 "libc",
1202 ],
1203 },
1204 },
1205 },
Paul Duffin13f02712020-03-06 12:30:43 +00001206 stl: "none",
1207 }
1208 `)
1209
Paul Duffin36474d32021-03-12 12:19:43 +00001210 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001211 checkUnversionedAndroidBpContents(`
Paul Duffin13f02712020-03-06 12:30:43 +00001212// This is auto-generated. DO NOT EDIT.
1213
1214cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001215 name: "mynativelib",
1216 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001217 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001218 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001219 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001220 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001221 shared_libs: [
1222 "myothernativelib",
1223 "libc",
1224 ],
1225 arch: {
1226 arm64: {
1227 srcs: ["arm64/lib/mynativelib.so"],
1228 },
1229 arm: {
1230 srcs: ["arm/lib/mynativelib.so"],
1231 },
1232 },
Paul Duffin13f02712020-03-06 12:30:43 +00001233}
1234
1235cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001236 name: "myothernativelib",
1237 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001238 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001239 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001240 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001241 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001242 system_shared_libs: ["libm"],
1243 arch: {
1244 arm64: {
1245 srcs: ["arm64/lib/myothernativelib.so"],
1246 },
1247 arm: {
1248 srcs: ["arm/lib/myothernativelib.so"],
1249 },
1250 },
Paul Duffin13f02712020-03-06 12:30:43 +00001251}
1252
1253cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001254 name: "mysystemnativelib",
1255 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001256 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001257 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001258 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001259 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001260 arch: {
1261 arm64: {
1262 srcs: ["arm64/lib/mysystemnativelib.so"],
1263 },
1264 arm: {
1265 srcs: ["arm/lib/mysystemnativelib.so"],
1266 },
1267 },
Paul Duffin13f02712020-03-06 12:30:43 +00001268}
Paul Duffin13f02712020-03-06 12:30:43 +00001269`),
1270 checkAllCopyRules(`
1271.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1272.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1273.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1274.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1275.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1276.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1277`),
1278 )
1279}
1280
Paul Duffin9ab556f2019-12-11 18:42:17 +00001281func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001282 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001283 sdk {
1284 name: "mysdk",
1285 device_supported: false,
1286 host_supported: true,
1287 native_shared_libs: ["mynativelib"],
1288 }
1289
1290 cc_library_shared {
1291 name: "mynativelib",
1292 device_supported: false,
1293 host_supported: true,
1294 srcs: [
1295 "Test.cpp",
1296 "aidl/foo/bar/Test.aidl",
1297 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001298 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001299 aidl: {
1300 export_aidl_headers: true,
1301 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001302 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001303 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001304 }
1305 `)
1306
Paul Duffin36474d32021-03-12 12:19:43 +00001307 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001308 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001309// This is auto-generated. DO NOT EDIT.
1310
1311cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001312 name: "mynativelib",
1313 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001314 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001315 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001316 device_supported: false,
1317 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001318 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001319 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001320 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001321 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001322 target: {
1323 host: {
1324 enabled: false,
1325 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001326 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001327 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001328 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001329 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001330 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001331 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001332 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001333 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001334 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001335 },
1336 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001337}
Paul Duffin75b902a2021-02-22 12:13:13 +00001338`),
1339 checkVersionedAndroidBpContents(`
1340// This is auto-generated. DO NOT EDIT.
Paul Duffina80fdec2019-12-03 15:25:00 +00001341
1342cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001343 name: "mysdk_mynativelib@current",
1344 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001345 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001346 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001347 device_supported: false,
1348 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001349 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001350 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001351 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001352 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001353 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001354 target: {
1355 host: {
1356 enabled: false,
1357 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001358 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001359 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001360 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001361 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001362 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001363 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001364 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001365 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001366 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001367 },
1368 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001369}
1370
1371sdk_snapshot {
1372 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001373 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001374 device_supported: false,
1375 host_supported: true,
1376 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001377 target: {
1378 host: {
1379 enabled: false,
1380 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001381 linux_glibc_x86_64: {
1382 enabled: true,
1383 },
1384 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001385 enabled: true,
1386 },
1387 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001388}
1389`),
1390 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001391myinclude/Test.h -> include/myinclude/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001392.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001393.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
1394.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
1395.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 +00001396.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001397.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
1398.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
1399.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 +00001400`),
1401 )
1402}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001403
Paul Duffina04c1072020-03-02 10:16:35 +00001404func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001405 result := testSdkWithCc(t, `
1406 sdk {
1407 name: "mysdk",
1408 device_supported: false,
1409 host_supported: true,
1410 native_shared_libs: ["mynativelib"],
1411 target: {
1412 windows: {
1413 enabled: true,
1414 },
1415 },
1416 }
1417
1418 cc_library_shared {
1419 name: "mynativelib",
1420 device_supported: false,
1421 host_supported: true,
1422 srcs: [
1423 "Test.cpp",
1424 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001425 stl: "none",
1426 target: {
1427 windows: {
1428 enabled: true,
1429 },
1430 },
1431 }
1432 `)
1433
Paul Duffin36474d32021-03-12 12:19:43 +00001434 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001435 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00001436// This is auto-generated. DO NOT EDIT.
1437
1438cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001439 name: "mynativelib",
1440 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001441 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001442 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001443 device_supported: false,
1444 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001445 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001446 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001447 host: {
1448 enabled: false,
1449 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001450 linux_glibc: {
1451 compile_multilib: "both",
1452 },
Paul Duffina04c1072020-03-02 10:16:35 +00001453 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001454 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001455 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1456 },
1457 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001458 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001459 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1460 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001461 windows: {
1462 compile_multilib: "64",
1463 },
Paul Duffina04c1072020-03-02 10:16:35 +00001464 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001465 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001466 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1467 },
1468 },
Paul Duffina04c1072020-03-02 10:16:35 +00001469}
Paul Duffin75b902a2021-02-22 12:13:13 +00001470`),
1471 checkVersionedAndroidBpContents(`
1472// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00001473
1474cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001475 name: "mysdk_mynativelib@current",
1476 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001477 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001478 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001479 device_supported: false,
1480 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001481 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001482 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001483 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001484 host: {
1485 enabled: false,
1486 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001487 linux_glibc: {
1488 compile_multilib: "both",
1489 },
Paul Duffina04c1072020-03-02 10:16:35 +00001490 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001491 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001492 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1493 },
1494 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001495 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001496 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1497 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001498 windows: {
1499 compile_multilib: "64",
1500 },
Paul Duffina04c1072020-03-02 10:16:35 +00001501 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001502 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001503 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1504 },
1505 },
Paul Duffina04c1072020-03-02 10:16:35 +00001506}
1507
1508sdk_snapshot {
1509 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001510 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001511 device_supported: false,
1512 host_supported: true,
1513 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001514 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001515 windows: {
1516 compile_multilib: "64",
1517 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001518 host: {
1519 enabled: false,
1520 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001521 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001522 enabled: true,
1523 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001524 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001525 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +09001526 },
1527 windows_x86_64: {
1528 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001529 },
1530 },
Paul Duffina04c1072020-03-02 10:16:35 +00001531}
1532`),
1533 checkAllCopyRules(`
1534.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1535.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1536.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1537`),
1538 )
1539}
1540
Paul Duffin9ab556f2019-12-11 18:42:17 +00001541func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1542 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001543 module_exports {
1544 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001545 native_static_libs: ["mynativelib"],
1546 }
1547
1548 cc_library_static {
1549 name: "mynativelib",
1550 srcs: [
1551 "Test.cpp",
1552 "aidl/foo/bar/Test.aidl",
1553 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001554 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001555 aidl: {
1556 export_aidl_headers: true,
1557 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001558 stl: "none",
1559 }
1560 `)
1561
Paul Duffin36474d32021-03-12 12:19:43 +00001562 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001563 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001564// This is auto-generated. DO NOT EDIT.
1565
1566cc_prebuilt_library_static {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001567 name: "mynativelib",
1568 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001569 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001570 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001571 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001572 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001573 export_include_dirs: ["include/myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001574 arch: {
1575 arm64: {
1576 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001577 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001578 },
1579 arm: {
1580 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001581 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001582 },
1583 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001584}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001585`),
1586 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001587myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001588.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001589.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
1590.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
1591.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 -08001592.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001593.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
1594.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
1595.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 +00001596`),
1597 )
1598}
1599
1600func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001601 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001602 module_exports {
1603 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001604 device_supported: false,
1605 host_supported: true,
1606 native_static_libs: ["mynativelib"],
1607 }
1608
1609 cc_library_static {
1610 name: "mynativelib",
1611 device_supported: false,
1612 host_supported: true,
1613 srcs: [
1614 "Test.cpp",
1615 "aidl/foo/bar/Test.aidl",
1616 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001617 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001618 aidl: {
1619 export_aidl_headers: true,
1620 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001621 stl: "none",
1622 }
1623 `)
1624
Paul Duffin36474d32021-03-12 12:19:43 +00001625 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001626 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001627// This is auto-generated. DO NOT EDIT.
1628
1629cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001630 name: "mynativelib",
1631 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001632 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001633 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001634 device_supported: false,
1635 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001636 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001637 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001638 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001639 target: {
1640 host: {
1641 enabled: false,
1642 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001643 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001644 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001645 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001646 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001647 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001648 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001649 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001650 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001651 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001652 },
1653 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001654}
Paul Duffin75b902a2021-02-22 12:13:13 +00001655`),
1656 checkVersionedAndroidBpContents(`
1657// This is auto-generated. DO NOT EDIT.
Paul Duffin9ab556f2019-12-11 18:42:17 +00001658
1659cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001660 name: "myexports_mynativelib@current",
1661 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001662 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001663 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001664 device_supported: false,
1665 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001666 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001667 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001668 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001669 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001670 target: {
1671 host: {
1672 enabled: false,
1673 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001674 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001675 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001676 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001677 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001678 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001679 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001680 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001681 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001682 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001683 },
1684 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001685}
1686
Paul Duffine6029182019-12-16 17:43:48 +00001687module_exports_snapshot {
1688 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001689 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001690 device_supported: false,
1691 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001692 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001693 target: {
1694 host: {
1695 enabled: false,
1696 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001697 linux_glibc_x86_64: {
1698 enabled: true,
1699 },
1700 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001701 enabled: true,
1702 },
1703 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001704}
1705`),
1706 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001707myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001708.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001709.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
1710.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
1711.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 +00001712.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001713.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
1714.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
1715.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 +00001716`),
1717 )
1718}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001719
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001720func TestSnapshotWithCcLibrary(t *testing.T) {
1721 result := testSdkWithCc(t, `
1722 module_exports {
1723 name: "myexports",
1724 native_libs: ["mynativelib"],
1725 }
1726
1727 cc_library {
1728 name: "mynativelib",
1729 srcs: [
1730 "Test.cpp",
1731 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001732 export_include_dirs: ["myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001733 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001734 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001735 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001736 }
1737 `)
1738
Paul Duffin36474d32021-03-12 12:19:43 +00001739 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001740 checkUnversionedAndroidBpContents(`
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001741// This is auto-generated. DO NOT EDIT.
1742
1743cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001744 name: "mynativelib",
1745 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001746 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001747 apex_available: ["//apex_available:platform"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001748 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001749 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001750 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001751 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001752 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001753 arch: {
1754 arm64: {
1755 static: {
1756 srcs: ["arm64/lib/mynativelib.a"],
1757 },
1758 shared: {
1759 srcs: ["arm64/lib/mynativelib.so"],
1760 },
1761 },
1762 arm: {
1763 static: {
1764 srcs: ["arm/lib/mynativelib.a"],
1765 },
1766 shared: {
1767 srcs: ["arm/lib/mynativelib.so"],
1768 },
1769 },
1770 },
1771}
Paul Duffin75b902a2021-02-22 12:13:13 +00001772`),
1773 // Make sure that the generated sdk_snapshot uses the native_libs property.
1774 checkVersionedAndroidBpContents(`
1775// This is auto-generated. DO NOT EDIT.
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001776
1777cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001778 name: "myexports_mynativelib@current",
1779 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001780 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001781 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +00001782 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001783 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001784 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001785 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001786 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001787 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001788 arch: {
1789 arm64: {
1790 static: {
1791 srcs: ["arm64/lib/mynativelib.a"],
1792 },
1793 shared: {
1794 srcs: ["arm64/lib/mynativelib.so"],
1795 },
1796 },
1797 arm: {
1798 static: {
1799 srcs: ["arm/lib/mynativelib.a"],
1800 },
1801 shared: {
1802 srcs: ["arm/lib/mynativelib.so"],
1803 },
1804 },
1805 },
1806}
1807
1808module_exports_snapshot {
1809 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001810 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001811 native_libs: ["myexports_mynativelib@current"],
1812}
1813`),
1814 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001815myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001816.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1817.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1818.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
Paul Duffin1822a0a2021-03-21 12:56:33 +00001819.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1820`),
1821 // TODO(b/183315522): Remove this and fix the issue.
1822 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\Qunrecognized property "arch.arm.shared.export_include_dirs"\E`)),
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001823 )
1824}
1825
Paul Duffin13ad94f2020-02-19 16:19:27 +00001826func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001827 result := testSdkWithCc(t, `
1828 module_exports {
1829 name: "myexports",
1830 device_supported: false,
1831 host_supported: true,
1832 target: {
1833 host: {
1834 compile_multilib: "64",
1835 },
1836 },
1837 native_static_libs: ["mynativelib"],
1838 }
1839
1840 cc_library_static {
1841 name: "mynativelib",
1842 device_supported: false,
1843 host_supported: true,
1844 srcs: [
1845 "Test.cpp",
1846 "aidl/foo/bar/Test.aidl",
1847 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001848 export_include_dirs: ["myinclude"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001849 aidl: {
1850 export_aidl_headers: true,
1851 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001852 stl: "none",
1853 }
1854 `)
1855
Paul Duffin36474d32021-03-12 12:19:43 +00001856 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001857 checkUnversionedAndroidBpContents(`
Paul Duffin13ad94f2020-02-19 16:19:27 +00001858// This is auto-generated. DO NOT EDIT.
1859
1860cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001861 name: "mynativelib",
1862 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001863 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001864 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001865 device_supported: false,
1866 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001867 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001868 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001869 export_include_dirs: [
1870 "include/myinclude",
1871 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1872 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001873 target: {
1874 host: {
1875 enabled: false,
1876 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001877 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001878 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001879 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001880 },
1881 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001882}
Paul Duffin75b902a2021-02-22 12:13:13 +00001883`),
1884 checkVersionedAndroidBpContents(`
1885// This is auto-generated. DO NOT EDIT.
Paul Duffin13ad94f2020-02-19 16:19:27 +00001886
1887cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001888 name: "myexports_mynativelib@current",
1889 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001890 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001891 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001892 device_supported: false,
1893 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001894 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001895 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001896 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001897 export_include_dirs: [
1898 "include/myinclude",
1899 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1900 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001901 target: {
1902 host: {
1903 enabled: false,
1904 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001905 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001906 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001907 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001908 },
1909 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001910}
1911
1912module_exports_snapshot {
1913 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001914 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001915 device_supported: false,
1916 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001917 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001918 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001919 target: {
1920 host: {
1921 enabled: false,
1922 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001923 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001924 enabled: true,
1925 },
1926 },
Paul Duffin75b902a2021-02-22 12:13:13 +00001927}
1928`),
Paul Duffin13ad94f2020-02-19 16:19:27 +00001929 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001930myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin7a7d0672021-02-17 12:17:40 +00001931.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
1932.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
1933.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 +00001934.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin13ad94f2020-02-19 16:19:27 +00001935`),
1936 )
1937}
Paul Duffin91756d22020-02-21 16:29:57 +00001938
1939func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1940 result := testSdkWithCc(t, `
1941 sdk {
1942 name: "mysdk",
1943 native_header_libs: ["mynativeheaders"],
1944 }
1945
1946 cc_library_headers {
1947 name: "mynativeheaders",
Paul Duffin86b02a72021-02-22 11:50:04 +00001948 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001949 stl: "none",
1950 }
1951 `)
1952
Paul Duffin36474d32021-03-12 12:19:43 +00001953 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001954 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001955// This is auto-generated. DO NOT EDIT.
1956
1957cc_prebuilt_library_headers {
Paul Duffin91756d22020-02-21 16:29:57 +00001958 name: "mynativeheaders",
1959 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001960 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001961 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00001962 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001963 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001964 export_include_dirs: ["include/myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001965}
Paul Duffin91756d22020-02-21 16:29:57 +00001966`),
1967 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001968myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00001969`),
1970 )
1971}
1972
1973func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001974 result := testSdkWithCc(t, `
1975 sdk {
1976 name: "mysdk",
1977 device_supported: false,
1978 host_supported: true,
1979 native_header_libs: ["mynativeheaders"],
1980 }
1981
1982 cc_library_headers {
1983 name: "mynativeheaders",
1984 device_supported: false,
1985 host_supported: true,
Paul Duffin86b02a72021-02-22 11:50:04 +00001986 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001987 stl: "none",
1988 }
1989 `)
1990
Paul Duffin36474d32021-03-12 12:19:43 +00001991 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001992 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001993// This is auto-generated. DO NOT EDIT.
1994
1995cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00001996 name: "mynativeheaders",
1997 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001998 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001999 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002000 device_supported: false,
2001 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002002 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002003 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002004 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002005 target: {
2006 host: {
2007 enabled: false,
2008 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002009 linux_glibc_x86_64: {
2010 enabled: true,
2011 },
2012 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002013 enabled: true,
2014 },
2015 },
Paul Duffin91756d22020-02-21 16:29:57 +00002016}
Paul Duffin75b902a2021-02-22 12:13:13 +00002017`),
2018 checkVersionedAndroidBpContents(`
2019// This is auto-generated. DO NOT EDIT.
Paul Duffin91756d22020-02-21 16:29:57 +00002020
2021cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002022 name: "mysdk_mynativeheaders@current",
2023 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002024 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002025 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002026 device_supported: false,
2027 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002028 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002029 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002030 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002031 target: {
2032 host: {
2033 enabled: false,
2034 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002035 linux_glibc_x86_64: {
2036 enabled: true,
2037 },
2038 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002039 enabled: true,
2040 },
2041 },
Paul Duffin91756d22020-02-21 16:29:57 +00002042}
2043
2044sdk_snapshot {
2045 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002046 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002047 device_supported: false,
2048 host_supported: true,
2049 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002050 target: {
2051 host: {
2052 enabled: false,
2053 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002054 linux_glibc_x86_64: {
2055 enabled: true,
2056 },
2057 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002058 enabled: true,
2059 },
2060 },
Paul Duffin91756d22020-02-21 16:29:57 +00002061}
2062`),
2063 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002064myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00002065`),
2066 )
2067}
Paul Duffina04c1072020-03-02 10:16:35 +00002068
2069func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00002070 result := testSdkWithCc(t, `
2071 sdk {
2072 name: "mysdk",
2073 host_supported: true,
2074 native_header_libs: ["mynativeheaders"],
2075 }
2076
2077 cc_library_headers {
2078 name: "mynativeheaders",
2079 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002080 stl: "none",
Paul Duffin86b02a72021-02-22 11:50:04 +00002081 export_system_include_dirs: ["myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002082 target: {
2083 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002084 export_include_dirs: ["myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002085 },
2086 host: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002087 export_include_dirs: ["myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002088 },
2089 },
2090 }
2091 `)
2092
Paul Duffin36474d32021-03-12 12:19:43 +00002093 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002094 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00002095// This is auto-generated. DO NOT EDIT.
2096
2097cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002098 name: "mynativeheaders",
2099 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002100 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002101 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002102 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002103 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002104 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002105 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002106 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002107 host: {
2108 enabled: false,
2109 },
Paul Duffina04c1072020-03-02 10:16:35 +00002110 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002111 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002112 },
2113 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002114 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002115 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002116 linux_glibc_x86_64: {
2117 enabled: true,
2118 },
2119 linux_glibc_x86: {
2120 enabled: true,
2121 },
Paul Duffina04c1072020-03-02 10:16:35 +00002122 },
Paul Duffina04c1072020-03-02 10:16:35 +00002123}
Paul Duffin75b902a2021-02-22 12:13:13 +00002124`),
Paul Duffin75b902a2021-02-22 12:13:13 +00002125 checkVersionedAndroidBpContents(`
2126// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00002127
2128cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002129 name: "mysdk_mynativeheaders@current",
2130 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002131 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002132 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002133 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002134 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002135 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002136 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002137 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002138 host: {
2139 enabled: false,
2140 },
Paul Duffina04c1072020-03-02 10:16:35 +00002141 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002142 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002143 },
2144 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002145 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002146 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002147 linux_glibc_x86_64: {
2148 enabled: true,
2149 },
2150 linux_glibc_x86: {
2151 enabled: true,
2152 },
Paul Duffina04c1072020-03-02 10:16:35 +00002153 },
Paul Duffina04c1072020-03-02 10:16:35 +00002154}
2155
2156sdk_snapshot {
2157 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002158 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002159 host_supported: true,
2160 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002161 target: {
2162 host: {
2163 enabled: false,
2164 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002165 linux_glibc_x86_64: {
2166 enabled: true,
2167 },
2168 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002169 enabled: true,
2170 },
2171 },
Paul Duffina04c1072020-03-02 10:16:35 +00002172}
2173`),
2174 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002175myinclude/Test.h -> common_os/include/myinclude/Test.h
2176myinclude-android/AndroidTest.h -> android/include/myinclude-android/AndroidTest.h
2177myinclude-host/HostTest.h -> linux_glibc/include/myinclude-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002178`),
2179 )
2180}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002181
2182func TestSystemSharedLibPropagation(t *testing.T) {
2183 result := testSdkWithCc(t, `
2184 sdk {
2185 name: "mysdk",
2186 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2187 }
2188
2189 cc_library {
2190 name: "sslnil",
2191 host_supported: true,
2192 }
2193
2194 cc_library {
2195 name: "sslempty",
2196 system_shared_libs: [],
2197 }
2198
2199 cc_library {
2200 name: "sslnonempty",
2201 system_shared_libs: ["sslnil"],
2202 }
2203 `)
2204
Paul Duffin36474d32021-03-12 12:19:43 +00002205 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002206 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002207// This is auto-generated. DO NOT EDIT.
2208
2209cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002210 name: "sslnil",
2211 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002212 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002213 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002214 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002215 arch: {
2216 arm64: {
2217 srcs: ["arm64/lib/sslnil.so"],
2218 },
2219 arm: {
2220 srcs: ["arm/lib/sslnil.so"],
2221 },
2222 },
2223}
2224
2225cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002226 name: "sslempty",
2227 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002228 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002229 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002230 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002231 system_shared_libs: [],
2232 arch: {
2233 arm64: {
2234 srcs: ["arm64/lib/sslempty.so"],
2235 },
2236 arm: {
2237 srcs: ["arm/lib/sslempty.so"],
2238 },
2239 },
2240}
2241
2242cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002243 name: "sslnonempty",
2244 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002245 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002246 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002247 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002248 system_shared_libs: ["sslnil"],
2249 arch: {
2250 arm64: {
2251 srcs: ["arm64/lib/sslnonempty.so"],
2252 },
2253 arm: {
2254 srcs: ["arm/lib/sslnonempty.so"],
2255 },
2256 },
2257}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002258`))
2259
2260 result = testSdkWithCc(t, `
2261 sdk {
2262 name: "mysdk",
2263 host_supported: true,
2264 native_shared_libs: ["sslvariants"],
2265 }
2266
2267 cc_library {
2268 name: "sslvariants",
2269 host_supported: true,
2270 target: {
2271 android: {
2272 system_shared_libs: [],
2273 },
2274 },
2275 }
2276 `)
2277
Paul Duffin36474d32021-03-12 12:19:43 +00002278 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002279 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002280// This is auto-generated. DO NOT EDIT.
2281
2282cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002283 name: "sslvariants",
2284 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002285 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002286 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002287 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002288 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002289 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002290 host: {
2291 enabled: false,
2292 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002293 android: {
2294 system_shared_libs: [],
2295 },
2296 android_arm64: {
2297 srcs: ["android/arm64/lib/sslvariants.so"],
2298 },
2299 android_arm: {
2300 srcs: ["android/arm/lib/sslvariants.so"],
2301 },
2302 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002303 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002304 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2305 },
2306 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002307 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002308 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2309 },
2310 },
2311}
Paul Duffin75b902a2021-02-22 12:13:13 +00002312`),
2313 checkVersionedAndroidBpContents(`
2314// This is auto-generated. DO NOT EDIT.
Martin Stjernholm10566a02020-03-24 01:19:52 +00002315
2316cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002317 name: "mysdk_sslvariants@current",
2318 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002319 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002320 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002321 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002322 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002323 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002324 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002325 host: {
2326 enabled: false,
2327 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002328 android: {
2329 system_shared_libs: [],
2330 },
2331 android_arm64: {
2332 srcs: ["android/arm64/lib/sslvariants.so"],
2333 },
2334 android_arm: {
2335 srcs: ["android/arm/lib/sslvariants.so"],
2336 },
2337 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002338 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002339 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2340 },
2341 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002342 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002343 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2344 },
2345 },
2346}
2347
2348sdk_snapshot {
2349 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002350 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002351 host_supported: true,
2352 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002353 target: {
2354 host: {
2355 enabled: false,
2356 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002357 linux_glibc_x86_64: {
2358 enabled: true,
2359 },
2360 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002361 enabled: true,
2362 },
2363 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002364}
2365`))
2366}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002367
2368func TestStubsLibrary(t *testing.T) {
2369 result := testSdkWithCc(t, `
2370 sdk {
2371 name: "mysdk",
2372 native_shared_libs: ["stubslib"],
2373 }
2374
2375 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002376 name: "internaldep",
2377 }
2378
2379 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002380 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002381 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002382 stubs: {
2383 symbol_file: "some/where/stubslib.map.txt",
2384 versions: ["1", "2", "3"],
2385 },
2386 }
2387 `)
2388
Paul Duffin36474d32021-03-12 12:19:43 +00002389 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002390 checkUnversionedAndroidBpContents(`
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002391// This is auto-generated. DO NOT EDIT.
2392
2393cc_prebuilt_library_shared {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002394 name: "stubslib",
2395 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002396 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002397 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002398 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002399 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002400 versions: [
2401 "1",
2402 "2",
2403 "3",
2404 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002405 },
2406 arch: {
2407 arm64: {
2408 srcs: ["arm64/lib/stubslib.so"],
2409 },
2410 arm: {
2411 srcs: ["arm/lib/stubslib.so"],
2412 },
2413 },
2414}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002415`))
2416}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002417
2418func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002419 result := testSdkWithCc(t, `
2420 sdk {
2421 name: "mysdk",
2422 host_supported: true,
2423 native_shared_libs: ["stubslib"],
2424 }
2425
2426 cc_library {
2427 name: "internaldep",
2428 host_supported: true,
2429 }
2430
2431 cc_library {
2432 name: "stubslib",
2433 host_supported: true,
2434 shared_libs: ["internaldep"],
2435 stubs: {
2436 symbol_file: "some/where/stubslib.map.txt",
2437 versions: ["1", "2", "3"],
2438 },
2439 }
2440 `)
2441
Paul Duffin36474d32021-03-12 12:19:43 +00002442 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002443 checkUnversionedAndroidBpContents(`
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002444// This is auto-generated. DO NOT EDIT.
2445
2446cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002447 name: "stubslib",
2448 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002449 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002450 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002451 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002452 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002453 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002454 versions: [
2455 "1",
2456 "2",
2457 "3",
2458 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002459 },
2460 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002461 host: {
2462 enabled: false,
2463 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002464 android_arm64: {
2465 srcs: ["android/arm64/lib/stubslib.so"],
2466 },
2467 android_arm: {
2468 srcs: ["android/arm/lib/stubslib.so"],
2469 },
2470 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002471 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002472 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2473 },
2474 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002475 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002476 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2477 },
2478 },
2479}
Paul Duffin75b902a2021-02-22 12:13:13 +00002480`),
2481 checkVersionedAndroidBpContents(`
2482// This is auto-generated. DO NOT EDIT.
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002483
2484cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002485 name: "mysdk_stubslib@current",
2486 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002487 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002488 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002489 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002490 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002491 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002492 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002493 versions: [
2494 "1",
2495 "2",
2496 "3",
2497 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002498 },
2499 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002500 host: {
2501 enabled: false,
2502 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002503 android_arm64: {
2504 srcs: ["android/arm64/lib/stubslib.so"],
2505 },
2506 android_arm: {
2507 srcs: ["android/arm/lib/stubslib.so"],
2508 },
2509 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002510 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002511 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2512 },
2513 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002514 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002515 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2516 },
2517 },
2518}
2519
2520sdk_snapshot {
2521 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002522 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002523 host_supported: true,
2524 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002525 target: {
2526 host: {
2527 enabled: false,
2528 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002529 linux_glibc_x86_64: {
2530 enabled: true,
2531 },
2532 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002533 enabled: true,
2534 },
2535 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002536}
2537`))
2538}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002539
2540func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002541 result := testSdkWithCc(t, `
2542 sdk {
2543 name: "mysdk",
2544 host_supported: true,
2545 native_shared_libs: ["mylib"],
2546 }
2547
2548 cc_library {
2549 name: "mylib",
2550 host_supported: true,
2551 unique_host_soname: true,
2552 }
2553 `)
2554
Paul Duffin36474d32021-03-12 12:19:43 +00002555 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002556 checkUnversionedAndroidBpContents(`
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002557// This is auto-generated. DO NOT EDIT.
2558
2559cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002560 name: "mylib",
2561 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002562 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002563 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002564 host_supported: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002565 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002566 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002567 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002568 host: {
2569 enabled: false,
2570 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002571 android_arm64: {
2572 srcs: ["android/arm64/lib/mylib.so"],
2573 },
2574 android_arm: {
2575 srcs: ["android/arm/lib/mylib.so"],
2576 },
2577 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002578 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002579 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2580 },
2581 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002582 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002583 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2584 },
2585 },
2586}
Paul Duffin75b902a2021-02-22 12:13:13 +00002587`),
2588 checkVersionedAndroidBpContents(`
2589// This is auto-generated. DO NOT EDIT.
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002590
2591cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002592 name: "mysdk_mylib@current",
2593 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002594 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002595 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002596 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002597 installable: false,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002598 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002599 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002600 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002601 host: {
2602 enabled: false,
2603 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002604 android_arm64: {
2605 srcs: ["android/arm64/lib/mylib.so"],
2606 },
2607 android_arm: {
2608 srcs: ["android/arm/lib/mylib.so"],
2609 },
2610 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002611 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002612 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2613 },
2614 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002615 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002616 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2617 },
2618 },
2619}
2620
2621sdk_snapshot {
2622 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002623 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002624 host_supported: true,
2625 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002626 target: {
2627 host: {
2628 enabled: false,
2629 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002630 linux_glibc_x86_64: {
2631 enabled: true,
2632 },
2633 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002634 enabled: true,
2635 },
2636 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002637}
2638`),
2639 checkAllCopyRules(`
2640.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2641.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2642.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2643.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2644`),
2645 )
2646}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002647
2648func TestNoSanitizerMembers(t *testing.T) {
2649 result := testSdkWithCc(t, `
2650 sdk {
2651 name: "mysdk",
2652 native_shared_libs: ["mynativelib"],
2653 }
2654
2655 cc_library_shared {
2656 name: "mynativelib",
2657 srcs: ["Test.cpp"],
Paul Duffin86b02a72021-02-22 11:50:04 +00002658 export_include_dirs: ["myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002659 arch: {
2660 arm64: {
2661 export_system_include_dirs: ["arm64/include"],
2662 sanitize: {
2663 hwaddress: true,
2664 },
2665 },
2666 },
2667 }
2668 `)
2669
Paul Duffin1822a0a2021-03-21 12:56:33 +00002670 // Mixing the snapshot with the source (irrespective of which one is preferred) causes a problem
2671 // due to missing variants.
2672 // TODO(b/183204176): Remove this and fix the cause.
2673 snapshotWithSourceErrorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QReplaceDependencies could not find identical variant {os:android,image:,arch:arm64_armv8-a,sdk:,link:shared,version:} for module mynativelib\E`)
2674
Paul Duffin36474d32021-03-12 12:19:43 +00002675 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002676 checkUnversionedAndroidBpContents(`
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002677// This is auto-generated. DO NOT EDIT.
2678
2679cc_prebuilt_library_shared {
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002680 name: "mynativelib",
2681 prefer: false,
2682 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002683 apex_available: ["//apex_available:platform"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002684 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002685 export_include_dirs: ["include/myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002686 arch: {
2687 arm64: {
2688 export_system_include_dirs: ["arm64/include/arm64/include"],
2689 },
2690 arm: {
2691 srcs: ["arm/lib/mynativelib.so"],
2692 },
2693 },
2694}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002695`),
2696 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002697myinclude/Test.h -> include/myinclude/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002698arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Paul Duffin1822a0a2021-03-21 12:56:33 +00002699.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
2700`),
2701 snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, snapshotWithSourceErrorHandler),
2702 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, snapshotWithSourceErrorHandler),
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002703 )
2704}