blob: 31555c02eb8e333471c4a6bcf75db88ddd644841 [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,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100160 compile_multilib: "64",
Paul Duffin7b0259f2021-04-24 11:34:46 +0100161 native_shared_libs: ["mysdk_sdkmember@current"],
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",
Paul Duffin525a5902021-05-06 16:33:52 +0100194 native_shared_libs: ["sdkmember_mysdk@1"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000195 }
196
197 sdk_snapshot {
198 name: "mysdk@2",
Paul Duffin525a5902021-05-06 16:33:52 +0100199 native_shared_libs: ["sdkmember_mysdk@2"],
Paul Duffina80fdec2019-12-03 15:25:00 +0000200 }
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 {
Paul Duffin525a5902021-05-06 16:33:52 +0100211 name: "sdkmember_mysdk@1",
Paul Duffina80fdec2019-12-03 15:25:00 +0000212 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 {
Paul Duffin525a5902021-05-06 16:33:52 +0100224 name: "sdkmember_mysdk@2",
Paul Duffina80fdec2019-12-03 15:25:00 +0000225 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
Paul Duffin525a5902021-05-06 16:33:52 +0100275 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 Duffindb462dd2021-03-21 22:01:55 +0000489 // TODO(b/183322862): Remove this and fix the issue.
490 errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module source path "snapshot/include_gen/generated_foo/gen/protos" does not exist`)
491
Paul Duffin36474d32021-03-12 12:19:43 +0000492 CheckSnapshot(t, result, "mysdk", "",
Paul Duffina43f9272021-02-17 10:55:25 +0000493 checkUnversionedAndroidBpContents(`
494// This is auto-generated. DO NOT EDIT.
495
496cc_prebuilt_library_shared {
497 name: "mynativelib",
498 prefer: false,
499 visibility: ["//visibility:public"],
500 apex_available: ["//apex_available:platform"],
501 stl: "none",
502 compile_multilib: "both",
Paul Duffin7a7d0672021-02-17 12:17:40 +0000503 export_include_dirs: [
504 "include/myinclude",
505 "include_gen/generated_foo/gen",
506 "include_gen/generated_foo/gen/protos",
507 ],
Paul Duffina43f9272021-02-17 10:55:25 +0000508 arch: {
509 arm64: {
510 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffina43f9272021-02-17 10:55:25 +0000511 },
512 arm: {
513 srcs: ["arm/lib/mynativelib.so"],
Paul Duffina43f9272021-02-17 10:55:25 +0000514 },
515 },
516}
517`),
518 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000519myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin7a7d0672021-02-17 12:17:40 +0000520.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 +0000521.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina43f9272021-02-17 10:55:25 +0000522.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
Paul Duffina43f9272021-02-17 10:55:25 +0000523`),
Paul Duffindb462dd2021-03-21 22:01:55 +0000524 snapshotTestErrorHandler(checkSnapshotWithoutSource, errorHandler),
525 snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, errorHandler),
526 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, errorHandler),
Paul Duffina43f9272021-02-17 10:55:25 +0000527 )
528}
529
Martin Stjernholmb0249572020-09-15 02:32:35 +0100530// Verify that when the shared library has some common and some arch specific
531// properties that the generated snapshot is optimized properly. Substruct
532// handling is tested with the sanitize clauses (but note there's a lot of
533// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000534func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
535 result := testSdkWithCc(t, `
536 sdk {
537 name: "mysdk",
538 native_shared_libs: ["mynativelib"],
539 }
540
541 cc_library_shared {
542 name: "mynativelib",
543 srcs: [
544 "Test.cpp",
545 "aidl/foo/bar/Test.aidl",
546 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000547 export_include_dirs: ["myinclude"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100548 sanitize: {
549 fuzzer: false,
550 integer_overflow: true,
551 diag: { undefined: false },
552 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000553 arch: {
554 arm64: {
555 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100556 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100557 integer_overflow: false,
558 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000559 },
560 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000561 stl: "none",
562 }
563 `)
564
Paul Duffin36474d32021-03-12 12:19:43 +0000565 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000566 checkUnversionedAndroidBpContents(`
Paul Duffina7cd8c82019-12-11 20:00:57 +0000567// This is auto-generated. DO NOT EDIT.
568
569cc_prebuilt_library_shared {
Paul Duffina7cd8c82019-12-11 20:00:57 +0000570 name: "mynativelib",
571 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100572 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000573 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000574 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100575 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +0000576 export_include_dirs: ["include/myinclude"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100577 sanitize: {
578 fuzzer: false,
579 diag: {
580 undefined: false,
581 },
582 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000583 arch: {
584 arm64: {
585 srcs: ["arm64/lib/mynativelib.so"],
586 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100587 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100588 integer_overflow: false,
589 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000590 },
591 arm: {
592 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100593 sanitize: {
594 integer_overflow: true,
595 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000596 },
597 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000598}
Paul Duffina7cd8c82019-12-11 20:00:57 +0000599`),
600 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000601myinclude/Test.h -> include/myinclude/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +0000602.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000603arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800604.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000605 )
606}
607
Paul Duffin25ce04b2020-01-16 11:47:25 +0000608func TestSnapshotWithCcBinary(t *testing.T) {
609 result := testSdkWithCc(t, `
610 module_exports {
611 name: "mymodule_exports",
612 native_binaries: ["mynativebinary"],
613 }
614
615 cc_binary {
616 name: "mynativebinary",
617 srcs: [
618 "Test.cpp",
619 ],
620 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000621 }
622 `)
623
Paul Duffin36474d32021-03-12 12:19:43 +0000624 CheckSnapshot(t, result, "mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000625 checkUnversionedAndroidBpContents(`
Paul Duffin25ce04b2020-01-16 11:47:25 +0000626// This is auto-generated. DO NOT EDIT.
627
628cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000629 name: "mynativebinary",
630 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100631 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000632 apex_available: ["//apex_available:platform"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000633 compile_multilib: "both",
634 arch: {
635 arm64: {
636 srcs: ["arm64/bin/mynativebinary"],
637 },
638 arm: {
639 srcs: ["arm/bin/mynativebinary"],
640 },
641 },
642}
Paul Duffin75b902a2021-02-22 12:13:13 +0000643`),
644 // Make sure that the generated sdk_snapshot uses the native_binaries property.
645 checkVersionedAndroidBpContents(`
646// This is auto-generated. DO NOT EDIT.
Paul Duffin25ce04b2020-01-16 11:47:25 +0000647
648cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000649 name: "mymodule_exports_mynativebinary@current",
650 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100651 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000652 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +0000653 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000654 compile_multilib: "both",
655 arch: {
656 arm64: {
657 srcs: ["arm64/bin/mynativebinary"],
658 },
659 arm: {
660 srcs: ["arm/bin/mynativebinary"],
661 },
662 },
663}
664
665module_exports_snapshot {
666 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100667 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000668 native_binaries: ["mymodule_exports_mynativebinary@current"],
669}
670`),
671 checkAllCopyRules(`
672.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
673.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
674`),
675 )
676}
677
Paul Duffina04c1072020-03-02 10:16:35 +0000678func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000679 result := testSdkWithCc(t, `
680 module_exports {
681 name: "myexports",
682 device_supported: false,
683 host_supported: true,
684 native_binaries: ["mynativebinary"],
685 target: {
686 windows: {
687 enabled: true,
688 },
689 },
690 }
691
692 cc_binary {
693 name: "mynativebinary",
694 device_supported: false,
695 host_supported: true,
696 srcs: [
697 "Test.cpp",
698 ],
699 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000700 stl: "none",
701 target: {
702 windows: {
703 enabled: true,
704 },
705 },
706 }
707 `)
708
Paul Duffin36474d32021-03-12 12:19:43 +0000709 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000710 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +0000711// This is auto-generated. DO NOT EDIT.
712
713cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000714 name: "mynativebinary",
715 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100716 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000717 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000718 device_supported: false,
719 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100720 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000721 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100722 host: {
723 enabled: false,
724 },
Paul Duffina04c1072020-03-02 10:16:35 +0000725 linux_glibc: {
726 compile_multilib: "both",
727 },
728 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900729 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000730 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
731 },
732 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900733 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000734 srcs: ["linux_glibc/x86/bin/mynativebinary"],
735 },
736 windows: {
737 compile_multilib: "64",
738 },
739 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900740 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000741 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
742 },
743 },
744}
Paul Duffin75b902a2021-02-22 12:13:13 +0000745`),
746 checkVersionedAndroidBpContents(`
747// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +0000748
749cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000750 name: "myexports_mynativebinary@current",
751 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100752 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000753 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000754 device_supported: false,
755 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +0000756 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100757 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000758 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100759 host: {
760 enabled: false,
761 },
Paul Duffina04c1072020-03-02 10:16:35 +0000762 linux_glibc: {
763 compile_multilib: "both",
764 },
765 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900766 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000767 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
768 },
769 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900770 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000771 srcs: ["linux_glibc/x86/bin/mynativebinary"],
772 },
773 windows: {
774 compile_multilib: "64",
775 },
776 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900777 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000778 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
779 },
780 },
781}
782
783module_exports_snapshot {
784 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100785 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000786 device_supported: false,
787 host_supported: true,
788 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000789 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900790 windows: {
791 compile_multilib: "64",
792 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100793 host: {
794 enabled: false,
795 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900796 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100797 enabled: true,
798 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900799 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100800 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +0900801 },
802 windows_x86_64: {
803 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000804 },
805 },
Paul Duffina04c1072020-03-02 10:16:35 +0000806}
807`),
808 checkAllCopyRules(`
809.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
810.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
811.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
812`),
813 )
814}
815
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100816func TestSnapshotWithSingleHostOsType(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000817 result := android.GroupFixturePreparers(
818 prepareForSdkTest,
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000819 ccTestFs.AddToFixture(),
820 cc.PrepareForTestOnLinuxBionic,
821 android.FixtureModifyConfig(func(config android.Config) {
822 config.Targets[android.LinuxBionic] = []android.Target{
823 {android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", false},
824 }
825 }),
826 ).RunTestWithBp(t, `
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100827 cc_defaults {
828 name: "mydefaults",
829 device_supported: false,
830 host_supported: true,
831 compile_multilib: "64",
832 target: {
833 host: {
834 enabled: false,
835 },
836 linux_bionic: {
837 enabled: true,
838 },
839 },
840 }
841
842 module_exports {
843 name: "myexports",
844 defaults: ["mydefaults"],
845 native_shared_libs: ["mynativelib"],
846 native_binaries: ["mynativebinary"],
847 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
848 }
849
850 cc_library {
851 name: "mynativelib",
852 defaults: ["mydefaults"],
853 srcs: [
854 "Test.cpp",
855 ],
856 stl: "none",
857 }
858
859 cc_binary {
860 name: "mynativebinary",
861 defaults: ["mydefaults"],
862 srcs: [
863 "Test.cpp",
864 ],
865 stl: "none",
866 }
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000867 `)
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100868
Paul Duffin36474d32021-03-12 12:19:43 +0000869 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000870 checkUnversionedAndroidBpContents(`
871// This is auto-generated. DO NOT EDIT.
872
873cc_prebuilt_binary {
874 name: "mynativebinary",
875 prefer: false,
876 visibility: ["//visibility:public"],
877 apex_available: ["//apex_available:platform"],
878 device_supported: false,
879 host_supported: true,
880 stl: "none",
881 compile_multilib: "64",
882 target: {
883 host: {
884 enabled: false,
885 },
886 linux_bionic_x86_64: {
887 enabled: true,
888 srcs: ["x86_64/bin/mynativebinary"],
889 },
890 },
891}
892
893cc_prebuilt_library_shared {
894 name: "mynativelib",
895 prefer: false,
896 visibility: ["//visibility:public"],
897 apex_available: ["//apex_available:platform"],
898 device_supported: false,
899 host_supported: true,
900 stl: "none",
901 compile_multilib: "64",
902 target: {
903 host: {
904 enabled: false,
905 },
906 linux_bionic_x86_64: {
907 enabled: true,
908 srcs: ["x86_64/lib/mynativelib.so"],
909 },
910 },
911}
912`),
913 checkVersionedAndroidBpContents(`
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100914// This is auto-generated. DO NOT EDIT.
915
916cc_prebuilt_binary {
917 name: "myexports_mynativebinary@current",
918 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100919 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000920 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100921 device_supported: false,
922 host_supported: true,
923 installable: false,
924 stl: "none",
925 compile_multilib: "64",
926 target: {
927 host: {
928 enabled: false,
929 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100930 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900931 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100932 srcs: ["x86_64/bin/mynativebinary"],
933 },
934 },
935}
936
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100937cc_prebuilt_library_shared {
938 name: "myexports_mynativelib@current",
939 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100940 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000941 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100942 device_supported: false,
943 host_supported: true,
944 installable: false,
945 stl: "none",
946 compile_multilib: "64",
947 target: {
948 host: {
949 enabled: false,
950 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100951 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900952 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100953 srcs: ["x86_64/lib/mynativelib.so"],
954 },
955 },
956}
957
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100958module_exports_snapshot {
959 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100960 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100961 device_supported: false,
962 host_supported: true,
Paul Duffin7b0259f2021-04-24 11:34:46 +0100963 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100964 native_binaries: ["myexports_mynativebinary@current"],
965 native_shared_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100966 target: {
967 host: {
968 enabled: false,
969 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900970 linux_bionic_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100971 enabled: true,
972 },
973 },
974}
975`),
976 checkAllCopyRules(`
977.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
978.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
979`),
980 )
981}
982
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100983// Test that we support the necessary flags for the linker binary, which is
984// special in several ways.
985func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100986 result := testSdkWithCc(t, `
987 module_exports {
988 name: "mymodule_exports",
989 host_supported: true,
990 device_supported: false,
991 native_binaries: ["linker"],
992 }
993
994 cc_binary {
995 name: "linker",
996 host_supported: true,
997 static_executable: true,
998 nocrt: true,
999 stl: "none",
1000 srcs: [
1001 "Test.cpp",
1002 ],
1003 compile_multilib: "both",
1004 }
1005 `)
1006
Paul Duffin36474d32021-03-12 12:19:43 +00001007 CheckSnapshot(t, result, "mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001008 checkUnversionedAndroidBpContents(`
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001009// This is auto-generated. DO NOT EDIT.
1010
1011cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +00001012 name: "linker",
1013 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001014 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001015 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001016 device_supported: false,
1017 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001018 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001019 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001020 static_executable: true,
1021 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001022 target: {
1023 host: {
1024 enabled: false,
1025 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001026 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001027 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001028 srcs: ["x86_64/bin/linker"],
1029 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001030 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001031 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001032 srcs: ["x86/bin/linker"],
1033 },
1034 },
1035}
Paul Duffin75b902a2021-02-22 12:13:13 +00001036`),
1037 checkVersionedAndroidBpContents(`
1038// This is auto-generated. DO NOT EDIT.
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001039
1040cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +00001041 name: "mymodule_exports_linker@current",
1042 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +01001043 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001044 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001045 device_supported: false,
1046 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001047 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001048 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001049 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001050 static_executable: true,
1051 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001052 target: {
1053 host: {
1054 enabled: false,
1055 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001056 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001057 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001058 srcs: ["x86_64/bin/linker"],
1059 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001060 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001061 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001062 srcs: ["x86/bin/linker"],
1063 },
1064 },
1065}
1066
1067module_exports_snapshot {
1068 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001069 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001070 device_supported: false,
1071 host_supported: true,
1072 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001073 target: {
1074 host: {
1075 enabled: false,
1076 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001077 linux_glibc_x86_64: {
1078 enabled: true,
1079 },
1080 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001081 enabled: true,
1082 },
1083 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001084}
1085`),
1086 checkAllCopyRules(`
1087.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1088.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1089`),
1090 )
1091}
1092
Paul Duffin9ab556f2019-12-11 18:42:17 +00001093func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001094 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001095 sdk {
1096 name: "mysdk",
1097 native_shared_libs: ["mynativelib"],
1098 }
1099
1100 cc_library_shared {
1101 name: "mynativelib",
1102 srcs: [
1103 "Test.cpp",
1104 "aidl/foo/bar/Test.aidl",
1105 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001106 apex_available: ["apex1", "apex2"],
Paul Duffin86b02a72021-02-22 11:50:04 +00001107 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001108 aidl: {
1109 export_aidl_headers: true,
1110 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001111 stl: "none",
1112 }
1113 `)
1114
Paul Duffin36474d32021-03-12 12:19:43 +00001115 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001116 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001117// This is auto-generated. DO NOT EDIT.
1118
1119cc_prebuilt_library_shared {
Paul Duffina80fdec2019-12-03 15:25:00 +00001120 name: "mynativelib",
1121 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001122 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001123 apex_available: [
1124 "apex1",
1125 "apex2",
1126 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001127 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001128 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001129 export_include_dirs: ["include/myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001130 arch: {
1131 arm64: {
1132 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001133 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001134 },
1135 arm: {
1136 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001137 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001138 },
1139 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001140}
Paul Duffina80fdec2019-12-03 15:25:00 +00001141`),
1142 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001143myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001144.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001145.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
1146.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
1147.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 -08001148.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001149.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
1150.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
1151.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 +00001152`),
1153 )
1154}
1155
Paul Duffin13f02712020-03-06 12:30:43 +00001156func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1157 result := testSdkWithCc(t, `
1158 sdk {
1159 name: "mysdk",
1160 native_shared_libs: [
1161 "mynativelib",
1162 "myothernativelib",
1163 "mysystemnativelib",
1164 ],
1165 }
1166
1167 cc_library {
1168 name: "mysystemnativelib",
1169 srcs: [
1170 "Test.cpp",
1171 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001172 stl: "none",
1173 }
1174
1175 cc_library_shared {
1176 name: "myothernativelib",
1177 srcs: [
1178 "Test.cpp",
1179 ],
1180 system_shared_libs: [
1181 // A reference to a library that is not an sdk member. Uses libm as that
1182 // is in the default set of modules available to this test and so is available
1183 // both here and also when the generated Android.bp file is tested in
1184 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1185 // handles references to modules that are not sdk members.
1186 "libm",
1187 ],
1188 stl: "none",
1189 }
1190
1191 cc_library {
1192 name: "mynativelib",
1193 srcs: [
1194 "Test.cpp",
1195 ],
1196 shared_libs: [
1197 // A reference to another sdk member.
1198 "myothernativelib",
1199 ],
1200 target: {
1201 android: {
1202 shared: {
1203 shared_libs: [
1204 // A reference to a library that is not an sdk member. The libc library
1205 // is used here to check that the shared_libs property is handled correctly
1206 // in a similar way to how libm is used to check system_shared_libs above.
1207 "libc",
1208 ],
1209 },
1210 },
1211 },
Paul Duffin13f02712020-03-06 12:30:43 +00001212 stl: "none",
1213 }
1214 `)
1215
Paul Duffin36474d32021-03-12 12:19:43 +00001216 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001217 checkUnversionedAndroidBpContents(`
Paul Duffin13f02712020-03-06 12:30:43 +00001218// This is auto-generated. DO NOT EDIT.
1219
1220cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001221 name: "mynativelib",
1222 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001223 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001224 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001225 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001226 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001227 shared_libs: [
1228 "myothernativelib",
1229 "libc",
1230 ],
1231 arch: {
1232 arm64: {
1233 srcs: ["arm64/lib/mynativelib.so"],
1234 },
1235 arm: {
1236 srcs: ["arm/lib/mynativelib.so"],
1237 },
1238 },
Paul Duffin13f02712020-03-06 12:30:43 +00001239}
1240
1241cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001242 name: "myothernativelib",
1243 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001244 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001245 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001246 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001247 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001248 system_shared_libs: ["libm"],
1249 arch: {
1250 arm64: {
1251 srcs: ["arm64/lib/myothernativelib.so"],
1252 },
1253 arm: {
1254 srcs: ["arm/lib/myothernativelib.so"],
1255 },
1256 },
Paul Duffin13f02712020-03-06 12:30:43 +00001257}
1258
1259cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001260 name: "mysystemnativelib",
1261 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001262 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001263 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001264 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001265 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001266 arch: {
1267 arm64: {
1268 srcs: ["arm64/lib/mysystemnativelib.so"],
1269 },
1270 arm: {
1271 srcs: ["arm/lib/mysystemnativelib.so"],
1272 },
1273 },
Paul Duffin13f02712020-03-06 12:30:43 +00001274}
Paul Duffin13f02712020-03-06 12:30:43 +00001275`),
1276 checkAllCopyRules(`
1277.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1278.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1279.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1280.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1281.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1282.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1283`),
1284 )
1285}
1286
Paul Duffin9ab556f2019-12-11 18:42:17 +00001287func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001288 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001289 sdk {
1290 name: "mysdk",
1291 device_supported: false,
1292 host_supported: true,
1293 native_shared_libs: ["mynativelib"],
1294 }
1295
1296 cc_library_shared {
1297 name: "mynativelib",
1298 device_supported: false,
1299 host_supported: true,
1300 srcs: [
1301 "Test.cpp",
1302 "aidl/foo/bar/Test.aidl",
1303 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001304 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001305 aidl: {
1306 export_aidl_headers: true,
1307 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001308 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001309 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001310 }
1311 `)
1312
Paul Duffin36474d32021-03-12 12:19:43 +00001313 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001314 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001315// This is auto-generated. DO NOT EDIT.
1316
1317cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001318 name: "mynativelib",
1319 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001320 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001321 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001322 device_supported: false,
1323 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001324 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001325 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001326 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001327 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001328 target: {
1329 host: {
1330 enabled: false,
1331 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001332 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001333 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001334 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001335 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001336 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001337 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001338 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001339 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001340 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001341 },
1342 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001343}
Paul Duffin75b902a2021-02-22 12:13:13 +00001344`),
1345 checkVersionedAndroidBpContents(`
1346// This is auto-generated. DO NOT EDIT.
Paul Duffina80fdec2019-12-03 15:25:00 +00001347
1348cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001349 name: "mysdk_mynativelib@current",
1350 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001351 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001352 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001353 device_supported: false,
1354 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001355 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001356 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001357 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001358 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001359 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001360 target: {
1361 host: {
1362 enabled: false,
1363 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001364 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001365 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001366 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001367 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001368 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001369 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001370 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001371 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001372 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001373 },
1374 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001375}
1376
1377sdk_snapshot {
1378 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001379 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001380 device_supported: false,
1381 host_supported: true,
1382 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001383 target: {
1384 host: {
1385 enabled: false,
1386 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001387 linux_glibc_x86_64: {
1388 enabled: true,
1389 },
1390 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001391 enabled: true,
1392 },
1393 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001394}
1395`),
1396 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001397myinclude/Test.h -> include/myinclude/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001398.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001399.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
1400.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
1401.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 +00001402.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001403.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
1404.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
1405.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 +00001406`),
1407 )
1408}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001409
Paul Duffina04c1072020-03-02 10:16:35 +00001410func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001411 result := testSdkWithCc(t, `
1412 sdk {
1413 name: "mysdk",
1414 device_supported: false,
1415 host_supported: true,
1416 native_shared_libs: ["mynativelib"],
1417 target: {
1418 windows: {
1419 enabled: true,
1420 },
1421 },
1422 }
1423
1424 cc_library_shared {
1425 name: "mynativelib",
1426 device_supported: false,
1427 host_supported: true,
1428 srcs: [
1429 "Test.cpp",
1430 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001431 stl: "none",
1432 target: {
1433 windows: {
1434 enabled: true,
1435 },
1436 },
1437 }
1438 `)
1439
Paul Duffin36474d32021-03-12 12:19:43 +00001440 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001441 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00001442// This is auto-generated. DO NOT EDIT.
1443
1444cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001445 name: "mynativelib",
1446 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001447 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001448 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001449 device_supported: false,
1450 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001451 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001452 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001453 host: {
1454 enabled: false,
1455 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001456 linux_glibc: {
1457 compile_multilib: "both",
1458 },
Paul Duffina04c1072020-03-02 10:16:35 +00001459 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001460 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001461 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1462 },
1463 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001464 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001465 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1466 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001467 windows: {
1468 compile_multilib: "64",
1469 },
Paul Duffina04c1072020-03-02 10:16:35 +00001470 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001471 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001472 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1473 },
1474 },
Paul Duffina04c1072020-03-02 10:16:35 +00001475}
Paul Duffin75b902a2021-02-22 12:13:13 +00001476`),
1477 checkVersionedAndroidBpContents(`
1478// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00001479
1480cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001481 name: "mysdk_mynativelib@current",
1482 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001483 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001484 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001485 device_supported: false,
1486 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001487 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001488 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001489 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001490 host: {
1491 enabled: false,
1492 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001493 linux_glibc: {
1494 compile_multilib: "both",
1495 },
Paul Duffina04c1072020-03-02 10:16:35 +00001496 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001497 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001498 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1499 },
1500 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001501 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001502 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1503 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001504 windows: {
1505 compile_multilib: "64",
1506 },
Paul Duffina04c1072020-03-02 10:16:35 +00001507 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001508 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001509 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1510 },
1511 },
Paul Duffina04c1072020-03-02 10:16:35 +00001512}
1513
1514sdk_snapshot {
1515 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001516 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001517 device_supported: false,
1518 host_supported: true,
1519 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001520 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001521 windows: {
1522 compile_multilib: "64",
1523 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001524 host: {
1525 enabled: false,
1526 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001527 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001528 enabled: true,
1529 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001530 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001531 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +09001532 },
1533 windows_x86_64: {
1534 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001535 },
1536 },
Paul Duffina04c1072020-03-02 10:16:35 +00001537}
1538`),
1539 checkAllCopyRules(`
1540.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1541.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1542.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1543`),
1544 )
1545}
1546
Paul Duffin9ab556f2019-12-11 18:42:17 +00001547func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1548 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001549 module_exports {
1550 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001551 native_static_libs: ["mynativelib"],
1552 }
1553
1554 cc_library_static {
1555 name: "mynativelib",
1556 srcs: [
1557 "Test.cpp",
1558 "aidl/foo/bar/Test.aidl",
1559 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001560 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001561 aidl: {
1562 export_aidl_headers: true,
1563 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001564 stl: "none",
1565 }
1566 `)
1567
Paul Duffin36474d32021-03-12 12:19:43 +00001568 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001569 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001570// This is auto-generated. DO NOT EDIT.
1571
1572cc_prebuilt_library_static {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001573 name: "mynativelib",
1574 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001575 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001576 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001577 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001578 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001579 export_include_dirs: ["include/myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001580 arch: {
1581 arm64: {
1582 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001583 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001584 },
1585 arm: {
1586 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001587 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001588 },
1589 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001590}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001591`),
1592 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001593myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001594.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001595.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
1596.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
1597.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 -08001598.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001599.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
1600.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
1601.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 +00001602`),
1603 )
1604}
1605
1606func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001607 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001608 module_exports {
1609 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001610 device_supported: false,
1611 host_supported: true,
1612 native_static_libs: ["mynativelib"],
1613 }
1614
1615 cc_library_static {
1616 name: "mynativelib",
1617 device_supported: false,
1618 host_supported: true,
1619 srcs: [
1620 "Test.cpp",
1621 "aidl/foo/bar/Test.aidl",
1622 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001623 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001624 aidl: {
1625 export_aidl_headers: true,
1626 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001627 stl: "none",
1628 }
1629 `)
1630
Paul Duffin36474d32021-03-12 12:19:43 +00001631 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001632 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001633// This is auto-generated. DO NOT EDIT.
1634
1635cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001636 name: "mynativelib",
1637 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001638 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001639 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001640 device_supported: false,
1641 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001642 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001643 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001644 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001645 target: {
1646 host: {
1647 enabled: false,
1648 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001649 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001650 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001651 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001652 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001653 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001654 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001655 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001656 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001657 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001658 },
1659 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001660}
Paul Duffin75b902a2021-02-22 12:13:13 +00001661`),
1662 checkVersionedAndroidBpContents(`
1663// This is auto-generated. DO NOT EDIT.
Paul Duffin9ab556f2019-12-11 18:42:17 +00001664
1665cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001666 name: "myexports_mynativelib@current",
1667 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001668 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001669 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001670 device_supported: false,
1671 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001672 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001673 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001674 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001675 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001676 target: {
1677 host: {
1678 enabled: false,
1679 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001680 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001681 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001682 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001683 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001684 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001685 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001686 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001687 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001688 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001689 },
1690 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001691}
1692
Paul Duffine6029182019-12-16 17:43:48 +00001693module_exports_snapshot {
1694 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001695 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001696 device_supported: false,
1697 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001698 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001699 target: {
1700 host: {
1701 enabled: false,
1702 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001703 linux_glibc_x86_64: {
1704 enabled: true,
1705 },
1706 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001707 enabled: true,
1708 },
1709 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001710}
1711`),
1712 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001713myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001714.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001715.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
1716.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
1717.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 +00001718.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001719.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
1720.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
1721.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 +00001722`),
1723 )
1724}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001725
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001726func TestSnapshotWithCcLibrary(t *testing.T) {
1727 result := testSdkWithCc(t, `
1728 module_exports {
1729 name: "myexports",
1730 native_libs: ["mynativelib"],
1731 }
1732
1733 cc_library {
1734 name: "mynativelib",
1735 srcs: [
1736 "Test.cpp",
1737 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001738 export_include_dirs: ["myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001739 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001740 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001741 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001742 }
1743 `)
1744
Paul Duffin36474d32021-03-12 12:19:43 +00001745 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001746 checkUnversionedAndroidBpContents(`
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001747// This is auto-generated. DO NOT EDIT.
1748
1749cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001750 name: "mynativelib",
1751 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001752 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001753 apex_available: ["//apex_available:platform"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001754 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001755 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001756 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001757 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001758 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001759 arch: {
1760 arm64: {
1761 static: {
1762 srcs: ["arm64/lib/mynativelib.a"],
1763 },
1764 shared: {
1765 srcs: ["arm64/lib/mynativelib.so"],
1766 },
1767 },
1768 arm: {
1769 static: {
1770 srcs: ["arm/lib/mynativelib.a"],
1771 },
1772 shared: {
1773 srcs: ["arm/lib/mynativelib.so"],
1774 },
1775 },
1776 },
1777}
Paul Duffin75b902a2021-02-22 12:13:13 +00001778`),
1779 // Make sure that the generated sdk_snapshot uses the native_libs property.
1780 checkVersionedAndroidBpContents(`
1781// This is auto-generated. DO NOT EDIT.
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001782
1783cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001784 name: "myexports_mynativelib@current",
1785 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001786 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001787 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +00001788 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001789 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001790 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001791 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001792 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001793 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001794 arch: {
1795 arm64: {
1796 static: {
1797 srcs: ["arm64/lib/mynativelib.a"],
1798 },
1799 shared: {
1800 srcs: ["arm64/lib/mynativelib.so"],
1801 },
1802 },
1803 arm: {
1804 static: {
1805 srcs: ["arm/lib/mynativelib.a"],
1806 },
1807 shared: {
1808 srcs: ["arm/lib/mynativelib.so"],
1809 },
1810 },
1811 },
1812}
1813
1814module_exports_snapshot {
1815 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001816 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001817 native_libs: ["myexports_mynativelib@current"],
1818}
1819`),
1820 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001821myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001822.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1823.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1824.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
Paul Duffin1822a0a2021-03-21 12:56:33 +00001825.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1826`),
1827 // TODO(b/183315522): Remove this and fix the issue.
1828 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\Qunrecognized property "arch.arm.shared.export_include_dirs"\E`)),
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001829 )
1830}
1831
Paul Duffin13ad94f2020-02-19 16:19:27 +00001832func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001833 result := testSdkWithCc(t, `
1834 module_exports {
1835 name: "myexports",
1836 device_supported: false,
1837 host_supported: true,
1838 target: {
1839 host: {
1840 compile_multilib: "64",
1841 },
1842 },
1843 native_static_libs: ["mynativelib"],
1844 }
1845
1846 cc_library_static {
1847 name: "mynativelib",
1848 device_supported: false,
1849 host_supported: true,
1850 srcs: [
1851 "Test.cpp",
1852 "aidl/foo/bar/Test.aidl",
1853 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001854 export_include_dirs: ["myinclude"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001855 aidl: {
1856 export_aidl_headers: true,
1857 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001858 stl: "none",
1859 }
1860 `)
1861
Paul Duffin36474d32021-03-12 12:19:43 +00001862 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001863 checkUnversionedAndroidBpContents(`
Paul Duffin13ad94f2020-02-19 16:19:27 +00001864// This is auto-generated. DO NOT EDIT.
1865
1866cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001867 name: "mynativelib",
1868 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001869 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001870 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001871 device_supported: false,
1872 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001873 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001874 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001875 export_include_dirs: [
1876 "include/myinclude",
1877 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1878 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001879 target: {
1880 host: {
1881 enabled: false,
1882 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001883 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001884 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001885 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001886 },
1887 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001888}
Paul Duffin75b902a2021-02-22 12:13:13 +00001889`),
1890 checkVersionedAndroidBpContents(`
1891// This is auto-generated. DO NOT EDIT.
Paul Duffin13ad94f2020-02-19 16:19:27 +00001892
1893cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001894 name: "myexports_mynativelib@current",
1895 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001896 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001897 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001898 device_supported: false,
1899 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001900 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001901 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001902 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001903 export_include_dirs: [
1904 "include/myinclude",
1905 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1906 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001907 target: {
1908 host: {
1909 enabled: false,
1910 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001911 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001912 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001913 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001914 },
1915 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001916}
1917
1918module_exports_snapshot {
1919 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001920 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001921 device_supported: false,
1922 host_supported: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001923 compile_multilib: "64",
Paul Duffin7b0259f2021-04-24 11:34:46 +01001924 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001925 target: {
1926 host: {
1927 enabled: false,
1928 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001929 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001930 enabled: true,
1931 },
1932 },
Paul Duffin75b902a2021-02-22 12:13:13 +00001933}
1934`),
Paul Duffin13ad94f2020-02-19 16:19:27 +00001935 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001936myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin7a7d0672021-02-17 12:17:40 +00001937.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
1938.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
1939.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 +00001940.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin13ad94f2020-02-19 16:19:27 +00001941`),
1942 )
1943}
Paul Duffin91756d22020-02-21 16:29:57 +00001944
1945func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1946 result := testSdkWithCc(t, `
1947 sdk {
1948 name: "mysdk",
1949 native_header_libs: ["mynativeheaders"],
1950 }
1951
1952 cc_library_headers {
1953 name: "mynativeheaders",
Paul Duffin86b02a72021-02-22 11:50:04 +00001954 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001955 stl: "none",
1956 }
1957 `)
1958
Paul Duffin36474d32021-03-12 12:19:43 +00001959 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001960 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001961// This is auto-generated. DO NOT EDIT.
1962
1963cc_prebuilt_library_headers {
Paul Duffin91756d22020-02-21 16:29:57 +00001964 name: "mynativeheaders",
1965 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001966 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001967 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00001968 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001969 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001970 export_include_dirs: ["include/myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001971}
Paul Duffin91756d22020-02-21 16:29:57 +00001972`),
1973 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001974myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00001975`),
1976 )
1977}
1978
1979func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001980 result := testSdkWithCc(t, `
1981 sdk {
1982 name: "mysdk",
1983 device_supported: false,
1984 host_supported: true,
1985 native_header_libs: ["mynativeheaders"],
1986 }
1987
1988 cc_library_headers {
1989 name: "mynativeheaders",
1990 device_supported: false,
1991 host_supported: true,
Paul Duffin86b02a72021-02-22 11:50:04 +00001992 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001993 stl: "none",
1994 }
1995 `)
1996
Paul Duffin36474d32021-03-12 12:19:43 +00001997 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001998 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001999// This is auto-generated. DO NOT EDIT.
2000
2001cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002002 name: "mynativeheaders",
2003 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002004 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002005 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002006 device_supported: false,
2007 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002008 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002009 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002010 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002011 target: {
2012 host: {
2013 enabled: false,
2014 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002015 linux_glibc_x86_64: {
2016 enabled: true,
2017 },
2018 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002019 enabled: true,
2020 },
2021 },
Paul Duffin91756d22020-02-21 16:29:57 +00002022}
Paul Duffin75b902a2021-02-22 12:13:13 +00002023`),
2024 checkVersionedAndroidBpContents(`
2025// This is auto-generated. DO NOT EDIT.
Paul Duffin91756d22020-02-21 16:29:57 +00002026
2027cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002028 name: "mysdk_mynativeheaders@current",
2029 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002030 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002031 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002032 device_supported: false,
2033 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002034 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002035 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002036 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002037 target: {
2038 host: {
2039 enabled: false,
2040 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002041 linux_glibc_x86_64: {
2042 enabled: true,
2043 },
2044 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002045 enabled: true,
2046 },
2047 },
Paul Duffin91756d22020-02-21 16:29:57 +00002048}
2049
2050sdk_snapshot {
2051 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002052 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002053 device_supported: false,
2054 host_supported: true,
2055 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002056 target: {
2057 host: {
2058 enabled: false,
2059 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002060 linux_glibc_x86_64: {
2061 enabled: true,
2062 },
2063 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002064 enabled: true,
2065 },
2066 },
Paul Duffin91756d22020-02-21 16:29:57 +00002067}
2068`),
2069 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002070myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00002071`),
2072 )
2073}
Paul Duffina04c1072020-03-02 10:16:35 +00002074
2075func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00002076 result := testSdkWithCc(t, `
2077 sdk {
2078 name: "mysdk",
2079 host_supported: true,
2080 native_header_libs: ["mynativeheaders"],
2081 }
2082
2083 cc_library_headers {
2084 name: "mynativeheaders",
2085 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002086 stl: "none",
Paul Duffin86b02a72021-02-22 11:50:04 +00002087 export_system_include_dirs: ["myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002088 target: {
2089 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002090 export_include_dirs: ["myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002091 },
2092 host: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002093 export_include_dirs: ["myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002094 },
2095 },
2096 }
2097 `)
2098
Paul Duffin36474d32021-03-12 12:19:43 +00002099 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002100 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00002101// This is auto-generated. DO NOT EDIT.
2102
2103cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002104 name: "mynativeheaders",
2105 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002106 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002107 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002108 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002109 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002110 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002111 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002112 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002113 host: {
2114 enabled: false,
2115 },
Paul Duffina04c1072020-03-02 10:16:35 +00002116 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002117 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002118 },
2119 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002120 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002121 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002122 linux_glibc_x86_64: {
2123 enabled: true,
2124 },
2125 linux_glibc_x86: {
2126 enabled: true,
2127 },
Paul Duffina04c1072020-03-02 10:16:35 +00002128 },
Paul Duffina04c1072020-03-02 10:16:35 +00002129}
Paul Duffin75b902a2021-02-22 12:13:13 +00002130`),
Paul Duffin75b902a2021-02-22 12:13:13 +00002131 checkVersionedAndroidBpContents(`
2132// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00002133
2134cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002135 name: "mysdk_mynativeheaders@current",
2136 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002137 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002138 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002139 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002140 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002141 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002142 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002143 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002144 host: {
2145 enabled: false,
2146 },
Paul Duffina04c1072020-03-02 10:16:35 +00002147 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002148 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002149 },
2150 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002151 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002152 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002153 linux_glibc_x86_64: {
2154 enabled: true,
2155 },
2156 linux_glibc_x86: {
2157 enabled: true,
2158 },
Paul Duffina04c1072020-03-02 10:16:35 +00002159 },
Paul Duffina04c1072020-03-02 10:16:35 +00002160}
2161
2162sdk_snapshot {
2163 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002164 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002165 host_supported: true,
2166 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002167 target: {
2168 host: {
2169 enabled: false,
2170 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002171 linux_glibc_x86_64: {
2172 enabled: true,
2173 },
2174 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002175 enabled: true,
2176 },
2177 },
Paul Duffina04c1072020-03-02 10:16:35 +00002178}
2179`),
2180 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002181myinclude/Test.h -> common_os/include/myinclude/Test.h
2182myinclude-android/AndroidTest.h -> android/include/myinclude-android/AndroidTest.h
2183myinclude-host/HostTest.h -> linux_glibc/include/myinclude-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002184`),
2185 )
2186}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002187
2188func TestSystemSharedLibPropagation(t *testing.T) {
2189 result := testSdkWithCc(t, `
2190 sdk {
2191 name: "mysdk",
2192 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2193 }
2194
2195 cc_library {
2196 name: "sslnil",
2197 host_supported: true,
2198 }
2199
2200 cc_library {
2201 name: "sslempty",
2202 system_shared_libs: [],
2203 }
2204
2205 cc_library {
2206 name: "sslnonempty",
2207 system_shared_libs: ["sslnil"],
2208 }
2209 `)
2210
Paul Duffin36474d32021-03-12 12:19:43 +00002211 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002212 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002213// This is auto-generated. DO NOT EDIT.
2214
2215cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002216 name: "sslnil",
2217 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002218 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002219 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002220 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002221 arch: {
2222 arm64: {
2223 srcs: ["arm64/lib/sslnil.so"],
2224 },
2225 arm: {
2226 srcs: ["arm/lib/sslnil.so"],
2227 },
2228 },
2229}
2230
2231cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002232 name: "sslempty",
2233 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002234 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002235 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002236 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002237 system_shared_libs: [],
2238 arch: {
2239 arm64: {
2240 srcs: ["arm64/lib/sslempty.so"],
2241 },
2242 arm: {
2243 srcs: ["arm/lib/sslempty.so"],
2244 },
2245 },
2246}
2247
2248cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002249 name: "sslnonempty",
2250 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002251 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002252 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002253 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002254 system_shared_libs: ["sslnil"],
2255 arch: {
2256 arm64: {
2257 srcs: ["arm64/lib/sslnonempty.so"],
2258 },
2259 arm: {
2260 srcs: ["arm/lib/sslnonempty.so"],
2261 },
2262 },
2263}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002264`))
2265
2266 result = testSdkWithCc(t, `
2267 sdk {
2268 name: "mysdk",
2269 host_supported: true,
2270 native_shared_libs: ["sslvariants"],
2271 }
2272
2273 cc_library {
2274 name: "sslvariants",
2275 host_supported: true,
2276 target: {
2277 android: {
2278 system_shared_libs: [],
2279 },
2280 },
2281 }
2282 `)
2283
Paul Duffin36474d32021-03-12 12:19:43 +00002284 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002285 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002286// This is auto-generated. DO NOT EDIT.
2287
2288cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002289 name: "sslvariants",
2290 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002291 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002292 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002293 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002294 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002295 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002296 host: {
2297 enabled: false,
2298 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002299 android: {
2300 system_shared_libs: [],
2301 },
2302 android_arm64: {
2303 srcs: ["android/arm64/lib/sslvariants.so"],
2304 },
2305 android_arm: {
2306 srcs: ["android/arm/lib/sslvariants.so"],
2307 },
2308 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002309 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002310 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2311 },
2312 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002313 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002314 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2315 },
2316 },
2317}
Paul Duffin75b902a2021-02-22 12:13:13 +00002318`),
2319 checkVersionedAndroidBpContents(`
2320// This is auto-generated. DO NOT EDIT.
Martin Stjernholm10566a02020-03-24 01:19:52 +00002321
2322cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002323 name: "mysdk_sslvariants@current",
2324 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002325 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002326 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002327 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002328 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002329 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002330 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002331 host: {
2332 enabled: false,
2333 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002334 android: {
2335 system_shared_libs: [],
2336 },
2337 android_arm64: {
2338 srcs: ["android/arm64/lib/sslvariants.so"],
2339 },
2340 android_arm: {
2341 srcs: ["android/arm/lib/sslvariants.so"],
2342 },
2343 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002344 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002345 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2346 },
2347 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002348 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002349 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2350 },
2351 },
2352}
2353
2354sdk_snapshot {
2355 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002356 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002357 host_supported: true,
2358 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002359 target: {
2360 host: {
2361 enabled: false,
2362 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002363 linux_glibc_x86_64: {
2364 enabled: true,
2365 },
2366 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002367 enabled: true,
2368 },
2369 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002370}
2371`))
2372}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002373
2374func TestStubsLibrary(t *testing.T) {
2375 result := testSdkWithCc(t, `
2376 sdk {
2377 name: "mysdk",
2378 native_shared_libs: ["stubslib"],
2379 }
2380
2381 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002382 name: "internaldep",
2383 }
2384
2385 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002386 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002387 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002388 stubs: {
2389 symbol_file: "some/where/stubslib.map.txt",
2390 versions: ["1", "2", "3"],
2391 },
2392 }
2393 `)
2394
Paul Duffin36474d32021-03-12 12:19:43 +00002395 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002396 checkUnversionedAndroidBpContents(`
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002397// This is auto-generated. DO NOT EDIT.
2398
2399cc_prebuilt_library_shared {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002400 name: "stubslib",
2401 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002402 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002403 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002404 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002405 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002406 versions: [
2407 "1",
2408 "2",
2409 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002410 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002411 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002412 },
2413 arch: {
2414 arm64: {
2415 srcs: ["arm64/lib/stubslib.so"],
2416 },
2417 arm: {
2418 srcs: ["arm/lib/stubslib.so"],
2419 },
2420 },
2421}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002422`))
2423}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002424
2425func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002426 result := testSdkWithCc(t, `
2427 sdk {
2428 name: "mysdk",
2429 host_supported: true,
2430 native_shared_libs: ["stubslib"],
2431 }
2432
2433 cc_library {
2434 name: "internaldep",
2435 host_supported: true,
2436 }
2437
2438 cc_library {
2439 name: "stubslib",
2440 host_supported: true,
2441 shared_libs: ["internaldep"],
2442 stubs: {
2443 symbol_file: "some/where/stubslib.map.txt",
2444 versions: ["1", "2", "3"],
2445 },
2446 }
2447 `)
2448
Paul Duffin36474d32021-03-12 12:19:43 +00002449 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002450 checkUnversionedAndroidBpContents(`
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002451// This is auto-generated. DO NOT EDIT.
2452
2453cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002454 name: "stubslib",
2455 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002456 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002457 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002458 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002459 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002460 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002461 versions: [
2462 "1",
2463 "2",
2464 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002465 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002466 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002467 },
2468 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002469 host: {
2470 enabled: false,
2471 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002472 android_arm64: {
2473 srcs: ["android/arm64/lib/stubslib.so"],
2474 },
2475 android_arm: {
2476 srcs: ["android/arm/lib/stubslib.so"],
2477 },
2478 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002479 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002480 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2481 },
2482 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002483 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002484 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2485 },
2486 },
2487}
Paul Duffin75b902a2021-02-22 12:13:13 +00002488`),
2489 checkVersionedAndroidBpContents(`
2490// This is auto-generated. DO NOT EDIT.
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002491
2492cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002493 name: "mysdk_stubslib@current",
2494 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002495 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002496 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002497 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002498 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002499 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002500 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002501 versions: [
2502 "1",
2503 "2",
2504 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002505 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002506 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002507 },
2508 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002509 host: {
2510 enabled: false,
2511 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002512 android_arm64: {
2513 srcs: ["android/arm64/lib/stubslib.so"],
2514 },
2515 android_arm: {
2516 srcs: ["android/arm/lib/stubslib.so"],
2517 },
2518 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002519 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002520 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2521 },
2522 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002523 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002524 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2525 },
2526 },
2527}
2528
2529sdk_snapshot {
2530 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002531 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002532 host_supported: true,
2533 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002534 target: {
2535 host: {
2536 enabled: false,
2537 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002538 linux_glibc_x86_64: {
2539 enabled: true,
2540 },
2541 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002542 enabled: true,
2543 },
2544 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002545}
2546`))
2547}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002548
2549func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002550 result := testSdkWithCc(t, `
2551 sdk {
2552 name: "mysdk",
2553 host_supported: true,
2554 native_shared_libs: ["mylib"],
2555 }
2556
2557 cc_library {
2558 name: "mylib",
2559 host_supported: true,
2560 unique_host_soname: true,
2561 }
2562 `)
2563
Paul Duffin36474d32021-03-12 12:19:43 +00002564 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002565 checkUnversionedAndroidBpContents(`
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002566// This is auto-generated. DO NOT EDIT.
2567
2568cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002569 name: "mylib",
2570 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002571 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002572 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002573 host_supported: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002574 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002575 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002576 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002577 host: {
2578 enabled: false,
2579 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002580 android_arm64: {
2581 srcs: ["android/arm64/lib/mylib.so"],
2582 },
2583 android_arm: {
2584 srcs: ["android/arm/lib/mylib.so"],
2585 },
2586 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002587 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002588 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2589 },
2590 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002591 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002592 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2593 },
2594 },
2595}
Paul Duffin75b902a2021-02-22 12:13:13 +00002596`),
2597 checkVersionedAndroidBpContents(`
2598// This is auto-generated. DO NOT EDIT.
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002599
2600cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002601 name: "mysdk_mylib@current",
2602 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002603 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002604 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002605 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002606 installable: false,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002607 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002608 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002609 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002610 host: {
2611 enabled: false,
2612 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002613 android_arm64: {
2614 srcs: ["android/arm64/lib/mylib.so"],
2615 },
2616 android_arm: {
2617 srcs: ["android/arm/lib/mylib.so"],
2618 },
2619 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002620 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002621 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2622 },
2623 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002624 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002625 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2626 },
2627 },
2628}
2629
2630sdk_snapshot {
2631 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002632 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002633 host_supported: true,
2634 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002635 target: {
2636 host: {
2637 enabled: false,
2638 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002639 linux_glibc_x86_64: {
2640 enabled: true,
2641 },
2642 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002643 enabled: true,
2644 },
2645 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002646}
2647`),
2648 checkAllCopyRules(`
2649.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2650.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2651.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2652.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2653`),
2654 )
2655}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002656
2657func TestNoSanitizerMembers(t *testing.T) {
2658 result := testSdkWithCc(t, `
2659 sdk {
2660 name: "mysdk",
2661 native_shared_libs: ["mynativelib"],
2662 }
2663
2664 cc_library_shared {
2665 name: "mynativelib",
2666 srcs: ["Test.cpp"],
Paul Duffin86b02a72021-02-22 11:50:04 +00002667 export_include_dirs: ["myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002668 arch: {
2669 arm64: {
2670 export_system_include_dirs: ["arm64/include"],
2671 sanitize: {
2672 hwaddress: true,
2673 },
2674 },
2675 },
2676 }
2677 `)
2678
Paul Duffin1822a0a2021-03-21 12:56:33 +00002679 // Mixing the snapshot with the source (irrespective of which one is preferred) causes a problem
2680 // due to missing variants.
2681 // TODO(b/183204176): Remove this and fix the cause.
2682 snapshotWithSourceErrorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QReplaceDependencies could not find identical variant {os:android,image:,arch:arm64_armv8-a,sdk:,link:shared,version:} for module mynativelib\E`)
2683
Paul Duffin36474d32021-03-12 12:19:43 +00002684 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002685 checkUnversionedAndroidBpContents(`
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002686// This is auto-generated. DO NOT EDIT.
2687
2688cc_prebuilt_library_shared {
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002689 name: "mynativelib",
2690 prefer: false,
2691 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002692 apex_available: ["//apex_available:platform"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002693 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002694 export_include_dirs: ["include/myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002695 arch: {
2696 arm64: {
2697 export_system_include_dirs: ["arm64/include/arm64/include"],
2698 },
2699 arm: {
2700 srcs: ["arm/lib/mynativelib.so"],
2701 },
2702 },
2703}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002704`),
2705 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002706myinclude/Test.h -> include/myinclude/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002707arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Paul Duffin1822a0a2021-03-21 12:56:33 +00002708.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
2709`),
2710 snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, snapshotWithSourceErrorHandler),
2711 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, snapshotWithSourceErrorHandler),
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002712 )
2713}