blob: 571d21420b86c1527ad9e281cc9d1e1a22395e75 [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 (
Paul Duffin63696222021-09-06 10:28:34 +010018 "fmt"
Paul Duffina80fdec2019-12-03 15:25:00 +000019 "testing"
20
Paul Duffin1356d8c2020-02-25 19:26:33 +000021 "android/soong/android"
Paul Duffina80fdec2019-12-03 15:25:00 +000022 "android/soong/cc"
23)
24
Paul Duffin4a2a29c2021-03-09 22:27:13 +000025var ccTestFs = android.MockFS{
Paul Duffin86b02a72021-02-22 11:50:04 +000026 "Test.cpp": nil,
27 "myinclude/Test.h": nil,
28 "myinclude-android/AndroidTest.h": nil,
29 "myinclude-host/HostTest.h": nil,
30 "arm64/include/Arm64Test.h": nil,
31 "libfoo.so": nil,
32 "aidl/foo/bar/Test.aidl": nil,
33 "some/where/stubslib.map.txt": nil,
Martin Stjernholm7feceb22020-07-11 04:33:29 +010034}
35
Paul Duffin93b750e2019-11-19 19:44:10 +000036// Adds a native bridge target to the configured list of targets.
37var prepareForTestWithNativeBridgeTarget = android.FixtureModifyConfig(func(config android.Config) {
38 config.Targets[android.Android] = append(config.Targets[android.Android], android.Target{
39 Os: android.Android,
40 Arch: android.Arch{
41 ArchType: android.Arm64,
42 ArchVariant: "armv8-a",
43 CpuVariant: "cpu",
44 Abi: nil,
45 ArchFeatures: nil,
46 },
47 NativeBridge: android.NativeBridgeEnabled,
48 NativeBridgeHostArchName: "x86_64",
49 NativeBridgeRelativePath: "native_bridge",
50 })
51})
52
Paul Duffin4a2a29c2021-03-09 22:27:13 +000053func testSdkWithCc(t *testing.T, bp string) *android.TestResult {
Paul Duffind835daa2019-11-30 17:49:09 +000054 t.Helper()
Martin Stjernholm7feceb22020-07-11 04:33:29 +010055 return testSdkWithFs(t, bp, ccTestFs)
Paul Duffind835daa2019-11-30 17:49:09 +000056}
57
Paul Duffina80fdec2019-12-03 15:25:00 +000058// Contains tests for SDK members provided by the cc package.
59
Martin Stjernholmcaa47d72020-07-11 04:52:24 +010060func TestSingleDeviceOsAssumption(t *testing.T) {
61 // Mock a module with DeviceSupported() == true.
62 s := &sdk{}
63 android.InitAndroidArchModule(s, android.DeviceSupported, android.MultilibCommon)
64
65 osTypes := s.getPossibleOsTypes()
66 if len(osTypes) != 1 {
67 // The snapshot generation assumes there is a single device OS. If more are
68 // added it might need to disable them by default, like it does for host
69 // OS'es.
70 t.Errorf("expected a single device OS, got %v", osTypes)
71 }
72}
73
Paul Duffina80fdec2019-12-03 15:25:00 +000074func TestSdkIsCompileMultilibBoth(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +000075 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000076 sdk {
77 name: "mysdk",
78 native_shared_libs: ["sdkmember"],
79 }
80
81 cc_library_shared {
82 name: "sdkmember",
83 srcs: ["Test.cpp"],
Paul Duffina80fdec2019-12-03 15:25:00 +000084 stl: "none",
85 }
86 `)
87
Colin Cross7113d202019-11-20 16:39:12 -080088 armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile()
89 arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile()
Paul Duffina80fdec2019-12-03 15:25:00 +000090
91 var inputs []string
Paul Duffin1356d8c2020-02-25 19:26:33 +000092 buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests()
Paul Duffina80fdec2019-12-03 15:25:00 +000093 for _, bp := range buildParams {
94 if bp.Input != nil {
95 inputs = append(inputs, bp.Input.String())
96 }
97 }
98
99 // ensure that both 32/64 outputs are inputs of the sdk snapshot
100 ensureListContains(t, inputs, armOutput.String())
101 ensureListContains(t, inputs, arm64Output.String())
102}
103
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100104func TestSdkCompileMultilibOverride(t *testing.T) {
105 result := testSdkWithCc(t, `
106 sdk {
107 name: "mysdk",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100108 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100109 native_shared_libs: ["sdkmember"],
110 compile_multilib: "64",
111 }
112
113 cc_library_shared {
114 name: "sdkmember",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100115 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100116 srcs: ["Test.cpp"],
117 stl: "none",
118 compile_multilib: "64",
119 }
120 `)
121
Paul Duffin36474d32021-03-12 12:19:43 +0000122 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000123 checkUnversionedAndroidBpContents(`
Martin Stjernholm89238f42020-07-10 00:14:03 +0100124// This is auto-generated. DO NOT EDIT.
125
126cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +0000127 name: "sdkmember",
128 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100129 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000130 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100131 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +0100132 stl: "none",
133 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100134 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100135 host: {
136 enabled: false,
137 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100138 android_arm64: {
139 srcs: ["android/arm64/lib/sdkmember.so"],
140 },
141 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900142 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100143 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100144 },
145 },
146}
Paul Duffin75b902a2021-02-22 12:13:13 +0000147`),
148 checkVersionedAndroidBpContents(`
149// This is auto-generated. DO NOT EDIT.
Martin Stjernholm89238f42020-07-10 00:14:03 +0100150
151cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +0000152 name: "mysdk_sdkmember@current",
153 sdk_member_name: "sdkmember",
Paul Duffind99d9972020-09-29 16:00:55 +0100154 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000155 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100156 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +0000157 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +0100158 stl: "none",
159 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100160 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100161 host: {
162 enabled: false,
163 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100164 android_arm64: {
165 srcs: ["android/arm64/lib/sdkmember.so"],
166 },
167 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900168 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100169 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100170 },
171 },
172}
173
174sdk_snapshot {
175 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100176 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100177 host_supported: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100178 compile_multilib: "64",
Paul Duffin7b0259f2021-04-24 11:34:46 +0100179 native_shared_libs: ["mysdk_sdkmember@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100180 target: {
181 host: {
182 enabled: false,
183 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900184 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100185 enabled: true,
186 },
187 },
Martin Stjernholm89238f42020-07-10 00:14:03 +0100188}
189`),
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100190 checkAllCopyRules(`
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100191.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
192.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100193`))
194}
195
Paul Duffina0843f62019-12-13 19:50:38 +0000196// Make sure the sdk can use host specific cc libraries static/shared and both.
197func TestHostSdkWithCc(t *testing.T) {
198 testSdkWithCc(t, `
199 sdk {
200 name: "mysdk",
201 device_supported: false,
202 host_supported: true,
203 native_shared_libs: ["sdkshared"],
204 native_static_libs: ["sdkstatic"],
205 }
206
207 cc_library_host_shared {
208 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000209 stl: "none",
210 }
211
212 cc_library_host_static {
213 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000214 stl: "none",
215 }
216 `)
217}
218
219// Make sure the sdk can use cc libraries static/shared and both.
220func TestSdkWithCc(t *testing.T) {
221 testSdkWithCc(t, `
222 sdk {
223 name: "mysdk",
224 native_shared_libs: ["sdkshared", "sdkboth1"],
225 native_static_libs: ["sdkstatic", "sdkboth2"],
226 }
227
228 cc_library_shared {
229 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000230 stl: "none",
231 }
232
233 cc_library_static {
234 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000235 stl: "none",
236 }
237
238 cc_library {
239 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000240 stl: "none",
241 }
242
243 cc_library {
244 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000245 stl: "none",
246 }
247 `)
248}
249
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000250func TestSnapshotWithObject(t *testing.T) {
251 result := testSdkWithCc(t, `
252 sdk {
253 name: "mysdk",
254 native_objects: ["crtobj"],
255 }
256
257 cc_object {
258 name: "crtobj",
259 stl: "none",
Colin Cross6b8f4252021-07-22 11:39:44 -0700260 system_shared_libs: [],
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100261 sanitize: {
262 never: true,
263 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000264 }
265 `)
266
Paul Duffin36474d32021-03-12 12:19:43 +0000267 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000268 checkUnversionedAndroidBpContents(`
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000269// This is auto-generated. DO NOT EDIT.
270
271cc_prebuilt_object {
Paul Duffin75b902a2021-02-22 12:13:13 +0000272 name: "crtobj",
273 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100274 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000275 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000276 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100277 compile_multilib: "both",
Colin Cross6b8f4252021-07-22 11:39:44 -0700278 system_shared_libs: [],
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100279 sanitize: {
280 never: true,
281 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000282 arch: {
283 arm64: {
284 srcs: ["arm64/lib/crtobj.o"],
285 },
286 arm: {
287 srcs: ["arm/lib/crtobj.o"],
288 },
289 },
290}
Paul Duffin75b902a2021-02-22 12:13:13 +0000291`),
292 // Make sure that the generated sdk_snapshot uses the native_objects property.
293 checkVersionedAndroidBpContents(`
294// This is auto-generated. DO NOT EDIT.
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000295
296cc_prebuilt_object {
Paul Duffin75b902a2021-02-22 12:13:13 +0000297 name: "mysdk_crtobj@current",
298 sdk_member_name: "crtobj",
Paul Duffind99d9972020-09-29 16:00:55 +0100299 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000300 apex_available: ["//apex_available:platform"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000301 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100302 compile_multilib: "both",
Colin Cross6b8f4252021-07-22 11:39:44 -0700303 system_shared_libs: [],
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100304 sanitize: {
305 never: true,
306 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000307 arch: {
308 arm64: {
309 srcs: ["arm64/lib/crtobj.o"],
310 },
311 arm: {
312 srcs: ["arm/lib/crtobj.o"],
313 },
314 },
315}
316
317sdk_snapshot {
318 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100319 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000320 native_objects: ["mysdk_crtobj@current"],
321}
322`),
323 checkAllCopyRules(`
324.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
325.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
326`),
327 )
328}
329
Paul Duffinc62a5102019-12-11 18:34:15 +0000330func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
331 result := testSdkWithCc(t, `
332 sdk {
333 name: "mysdk",
334 native_shared_libs: ["mynativelib1", "mynativelib2"],
335 }
336
337 cc_library_shared {
338 name: "mynativelib1",
339 srcs: [
340 "Test.cpp",
341 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000342 export_include_dirs: ["myinclude"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000343 stl: "none",
344 }
345
346 cc_library_shared {
347 name: "mynativelib2",
348 srcs: [
349 "Test.cpp",
350 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000351 export_include_dirs: ["myinclude"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000352 stl: "none",
353 }
354 `)
355
Paul Duffin36474d32021-03-12 12:19:43 +0000356 CheckSnapshot(t, result, "mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000357 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000358myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800359.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
360.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
361.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
362.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000363`),
364 )
365}
366
Paul Duffina43f9272021-02-17 10:55:25 +0000367func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
368 result := testSdkWithCc(t, `
369 sdk {
370 name: "mysdk",
371 native_shared_libs: ["mynativelib"],
372 }
373
374 cc_library_shared {
375 name: "mynativelib",
376 srcs: [
377 "Test.cpp",
378 ],
379 generated_headers: [
380 "generated_foo",
381 ],
382 export_generated_headers: [
383 "generated_foo",
384 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000385 export_include_dirs: ["myinclude"],
Paul Duffina43f9272021-02-17 10:55:25 +0000386 stl: "none",
387 }
388
389 genrule {
390 name: "generated_foo",
391 cmd: "generate-foo",
392 out: [
393 "generated_foo/protos/foo/bar.h",
394 ],
395 export_include_dirs: [
396 ".",
397 "protos",
398 ],
399 }
400 `)
401
Paul Duffindb462dd2021-03-21 22:01:55 +0000402 // TODO(b/183322862): Remove this and fix the issue.
403 errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module source path "snapshot/include_gen/generated_foo/gen/protos" does not exist`)
404
Paul Duffin36474d32021-03-12 12:19:43 +0000405 CheckSnapshot(t, result, "mysdk", "",
Paul Duffina43f9272021-02-17 10:55:25 +0000406 checkUnversionedAndroidBpContents(`
407// This is auto-generated. DO NOT EDIT.
408
409cc_prebuilt_library_shared {
410 name: "mynativelib",
411 prefer: false,
412 visibility: ["//visibility:public"],
413 apex_available: ["//apex_available:platform"],
414 stl: "none",
415 compile_multilib: "both",
Paul Duffin7a7d0672021-02-17 12:17:40 +0000416 export_include_dirs: [
417 "include/myinclude",
418 "include_gen/generated_foo/gen",
419 "include_gen/generated_foo/gen/protos",
420 ],
Paul Duffina43f9272021-02-17 10:55:25 +0000421 arch: {
422 arm64: {
423 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffina43f9272021-02-17 10:55:25 +0000424 },
425 arm: {
426 srcs: ["arm/lib/mynativelib.so"],
Paul Duffina43f9272021-02-17 10:55:25 +0000427 },
428 },
429}
430`),
431 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000432myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin7a7d0672021-02-17 12:17:40 +0000433.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 +0000434.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina43f9272021-02-17 10:55:25 +0000435.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
Paul Duffina43f9272021-02-17 10:55:25 +0000436`),
Paul Duffindb462dd2021-03-21 22:01:55 +0000437 snapshotTestErrorHandler(checkSnapshotWithoutSource, errorHandler),
438 snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, errorHandler),
439 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, errorHandler),
Paul Duffina43f9272021-02-17 10:55:25 +0000440 )
441}
442
Martin Stjernholmb0249572020-09-15 02:32:35 +0100443// Verify that when the shared library has some common and some arch specific
444// properties that the generated snapshot is optimized properly. Substruct
445// handling is tested with the sanitize clauses (but note there's a lot of
446// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000447func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
448 result := testSdkWithCc(t, `
449 sdk {
450 name: "mysdk",
451 native_shared_libs: ["mynativelib"],
452 }
453
454 cc_library_shared {
455 name: "mynativelib",
456 srcs: [
457 "Test.cpp",
458 "aidl/foo/bar/Test.aidl",
459 ],
Paul Duffin86b02a72021-02-22 11:50:04 +0000460 export_include_dirs: ["myinclude"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100461 sanitize: {
462 fuzzer: false,
463 integer_overflow: true,
464 diag: { undefined: false },
465 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000466 arch: {
467 arm64: {
468 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100469 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100470 integer_overflow: false,
471 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000472 },
473 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000474 stl: "none",
475 }
476 `)
477
Paul Duffin36474d32021-03-12 12:19:43 +0000478 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000479 checkUnversionedAndroidBpContents(`
Paul Duffina7cd8c82019-12-11 20:00:57 +0000480// This is auto-generated. DO NOT EDIT.
481
482cc_prebuilt_library_shared {
Paul Duffina7cd8c82019-12-11 20:00:57 +0000483 name: "mynativelib",
484 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100485 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000486 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000487 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100488 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +0000489 export_include_dirs: ["include/myinclude"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100490 sanitize: {
491 fuzzer: false,
492 diag: {
493 undefined: false,
494 },
495 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000496 arch: {
497 arm64: {
498 srcs: ["arm64/lib/mynativelib.so"],
499 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100500 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100501 integer_overflow: false,
502 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000503 },
504 arm: {
505 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100506 sanitize: {
507 integer_overflow: true,
508 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000509 },
510 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000511}
Paul Duffina7cd8c82019-12-11 20:00:57 +0000512`),
513 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +0000514myinclude/Test.h -> include/myinclude/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +0000515.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000516arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800517.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000518 )
519}
520
Paul Duffin25ce04b2020-01-16 11:47:25 +0000521func TestSnapshotWithCcBinary(t *testing.T) {
522 result := testSdkWithCc(t, `
523 module_exports {
524 name: "mymodule_exports",
525 native_binaries: ["mynativebinary"],
526 }
527
528 cc_binary {
529 name: "mynativebinary",
530 srcs: [
531 "Test.cpp",
532 ],
533 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000534 }
535 `)
536
Paul Duffin36474d32021-03-12 12:19:43 +0000537 CheckSnapshot(t, result, "mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000538 checkUnversionedAndroidBpContents(`
Paul Duffin25ce04b2020-01-16 11:47:25 +0000539// This is auto-generated. DO NOT EDIT.
540
541cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000542 name: "mynativebinary",
543 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100544 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000545 apex_available: ["//apex_available:platform"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000546 compile_multilib: "both",
547 arch: {
548 arm64: {
549 srcs: ["arm64/bin/mynativebinary"],
550 },
551 arm: {
552 srcs: ["arm/bin/mynativebinary"],
553 },
554 },
555}
Paul Duffin75b902a2021-02-22 12:13:13 +0000556`),
557 // Make sure that the generated sdk_snapshot uses the native_binaries property.
558 checkVersionedAndroidBpContents(`
559// This is auto-generated. DO NOT EDIT.
Paul Duffin25ce04b2020-01-16 11:47:25 +0000560
561cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000562 name: "mymodule_exports_mynativebinary@current",
563 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100564 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000565 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +0000566 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000567 compile_multilib: "both",
568 arch: {
569 arm64: {
570 srcs: ["arm64/bin/mynativebinary"],
571 },
572 arm: {
573 srcs: ["arm/bin/mynativebinary"],
574 },
575 },
576}
577
578module_exports_snapshot {
579 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100580 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000581 native_binaries: ["mymodule_exports_mynativebinary@current"],
582}
583`),
584 checkAllCopyRules(`
585.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
586.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
587`),
588 )
589}
590
Paul Duffina04c1072020-03-02 10:16:35 +0000591func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000592 result := testSdkWithCc(t, `
593 module_exports {
594 name: "myexports",
595 device_supported: false,
596 host_supported: true,
597 native_binaries: ["mynativebinary"],
598 target: {
599 windows: {
600 enabled: true,
601 },
602 },
603 }
604
605 cc_binary {
606 name: "mynativebinary",
607 device_supported: false,
608 host_supported: true,
609 srcs: [
610 "Test.cpp",
611 ],
612 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000613 stl: "none",
614 target: {
615 windows: {
616 enabled: true,
617 },
618 },
619 }
620 `)
621
Paul Duffin36474d32021-03-12 12:19:43 +0000622 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000623 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +0000624// This is auto-generated. DO NOT EDIT.
625
626cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000627 name: "mynativebinary",
628 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100629 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000630 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000631 device_supported: false,
632 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100633 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000634 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100635 host: {
636 enabled: false,
637 },
Paul Duffina04c1072020-03-02 10:16:35 +0000638 linux_glibc: {
639 compile_multilib: "both",
640 },
641 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900642 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000643 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
644 },
645 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900646 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000647 srcs: ["linux_glibc/x86/bin/mynativebinary"],
648 },
649 windows: {
650 compile_multilib: "64",
651 },
652 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900653 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000654 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
655 },
656 },
657}
Paul Duffin75b902a2021-02-22 12:13:13 +0000658`),
659 checkVersionedAndroidBpContents(`
660// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +0000661
662cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000663 name: "myexports_mynativebinary@current",
664 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100665 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000666 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +0000667 device_supported: false,
668 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +0000669 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100670 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000671 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100672 host: {
673 enabled: false,
674 },
Paul Duffina04c1072020-03-02 10:16:35 +0000675 linux_glibc: {
676 compile_multilib: "both",
677 },
678 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900679 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000680 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
681 },
682 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900683 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000684 srcs: ["linux_glibc/x86/bin/mynativebinary"],
685 },
686 windows: {
687 compile_multilib: "64",
688 },
689 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900690 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000691 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
692 },
693 },
694}
695
696module_exports_snapshot {
697 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100698 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000699 device_supported: false,
700 host_supported: true,
701 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000702 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900703 windows: {
704 compile_multilib: "64",
705 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100706 host: {
707 enabled: false,
708 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900709 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100710 enabled: true,
711 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900712 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100713 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +0900714 },
715 windows_x86_64: {
716 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000717 },
718 },
Paul Duffina04c1072020-03-02 10:16:35 +0000719}
720`),
721 checkAllCopyRules(`
722.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
723.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
724.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
725`),
726 )
727}
728
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100729func TestSnapshotWithSingleHostOsType(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000730 result := android.GroupFixturePreparers(
731 prepareForSdkTest,
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000732 ccTestFs.AddToFixture(),
733 cc.PrepareForTestOnLinuxBionic,
734 android.FixtureModifyConfig(func(config android.Config) {
735 config.Targets[android.LinuxBionic] = []android.Target{
736 {android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", false},
737 }
738 }),
739 ).RunTestWithBp(t, `
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100740 cc_defaults {
741 name: "mydefaults",
742 device_supported: false,
743 host_supported: true,
744 compile_multilib: "64",
745 target: {
746 host: {
747 enabled: false,
748 },
749 linux_bionic: {
750 enabled: true,
751 },
752 },
753 }
754
755 module_exports {
756 name: "myexports",
757 defaults: ["mydefaults"],
758 native_shared_libs: ["mynativelib"],
759 native_binaries: ["mynativebinary"],
760 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
761 }
762
763 cc_library {
764 name: "mynativelib",
765 defaults: ["mydefaults"],
766 srcs: [
767 "Test.cpp",
768 ],
769 stl: "none",
770 }
771
772 cc_binary {
773 name: "mynativebinary",
774 defaults: ["mydefaults"],
775 srcs: [
776 "Test.cpp",
777 ],
778 stl: "none",
779 }
Paul Duffin4a2a29c2021-03-09 22:27:13 +0000780 `)
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100781
Paul Duffin36474d32021-03-12 12:19:43 +0000782 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000783 checkUnversionedAndroidBpContents(`
784// This is auto-generated. DO NOT EDIT.
785
786cc_prebuilt_binary {
787 name: "mynativebinary",
788 prefer: false,
789 visibility: ["//visibility:public"],
790 apex_available: ["//apex_available:platform"],
791 device_supported: false,
792 host_supported: true,
793 stl: "none",
794 compile_multilib: "64",
795 target: {
796 host: {
797 enabled: false,
798 },
799 linux_bionic_x86_64: {
800 enabled: true,
801 srcs: ["x86_64/bin/mynativebinary"],
802 },
803 },
804}
805
806cc_prebuilt_library_shared {
807 name: "mynativelib",
808 prefer: false,
809 visibility: ["//visibility:public"],
810 apex_available: ["//apex_available:platform"],
811 device_supported: false,
812 host_supported: true,
813 stl: "none",
814 compile_multilib: "64",
815 target: {
816 host: {
817 enabled: false,
818 },
819 linux_bionic_x86_64: {
820 enabled: true,
821 srcs: ["x86_64/lib/mynativelib.so"],
822 },
823 },
824}
825`),
826 checkVersionedAndroidBpContents(`
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100827// This is auto-generated. DO NOT EDIT.
828
829cc_prebuilt_binary {
830 name: "myexports_mynativebinary@current",
831 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100832 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000833 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100834 device_supported: false,
835 host_supported: true,
836 installable: false,
837 stl: "none",
838 compile_multilib: "64",
839 target: {
840 host: {
841 enabled: false,
842 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100843 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900844 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100845 srcs: ["x86_64/bin/mynativebinary"],
846 },
847 },
848}
849
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100850cc_prebuilt_library_shared {
851 name: "myexports_mynativelib@current",
852 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100853 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000854 apex_available: ["//apex_available:platform"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100855 device_supported: false,
856 host_supported: true,
857 installable: false,
858 stl: "none",
859 compile_multilib: "64",
860 target: {
861 host: {
862 enabled: false,
863 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100864 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900865 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100866 srcs: ["x86_64/lib/mynativelib.so"],
867 },
868 },
869}
870
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100871module_exports_snapshot {
872 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100873 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100874 device_supported: false,
875 host_supported: true,
Paul Duffin7b0259f2021-04-24 11:34:46 +0100876 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100877 native_binaries: ["myexports_mynativebinary@current"],
878 native_shared_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100879 target: {
880 host: {
881 enabled: false,
882 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900883 linux_bionic_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100884 enabled: true,
885 },
886 },
887}
888`),
889 checkAllCopyRules(`
890.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
891.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
892`),
893 )
894}
895
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100896// Test that we support the necessary flags for the linker binary, which is
897// special in several ways.
898func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100899 result := testSdkWithCc(t, `
900 module_exports {
901 name: "mymodule_exports",
902 host_supported: true,
903 device_supported: false,
904 native_binaries: ["linker"],
905 }
906
907 cc_binary {
908 name: "linker",
909 host_supported: true,
910 static_executable: true,
911 nocrt: true,
912 stl: "none",
913 srcs: [
914 "Test.cpp",
915 ],
916 compile_multilib: "both",
917 }
918 `)
919
Paul Duffin36474d32021-03-12 12:19:43 +0000920 CheckSnapshot(t, result, "mymodule_exports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +0000921 checkUnversionedAndroidBpContents(`
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100922// This is auto-generated. DO NOT EDIT.
923
924cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000925 name: "linker",
926 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100927 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000928 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100929 device_supported: false,
930 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100931 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100932 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100933 static_executable: true,
934 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100935 target: {
936 host: {
937 enabled: false,
938 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100939 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900940 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100941 srcs: ["x86_64/bin/linker"],
942 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100943 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900944 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100945 srcs: ["x86/bin/linker"],
946 },
947 },
948}
Paul Duffin75b902a2021-02-22 12:13:13 +0000949`),
950 checkVersionedAndroidBpContents(`
951// This is auto-generated. DO NOT EDIT.
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100952
953cc_prebuilt_binary {
Paul Duffin75b902a2021-02-22 12:13:13 +0000954 name: "mymodule_exports_linker@current",
955 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +0100956 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +0000957 apex_available: ["//apex_available:platform"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100958 device_supported: false,
959 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +0000960 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100961 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100962 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100963 static_executable: true,
964 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100965 target: {
966 host: {
967 enabled: false,
968 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100969 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900970 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100971 srcs: ["x86_64/bin/linker"],
972 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100973 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900974 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100975 srcs: ["x86/bin/linker"],
976 },
977 },
978}
979
980module_exports_snapshot {
981 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100982 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100983 device_supported: false,
984 host_supported: true,
985 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100986 target: {
987 host: {
988 enabled: false,
989 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900990 linux_glibc_x86_64: {
991 enabled: true,
992 },
993 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100994 enabled: true,
995 },
996 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100997}
998`),
999 checkAllCopyRules(`
1000.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1001.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1002`),
1003 )
1004}
1005
Paul Duffin9ab556f2019-12-11 18:42:17 +00001006func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001007 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001008 sdk {
1009 name: "mysdk",
1010 native_shared_libs: ["mynativelib"],
1011 }
1012
1013 cc_library_shared {
1014 name: "mynativelib",
1015 srcs: [
1016 "Test.cpp",
1017 "aidl/foo/bar/Test.aidl",
1018 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001019 apex_available: ["apex1", "apex2"],
Paul Duffin86b02a72021-02-22 11:50:04 +00001020 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001021 aidl: {
1022 export_aidl_headers: true,
1023 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001024 stl: "none",
1025 }
1026 `)
1027
Paul Duffin36474d32021-03-12 12:19:43 +00001028 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001029 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001030// This is auto-generated. DO NOT EDIT.
1031
1032cc_prebuilt_library_shared {
Paul Duffina80fdec2019-12-03 15:25:00 +00001033 name: "mynativelib",
1034 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001035 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001036 apex_available: [
1037 "apex1",
1038 "apex2",
1039 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001040 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001041 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001042 export_include_dirs: ["include/myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001043 arch: {
1044 arm64: {
1045 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001046 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001047 },
1048 arm: {
1049 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001050 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001051 },
1052 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001053}
Paul Duffina80fdec2019-12-03 15:25:00 +00001054`),
1055 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001056myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001057.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001058.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
1059.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
1060.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 -08001061.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001062.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
1063.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
1064.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 +00001065`),
1066 )
1067}
1068
Paul Duffin13f02712020-03-06 12:30:43 +00001069func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1070 result := testSdkWithCc(t, `
1071 sdk {
1072 name: "mysdk",
1073 native_shared_libs: [
1074 "mynativelib",
1075 "myothernativelib",
1076 "mysystemnativelib",
1077 ],
1078 }
1079
1080 cc_library {
1081 name: "mysystemnativelib",
1082 srcs: [
1083 "Test.cpp",
1084 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001085 stl: "none",
1086 }
1087
1088 cc_library_shared {
1089 name: "myothernativelib",
1090 srcs: [
1091 "Test.cpp",
1092 ],
1093 system_shared_libs: [
1094 // A reference to a library that is not an sdk member. Uses libm as that
1095 // is in the default set of modules available to this test and so is available
1096 // both here and also when the generated Android.bp file is tested in
1097 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1098 // handles references to modules that are not sdk members.
1099 "libm",
1100 ],
1101 stl: "none",
1102 }
1103
1104 cc_library {
1105 name: "mynativelib",
1106 srcs: [
1107 "Test.cpp",
1108 ],
1109 shared_libs: [
1110 // A reference to another sdk member.
1111 "myothernativelib",
1112 ],
1113 target: {
1114 android: {
1115 shared: {
1116 shared_libs: [
1117 // A reference to a library that is not an sdk member. The libc library
1118 // is used here to check that the shared_libs property is handled correctly
1119 // in a similar way to how libm is used to check system_shared_libs above.
1120 "libc",
1121 ],
1122 },
1123 },
1124 },
Paul Duffin13f02712020-03-06 12:30:43 +00001125 stl: "none",
1126 }
1127 `)
1128
Paul Duffin36474d32021-03-12 12:19:43 +00001129 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001130 checkUnversionedAndroidBpContents(`
Paul Duffin13f02712020-03-06 12:30:43 +00001131// This is auto-generated. DO NOT EDIT.
1132
1133cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001134 name: "mynativelib",
1135 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001136 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001137 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001138 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001139 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001140 shared_libs: [
1141 "myothernativelib",
1142 "libc",
1143 ],
1144 arch: {
1145 arm64: {
1146 srcs: ["arm64/lib/mynativelib.so"],
1147 },
1148 arm: {
1149 srcs: ["arm/lib/mynativelib.so"],
1150 },
1151 },
Paul Duffin13f02712020-03-06 12:30:43 +00001152}
1153
1154cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001155 name: "myothernativelib",
1156 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001157 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001158 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001159 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001160 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001161 system_shared_libs: ["libm"],
1162 arch: {
1163 arm64: {
1164 srcs: ["arm64/lib/myothernativelib.so"],
1165 },
1166 arm: {
1167 srcs: ["arm/lib/myothernativelib.so"],
1168 },
1169 },
Paul Duffin13f02712020-03-06 12:30:43 +00001170}
1171
1172cc_prebuilt_library_shared {
Paul Duffin13f02712020-03-06 12:30:43 +00001173 name: "mysystemnativelib",
1174 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001175 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001176 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001177 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001178 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001179 arch: {
1180 arm64: {
1181 srcs: ["arm64/lib/mysystemnativelib.so"],
1182 },
1183 arm: {
1184 srcs: ["arm/lib/mysystemnativelib.so"],
1185 },
1186 },
Paul Duffin13f02712020-03-06 12:30:43 +00001187}
Paul Duffin13f02712020-03-06 12:30:43 +00001188`),
1189 checkAllCopyRules(`
1190.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1191.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1192.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1193.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1194.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1195.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1196`),
1197 )
1198}
1199
Paul Duffin9ab556f2019-12-11 18:42:17 +00001200func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001201 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001202 sdk {
1203 name: "mysdk",
1204 device_supported: false,
1205 host_supported: true,
1206 native_shared_libs: ["mynativelib"],
1207 }
1208
1209 cc_library_shared {
1210 name: "mynativelib",
1211 device_supported: false,
1212 host_supported: true,
1213 srcs: [
1214 "Test.cpp",
1215 "aidl/foo/bar/Test.aidl",
1216 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001217 export_include_dirs: ["myinclude"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001218 aidl: {
1219 export_aidl_headers: true,
1220 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001221 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001222 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001223 }
1224 `)
1225
Paul Duffin36474d32021-03-12 12:19:43 +00001226 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001227 checkUnversionedAndroidBpContents(`
Paul Duffina80fdec2019-12-03 15:25:00 +00001228// This is auto-generated. DO NOT EDIT.
1229
1230cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001231 name: "mynativelib",
1232 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001233 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001234 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001235 device_supported: false,
1236 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001237 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001238 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001239 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001240 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001241 target: {
1242 host: {
1243 enabled: false,
1244 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001245 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001246 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001247 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001248 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001249 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001250 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001251 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001252 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001253 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001254 },
1255 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001256}
Paul Duffin75b902a2021-02-22 12:13:13 +00001257`),
1258 checkVersionedAndroidBpContents(`
1259// This is auto-generated. DO NOT EDIT.
Paul Duffina80fdec2019-12-03 15:25:00 +00001260
1261cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001262 name: "mysdk_mynativelib@current",
1263 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001264 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001265 apex_available: ["//apex_available:platform"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001266 device_supported: false,
1267 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001268 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001269 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001270 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001271 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001272 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001273 target: {
1274 host: {
1275 enabled: false,
1276 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001277 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001278 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001279 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001280 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001281 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001282 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001283 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001284 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001285 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001286 },
1287 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001288}
1289
1290sdk_snapshot {
1291 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001292 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001293 device_supported: false,
1294 host_supported: true,
1295 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001296 target: {
1297 host: {
1298 enabled: false,
1299 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001300 linux_glibc_x86_64: {
1301 enabled: true,
1302 },
1303 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001304 enabled: true,
1305 },
1306 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001307}
1308`),
1309 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001310myinclude/Test.h -> include/myinclude/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001311.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001312.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
1313.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
1314.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 +00001315.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffin42dd4e62021-02-22 11:35:24 +00001316.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
1317.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
1318.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 +00001319`),
1320 )
1321}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001322
Paul Duffina04c1072020-03-02 10:16:35 +00001323func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001324 result := testSdkWithCc(t, `
1325 sdk {
1326 name: "mysdk",
1327 device_supported: false,
1328 host_supported: true,
1329 native_shared_libs: ["mynativelib"],
1330 target: {
1331 windows: {
1332 enabled: true,
1333 },
1334 },
1335 }
1336
1337 cc_library_shared {
1338 name: "mynativelib",
1339 device_supported: false,
1340 host_supported: true,
1341 srcs: [
1342 "Test.cpp",
1343 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001344 stl: "none",
1345 target: {
1346 windows: {
1347 enabled: true,
1348 },
1349 },
1350 }
1351 `)
1352
Paul Duffin36474d32021-03-12 12:19:43 +00001353 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001354 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00001355// This is auto-generated. DO NOT EDIT.
1356
1357cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001358 name: "mynativelib",
1359 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001360 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001361 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001362 device_supported: false,
1363 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001364 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001365 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001366 host: {
1367 enabled: false,
1368 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001369 linux_glibc: {
1370 compile_multilib: "both",
1371 },
Paul Duffina04c1072020-03-02 10:16:35 +00001372 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001373 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001374 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1375 },
1376 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001377 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001378 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1379 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001380 windows: {
1381 compile_multilib: "64",
1382 },
Paul Duffina04c1072020-03-02 10:16:35 +00001383 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001384 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001385 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1386 },
1387 },
Paul Duffina04c1072020-03-02 10:16:35 +00001388}
Paul Duffin75b902a2021-02-22 12:13:13 +00001389`),
1390 checkVersionedAndroidBpContents(`
1391// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00001392
1393cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00001394 name: "mysdk_mynativelib@current",
1395 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001396 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001397 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00001398 device_supported: false,
1399 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001400 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001401 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001402 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001403 host: {
1404 enabled: false,
1405 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001406 linux_glibc: {
1407 compile_multilib: "both",
1408 },
Paul Duffina04c1072020-03-02 10:16:35 +00001409 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001410 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001411 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1412 },
1413 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001414 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001415 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1416 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001417 windows: {
1418 compile_multilib: "64",
1419 },
Paul Duffina04c1072020-03-02 10:16:35 +00001420 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001421 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001422 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1423 },
1424 },
Paul Duffina04c1072020-03-02 10:16:35 +00001425}
1426
1427sdk_snapshot {
1428 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001429 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001430 device_supported: false,
1431 host_supported: true,
1432 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001433 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001434 windows: {
1435 compile_multilib: "64",
1436 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001437 host: {
1438 enabled: false,
1439 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001440 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001441 enabled: true,
1442 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001443 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001444 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +09001445 },
1446 windows_x86_64: {
1447 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001448 },
1449 },
Paul Duffina04c1072020-03-02 10:16:35 +00001450}
1451`),
1452 checkAllCopyRules(`
1453.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1454.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1455.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1456`),
1457 )
1458}
1459
Paul Duffin9ab556f2019-12-11 18:42:17 +00001460func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1461 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001462 module_exports {
1463 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001464 native_static_libs: ["mynativelib"],
1465 }
1466
1467 cc_library_static {
1468 name: "mynativelib",
1469 srcs: [
1470 "Test.cpp",
1471 "aidl/foo/bar/Test.aidl",
1472 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001473 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001474 aidl: {
1475 export_aidl_headers: true,
1476 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001477 stl: "none",
1478 }
1479 `)
1480
Paul Duffin36474d32021-03-12 12:19:43 +00001481 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001482 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001483// This is auto-generated. DO NOT EDIT.
1484
1485cc_prebuilt_library_static {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001486 name: "mynativelib",
1487 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001488 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001489 apex_available: ["//apex_available:platform"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001490 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001491 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001492 export_include_dirs: ["include/myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001493 arch: {
1494 arm64: {
1495 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001496 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001497 },
1498 arm: {
1499 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001500 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001501 },
1502 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001503}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001504`),
1505 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001506myinclude/Test.h -> include/myinclude/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001507.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001508.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
1509.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
1510.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 -08001511.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001512.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
1513.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
1514.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 +00001515`),
1516 )
1517}
1518
1519func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001520 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001521 module_exports {
1522 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001523 device_supported: false,
1524 host_supported: true,
1525 native_static_libs: ["mynativelib"],
1526 }
1527
1528 cc_library_static {
1529 name: "mynativelib",
1530 device_supported: false,
1531 host_supported: true,
1532 srcs: [
1533 "Test.cpp",
1534 "aidl/foo/bar/Test.aidl",
1535 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001536 export_include_dirs: ["myinclude"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001537 aidl: {
1538 export_aidl_headers: true,
1539 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001540 stl: "none",
1541 }
1542 `)
1543
Paul Duffin36474d32021-03-12 12:19:43 +00001544 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001545 checkUnversionedAndroidBpContents(`
Paul Duffin9ab556f2019-12-11 18:42:17 +00001546// This is auto-generated. DO NOT EDIT.
1547
1548cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001549 name: "mynativelib",
1550 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001551 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001552 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001553 device_supported: false,
1554 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001555 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001556 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001557 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001558 target: {
1559 host: {
1560 enabled: false,
1561 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001562 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001563 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001564 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001565 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001566 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001567 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001568 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001569 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001570 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001571 },
1572 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001573}
Paul Duffin75b902a2021-02-22 12:13:13 +00001574`),
1575 checkVersionedAndroidBpContents(`
1576// This is auto-generated. DO NOT EDIT.
Paul Duffin9ab556f2019-12-11 18:42:17 +00001577
1578cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001579 name: "myexports_mynativelib@current",
1580 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001581 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001582 apex_available: ["//apex_available:platform"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001583 device_supported: false,
1584 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001585 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001586 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001587 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001588 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001589 target: {
1590 host: {
1591 enabled: false,
1592 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001593 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001594 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001595 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001596 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001597 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001598 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001599 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001600 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin42dd4e62021-02-22 11:35:24 +00001601 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001602 },
1603 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001604}
1605
Paul Duffine6029182019-12-16 17:43:48 +00001606module_exports_snapshot {
1607 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001608 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001609 device_supported: false,
1610 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001611 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001612 target: {
1613 host: {
1614 enabled: false,
1615 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001616 linux_glibc_x86_64: {
1617 enabled: true,
1618 },
1619 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001620 enabled: true,
1621 },
1622 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001623}
1624`),
1625 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001626myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001627.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001628.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
1629.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
1630.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 +00001631.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin42dd4e62021-02-22 11:35:24 +00001632.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
1633.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
1634.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 +00001635`),
1636 )
1637}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001638
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001639func TestSnapshotWithCcLibrary(t *testing.T) {
1640 result := testSdkWithCc(t, `
1641 module_exports {
1642 name: "myexports",
1643 native_libs: ["mynativelib"],
1644 }
1645
1646 cc_library {
1647 name: "mynativelib",
1648 srcs: [
1649 "Test.cpp",
1650 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001651 export_include_dirs: ["myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001652 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001653 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001654 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001655 }
1656 `)
1657
Paul Duffin36474d32021-03-12 12:19:43 +00001658 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001659 checkUnversionedAndroidBpContents(`
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001660// This is auto-generated. DO NOT EDIT.
1661
1662cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001663 name: "mynativelib",
1664 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001665 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001666 apex_available: ["//apex_available:platform"],
Paul Duffind1edbd42020-08-13 19:45:31 +01001667 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001668 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001669 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001670 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001671 arch: {
1672 arm64: {
1673 static: {
1674 srcs: ["arm64/lib/mynativelib.a"],
1675 },
1676 shared: {
1677 srcs: ["arm64/lib/mynativelib.so"],
1678 },
1679 },
1680 arm: {
1681 static: {
1682 srcs: ["arm/lib/mynativelib.a"],
1683 },
1684 shared: {
1685 srcs: ["arm/lib/mynativelib.so"],
1686 },
1687 },
1688 },
1689}
Paul Duffin75b902a2021-02-22 12:13:13 +00001690`),
1691 // Make sure that the generated sdk_snapshot uses the native_libs property.
1692 checkVersionedAndroidBpContents(`
1693// This is auto-generated. DO NOT EDIT.
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001694
1695cc_prebuilt_library {
Paul Duffin75b902a2021-02-22 12:13:13 +00001696 name: "myexports_mynativelib@current",
1697 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001698 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001699 apex_available: ["//apex_available:platform"],
Paul Duffin75b902a2021-02-22 12:13:13 +00001700 installable: false,
Paul Duffind1edbd42020-08-13 19:45:31 +01001701 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001702 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001703 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001704 export_include_dirs: ["include/myinclude"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001705 arch: {
1706 arm64: {
1707 static: {
1708 srcs: ["arm64/lib/mynativelib.a"],
1709 },
1710 shared: {
1711 srcs: ["arm64/lib/mynativelib.so"],
1712 },
1713 },
1714 arm: {
1715 static: {
1716 srcs: ["arm/lib/mynativelib.a"],
1717 },
1718 shared: {
1719 srcs: ["arm/lib/mynativelib.so"],
1720 },
1721 },
1722 },
1723}
1724
1725module_exports_snapshot {
1726 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001727 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001728 native_libs: ["myexports_mynativelib@current"],
1729}
1730`),
1731 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001732myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001733.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1734.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1735.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
Paul Duffin1822a0a2021-03-21 12:56:33 +00001736.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1737`),
1738 // TODO(b/183315522): Remove this and fix the issue.
1739 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\Qunrecognized property "arch.arm.shared.export_include_dirs"\E`)),
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001740 )
1741}
1742
Paul Duffin13ad94f2020-02-19 16:19:27 +00001743func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001744 result := testSdkWithCc(t, `
1745 module_exports {
1746 name: "myexports",
1747 device_supported: false,
1748 host_supported: true,
1749 target: {
1750 host: {
1751 compile_multilib: "64",
1752 },
1753 },
1754 native_static_libs: ["mynativelib"],
1755 }
1756
1757 cc_library_static {
1758 name: "mynativelib",
1759 device_supported: false,
1760 host_supported: true,
1761 srcs: [
1762 "Test.cpp",
1763 "aidl/foo/bar/Test.aidl",
1764 ],
Paul Duffin86b02a72021-02-22 11:50:04 +00001765 export_include_dirs: ["myinclude"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001766 aidl: {
1767 export_aidl_headers: true,
1768 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001769 stl: "none",
1770 }
1771 `)
1772
Paul Duffin36474d32021-03-12 12:19:43 +00001773 CheckSnapshot(t, result, "myexports", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001774 checkUnversionedAndroidBpContents(`
Paul Duffin13ad94f2020-02-19 16:19:27 +00001775// This is auto-generated. DO NOT EDIT.
1776
1777cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001778 name: "mynativelib",
1779 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001780 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001781 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001782 device_supported: false,
1783 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001784 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001785 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001786 export_include_dirs: [
1787 "include/myinclude",
1788 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1789 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001790 target: {
1791 host: {
1792 enabled: false,
1793 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001794 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001795 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001796 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001797 },
1798 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001799}
Paul Duffin75b902a2021-02-22 12:13:13 +00001800`),
1801 checkVersionedAndroidBpContents(`
1802// This is auto-generated. DO NOT EDIT.
Paul Duffin13ad94f2020-02-19 16:19:27 +00001803
1804cc_prebuilt_library_static {
Paul Duffin75b902a2021-02-22 12:13:13 +00001805 name: "myexports_mynativelib@current",
1806 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001807 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001808 apex_available: ["//apex_available:platform"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001809 device_supported: false,
1810 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00001811 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001812 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001813 compile_multilib: "64",
Paul Duffin7a7d0672021-02-17 12:17:40 +00001814 export_include_dirs: [
1815 "include/myinclude",
1816 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
1817 ],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001818 target: {
1819 host: {
1820 enabled: false,
1821 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001822 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001823 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001824 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001825 },
1826 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001827}
1828
1829module_exports_snapshot {
1830 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001831 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001832 device_supported: false,
1833 host_supported: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001834 compile_multilib: "64",
Paul Duffin7b0259f2021-04-24 11:34:46 +01001835 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001836 target: {
1837 host: {
1838 enabled: false,
1839 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001840 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001841 enabled: true,
1842 },
1843 },
Paul Duffin75b902a2021-02-22 12:13:13 +00001844}
1845`),
Paul Duffin13ad94f2020-02-19 16:19:27 +00001846 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001847myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin7a7d0672021-02-17 12:17:40 +00001848.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
1849.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
1850.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 +00001851.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin13ad94f2020-02-19 16:19:27 +00001852`),
1853 )
1854}
Paul Duffin91756d22020-02-21 16:29:57 +00001855
1856func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1857 result := testSdkWithCc(t, `
1858 sdk {
1859 name: "mysdk",
1860 native_header_libs: ["mynativeheaders"],
1861 }
1862
1863 cc_library_headers {
1864 name: "mynativeheaders",
Paul Duffin86b02a72021-02-22 11:50:04 +00001865 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001866 stl: "none",
1867 }
1868 `)
1869
Paul Duffin36474d32021-03-12 12:19:43 +00001870 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00001871 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00001872// This is auto-generated. DO NOT EDIT.
1873
1874cc_prebuilt_library_headers {
Paul Duffin91756d22020-02-21 16:29:57 +00001875 name: "mynativeheaders",
1876 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001877 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00001878 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00001879 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001880 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00001881 export_include_dirs: ["include/myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00001882}
Paul Duffin91756d22020-02-21 16:29:57 +00001883`),
1884 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00001885myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00001886`),
1887 )
1888}
1889
Paul Duffin93b750e2019-11-19 19:44:10 +00001890func TestSnapshotWithCcHeadersLibraryAndNativeBridgeSupport(t *testing.T) {
1891 result := android.GroupFixturePreparers(
1892 cc.PrepareForTestWithCcDefaultModules,
1893 PrepareForTestWithSdkBuildComponents,
1894 ccTestFs.AddToFixture(),
1895 prepareForTestWithNativeBridgeTarget,
1896 ).RunTestWithBp(t, `
1897 sdk {
1898 name: "mysdk",
1899 native_header_libs: ["mynativeheaders"],
1900 traits: {
1901 native_bridge_support: ["mynativeheaders"],
1902 },
1903 }
1904
1905 cc_library_headers {
1906 name: "mynativeheaders",
1907 export_include_dirs: ["myinclude"],
1908 stl: "none",
1909 system_shared_libs: [],
1910 native_bridge_supported: true,
1911 }
1912 `)
1913
1914 CheckSnapshot(t, result, "mysdk", "",
1915 checkUnversionedAndroidBpContents(`
1916// This is auto-generated. DO NOT EDIT.
1917
1918cc_prebuilt_library_headers {
1919 name: "mynativeheaders",
1920 prefer: false,
1921 visibility: ["//visibility:public"],
1922 apex_available: ["//apex_available:platform"],
1923 native_bridge_supported: true,
1924 stl: "none",
1925 compile_multilib: "both",
1926 system_shared_libs: [],
1927 export_include_dirs: ["include/myinclude"],
1928}
1929`),
1930 checkAllCopyRules(`
1931myinclude/Test.h -> include/myinclude/Test.h
1932`),
1933 )
1934}
1935
1936// TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties verifies that when a
1937// module that has different output files for a native bridge target requests the native bridge
1938// variants are copied into the sdk snapshot that it reports an error.
1939func TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties(t *testing.T) {
1940 android.GroupFixturePreparers(
1941 cc.PrepareForTestWithCcDefaultModules,
1942 PrepareForTestWithSdkBuildComponents,
1943 ccTestFs.AddToFixture(),
1944 prepareForTestWithNativeBridgeTarget,
1945 ).ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
1946 `\QArchitecture variant "arm64_native_bridge" of sdk member "mynativeheaders" has properties distinct from other variants; this is not yet supported. The properties are:
1947 export_include_dirs: [
1948 "arm64_native_bridge/include/myinclude_nativebridge",
1949 "arm64_native_bridge/include/myinclude",
1950 ],\E`)).
1951 RunTestWithBp(t, `
1952 sdk {
1953 name: "mysdk",
1954 native_header_libs: ["mynativeheaders"],
1955 traits: {
1956 native_bridge_support: ["mynativeheaders"],
1957 },
1958 }
1959
1960 cc_library_headers {
1961 name: "mynativeheaders",
1962 export_include_dirs: ["myinclude"],
1963 stl: "none",
1964 system_shared_libs: [],
1965 native_bridge_supported: true,
1966 target: {
1967 native_bridge: {
1968 export_include_dirs: ["myinclude_nativebridge"],
1969 },
1970 },
1971 }
1972 `)
1973}
1974
Paul Duffin63696222021-09-06 10:28:34 +01001975func TestSnapshotWithCcHeadersLibraryAndImageVariants(t *testing.T) {
1976 testImageVariant := func(t *testing.T, property, trait string) {
1977 result := android.GroupFixturePreparers(
1978 cc.PrepareForTestWithCcDefaultModules,
1979 PrepareForTestWithSdkBuildComponents,
1980 ccTestFs.AddToFixture(),
1981 ).RunTestWithBp(t, fmt.Sprintf(`
1982 sdk {
1983 name: "mysdk",
1984 native_header_libs: ["mynativeheaders"],
1985 traits: {
1986 %s: ["mynativeheaders"],
1987 },
1988 }
1989
1990 cc_library_headers {
1991 name: "mynativeheaders",
1992 export_include_dirs: ["myinclude"],
1993 stl: "none",
1994 system_shared_libs: [],
1995 %s: true,
1996 }
1997 `, trait, property))
1998
1999 CheckSnapshot(t, result, "mysdk", "",
2000 checkUnversionedAndroidBpContents(fmt.Sprintf(`
2001// This is auto-generated. DO NOT EDIT.
2002
2003cc_prebuilt_library_headers {
2004 name: "mynativeheaders",
2005 prefer: false,
2006 visibility: ["//visibility:public"],
2007 apex_available: ["//apex_available:platform"],
2008 %s: true,
2009 stl: "none",
2010 compile_multilib: "both",
2011 system_shared_libs: [],
2012 export_include_dirs: ["include/myinclude"],
2013}
2014`, property)),
2015 checkAllCopyRules(`
2016myinclude/Test.h -> include/myinclude/Test.h
2017`),
2018 )
2019 }
2020
Paul Duffin12a0a312021-09-15 17:25:10 +01002021 t.Run("ramdisk", func(t *testing.T) {
2022 testImageVariant(t, "ramdisk_available", "ramdisk_image_required")
2023 })
2024
Paul Duffin63696222021-09-06 10:28:34 +01002025 t.Run("recovery", func(t *testing.T) {
2026 testImageVariant(t, "recovery_available", "recovery_image_required")
2027 })
2028}
2029
Paul Duffin91756d22020-02-21 16:29:57 +00002030func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00002031 result := testSdkWithCc(t, `
2032 sdk {
2033 name: "mysdk",
2034 device_supported: false,
2035 host_supported: true,
2036 native_header_libs: ["mynativeheaders"],
2037 }
2038
2039 cc_library_headers {
2040 name: "mynativeheaders",
2041 device_supported: false,
2042 host_supported: true,
Paul Duffin86b02a72021-02-22 11:50:04 +00002043 export_include_dirs: ["myinclude"],
Paul Duffin91756d22020-02-21 16:29:57 +00002044 stl: "none",
2045 }
2046 `)
2047
Paul Duffin36474d32021-03-12 12:19:43 +00002048 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002049 checkUnversionedAndroidBpContents(`
Paul Duffin91756d22020-02-21 16:29:57 +00002050// This is auto-generated. DO NOT EDIT.
2051
2052cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002053 name: "mynativeheaders",
2054 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002055 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002056 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002057 device_supported: false,
2058 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002059 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002060 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002061 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002062 target: {
2063 host: {
2064 enabled: false,
2065 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002066 linux_glibc_x86_64: {
2067 enabled: true,
2068 },
2069 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002070 enabled: true,
2071 },
2072 },
Paul Duffin91756d22020-02-21 16:29:57 +00002073}
Paul Duffin75b902a2021-02-22 12:13:13 +00002074`),
2075 checkVersionedAndroidBpContents(`
2076// This is auto-generated. DO NOT EDIT.
Paul Duffin91756d22020-02-21 16:29:57 +00002077
2078cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002079 name: "mysdk_mynativeheaders@current",
2080 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002081 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002082 apex_available: ["//apex_available:platform"],
Paul Duffin91756d22020-02-21 16:29:57 +00002083 device_supported: false,
2084 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002085 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002086 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002087 export_include_dirs: ["include/myinclude"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002088 target: {
2089 host: {
2090 enabled: false,
2091 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002092 linux_glibc_x86_64: {
2093 enabled: true,
2094 },
2095 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002096 enabled: true,
2097 },
2098 },
Paul Duffin91756d22020-02-21 16:29:57 +00002099}
2100
2101sdk_snapshot {
2102 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002103 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002104 device_supported: false,
2105 host_supported: true,
2106 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002107 target: {
2108 host: {
2109 enabled: false,
2110 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002111 linux_glibc_x86_64: {
2112 enabled: true,
2113 },
2114 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002115 enabled: true,
2116 },
2117 },
Paul Duffin91756d22020-02-21 16:29:57 +00002118}
2119`),
2120 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002121myinclude/Test.h -> include/myinclude/Test.h
Paul Duffin91756d22020-02-21 16:29:57 +00002122`),
2123 )
2124}
Paul Duffina04c1072020-03-02 10:16:35 +00002125
2126func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00002127 result := testSdkWithCc(t, `
2128 sdk {
2129 name: "mysdk",
2130 host_supported: true,
2131 native_header_libs: ["mynativeheaders"],
2132 }
2133
2134 cc_library_headers {
2135 name: "mynativeheaders",
2136 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002137 stl: "none",
Paul Duffin86b02a72021-02-22 11:50:04 +00002138 export_system_include_dirs: ["myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002139 target: {
2140 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002141 export_include_dirs: ["myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002142 },
2143 host: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002144 export_include_dirs: ["myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002145 },
2146 },
2147 }
2148 `)
2149
Paul Duffin36474d32021-03-12 12:19:43 +00002150 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002151 checkUnversionedAndroidBpContents(`
Paul Duffina04c1072020-03-02 10:16:35 +00002152// This is auto-generated. DO NOT EDIT.
2153
2154cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002155 name: "mynativeheaders",
2156 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002157 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002158 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002159 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002160 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002161 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002162 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002163 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002164 host: {
2165 enabled: false,
2166 },
Paul Duffina04c1072020-03-02 10:16:35 +00002167 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002168 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002169 },
2170 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002171 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002172 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002173 linux_glibc_x86_64: {
2174 enabled: true,
2175 },
2176 linux_glibc_x86: {
2177 enabled: true,
2178 },
Paul Duffina04c1072020-03-02 10:16:35 +00002179 },
Paul Duffina04c1072020-03-02 10:16:35 +00002180}
Paul Duffin75b902a2021-02-22 12:13:13 +00002181`),
Paul Duffin75b902a2021-02-22 12:13:13 +00002182 checkVersionedAndroidBpContents(`
2183// This is auto-generated. DO NOT EDIT.
Paul Duffina04c1072020-03-02 10:16:35 +00002184
2185cc_prebuilt_library_headers {
Paul Duffin75b902a2021-02-22 12:13:13 +00002186 name: "mysdk_mynativeheaders@current",
2187 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002188 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002189 apex_available: ["//apex_available:platform"],
Paul Duffina04c1072020-03-02 10:16:35 +00002190 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002191 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002192 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002193 export_system_include_dirs: ["common_os/include/myinclude"],
Paul Duffina04c1072020-03-02 10:16:35 +00002194 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002195 host: {
2196 enabled: false,
2197 },
Paul Duffina04c1072020-03-02 10:16:35 +00002198 android: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002199 export_include_dirs: ["android/include/myinclude-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002200 },
2201 linux_glibc: {
Paul Duffin86b02a72021-02-22 11:50:04 +00002202 export_include_dirs: ["linux_glibc/include/myinclude-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002203 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002204 linux_glibc_x86_64: {
2205 enabled: true,
2206 },
2207 linux_glibc_x86: {
2208 enabled: true,
2209 },
Paul Duffina04c1072020-03-02 10:16:35 +00002210 },
Paul Duffina04c1072020-03-02 10:16:35 +00002211}
2212
2213sdk_snapshot {
2214 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002215 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002216 host_supported: true,
2217 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002218 target: {
2219 host: {
2220 enabled: false,
2221 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002222 linux_glibc_x86_64: {
2223 enabled: true,
2224 },
2225 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002226 enabled: true,
2227 },
2228 },
Paul Duffina04c1072020-03-02 10:16:35 +00002229}
2230`),
2231 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002232myinclude/Test.h -> common_os/include/myinclude/Test.h
2233myinclude-android/AndroidTest.h -> android/include/myinclude-android/AndroidTest.h
2234myinclude-host/HostTest.h -> linux_glibc/include/myinclude-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002235`),
2236 )
2237}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002238
2239func TestSystemSharedLibPropagation(t *testing.T) {
2240 result := testSdkWithCc(t, `
2241 sdk {
2242 name: "mysdk",
Colin Cross6b8f4252021-07-22 11:39:44 -07002243 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002244 }
2245
2246 cc_library {
2247 name: "sslnil",
2248 host_supported: true,
2249 }
2250
2251 cc_library {
2252 name: "sslempty",
2253 system_shared_libs: [],
2254 }
2255
2256 cc_library {
2257 name: "sslnonempty",
2258 system_shared_libs: ["sslnil"],
2259 }
2260 `)
2261
Paul Duffin36474d32021-03-12 12:19:43 +00002262 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002263 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002264// This is auto-generated. DO NOT EDIT.
2265
2266cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002267 name: "sslnil",
2268 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002269 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002270 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002271 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002272 arch: {
2273 arm64: {
2274 srcs: ["arm64/lib/sslnil.so"],
2275 },
2276 arm: {
2277 srcs: ["arm/lib/sslnil.so"],
2278 },
2279 },
2280}
2281
2282cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002283 name: "sslempty",
2284 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002285 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002286 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002287 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002288 system_shared_libs: [],
2289 arch: {
2290 arm64: {
2291 srcs: ["arm64/lib/sslempty.so"],
2292 },
2293 arm: {
2294 srcs: ["arm/lib/sslempty.so"],
2295 },
2296 },
2297}
2298
2299cc_prebuilt_library_shared {
Martin Stjernholm10566a02020-03-24 01:19:52 +00002300 name: "sslnonempty",
2301 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002302 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002303 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002304 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002305 system_shared_libs: ["sslnil"],
2306 arch: {
2307 arm64: {
2308 srcs: ["arm64/lib/sslnonempty.so"],
2309 },
2310 arm: {
2311 srcs: ["arm/lib/sslnonempty.so"],
2312 },
2313 },
2314}
Colin Cross6b8f4252021-07-22 11:39:44 -07002315`))
Martin Stjernholm10566a02020-03-24 01:19:52 +00002316
2317 result = testSdkWithCc(t, `
2318 sdk {
2319 name: "mysdk",
2320 host_supported: true,
Colin Cross6b8f4252021-07-22 11:39:44 -07002321 native_shared_libs: ["sslvariants"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002322 }
2323
2324 cc_library {
2325 name: "sslvariants",
2326 host_supported: true,
2327 target: {
2328 android: {
2329 system_shared_libs: [],
2330 },
2331 },
2332 }
2333 `)
2334
Paul Duffin36474d32021-03-12 12:19:43 +00002335 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002336 checkUnversionedAndroidBpContents(`
Martin Stjernholm10566a02020-03-24 01:19:52 +00002337// This is auto-generated. DO NOT EDIT.
2338
2339cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002340 name: "sslvariants",
2341 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002342 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002343 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002344 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002345 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002346 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002347 host: {
2348 enabled: false,
2349 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002350 android: {
2351 system_shared_libs: [],
2352 },
2353 android_arm64: {
2354 srcs: ["android/arm64/lib/sslvariants.so"],
2355 },
2356 android_arm: {
2357 srcs: ["android/arm/lib/sslvariants.so"],
2358 },
2359 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002360 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002361 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2362 },
2363 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002364 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002365 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2366 },
2367 },
2368}
Paul Duffin75b902a2021-02-22 12:13:13 +00002369`),
2370 checkVersionedAndroidBpContents(`
2371// This is auto-generated. DO NOT EDIT.
Martin Stjernholm10566a02020-03-24 01:19:52 +00002372
2373cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002374 name: "mysdk_sslvariants@current",
2375 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002376 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002377 apex_available: ["//apex_available:platform"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002378 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002379 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002380 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002381 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002382 host: {
2383 enabled: false,
2384 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002385 android: {
2386 system_shared_libs: [],
2387 },
2388 android_arm64: {
2389 srcs: ["android/arm64/lib/sslvariants.so"],
2390 },
2391 android_arm: {
2392 srcs: ["android/arm/lib/sslvariants.so"],
2393 },
2394 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002395 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002396 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2397 },
2398 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002399 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002400 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2401 },
2402 },
2403}
2404
2405sdk_snapshot {
2406 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002407 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002408 host_supported: true,
Colin Cross6b8f4252021-07-22 11:39:44 -07002409 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002410 target: {
2411 host: {
2412 enabled: false,
2413 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002414 linux_glibc_x86_64: {
2415 enabled: true,
2416 },
2417 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002418 enabled: true,
2419 },
2420 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002421}
2422`))
2423}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002424
2425func TestStubsLibrary(t *testing.T) {
2426 result := testSdkWithCc(t, `
2427 sdk {
2428 name: "mysdk",
2429 native_shared_libs: ["stubslib"],
2430 }
2431
2432 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002433 name: "internaldep",
2434 }
2435
2436 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002437 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002438 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002439 stubs: {
2440 symbol_file: "some/where/stubslib.map.txt",
2441 versions: ["1", "2", "3"],
2442 },
2443 }
2444 `)
2445
Paul Duffin36474d32021-03-12 12:19:43 +00002446 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002447 checkUnversionedAndroidBpContents(`
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002448// This is auto-generated. DO NOT EDIT.
2449
2450cc_prebuilt_library_shared {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002451 name: "stubslib",
2452 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002453 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002454 apex_available: ["//apex_available:platform"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002455 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002456 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002457 versions: [
2458 "1",
2459 "2",
2460 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002461 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002462 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002463 },
2464 arch: {
2465 arm64: {
2466 srcs: ["arm64/lib/stubslib.so"],
2467 },
2468 arm: {
2469 srcs: ["arm/lib/stubslib.so"],
2470 },
2471 },
2472}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002473`))
2474}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002475
2476func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002477 result := testSdkWithCc(t, `
2478 sdk {
2479 name: "mysdk",
2480 host_supported: true,
2481 native_shared_libs: ["stubslib"],
2482 }
2483
2484 cc_library {
2485 name: "internaldep",
2486 host_supported: true,
2487 }
2488
2489 cc_library {
2490 name: "stubslib",
2491 host_supported: true,
2492 shared_libs: ["internaldep"],
2493 stubs: {
2494 symbol_file: "some/where/stubslib.map.txt",
2495 versions: ["1", "2", "3"],
2496 },
2497 }
2498 `)
2499
Paul Duffin36474d32021-03-12 12:19:43 +00002500 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002501 checkUnversionedAndroidBpContents(`
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002502// This is auto-generated. DO NOT EDIT.
2503
2504cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002505 name: "stubslib",
2506 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002507 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002508 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002509 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002510 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002511 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002512 versions: [
2513 "1",
2514 "2",
2515 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002516 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002517 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002518 },
2519 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002520 host: {
2521 enabled: false,
2522 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002523 android_arm64: {
2524 srcs: ["android/arm64/lib/stubslib.so"],
2525 },
2526 android_arm: {
2527 srcs: ["android/arm/lib/stubslib.so"],
2528 },
2529 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002530 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002531 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2532 },
2533 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002534 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002535 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2536 },
2537 },
2538}
Paul Duffin75b902a2021-02-22 12:13:13 +00002539`),
2540 checkVersionedAndroidBpContents(`
2541// This is auto-generated. DO NOT EDIT.
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002542
2543cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002544 name: "mysdk_stubslib@current",
2545 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002546 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002547 apex_available: ["//apex_available:platform"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002548 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002549 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002550 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002551 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002552 versions: [
2553 "1",
2554 "2",
2555 "3",
Jiyong Parkd4a3a132021-03-17 20:21:35 +09002556 "current",
Martin Stjernholm618b6712020-09-24 16:53:04 +01002557 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002558 },
2559 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002560 host: {
2561 enabled: false,
2562 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002563 android_arm64: {
2564 srcs: ["android/arm64/lib/stubslib.so"],
2565 },
2566 android_arm: {
2567 srcs: ["android/arm/lib/stubslib.so"],
2568 },
2569 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002570 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002571 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2572 },
2573 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002574 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002575 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2576 },
2577 },
2578}
2579
2580sdk_snapshot {
2581 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002582 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002583 host_supported: true,
2584 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002585 target: {
2586 host: {
2587 enabled: false,
2588 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002589 linux_glibc_x86_64: {
2590 enabled: true,
2591 },
2592 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002593 enabled: true,
2594 },
2595 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002596}
2597`))
2598}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002599
2600func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002601 result := testSdkWithCc(t, `
2602 sdk {
2603 name: "mysdk",
2604 host_supported: true,
2605 native_shared_libs: ["mylib"],
2606 }
2607
2608 cc_library {
2609 name: "mylib",
2610 host_supported: true,
2611 unique_host_soname: true,
2612 }
2613 `)
2614
Paul Duffin36474d32021-03-12 12:19:43 +00002615 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002616 checkUnversionedAndroidBpContents(`
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002617// This is auto-generated. DO NOT EDIT.
2618
2619cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002620 name: "mylib",
2621 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002622 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002623 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002624 host_supported: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002625 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002626 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002627 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002628 host: {
2629 enabled: false,
2630 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002631 android_arm64: {
2632 srcs: ["android/arm64/lib/mylib.so"],
2633 },
2634 android_arm: {
2635 srcs: ["android/arm/lib/mylib.so"],
2636 },
2637 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002638 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002639 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2640 },
2641 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002642 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002643 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2644 },
2645 },
2646}
Paul Duffin75b902a2021-02-22 12:13:13 +00002647`),
2648 checkVersionedAndroidBpContents(`
2649// This is auto-generated. DO NOT EDIT.
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002650
2651cc_prebuilt_library_shared {
Paul Duffin75b902a2021-02-22 12:13:13 +00002652 name: "mysdk_mylib@current",
2653 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002654 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002655 apex_available: ["//apex_available:platform"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002656 host_supported: true,
Paul Duffin75b902a2021-02-22 12:13:13 +00002657 installable: false,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002658 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002659 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002660 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002661 host: {
2662 enabled: false,
2663 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002664 android_arm64: {
2665 srcs: ["android/arm64/lib/mylib.so"],
2666 },
2667 android_arm: {
2668 srcs: ["android/arm/lib/mylib.so"],
2669 },
2670 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002671 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002672 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2673 },
2674 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002675 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002676 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2677 },
2678 },
2679}
2680
2681sdk_snapshot {
2682 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002683 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002684 host_supported: true,
2685 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002686 target: {
2687 host: {
2688 enabled: false,
2689 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002690 linux_glibc_x86_64: {
2691 enabled: true,
2692 },
2693 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002694 enabled: true,
2695 },
2696 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002697}
2698`),
2699 checkAllCopyRules(`
2700.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2701.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2702.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2703.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2704`),
2705 )
2706}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002707
2708func TestNoSanitizerMembers(t *testing.T) {
2709 result := testSdkWithCc(t, `
2710 sdk {
2711 name: "mysdk",
2712 native_shared_libs: ["mynativelib"],
2713 }
2714
2715 cc_library_shared {
2716 name: "mynativelib",
2717 srcs: ["Test.cpp"],
Paul Duffin86b02a72021-02-22 11:50:04 +00002718 export_include_dirs: ["myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002719 arch: {
2720 arm64: {
2721 export_system_include_dirs: ["arm64/include"],
2722 sanitize: {
2723 hwaddress: true,
2724 },
2725 },
2726 },
2727 }
2728 `)
2729
Paul Duffin36474d32021-03-12 12:19:43 +00002730 CheckSnapshot(t, result, "mysdk", "",
Paul Duffin75b902a2021-02-22 12:13:13 +00002731 checkUnversionedAndroidBpContents(`
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002732// This is auto-generated. DO NOT EDIT.
2733
2734cc_prebuilt_library_shared {
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002735 name: "mynativelib",
2736 prefer: false,
2737 visibility: ["//visibility:public"],
Martin Stjernholm1e041092020-11-03 00:11:09 +00002738 apex_available: ["//apex_available:platform"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002739 compile_multilib: "both",
Paul Duffin86b02a72021-02-22 11:50:04 +00002740 export_include_dirs: ["include/myinclude"],
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002741 arch: {
2742 arm64: {
2743 export_system_include_dirs: ["arm64/include/arm64/include"],
2744 },
2745 arm: {
2746 srcs: ["arm/lib/mynativelib.so"],
2747 },
2748 },
2749}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002750`),
2751 checkAllCopyRules(`
Paul Duffin86b02a72021-02-22 11:50:04 +00002752myinclude/Test.h -> include/myinclude/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002753arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Paul Duffin1822a0a2021-03-21 12:56:33 +00002754.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
2755`),
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002756 )
2757}