blob: 25e35fcdb8fb5735f036af2773f1f09b53bd476d [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",
Colin Cross6b8f4252021-07-22 11:39:44 -0700350 system_shared_libs: [],
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100351 sanitize: {
352 never: true,
353 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000354 }
355 `)
356
Paul Duffin36474d32021-03-12 12:19:43 +0000357 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000358 checkUnversionedAndroidBpContents(`
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000359// This is auto-generated. DO NOT EDIT.
360
361cc_prebuilt_object {
Paul Duffin75b902a2021-02-22 12:13:13 +0000362 name: "crtobj",
363 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100364 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000365 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000366 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100367 compile_multilib: "both",
Colin Cross6b8f4252021-07-22 11:39:44 -0700368 system_shared_libs: [],
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100369 sanitize: {
370 never: true,
371 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000372 arch: {
373 arm64: {
374 srcs: ["arm64/lib/crtobj.o"],
375 },
376 arm: {
377 srcs: ["arm/lib/crtobj.o"],
378 },
379 },
380}
Paul Duffin75b902a2021-02-22 12:13:13 +0000381`),
382 // Make sure that the generated sdk_snapshot uses the native_objects property.
383 checkVersionedAndroidBpContents(`
384// This is auto-generated. DO NOT EDIT.
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000385
386cc_prebuilt_object {
Paul Duffin75b902a2021-02-22 12:13:13 +0000387 name: "mysdk_crtobj@current",
388 sdk_member_name: "crtobj",
Paul Duffind99d9972020-09-29 16:00:55 +0100389 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000390 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000391 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100392 compile_multilib: "both",
Colin Cross6b8f4252021-07-22 11:39:44 -0700393 system_shared_libs: [],
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100394 sanitize: {
395 never: true,
396 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000397 arch: {
398 arm64: {
399 srcs: ["arm64/lib/crtobj.o"],
400 },
401 arm: {
402 srcs: ["arm/lib/crtobj.o"],
403 },
404 },
405}
406
407sdk_snapshot {
408 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100409 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000410 native_objects: ["mysdk_crtobj@current"],
411}
412`),
413 checkAllCopyRules(`
414.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
415.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
416`),
417 )
418}
419
Paul Duffinc62a5102019-12-11 18:34:15 +0000420func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
421 result := testSdkWithCc(t, `
422 sdk {
423 name: "mysdk",
424 native_shared_libs: ["mynativelib1", "mynativelib2"],
425 }
426
427 cc_library_shared {
428 name: "mynativelib1",
429 srcs: [
430 "Test.cpp",
431 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000432 export_include_dirs: ["myinclude"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000433 stl: "none",
434 }
435
436 cc_library_shared {
437 name: "mynativelib2",
438 srcs: [
439 "Test.cpp",
440 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000441 export_include_dirs: ["myinclude"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000442 stl: "none",
443 }
444 `)
445
Paul Duffin36474d32021-03-12 12:19:43 +0000446 CheckSnapshot(t, result, "mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000447 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000448myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800449.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
450.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
451.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
452.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000453`),
454 )
455}
456
Paul Duffina43f9272021-02-17 10:55:25 +0000457func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
458 result := testSdkWithCc(t, `
459 sdk {
460 name: "mysdk",
461 native_shared_libs: ["mynativelib"],
462 }
463
464 cc_library_shared {
465 name: "mynativelib",
466 srcs: [
467 "Test.cpp",
468 ],
469 generated_headers: [
470 "generated_foo",
471 ],
472 export_generated_headers: [
473 "generated_foo",
474 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000475 export_include_dirs: ["myinclude"],
Paul Duffina43f9272021-02-17 10:55:25 +0000476 stl: "none",
477 }
478
479 genrule {
480 name: "generated_foo",
481 cmd: "generate-foo",
482 out: [
483 "generated_foo/protos/foo/bar.h",
484 ],
485 export_include_dirs: [
486 ".",
487 "protos",
488 ],
489 }
490 `)
491
Paul Duffindb462dd2021-03-21 22:01:55 +0000492 // TODO(b/183322862): Remove this and fix the issue.
493 errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module source path "snapshot/include_gen/generated_foo/gen/protos" does not exist`)
494
Paul Duffin36474d32021-03-12 12:19:43 +0000495 CheckSnapshot(t, result, "mysdk", "",
Paul Duffina43f9272021-02-17 10:55:25 +0000496 checkUnversionedAndroidBpContents(`
497// This is auto-generated. DO NOT EDIT.
498
499cc_prebuilt_library_shared {
500 name: "mynativelib",
501 prefer: false,
502 visibility: ["//visibility:public"],
503 apex_available: ["//apex_available:platform"],
504 stl: "none",
505 compile_multilib: "both",
Paul Duffin7a7d0672021-02-17 12:17:40 +0000506 export_include_dirs: [
507 "include/myinclude",
508 "include_gen/generated_foo/gen",
509 "include_gen/generated_foo/gen/protos",
510 ],
Paul Duffina43f9272021-02-17 10:55:25 +0000511 arch: {
512 arm64: {
513 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffina43f9272021-02-17 10:55:25 +0000514 },
515 arm: {
516 srcs: ["arm/lib/mynativelib.so"],
Paul Duffina43f9272021-02-17 10:55:25 +0000517 },
518 },
519}
520`),
521 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000522myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin7a7d0672021-02-17 12:17:40 +0000523.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 +0000524.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina43f9272021-02-17 10:55:25 +0000525.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
Paul Duffina43f9272021-02-17 10:55:25 +0000526`),
Paul Duffindb462dd2021-03-21 22:01:55 +0000527 snapshotTestErrorHandler(checkSnapshotWithoutSource, errorHandler),
528 snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, errorHandler),
529 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, errorHandler),
Paul Duffina43f9272021-02-17 10:55:25 +0000530 )
531}
532
Martin Stjernholmb0249572020-09-15 02:32:35 +0100533// Verify that when the shared library has some common and some arch specific
534// properties that the generated snapshot is optimized properly. Substruct
535// handling is tested with the sanitize clauses (but note there's a lot of
536// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000537func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
538 result := testSdkWithCc(t, `
539 sdk {
540 name: "mysdk",
541 native_shared_libs: ["mynativelib"],
542 }
543
544 cc_library_shared {
545 name: "mynativelib",
546 srcs: [
547 "Test.cpp",
548 "aidl/foo/bar/Test.aidl",
549 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000550 export_include_dirs: ["myinclude"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100551 sanitize: {
552 fuzzer: false,
553 integer_overflow: true,
554 diag: { undefined: false },
555 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000556 arch: {
557 arm64: {
558 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100559 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100560 integer_overflow: false,
561 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000562 },
563 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000564 stl: "none",
565 }
566 `)
567
Paul Duffin36474d32021-03-12 12:19:43 +0000568 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000569 checkUnversionedAndroidBpContents(`
Paul Duffina7cd8c82019-12-11 20:00:57 +0000570// This is auto-generated. DO NOT EDIT.
571
572cc_prebuilt_library_shared {
Paul Duffina7cd8c82019-12-11 20:00:57 +0000573 name: "mynativelib",
574 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100575 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000576 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000577 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100578 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +0000579 export_include_dirs: ["include/myinclude"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100580 sanitize: {
581 fuzzer: false,
582 diag: {
583 undefined: false,
584 },
585 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000586 arch: {
587 arm64: {
588 srcs: ["arm64/lib/mynativelib.so"],
589 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100590 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100591 integer_overflow: false,
592 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000593 },
594 arm: {
595 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100596 sanitize: {
597 integer_overflow: true,
598 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000599 },
600 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000601}
Paul Duffina7cd8c82019-12-11 20:00:57 +0000602`),
603 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000604myinclude/Test.h -> include/myinclude/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +0000605.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000606arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800607.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000608 )
609}
610
Paul Duffin25ce04b2020-01-16 11:47:25 +0000611func TestSnapshotWithCcBinary(t *testing.T) {
612 result := testSdkWithCc(t, `
613 module_exports {
614 name: "mymodule_exports",
615 native_binaries: ["mynativebinary"],
616 }
617
618 cc_binary {
619 name: "mynativebinary",
620 srcs: [
621 "Test.cpp",
622 ],
623 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000624 }
625 `)
626
Paul Duffin36474d32021-03-12 12:19:43 +0000627 CheckSnapshot(t, result, "mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000628 checkUnversionedAndroidBpContents(`
Paul Duffin25ce04b2020-01-16 11:47:25 +0000629// This is auto-generated. DO NOT EDIT.
630
631cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000632 name: "mynativebinary",
633 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100634 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000635 apex_available: ["//apex_available:platform"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000636 compile_multilib: "both",
637 arch: {
638 arm64: {
639 srcs: ["arm64/bin/mynativebinary"],
640 },
641 arm: {
642 srcs: ["arm/bin/mynativebinary"],
643 },
644 },
645}
Paul Duffin75b902a2021-02-22 12:13:13 +0000646`),
647 // Make sure that the generated sdk_snapshot uses the native_binaries property.
648 checkVersionedAndroidBpContents(`
649// This is auto-generated. DO NOT EDIT.
Paul Duffin25ce04b2020-01-16 11:47:25 +0000650
651cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000652 name: "mymodule_exports_mynativebinary@current",
653 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100654 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000655 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +0000656 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000657 compile_multilib: "both",
658 arch: {
659 arm64: {
660 srcs: ["arm64/bin/mynativebinary"],
661 },
662 arm: {
663 srcs: ["arm/bin/mynativebinary"],
664 },
665 },
666}
667
668module_exports_snapshot {
669 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100670 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000671 native_binaries: ["mymodule_exports_mynativebinary@current"],
672}
673`),
674 checkAllCopyRules(`
675.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
676.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
677`),
678 )
679}
680
Paul Duffina04c1072020-03-02 10:16:35 +0000681func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000682 result := testSdkWithCc(t, `
683 module_exports {
684 name: "myexports",
685 device_supported: false,
686 host_supported: true,
687 native_binaries: ["mynativebinary"],
688 target: {
689 windows: {
690 enabled: true,
691 },
692 },
693 }
694
695 cc_binary {
696 name: "mynativebinary",
697 device_supported: false,
698 host_supported: true,
699 srcs: [
700 "Test.cpp",
701 ],
702 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000703 stl: "none",
704 target: {
705 windows: {
706 enabled: true,
707 },
708 },
709 }
710 `)
711
Paul Duffin36474d32021-03-12 12:19:43 +0000712 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000713 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +0000714// This is auto-generated. DO NOT EDIT.
715
716cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000717 name: "mynativebinary",
718 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100719 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000720 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000721 device_supported: false,
722 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100723 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000724 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100725 host: {
726 enabled: false,
727 },
Paul Duffina04c1072020-03-02 10:16:35 +0000728 linux_glibc: {
729 compile_multilib: "both",
730 },
731 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900732 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000733 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
734 },
735 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900736 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000737 srcs: ["linux_glibc/x86/bin/mynativebinary"],
738 },
739 windows: {
740 compile_multilib: "64",
741 },
742 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900743 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000744 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
745 },
746 },
747}
Paul Duffin75b902a2021-02-22 12:13:13 +0000748`),
749 checkVersionedAndroidBpContents(`
750// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +0000751
752cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000753 name: "myexports_mynativebinary@current",
754 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100755 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000756 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000757 device_supported: false,
758 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +0000759 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100760 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000761 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100762 host: {
763 enabled: false,
764 },
Paul Duffina04c1072020-03-02 10:16:35 +0000765 linux_glibc: {
766 compile_multilib: "both",
767 },
768 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900769 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000770 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
771 },
772 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900773 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000774 srcs: ["linux_glibc/x86/bin/mynativebinary"],
775 },
776 windows: {
777 compile_multilib: "64",
778 },
779 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900780 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000781 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
782 },
783 },
784}
785
786module_exports_snapshot {
787 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100788 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000789 device_supported: false,
790 host_supported: true,
791 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000792 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900793 windows: {
794 compile_multilib: "64",
795 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100796 host: {
797 enabled: false,
798 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900799 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100800 enabled: true,
801 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900802 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100803 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +0900804 },
805 windows_x86_64: {
806 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000807 },
808 },
Paul Duffina04c1072020-03-02 10:16:35 +0000809}
810`),
811 checkAllCopyRules(`
812.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
813.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
814.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
815`),
816 )
817}
818
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100819func TestSnapshotWithSingleHostOsType(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000820 result := android.GroupFixturePreparers(
821 prepareForSdkTest,
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000822 ccTestFs.AddToFixture(),
823 cc.PrepareForTestOnLinuxBionic,
824 android.FixtureModifyConfig(func(config android.Config) {
825 config.Targets[android.LinuxBionic] = []android.Target{
826 {android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", false},
827 }
828 }),
829 ).RunTestWithBp(t, `
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100830 cc_defaults {
831 name: "mydefaults",
832 device_supported: false,
833 host_supported: true,
834 compile_multilib: "64",
835 target: {
836 host: {
837 enabled: false,
838 },
839 linux_bionic: {
840 enabled: true,
841 },
842 },
843 }
844
845 module_exports {
846 name: "myexports",
847 defaults: ["mydefaults"],
848 native_shared_libs: ["mynativelib"],
849 native_binaries: ["mynativebinary"],
850 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
851 }
852
853 cc_library {
854 name: "mynativelib",
855 defaults: ["mydefaults"],
856 srcs: [
857 "Test.cpp",
858 ],
859 stl: "none",
860 }
861
862 cc_binary {
863 name: "mynativebinary",
864 defaults: ["mydefaults"],
865 srcs: [
866 "Test.cpp",
867 ],
868 stl: "none",
869 }
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000870 `)
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100871
Paul Duffin36474d32021-03-12 12:19:43 +0000872 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000873 checkUnversionedAndroidBpContents(`
874// This is auto-generated. DO NOT EDIT.
875
876cc_prebuilt_binary {
877 name: "mynativebinary",
878 prefer: false,
879 visibility: ["//visibility:public"],
880 apex_available: ["//apex_available:platform"],
881 device_supported: false,
882 host_supported: true,
883 stl: "none",
884 compile_multilib: "64",
885 target: {
886 host: {
887 enabled: false,
888 },
889 linux_bionic_x86_64: {
890 enabled: true,
891 srcs: ["x86_64/bin/mynativebinary"],
892 },
893 },
894}
895
896cc_prebuilt_library_shared {
897 name: "mynativelib",
898 prefer: false,
899 visibility: ["//visibility:public"],
900 apex_available: ["//apex_available:platform"],
901 device_supported: false,
902 host_supported: true,
903 stl: "none",
904 compile_multilib: "64",
905 target: {
906 host: {
907 enabled: false,
908 },
909 linux_bionic_x86_64: {
910 enabled: true,
911 srcs: ["x86_64/lib/mynativelib.so"],
912 },
913 },
914}
915`),
916 checkVersionedAndroidBpContents(`
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100917// This is auto-generated. DO NOT EDIT.
918
919cc_prebuilt_binary {
920 name: "myexports_mynativebinary@current",
921 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100922 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000923 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100924 device_supported: false,
925 host_supported: true,
926 installable: false,
927 stl: "none",
928 compile_multilib: "64",
929 target: {
930 host: {
931 enabled: false,
932 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100933 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900934 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100935 srcs: ["x86_64/bin/mynativebinary"],
936 },
937 },
938}
939
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100940cc_prebuilt_library_shared {
941 name: "myexports_mynativelib@current",
942 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100943 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000944 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100945 device_supported: false,
946 host_supported: true,
947 installable: false,
948 stl: "none",
949 compile_multilib: "64",
950 target: {
951 host: {
952 enabled: false,
953 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100954 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900955 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100956 srcs: ["x86_64/lib/mynativelib.so"],
957 },
958 },
959}
960
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100961module_exports_snapshot {
962 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100963 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100964 device_supported: false,
965 host_supported: true,
Paul Duffin7b0259f2021-04-24 11:34:46 +0100966 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100967 native_binaries: ["myexports_mynativebinary@current"],
968 native_shared_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100969 target: {
970 host: {
971 enabled: false,
972 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900973 linux_bionic_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100974 enabled: true,
975 },
976 },
977}
978`),
979 checkAllCopyRules(`
980.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
981.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
982`),
983 )
984}
985
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100986// Test that we support the necessary flags for the linker binary, which is
987// special in several ways.
988func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100989 result := testSdkWithCc(t, `
990 module_exports {
991 name: "mymodule_exports",
992 host_supported: true,
993 device_supported: false,
994 native_binaries: ["linker"],
995 }
996
997 cc_binary {
998 name: "linker",
999 host_supported: true,
1000 static_executable: true,
1001 nocrt: true,
1002 stl: "none",
1003 srcs: [
1004 "Test.cpp",
1005 ],
1006 compile_multilib: "both",
1007 }
1008 `)
1009
Paul Duffin36474d32021-03-12 12:19:43 +00001010 CheckSnapshot(t, result, "mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001011 checkUnversionedAndroidBpContents(`
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001012// This is auto-generated. DO NOT EDIT.
1013
1014cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +00001015 name: "linker",
1016 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001017 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001018 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001019 device_supported: false,
1020 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001021 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001022 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001023 static_executable: true,
1024 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001025 target: {
1026 host: {
1027 enabled: false,
1028 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001029 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001030 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001031 srcs: ["x86_64/bin/linker"],
1032 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001033 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001034 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001035 srcs: ["x86/bin/linker"],
1036 },
1037 },
1038}
Paul Duffin75b902a2021-02-22 12:13:13 +00001039`),
1040 checkVersionedAndroidBpContents(`
1041// This is auto-generated. DO NOT EDIT.
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001042
1043cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +00001044 name: "mymodule_exports_linker@current",
1045 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +01001046 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001047 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001048 device_supported: false,
1049 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001050 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001051 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001052 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001053 static_executable: true,
1054 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001055 target: {
1056 host: {
1057 enabled: false,
1058 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001059 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001060 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001061 srcs: ["x86_64/bin/linker"],
1062 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001063 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001064 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001065 srcs: ["x86/bin/linker"],
1066 },
1067 },
1068}
1069
1070module_exports_snapshot {
1071 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001072 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001073 device_supported: false,
1074 host_supported: true,
1075 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001076 target: {
1077 host: {
1078 enabled: false,
1079 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001080 linux_glibc_x86_64: {
1081 enabled: true,
1082 },
1083 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001084 enabled: true,
1085 },
1086 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001087}
1088`),
1089 checkAllCopyRules(`
1090.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1091.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1092`),
1093 )
1094}
1095
Paul Duffin9ab556f2019-12-11 18:42:17 +00001096func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001097 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001098 sdk {
1099 name: "mysdk",
1100 native_shared_libs: ["mynativelib"],
1101 }
1102
1103 cc_library_shared {
1104 name: "mynativelib",
1105 srcs: [
1106 "Test.cpp",
1107 "aidl/foo/bar/Test.aidl",
1108 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001109 apex_available: ["apex1", "apex2"],
Paul Duffin86b02a72021-02-22 11:50:04 +00001110 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001111 aidl: {
1112 export_aidl_headers: true,
1113 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001114 stl: "none",
1115 }
1116 `)
1117
Paul Duffin36474d32021-03-12 12:19:43 +00001118 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001119 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001120// This is auto-generated. DO NOT EDIT.
1121
1122cc_prebuilt_library_shared {
Paul Duffina80fdec2019-12-03 15:25:00 +00001123 name: "mynativelib",
1124 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001125 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001126 apex_available: [
1127 "apex1",
1128 "apex2",
1129 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001130 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001131 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001132 export_include_dirs: ["include/myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001133 arch: {
1134 arm64: {
1135 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001136 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001137 },
1138 arm: {
1139 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001140 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001141 },
1142 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001143}
Paul Duffina80fdec2019-12-03 15:25:00 +00001144`),
1145 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001146myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001147.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001148.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
1149.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
1150.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 -08001151.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001152.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
1153.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
1154.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 +00001155`),
1156 )
1157}
1158
Paul Duffin13f02712020-03-06 12:30:43 +00001159func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1160 result := testSdkWithCc(t, `
1161 sdk {
1162 name: "mysdk",
1163 native_shared_libs: [
1164 "mynativelib",
1165 "myothernativelib",
1166 "mysystemnativelib",
1167 ],
1168 }
1169
1170 cc_library {
1171 name: "mysystemnativelib",
1172 srcs: [
1173 "Test.cpp",
1174 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001175 stl: "none",
1176 }
1177
1178 cc_library_shared {
1179 name: "myothernativelib",
1180 srcs: [
1181 "Test.cpp",
1182 ],
1183 system_shared_libs: [
1184 // A reference to a library that is not an sdk member. Uses libm as that
1185 // is in the default set of modules available to this test and so is available
1186 // both here and also when the generated Android.bp file is tested in
1187 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1188 // handles references to modules that are not sdk members.
1189 "libm",
1190 ],
1191 stl: "none",
1192 }
1193
1194 cc_library {
1195 name: "mynativelib",
1196 srcs: [
1197 "Test.cpp",
1198 ],
1199 shared_libs: [
1200 // A reference to another sdk member.
1201 "myothernativelib",
1202 ],
1203 target: {
1204 android: {
1205 shared: {
1206 shared_libs: [
1207 // A reference to a library that is not an sdk member. The libc library
1208 // is used here to check that the shared_libs property is handled correctly
1209 // in a similar way to how libm is used to check system_shared_libs above.
1210 "libc",
1211 ],
1212 },
1213 },
1214 },
Paul Duffin13f02712020-03-06 12:30:43 +00001215 stl: "none",
1216 }
1217 `)
1218
Paul Duffin36474d32021-03-12 12:19:43 +00001219 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001220 checkUnversionedAndroidBpContents(`
Paul Duffin13f02712020-03-06 12:30:43 +00001221// This is auto-generated. DO NOT EDIT.
1222
1223cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001224 name: "mynativelib",
1225 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001226 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001227 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001228 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001229 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001230 shared_libs: [
1231 "myothernativelib",
1232 "libc",
1233 ],
1234 arch: {
1235 arm64: {
1236 srcs: ["arm64/lib/mynativelib.so"],
1237 },
1238 arm: {
1239 srcs: ["arm/lib/mynativelib.so"],
1240 },
1241 },
Paul Duffin13f02712020-03-06 12:30:43 +00001242}
1243
1244cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001245 name: "myothernativelib",
1246 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001247 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001248 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001249 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001250 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001251 system_shared_libs: ["libm"],
1252 arch: {
1253 arm64: {
1254 srcs: ["arm64/lib/myothernativelib.so"],
1255 },
1256 arm: {
1257 srcs: ["arm/lib/myothernativelib.so"],
1258 },
1259 },
Paul Duffin13f02712020-03-06 12:30:43 +00001260}
1261
1262cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001263 name: "mysystemnativelib",
1264 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001265 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001266 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001267 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001268 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001269 arch: {
1270 arm64: {
1271 srcs: ["arm64/lib/mysystemnativelib.so"],
1272 },
1273 arm: {
1274 srcs: ["arm/lib/mysystemnativelib.so"],
1275 },
1276 },
Paul Duffin13f02712020-03-06 12:30:43 +00001277}
Paul Duffin13f02712020-03-06 12:30:43 +00001278`),
1279 checkAllCopyRules(`
1280.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1281.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1282.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1283.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1284.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1285.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1286`),
1287 )
1288}
1289
Paul Duffin9ab556f2019-12-11 18:42:17 +00001290func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001291 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001292 sdk {
1293 name: "mysdk",
1294 device_supported: false,
1295 host_supported: true,
1296 native_shared_libs: ["mynativelib"],
1297 }
1298
1299 cc_library_shared {
1300 name: "mynativelib",
1301 device_supported: false,
1302 host_supported: true,
1303 srcs: [
1304 "Test.cpp",
1305 "aidl/foo/bar/Test.aidl",
1306 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001307 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001308 aidl: {
1309 export_aidl_headers: true,
1310 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001311 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001312 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001313 }
1314 `)
1315
Paul Duffin36474d32021-03-12 12:19:43 +00001316 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001317 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001318// This is auto-generated. DO NOT EDIT.
1319
1320cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001321 name: "mynativelib",
1322 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001323 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001324 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001325 device_supported: false,
1326 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001327 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001328 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001329 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001330 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001331 target: {
1332 host: {
1333 enabled: false,
1334 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001335 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001336 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001337 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001338 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001339 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001340 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001341 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001342 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001343 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001344 },
1345 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001346}
Paul Duffin75b902a2021-02-22 12:13:13 +00001347`),
1348 checkVersionedAndroidBpContents(`
1349// This is auto-generated. DO NOT EDIT.
Paul Duffina80fdec2019-12-03 15:25:00 +00001350
1351cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001352 name: "mysdk_mynativelib@current",
1353 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001354 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001355 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001356 device_supported: false,
1357 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001358 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001359 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001360 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001361 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001362 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001363 target: {
1364 host: {
1365 enabled: false,
1366 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001367 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001368 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001369 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001370 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001371 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001372 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001373 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001374 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001375 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001376 },
1377 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001378}
1379
1380sdk_snapshot {
1381 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001382 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001383 device_supported: false,
1384 host_supported: true,
1385 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001386 target: {
1387 host: {
1388 enabled: false,
1389 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001390 linux_glibc_x86_64: {
1391 enabled: true,
1392 },
1393 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001394 enabled: true,
1395 },
1396 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001397}
1398`),
1399 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001400myinclude/Test.h -> include/myinclude/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001401.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001402.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
1403.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
1404.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 +00001405.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001406.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
1407.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
1408.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 +00001409`),
1410 )
1411}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001412
Paul Duffina04c1072020-03-02 10:16:35 +00001413func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001414 result := testSdkWithCc(t, `
1415 sdk {
1416 name: "mysdk",
1417 device_supported: false,
1418 host_supported: true,
1419 native_shared_libs: ["mynativelib"],
1420 target: {
1421 windows: {
1422 enabled: true,
1423 },
1424 },
1425 }
1426
1427 cc_library_shared {
1428 name: "mynativelib",
1429 device_supported: false,
1430 host_supported: true,
1431 srcs: [
1432 "Test.cpp",
1433 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001434 stl: "none",
1435 target: {
1436 windows: {
1437 enabled: true,
1438 },
1439 },
1440 }
1441 `)
1442
Paul Duffin36474d32021-03-12 12:19:43 +00001443 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001444 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00001445// This is auto-generated. DO NOT EDIT.
1446
1447cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001448 name: "mynativelib",
1449 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001450 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001451 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001452 device_supported: false,
1453 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001454 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001455 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001456 host: {
1457 enabled: false,
1458 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001459 linux_glibc: {
1460 compile_multilib: "both",
1461 },
Paul Duffina04c1072020-03-02 10:16:35 +00001462 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001463 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001464 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1465 },
1466 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001467 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001468 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1469 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001470 windows: {
1471 compile_multilib: "64",
1472 },
Paul Duffina04c1072020-03-02 10:16:35 +00001473 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001474 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001475 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1476 },
1477 },
Paul Duffina04c1072020-03-02 10:16:35 +00001478}
Paul Duffin75b902a2021-02-22 12:13:13 +00001479`),
1480 checkVersionedAndroidBpContents(`
1481// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00001482
1483cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001484 name: "mysdk_mynativelib@current",
1485 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001486 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001487 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001488 device_supported: false,
1489 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001490 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001491 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001492 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001493 host: {
1494 enabled: false,
1495 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001496 linux_glibc: {
1497 compile_multilib: "both",
1498 },
Paul Duffina04c1072020-03-02 10:16:35 +00001499 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001500 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001501 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1502 },
1503 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001504 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001505 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1506 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001507 windows: {
1508 compile_multilib: "64",
1509 },
Paul Duffina04c1072020-03-02 10:16:35 +00001510 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001511 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001512 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1513 },
1514 },
Paul Duffina04c1072020-03-02 10:16:35 +00001515}
1516
1517sdk_snapshot {
1518 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001519 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001520 device_supported: false,
1521 host_supported: true,
1522 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001523 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001524 windows: {
1525 compile_multilib: "64",
1526 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001527 host: {
1528 enabled: false,
1529 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001530 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001531 enabled: true,
1532 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001533 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001534 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +09001535 },
1536 windows_x86_64: {
1537 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001538 },
1539 },
Paul Duffina04c1072020-03-02 10:16:35 +00001540}
1541`),
1542 checkAllCopyRules(`
1543.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1544.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1545.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1546`),
1547 )
1548}
1549
Paul Duffin9ab556f2019-12-11 18:42:17 +00001550func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1551 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001552 module_exports {
1553 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001554 native_static_libs: ["mynativelib"],
1555 }
1556
1557 cc_library_static {
1558 name: "mynativelib",
1559 srcs: [
1560 "Test.cpp",
1561 "aidl/foo/bar/Test.aidl",
1562 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001563 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001564 aidl: {
1565 export_aidl_headers: true,
1566 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001567 stl: "none",
1568 }
1569 `)
1570
Paul Duffin36474d32021-03-12 12:19:43 +00001571 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001572 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001573// This is auto-generated. DO NOT EDIT.
1574
1575cc_prebuilt_library_static {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001576 name: "mynativelib",
1577 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001578 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001579 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001580 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001581 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001582 export_include_dirs: ["include/myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001583 arch: {
1584 arm64: {
1585 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001586 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001587 },
1588 arm: {
1589 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001590 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001591 },
1592 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001593}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001594`),
1595 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001596myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001597.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001598.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
1599.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
1600.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 -08001601.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001602.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
1603.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
1604.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 +00001605`),
1606 )
1607}
1608
1609func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001610 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001611 module_exports {
1612 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001613 device_supported: false,
1614 host_supported: true,
1615 native_static_libs: ["mynativelib"],
1616 }
1617
1618 cc_library_static {
1619 name: "mynativelib",
1620 device_supported: false,
1621 host_supported: true,
1622 srcs: [
1623 "Test.cpp",
1624 "aidl/foo/bar/Test.aidl",
1625 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001626 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001627 aidl: {
1628 export_aidl_headers: true,
1629 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001630 stl: "none",
1631 }
1632 `)
1633
Paul Duffin36474d32021-03-12 12:19:43 +00001634 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001635 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001636// This is auto-generated. DO NOT EDIT.
1637
1638cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001639 name: "mynativelib",
1640 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001641 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001642 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001643 device_supported: false,
1644 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001645 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001646 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001647 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001648 target: {
1649 host: {
1650 enabled: false,
1651 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001652 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001653 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001654 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001655 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001656 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001657 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001658 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001659 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001660 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001661 },
1662 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001663}
Paul Duffin75b902a2021-02-22 12:13:13 +00001664`),
1665 checkVersionedAndroidBpContents(`
1666// This is auto-generated. DO NOT EDIT.
Paul Duffin9ab556f2019-12-11 18:42:17 +00001667
1668cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001669 name: "myexports_mynativelib@current",
1670 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001671 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001672 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001673 device_supported: false,
1674 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001675 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001676 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001677 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001678 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001679 target: {
1680 host: {
1681 enabled: false,
1682 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001683 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001684 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001685 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001686 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001687 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001688 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001689 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001690 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001691 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001692 },
1693 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001694}
1695
Paul Duffine6029182019-12-16 17:43:48 +00001696module_exports_snapshot {
1697 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001698 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001699 device_supported: false,
1700 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001701 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001702 target: {
1703 host: {
1704 enabled: false,
1705 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001706 linux_glibc_x86_64: {
1707 enabled: true,
1708 },
1709 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001710 enabled: true,
1711 },
1712 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001713}
1714`),
1715 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001716myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001717.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001718.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
1719.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
1720.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 +00001721.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001722.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
1723.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
1724.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 +00001725`),
1726 )
1727}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001728
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001729func TestSnapshotWithCcLibrary(t *testing.T) {
1730 result := testSdkWithCc(t, `
1731 module_exports {
1732 name: "myexports",
1733 native_libs: ["mynativelib"],
1734 }
1735
1736 cc_library {
1737 name: "mynativelib",
1738 srcs: [
1739 "Test.cpp",
1740 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001741 export_include_dirs: ["myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001742 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001743 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001744 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001745 }
1746 `)
1747
Paul Duffin36474d32021-03-12 12:19:43 +00001748 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001749 checkUnversionedAndroidBpContents(`
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001750// This is auto-generated. DO NOT EDIT.
1751
1752cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001753 name: "mynativelib",
1754 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001755 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001756 apex_available: ["//apex_available:platform"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001757 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001758 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001759 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001760 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001761 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001762 arch: {
1763 arm64: {
1764 static: {
1765 srcs: ["arm64/lib/mynativelib.a"],
1766 },
1767 shared: {
1768 srcs: ["arm64/lib/mynativelib.so"],
1769 },
1770 },
1771 arm: {
1772 static: {
1773 srcs: ["arm/lib/mynativelib.a"],
1774 },
1775 shared: {
1776 srcs: ["arm/lib/mynativelib.so"],
1777 },
1778 },
1779 },
1780}
Paul Duffin75b902a2021-02-22 12:13:13 +00001781`),
1782 // Make sure that the generated sdk_snapshot uses the native_libs property.
1783 checkVersionedAndroidBpContents(`
1784// This is auto-generated. DO NOT EDIT.
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001785
1786cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001787 name: "myexports_mynativelib@current",
1788 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001789 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001790 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +00001791 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001792 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001793 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001794 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001795 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001796 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001797 arch: {
1798 arm64: {
1799 static: {
1800 srcs: ["arm64/lib/mynativelib.a"],
1801 },
1802 shared: {
1803 srcs: ["arm64/lib/mynativelib.so"],
1804 },
1805 },
1806 arm: {
1807 static: {
1808 srcs: ["arm/lib/mynativelib.a"],
1809 },
1810 shared: {
1811 srcs: ["arm/lib/mynativelib.so"],
1812 },
1813 },
1814 },
1815}
1816
1817module_exports_snapshot {
1818 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001819 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001820 native_libs: ["myexports_mynativelib@current"],
1821}
1822`),
1823 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001824myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001825.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1826.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1827.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
Paul Duffin1822a0a2021-03-21 12:56:33 +00001828.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1829`),
1830 // TODO(b/183315522): Remove this and fix the issue.
1831 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\Qunrecognized property "arch.arm.shared.export_include_dirs"\E`)),
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001832 )
1833}
1834
Paul Duffin13ad94f2020-02-19 16:19:27 +00001835func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001836 result := testSdkWithCc(t, `
1837 module_exports {
1838 name: "myexports",
1839 device_supported: false,
1840 host_supported: true,
1841 target: {
1842 host: {
1843 compile_multilib: "64",
1844 },
1845 },
1846 native_static_libs: ["mynativelib"],
1847 }
1848
1849 cc_library_static {
1850 name: "mynativelib",
1851 device_supported: false,
1852 host_supported: true,
1853 srcs: [
1854 "Test.cpp",
1855 "aidl/foo/bar/Test.aidl",
1856 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001857 export_include_dirs: ["myinclude"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001858 aidl: {
1859 export_aidl_headers: true,
1860 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001861 stl: "none",
1862 }
1863 `)
1864
Paul Duffin36474d32021-03-12 12:19:43 +00001865 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001866 checkUnversionedAndroidBpContents(`
Paul Duffin13ad94f2020-02-19 16:19:27 +00001867// This is auto-generated. DO NOT EDIT.
1868
1869cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001870 name: "mynativelib",
1871 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001872 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001873 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001874 device_supported: false,
1875 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001876 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001877 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001878 export_include_dirs: [
1879 "include/myinclude",
1880 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1881 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001882 target: {
1883 host: {
1884 enabled: false,
1885 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001886 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001887 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001888 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001889 },
1890 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001891}
Paul Duffin75b902a2021-02-22 12:13:13 +00001892`),
1893 checkVersionedAndroidBpContents(`
1894// This is auto-generated. DO NOT EDIT.
Paul Duffin13ad94f2020-02-19 16:19:27 +00001895
1896cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001897 name: "myexports_mynativelib@current",
1898 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001899 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001900 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001901 device_supported: false,
1902 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001903 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001904 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001905 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001906 export_include_dirs: [
1907 "include/myinclude",
1908 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1909 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001910 target: {
1911 host: {
1912 enabled: false,
1913 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001914 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001915 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001916 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001917 },
1918 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001919}
1920
1921module_exports_snapshot {
1922 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001923 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001924 device_supported: false,
1925 host_supported: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001926 compile_multilib: "64",
Paul Duffin7b0259f2021-04-24 11:34:46 +01001927 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001928 target: {
1929 host: {
1930 enabled: false,
1931 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001932 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001933 enabled: true,
1934 },
1935 },
Paul Duffin75b902a2021-02-22 12:13:13 +00001936}
1937`),
Paul Duffin13ad94f2020-02-19 16:19:27 +00001938 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001939myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin7a7d0672021-02-17 12:17:40 +00001940.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
1941.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
1942.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 +00001943.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin13ad94f2020-02-19 16:19:27 +00001944`),
1945 )
1946}
Paul Duffin91756d22020-02-21 16:29:57 +00001947
1948func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1949 result := testSdkWithCc(t, `
1950 sdk {
1951 name: "mysdk",
1952 native_header_libs: ["mynativeheaders"],
1953 }
1954
1955 cc_library_headers {
1956 name: "mynativeheaders",
Paul Duffin86b02a72021-02-22 11:50:04 +00001957 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001958 stl: "none",
1959 }
1960 `)
1961
Paul Duffin36474d32021-03-12 12:19:43 +00001962 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001963 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001964// This is auto-generated. DO NOT EDIT.
1965
1966cc_prebuilt_library_headers {
Paul Duffin91756d22020-02-21 16:29:57 +00001967 name: "mynativeheaders",
1968 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001969 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001970 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00001971 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001972 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001973 export_include_dirs: ["include/myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001974}
Paul Duffin91756d22020-02-21 16:29:57 +00001975`),
1976 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001977myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00001978`),
1979 )
1980}
1981
1982func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001983 result := testSdkWithCc(t, `
1984 sdk {
1985 name: "mysdk",
1986 device_supported: false,
1987 host_supported: true,
1988 native_header_libs: ["mynativeheaders"],
1989 }
1990
1991 cc_library_headers {
1992 name: "mynativeheaders",
1993 device_supported: false,
1994 host_supported: true,
Paul Duffin86b02a72021-02-22 11:50:04 +00001995 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001996 stl: "none",
1997 }
1998 `)
1999
Paul Duffin36474d32021-03-12 12:19:43 +00002000 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002001 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00002002// This is auto-generated. DO NOT EDIT.
2003
2004cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002005 name: "mynativeheaders",
2006 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002007 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002008 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002009 device_supported: false,
2010 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002011 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002012 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002013 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002014 target: {
2015 host: {
2016 enabled: false,
2017 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002018 linux_glibc_x86_64: {
2019 enabled: true,
2020 },
2021 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002022 enabled: true,
2023 },
2024 },
Paul Duffin91756d22020-02-21 16:29:57 +00002025}
Paul Duffin75b902a2021-02-22 12:13:13 +00002026`),
2027 checkVersionedAndroidBpContents(`
2028// This is auto-generated. DO NOT EDIT.
Paul Duffin91756d22020-02-21 16:29:57 +00002029
2030cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002031 name: "mysdk_mynativeheaders@current",
2032 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002033 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002034 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002035 device_supported: false,
2036 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002037 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002038 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002039 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002040 target: {
2041 host: {
2042 enabled: false,
2043 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002044 linux_glibc_x86_64: {
2045 enabled: true,
2046 },
2047 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002048 enabled: true,
2049 },
2050 },
Paul Duffin91756d22020-02-21 16:29:57 +00002051}
2052
2053sdk_snapshot {
2054 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002055 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002056 device_supported: false,
2057 host_supported: true,
2058 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002059 target: {
2060 host: {
2061 enabled: false,
2062 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002063 linux_glibc_x86_64: {
2064 enabled: true,
2065 },
2066 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002067 enabled: true,
2068 },
2069 },
Paul Duffin91756d22020-02-21 16:29:57 +00002070}
2071`),
2072 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002073myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00002074`),
2075 )
2076}
Paul Duffina04c1072020-03-02 10:16:35 +00002077
2078func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00002079 result := testSdkWithCc(t, `
2080 sdk {
2081 name: "mysdk",
2082 host_supported: true,
2083 native_header_libs: ["mynativeheaders"],
2084 }
2085
2086 cc_library_headers {
2087 name: "mynativeheaders",
2088 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002089 stl: "none",
Paul Duffin86b02a72021-02-22 11:50:04 +00002090 export_system_include_dirs: ["myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002091 target: {
2092 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002093 export_include_dirs: ["myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002094 },
2095 host: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002096 export_include_dirs: ["myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002097 },
2098 },
2099 }
2100 `)
2101
Paul Duffin36474d32021-03-12 12:19:43 +00002102 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002103 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00002104// This is auto-generated. DO NOT EDIT.
2105
2106cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002107 name: "mynativeheaders",
2108 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002109 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002110 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002111 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002112 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002113 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002114 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002115 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002116 host: {
2117 enabled: false,
2118 },
Paul Duffina04c1072020-03-02 10:16:35 +00002119 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002120 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002121 },
2122 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002123 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002124 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002125 linux_glibc_x86_64: {
2126 enabled: true,
2127 },
2128 linux_glibc_x86: {
2129 enabled: true,
2130 },
Paul Duffina04c1072020-03-02 10:16:35 +00002131 },
Paul Duffina04c1072020-03-02 10:16:35 +00002132}
Paul Duffin75b902a2021-02-22 12:13:13 +00002133`),
Paul Duffin75b902a2021-02-22 12:13:13 +00002134 checkVersionedAndroidBpContents(`
2135// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00002136
2137cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002138 name: "mysdk_mynativeheaders@current",
2139 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002140 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002141 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002142 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002143 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002144 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002145 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002146 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002147 host: {
2148 enabled: false,
2149 },
Paul Duffina04c1072020-03-02 10:16:35 +00002150 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002151 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002152 },
2153 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002154 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002155 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002156 linux_glibc_x86_64: {
2157 enabled: true,
2158 },
2159 linux_glibc_x86: {
2160 enabled: true,
2161 },
Paul Duffina04c1072020-03-02 10:16:35 +00002162 },
Paul Duffina04c1072020-03-02 10:16:35 +00002163}
2164
2165sdk_snapshot {
2166 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002167 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002168 host_supported: true,
2169 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002170 target: {
2171 host: {
2172 enabled: false,
2173 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002174 linux_glibc_x86_64: {
2175 enabled: true,
2176 },
2177 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002178 enabled: true,
2179 },
2180 },
Paul Duffina04c1072020-03-02 10:16:35 +00002181}
2182`),
2183 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002184myinclude/Test.h -> common_os/include/myinclude/Test.h
2185myinclude-android/AndroidTest.h -> android/include/myinclude-android/AndroidTest.h
2186myinclude-host/HostTest.h -> linux_glibc/include/myinclude-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002187`),
2188 )
2189}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002190
2191func TestSystemSharedLibPropagation(t *testing.T) {
2192 result := testSdkWithCc(t, `
2193 sdk {
2194 name: "mysdk",
Colin Cross6b8f4252021-07-22 11:39:44 -07002195 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002196 }
2197
2198 cc_library {
2199 name: "sslnil",
2200 host_supported: true,
2201 }
2202
2203 cc_library {
2204 name: "sslempty",
2205 system_shared_libs: [],
2206 }
2207
2208 cc_library {
2209 name: "sslnonempty",
2210 system_shared_libs: ["sslnil"],
2211 }
2212 `)
2213
Paul Duffin36474d32021-03-12 12:19:43 +00002214 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002215 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002216// This is auto-generated. DO NOT EDIT.
2217
2218cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002219 name: "sslnil",
2220 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002221 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002222 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002223 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002224 arch: {
2225 arm64: {
2226 srcs: ["arm64/lib/sslnil.so"],
2227 },
2228 arm: {
2229 srcs: ["arm/lib/sslnil.so"],
2230 },
2231 },
2232}
2233
2234cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002235 name: "sslempty",
2236 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002237 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002238 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002239 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002240 system_shared_libs: [],
2241 arch: {
2242 arm64: {
2243 srcs: ["arm64/lib/sslempty.so"],
2244 },
2245 arm: {
2246 srcs: ["arm/lib/sslempty.so"],
2247 },
2248 },
2249}
2250
2251cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002252 name: "sslnonempty",
2253 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002254 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002255 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002256 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002257 system_shared_libs: ["sslnil"],
2258 arch: {
2259 arm64: {
2260 srcs: ["arm64/lib/sslnonempty.so"],
2261 },
2262 arm: {
2263 srcs: ["arm/lib/sslnonempty.so"],
2264 },
2265 },
2266}
Colin Cross6b8f4252021-07-22 11:39:44 -07002267`))
Martin Stjernholm10566a02020-03-24 01:19:52 +00002268
2269 result = testSdkWithCc(t, `
2270 sdk {
2271 name: "mysdk",
2272 host_supported: true,
Colin Cross6b8f4252021-07-22 11:39:44 -07002273 native_shared_libs: ["sslvariants"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002274 }
2275
2276 cc_library {
2277 name: "sslvariants",
2278 host_supported: true,
2279 target: {
2280 android: {
2281 system_shared_libs: [],
2282 },
2283 },
2284 }
2285 `)
2286
Paul Duffin36474d32021-03-12 12:19:43 +00002287 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002288 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002289// This is auto-generated. DO NOT EDIT.
2290
2291cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002292 name: "sslvariants",
2293 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002294 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002295 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002296 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002297 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002298 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002299 host: {
2300 enabled: false,
2301 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002302 android: {
2303 system_shared_libs: [],
2304 },
2305 android_arm64: {
2306 srcs: ["android/arm64/lib/sslvariants.so"],
2307 },
2308 android_arm: {
2309 srcs: ["android/arm/lib/sslvariants.so"],
2310 },
2311 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002312 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002313 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2314 },
2315 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002316 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002317 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2318 },
2319 },
2320}
Paul Duffin75b902a2021-02-22 12:13:13 +00002321`),
2322 checkVersionedAndroidBpContents(`
2323// This is auto-generated. DO NOT EDIT.
Martin Stjernholm10566a02020-03-24 01:19:52 +00002324
2325cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002326 name: "mysdk_sslvariants@current",
2327 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002328 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002329 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002330 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002331 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002332 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002333 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002334 host: {
2335 enabled: false,
2336 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002337 android: {
2338 system_shared_libs: [],
2339 },
2340 android_arm64: {
2341 srcs: ["android/arm64/lib/sslvariants.so"],
2342 },
2343 android_arm: {
2344 srcs: ["android/arm/lib/sslvariants.so"],
2345 },
2346 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002347 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002348 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2349 },
2350 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002351 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002352 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2353 },
2354 },
2355}
2356
2357sdk_snapshot {
2358 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002359 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002360 host_supported: true,
Colin Cross6b8f4252021-07-22 11:39:44 -07002361 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002362 target: {
2363 host: {
2364 enabled: false,
2365 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002366 linux_glibc_x86_64: {
2367 enabled: true,
2368 },
2369 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002370 enabled: true,
2371 },
2372 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002373}
2374`))
2375}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002376
2377func TestStubsLibrary(t *testing.T) {
2378 result := testSdkWithCc(t, `
2379 sdk {
2380 name: "mysdk",
2381 native_shared_libs: ["stubslib"],
2382 }
2383
2384 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002385 name: "internaldep",
2386 }
2387
2388 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002389 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002390 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002391 stubs: {
2392 symbol_file: "some/where/stubslib.map.txt",
2393 versions: ["1", "2", "3"],
2394 },
2395 }
2396 `)
2397
Paul Duffin36474d32021-03-12 12:19:43 +00002398 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002399 checkUnversionedAndroidBpContents(`
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002400// This is auto-generated. DO NOT EDIT.
2401
2402cc_prebuilt_library_shared {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002403 name: "stubslib",
2404 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002405 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002406 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002407 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002408 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002409 versions: [
2410 "1",
2411 "2",
2412 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002413 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002414 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002415 },
2416 arch: {
2417 arm64: {
2418 srcs: ["arm64/lib/stubslib.so"],
2419 },
2420 arm: {
2421 srcs: ["arm/lib/stubslib.so"],
2422 },
2423 },
2424}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002425`))
2426}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002427
2428func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002429 result := testSdkWithCc(t, `
2430 sdk {
2431 name: "mysdk",
2432 host_supported: true,
2433 native_shared_libs: ["stubslib"],
2434 }
2435
2436 cc_library {
2437 name: "internaldep",
2438 host_supported: true,
2439 }
2440
2441 cc_library {
2442 name: "stubslib",
2443 host_supported: true,
2444 shared_libs: ["internaldep"],
2445 stubs: {
2446 symbol_file: "some/where/stubslib.map.txt",
2447 versions: ["1", "2", "3"],
2448 },
2449 }
2450 `)
2451
Paul Duffin36474d32021-03-12 12:19:43 +00002452 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002453 checkUnversionedAndroidBpContents(`
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002454// This is auto-generated. DO NOT EDIT.
2455
2456cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002457 name: "stubslib",
2458 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002459 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002460 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002461 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002462 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002463 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002464 versions: [
2465 "1",
2466 "2",
2467 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002468 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002469 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002470 },
2471 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002472 host: {
2473 enabled: false,
2474 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002475 android_arm64: {
2476 srcs: ["android/arm64/lib/stubslib.so"],
2477 },
2478 android_arm: {
2479 srcs: ["android/arm/lib/stubslib.so"],
2480 },
2481 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002482 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002483 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2484 },
2485 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002486 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002487 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2488 },
2489 },
2490}
Paul Duffin75b902a2021-02-22 12:13:13 +00002491`),
2492 checkVersionedAndroidBpContents(`
2493// This is auto-generated. DO NOT EDIT.
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002494
2495cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002496 name: "mysdk_stubslib@current",
2497 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002498 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002499 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002500 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002501 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002502 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002503 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002504 versions: [
2505 "1",
2506 "2",
2507 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002508 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002509 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002510 },
2511 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002512 host: {
2513 enabled: false,
2514 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002515 android_arm64: {
2516 srcs: ["android/arm64/lib/stubslib.so"],
2517 },
2518 android_arm: {
2519 srcs: ["android/arm/lib/stubslib.so"],
2520 },
2521 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002522 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002523 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2524 },
2525 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002526 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002527 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2528 },
2529 },
2530}
2531
2532sdk_snapshot {
2533 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002534 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002535 host_supported: true,
2536 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002537 target: {
2538 host: {
2539 enabled: false,
2540 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002541 linux_glibc_x86_64: {
2542 enabled: true,
2543 },
2544 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002545 enabled: true,
2546 },
2547 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002548}
2549`))
2550}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002551
2552func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002553 result := testSdkWithCc(t, `
2554 sdk {
2555 name: "mysdk",
2556 host_supported: true,
2557 native_shared_libs: ["mylib"],
2558 }
2559
2560 cc_library {
2561 name: "mylib",
2562 host_supported: true,
2563 unique_host_soname: true,
2564 }
2565 `)
2566
Paul Duffin36474d32021-03-12 12:19:43 +00002567 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002568 checkUnversionedAndroidBpContents(`
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002569// This is auto-generated. DO NOT EDIT.
2570
2571cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002572 name: "mylib",
2573 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002574 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002575 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002576 host_supported: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002577 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002578 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002579 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002580 host: {
2581 enabled: false,
2582 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002583 android_arm64: {
2584 srcs: ["android/arm64/lib/mylib.so"],
2585 },
2586 android_arm: {
2587 srcs: ["android/arm/lib/mylib.so"],
2588 },
2589 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002590 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002591 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2592 },
2593 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002594 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002595 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2596 },
2597 },
2598}
Paul Duffin75b902a2021-02-22 12:13:13 +00002599`),
2600 checkVersionedAndroidBpContents(`
2601// This is auto-generated. DO NOT EDIT.
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002602
2603cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002604 name: "mysdk_mylib@current",
2605 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002606 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002607 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002608 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002609 installable: false,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002610 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002611 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002612 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002613 host: {
2614 enabled: false,
2615 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002616 android_arm64: {
2617 srcs: ["android/arm64/lib/mylib.so"],
2618 },
2619 android_arm: {
2620 srcs: ["android/arm/lib/mylib.so"],
2621 },
2622 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002623 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002624 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2625 },
2626 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002627 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002628 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2629 },
2630 },
2631}
2632
2633sdk_snapshot {
2634 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002635 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002636 host_supported: true,
2637 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002638 target: {
2639 host: {
2640 enabled: false,
2641 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002642 linux_glibc_x86_64: {
2643 enabled: true,
2644 },
2645 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002646 enabled: true,
2647 },
2648 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002649}
2650`),
2651 checkAllCopyRules(`
2652.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2653.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2654.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2655.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2656`),
2657 )
2658}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002659
2660func TestNoSanitizerMembers(t *testing.T) {
2661 result := testSdkWithCc(t, `
2662 sdk {
2663 name: "mysdk",
2664 native_shared_libs: ["mynativelib"],
2665 }
2666
2667 cc_library_shared {
2668 name: "mynativelib",
2669 srcs: ["Test.cpp"],
Paul Duffin86b02a72021-02-22 11:50:04 +00002670 export_include_dirs: ["myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002671 arch: {
2672 arm64: {
2673 export_system_include_dirs: ["arm64/include"],
2674 sanitize: {
2675 hwaddress: true,
2676 },
2677 },
2678 },
2679 }
2680 `)
2681
Paul Duffin1822a0a2021-03-21 12:56:33 +00002682 // Mixing the snapshot with the source (irrespective of which one is preferred) causes a problem
2683 // due to missing variants.
2684 // TODO(b/183204176): Remove this and fix the cause.
2685 snapshotWithSourceErrorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QReplaceDependencies could not find identical variant {os:android,image:,arch:arm64_armv8-a,sdk:,link:shared,version:} for module mynativelib\E`)
2686
Paul Duffin36474d32021-03-12 12:19:43 +00002687 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002688 checkUnversionedAndroidBpContents(`
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002689// This is auto-generated. DO NOT EDIT.
2690
2691cc_prebuilt_library_shared {
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002692 name: "mynativelib",
2693 prefer: false,
2694 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002695 apex_available: ["//apex_available:platform"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002696 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002697 export_include_dirs: ["include/myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002698 arch: {
2699 arm64: {
2700 export_system_include_dirs: ["arm64/include/arm64/include"],
2701 },
2702 arm: {
2703 srcs: ["arm/lib/mynativelib.so"],
2704 },
2705 },
2706}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002707`),
2708 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002709myinclude/Test.h -> include/myinclude/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002710arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Paul Duffin1822a0a2021-03-21 12:56:33 +00002711.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
2712`),
2713 snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, snapshotWithSourceErrorHandler),
2714 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, snapshotWithSourceErrorHandler),
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002715 )
2716}