blob: 84e4f285f9d050bff8d1cfaf743ae5a57398200b [file] [log] [blame]
Paul Duffina80fdec2019-12-03 15:25:00 +00001// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package sdk
16
17import (
18 "testing"
19
Paul Duffin1356d8c2020-02-25 19:26:33 +000020 "android/soong/android"
Paul Duffina80fdec2019-12-03 15:25:00 +000021 "android/soong/cc"
22)
23
Martin Stjernholm7feceb22020-07-11 04:33:29 +010024var ccTestFs = map[string][]byte{
25 "Test.cpp": nil,
26 "include/Test.h": nil,
27 "include-android/AndroidTest.h": nil,
28 "include-host/HostTest.h": nil,
29 "arm64/include/Arm64Test.h": nil,
30 "libfoo.so": nil,
31 "aidl/foo/bar/Test.aidl": nil,
32 "some/where/stubslib.map.txt": nil,
33}
34
Paul Duffind835daa2019-11-30 17:49:09 +000035func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
36 t.Helper()
Martin Stjernholm7feceb22020-07-11 04:33:29 +010037 return testSdkWithFs(t, bp, ccTestFs)
Paul Duffind835daa2019-11-30 17:49:09 +000038}
39
Paul Duffina80fdec2019-12-03 15:25:00 +000040// Contains tests for SDK members provided by the cc package.
41
Martin Stjernholmcaa47d72020-07-11 04:52:24 +010042func TestSingleDeviceOsAssumption(t *testing.T) {
43 // Mock a module with DeviceSupported() == true.
44 s := &sdk{}
45 android.InitAndroidArchModule(s, android.DeviceSupported, android.MultilibCommon)
46
47 osTypes := s.getPossibleOsTypes()
48 if len(osTypes) != 1 {
49 // The snapshot generation assumes there is a single device OS. If more are
50 // added it might need to disable them by default, like it does for host
51 // OS'es.
52 t.Errorf("expected a single device OS, got %v", osTypes)
53 }
54}
55
Paul Duffina80fdec2019-12-03 15:25:00 +000056func TestSdkIsCompileMultilibBoth(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +000057 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000058 sdk {
59 name: "mysdk",
60 native_shared_libs: ["sdkmember"],
61 }
62
63 cc_library_shared {
64 name: "sdkmember",
65 srcs: ["Test.cpp"],
Paul Duffina80fdec2019-12-03 15:25:00 +000066 stl: "none",
67 }
68 `)
69
Colin Cross7113d202019-11-20 16:39:12 -080070 armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile()
71 arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile()
Paul Duffina80fdec2019-12-03 15:25:00 +000072
73 var inputs []string
Paul Duffin1356d8c2020-02-25 19:26:33 +000074 buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests()
Paul Duffina80fdec2019-12-03 15:25:00 +000075 for _, bp := range buildParams {
76 if bp.Input != nil {
77 inputs = append(inputs, bp.Input.String())
78 }
79 }
80
81 // ensure that both 32/64 outputs are inputs of the sdk snapshot
82 ensureListContains(t, inputs, armOutput.String())
83 ensureListContains(t, inputs, arm64Output.String())
84}
85
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010086func TestSdkCompileMultilibOverride(t *testing.T) {
87 result := testSdkWithCc(t, `
88 sdk {
89 name: "mysdk",
Martin Stjernholm89238f42020-07-10 00:14:03 +010090 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010091 native_shared_libs: ["sdkmember"],
92 compile_multilib: "64",
93 }
94
95 cc_library_shared {
96 name: "sdkmember",
Martin Stjernholm89238f42020-07-10 00:14:03 +010097 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010098 srcs: ["Test.cpp"],
99 stl: "none",
100 compile_multilib: "64",
101 }
102 `)
103
104 result.CheckSnapshot("mysdk", "",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100105 checkAndroidBpContents(`
106// This is auto-generated. DO NOT EDIT.
107
108cc_prebuilt_library_shared {
109 name: "mysdk_sdkmember@current",
110 sdk_member_name: "sdkmember",
Paul Duffind99d9972020-09-29 16:00:55 +0100111 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100112 host_supported: true,
113 installable: false,
114 stl: "none",
115 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100116 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100117 host: {
118 enabled: false,
119 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100120 android_arm64: {
121 srcs: ["android/arm64/lib/sdkmember.so"],
122 },
123 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900124 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100125 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100126 },
127 },
128}
129
130cc_prebuilt_library_shared {
131 name: "sdkmember",
132 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100133 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100134 host_supported: true,
135 stl: "none",
136 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100137 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100138 host: {
139 enabled: false,
140 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100141 android_arm64: {
142 srcs: ["android/arm64/lib/sdkmember.so"],
143 },
144 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900145 enabled: true,
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100146 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100147 },
148 },
149}
150
151sdk_snapshot {
152 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100153 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100154 host_supported: true,
155 native_shared_libs: ["mysdk_sdkmember@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100156 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100157 target: {
158 host: {
159 enabled: false,
160 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900161 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100162 enabled: true,
163 },
164 },
Martin Stjernholm89238f42020-07-10 00:14:03 +0100165}
166`),
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100167 checkAllCopyRules(`
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100168.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
169.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100170`))
171}
172
Paul Duffina80fdec2019-12-03 15:25:00 +0000173func TestBasicSdkWithCc(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +0000174 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000175 sdk {
176 name: "mysdk",
177 native_shared_libs: ["sdkmember"],
178 }
179
Paul Duffina0843f62019-12-13 19:50:38 +0000180 cc_library_shared {
181 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -0800182 system_shared_libs: [],
Martin Stjernholmcc776012020-07-07 03:22:21 +0100183 stl: "none",
184 apex_available: ["mysdkapex"],
Paul Duffina0843f62019-12-13 19:50:38 +0000185 }
186
Paul Duffina80fdec2019-12-03 15:25:00 +0000187 sdk_snapshot {
188 name: "mysdk@1",
189 native_shared_libs: ["sdkmember_mysdk_1"],
190 }
191
192 sdk_snapshot {
193 name: "mysdk@2",
194 native_shared_libs: ["sdkmember_mysdk_2"],
195 }
196
197 cc_prebuilt_library_shared {
198 name: "sdkmember",
199 srcs: ["libfoo.so"],
200 prefer: false,
201 system_shared_libs: [],
202 stl: "none",
203 }
204
205 cc_prebuilt_library_shared {
206 name: "sdkmember_mysdk_1",
207 sdk_member_name: "sdkmember",
208 srcs: ["libfoo.so"],
209 system_shared_libs: [],
210 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000211 // TODO: remove //apex_available:platform
212 apex_available: [
213 "//apex_available:platform",
214 "myapex",
215 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000216 }
217
218 cc_prebuilt_library_shared {
219 name: "sdkmember_mysdk_2",
220 sdk_member_name: "sdkmember",
221 srcs: ["libfoo.so"],
222 system_shared_libs: [],
223 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000224 // TODO: remove //apex_available:platform
225 apex_available: [
226 "//apex_available:platform",
227 "myapex2",
228 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000229 }
230
231 cc_library_shared {
232 name: "mycpplib",
233 srcs: ["Test.cpp"],
234 shared_libs: ["sdkmember"],
235 system_shared_libs: [],
236 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000237 apex_available: [
238 "myapex",
239 "myapex2",
240 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000241 }
242
243 apex {
244 name: "myapex",
245 native_shared_libs: ["mycpplib"],
246 uses_sdks: ["mysdk@1"],
247 key: "myapex.key",
248 certificate: ":myapex.cert",
249 }
250
251 apex {
252 name: "myapex2",
253 native_shared_libs: ["mycpplib"],
254 uses_sdks: ["mysdk@2"],
255 key: "myapex.key",
256 certificate: ":myapex.cert",
257 }
Martin Stjernholmcc776012020-07-07 03:22:21 +0100258
259 apex {
260 name: "mysdkapex",
261 native_shared_libs: ["sdkmember"],
262 key: "myapex.key",
263 certificate: ":myapex.cert",
264 }
Paul Duffina80fdec2019-12-03 15:25:00 +0000265 `)
266
Colin Crossaede88c2020-08-11 12:17:01 -0700267 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
268 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000269
Colin Crossaede88c2020-08-11 12:17:01 -0700270 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1")
271 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000272
273 // Depending on the uses_sdks value, different libs are linked
274 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
275 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
276}
277
Paul Duffina0843f62019-12-13 19:50:38 +0000278// Make sure the sdk can use host specific cc libraries static/shared and both.
279func TestHostSdkWithCc(t *testing.T) {
280 testSdkWithCc(t, `
281 sdk {
282 name: "mysdk",
283 device_supported: false,
284 host_supported: true,
285 native_shared_libs: ["sdkshared"],
286 native_static_libs: ["sdkstatic"],
287 }
288
289 cc_library_host_shared {
290 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000291 stl: "none",
292 }
293
294 cc_library_host_static {
295 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000296 stl: "none",
297 }
298 `)
299}
300
301// Make sure the sdk can use cc libraries static/shared and both.
302func TestSdkWithCc(t *testing.T) {
303 testSdkWithCc(t, `
304 sdk {
305 name: "mysdk",
306 native_shared_libs: ["sdkshared", "sdkboth1"],
307 native_static_libs: ["sdkstatic", "sdkboth2"],
308 }
309
310 cc_library_shared {
311 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000312 stl: "none",
313 }
314
315 cc_library_static {
316 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000317 stl: "none",
318 }
319
320 cc_library {
321 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000322 stl: "none",
323 }
324
325 cc_library {
326 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000327 stl: "none",
328 }
329 `)
330}
331
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000332func TestSnapshotWithObject(t *testing.T) {
333 result := testSdkWithCc(t, `
334 sdk {
335 name: "mysdk",
336 native_objects: ["crtobj"],
337 }
338
339 cc_object {
340 name: "crtobj",
341 stl: "none",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100342 sanitize: {
343 never: true,
344 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000345 }
346 `)
347
348 result.CheckSnapshot("mysdk", "",
349 checkAndroidBpContents(`
350// This is auto-generated. DO NOT EDIT.
351
352cc_prebuilt_object {
353 name: "mysdk_crtobj@current",
354 sdk_member_name: "crtobj",
Paul Duffind99d9972020-09-29 16:00:55 +0100355 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000356 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100357 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100358 sanitize: {
359 never: true,
360 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000361 arch: {
362 arm64: {
363 srcs: ["arm64/lib/crtobj.o"],
364 },
365 arm: {
366 srcs: ["arm/lib/crtobj.o"],
367 },
368 },
369}
370
371cc_prebuilt_object {
372 name: "crtobj",
373 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100374 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000375 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100376 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100377 sanitize: {
378 never: true,
379 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000380 arch: {
381 arm64: {
382 srcs: ["arm64/lib/crtobj.o"],
383 },
384 arm: {
385 srcs: ["arm/lib/crtobj.o"],
386 },
387 },
388}
389
390sdk_snapshot {
391 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100392 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000393 native_objects: ["mysdk_crtobj@current"],
394}
395`),
396 checkAllCopyRules(`
397.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
398.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
399`),
400 )
401}
402
Paul Duffinc62a5102019-12-11 18:34:15 +0000403func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
404 result := testSdkWithCc(t, `
405 sdk {
406 name: "mysdk",
407 native_shared_libs: ["mynativelib1", "mynativelib2"],
408 }
409
410 cc_library_shared {
411 name: "mynativelib1",
412 srcs: [
413 "Test.cpp",
414 ],
415 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000416 stl: "none",
417 }
418
419 cc_library_shared {
420 name: "mynativelib2",
421 srcs: [
422 "Test.cpp",
423 ],
424 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000425 stl: "none",
426 }
427 `)
428
Paul Duffin1356d8c2020-02-25 19:26:33 +0000429 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000430 checkAllCopyRules(`
431include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800432.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
433.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
434.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
435.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000436`),
437 )
438}
439
Martin Stjernholmb0249572020-09-15 02:32:35 +0100440// Verify that when the shared library has some common and some arch specific
441// properties that the generated snapshot is optimized properly. Substruct
442// handling is tested with the sanitize clauses (but note there's a lot of
443// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000444func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
445 result := testSdkWithCc(t, `
446 sdk {
447 name: "mysdk",
448 native_shared_libs: ["mynativelib"],
449 }
450
451 cc_library_shared {
452 name: "mynativelib",
453 srcs: [
454 "Test.cpp",
455 "aidl/foo/bar/Test.aidl",
456 ],
457 export_include_dirs: ["include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100458 sanitize: {
459 fuzzer: false,
460 integer_overflow: true,
461 diag: { undefined: false },
462 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000463 arch: {
464 arm64: {
465 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100466 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100467 integer_overflow: false,
468 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000469 },
470 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000471 stl: "none",
472 }
473 `)
474
Paul Duffin1356d8c2020-02-25 19:26:33 +0000475 result.CheckSnapshot("mysdk", "",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000476 checkAndroidBpContents(`
477// This is auto-generated. DO NOT EDIT.
478
479cc_prebuilt_library_shared {
480 name: "mysdk_mynativelib@current",
481 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100482 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000483 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000484 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100485 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000486 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100487 sanitize: {
488 fuzzer: false,
489 diag: {
490 undefined: false,
491 },
492 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000493 arch: {
494 arm64: {
495 srcs: ["arm64/lib/mynativelib.so"],
496 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100497 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100498 integer_overflow: false,
499 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000500 },
501 arm: {
502 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100503 sanitize: {
504 integer_overflow: true,
505 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000506 },
507 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000508}
509
510cc_prebuilt_library_shared {
511 name: "mynativelib",
512 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100513 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000514 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100515 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000516 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100517 sanitize: {
518 fuzzer: false,
519 diag: {
520 undefined: false,
521 },
522 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000523 arch: {
524 arm64: {
525 srcs: ["arm64/lib/mynativelib.so"],
526 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100527 sanitize: {
Martin Stjernholmb0249572020-09-15 02:32:35 +0100528 integer_overflow: false,
529 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000530 },
531 arm: {
532 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100533 sanitize: {
534 integer_overflow: true,
535 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000536 },
537 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000538}
539
540sdk_snapshot {
541 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100542 visibility: ["//visibility:public"],
Paul Duffina7cd8c82019-12-11 20:00:57 +0000543 native_shared_libs: ["mysdk_mynativelib@current"],
544}
545`),
546 checkAllCopyRules(`
547include/Test.h -> include/include/Test.h
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +0000548.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000549arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800550.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000551 )
552}
553
Paul Duffin25ce04b2020-01-16 11:47:25 +0000554func TestSnapshotWithCcBinary(t *testing.T) {
555 result := testSdkWithCc(t, `
556 module_exports {
557 name: "mymodule_exports",
558 native_binaries: ["mynativebinary"],
559 }
560
561 cc_binary {
562 name: "mynativebinary",
563 srcs: [
564 "Test.cpp",
565 ],
566 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000567 }
568 `)
569
Paul Duffin1356d8c2020-02-25 19:26:33 +0000570 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000571 checkAndroidBpContents(`
572// This is auto-generated. DO NOT EDIT.
573
574cc_prebuilt_binary {
575 name: "mymodule_exports_mynativebinary@current",
576 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100577 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000578 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000579 compile_multilib: "both",
580 arch: {
581 arm64: {
582 srcs: ["arm64/bin/mynativebinary"],
583 },
584 arm: {
585 srcs: ["arm/bin/mynativebinary"],
586 },
587 },
588}
589
590cc_prebuilt_binary {
591 name: "mynativebinary",
592 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100593 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000594 compile_multilib: "both",
595 arch: {
596 arm64: {
597 srcs: ["arm64/bin/mynativebinary"],
598 },
599 arm: {
600 srcs: ["arm/bin/mynativebinary"],
601 },
602 },
603}
604
605module_exports_snapshot {
606 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100607 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000608 native_binaries: ["mymodule_exports_mynativebinary@current"],
609}
610`),
611 checkAllCopyRules(`
612.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
613.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
614`),
615 )
616}
617
Paul Duffina04c1072020-03-02 10:16:35 +0000618func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +0000619 result := testSdkWithCc(t, `
620 module_exports {
621 name: "myexports",
622 device_supported: false,
623 host_supported: true,
624 native_binaries: ["mynativebinary"],
625 target: {
626 windows: {
627 enabled: true,
628 },
629 },
630 }
631
632 cc_binary {
633 name: "mynativebinary",
634 device_supported: false,
635 host_supported: true,
636 srcs: [
637 "Test.cpp",
638 ],
639 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000640 stl: "none",
641 target: {
642 windows: {
643 enabled: true,
644 },
645 },
646 }
647 `)
648
649 result.CheckSnapshot("myexports", "",
650 checkAndroidBpContents(`
651// This is auto-generated. DO NOT EDIT.
652
653cc_prebuilt_binary {
654 name: "myexports_mynativebinary@current",
655 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100656 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000657 device_supported: false,
658 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000659 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100660 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000661 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100662 host: {
663 enabled: false,
664 },
Paul Duffina04c1072020-03-02 10:16:35 +0000665 linux_glibc: {
666 compile_multilib: "both",
667 },
668 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900669 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000670 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
671 },
672 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900673 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000674 srcs: ["linux_glibc/x86/bin/mynativebinary"],
675 },
676 windows: {
677 compile_multilib: "64",
678 },
679 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900680 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000681 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
682 },
683 },
684}
685
686cc_prebuilt_binary {
687 name: "mynativebinary",
688 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100689 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000690 device_supported: false,
691 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100692 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000693 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100694 host: {
695 enabled: false,
696 },
Paul Duffina04c1072020-03-02 10:16:35 +0000697 linux_glibc: {
698 compile_multilib: "both",
699 },
700 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900701 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000702 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
703 },
704 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900705 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000706 srcs: ["linux_glibc/x86/bin/mynativebinary"],
707 },
708 windows: {
709 compile_multilib: "64",
710 },
711 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900712 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000713 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
714 },
715 },
716}
717
718module_exports_snapshot {
719 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100720 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000721 device_supported: false,
722 host_supported: true,
723 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000724 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900725 windows: {
726 compile_multilib: "64",
727 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100728 host: {
729 enabled: false,
730 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900731 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100732 enabled: true,
733 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900734 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100735 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +0900736 },
737 windows_x86_64: {
738 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000739 },
740 },
Paul Duffina04c1072020-03-02 10:16:35 +0000741}
742`),
743 checkAllCopyRules(`
744.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
745.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
746.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
747`),
748 )
749}
750
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100751func TestSnapshotWithSingleHostOsType(t *testing.T) {
752 ctx, config := testSdkContext(`
753 cc_defaults {
754 name: "mydefaults",
755 device_supported: false,
756 host_supported: true,
757 compile_multilib: "64",
758 target: {
759 host: {
760 enabled: false,
761 },
762 linux_bionic: {
763 enabled: true,
764 },
765 },
766 }
767
768 module_exports {
769 name: "myexports",
770 defaults: ["mydefaults"],
771 native_shared_libs: ["mynativelib"],
772 native_binaries: ["mynativebinary"],
773 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
774 }
775
776 cc_library {
777 name: "mynativelib",
778 defaults: ["mydefaults"],
779 srcs: [
780 "Test.cpp",
781 ],
782 stl: "none",
783 }
784
785 cc_binary {
786 name: "mynativebinary",
787 defaults: ["mydefaults"],
788 srcs: [
789 "Test.cpp",
790 ],
791 stl: "none",
792 }
793 `, ccTestFs, []android.OsType{android.LinuxBionic})
794
795 result := runTests(t, ctx, config)
796
797 result.CheckSnapshot("myexports", "",
798 checkAndroidBpContents(`
799// This is auto-generated. DO NOT EDIT.
800
801cc_prebuilt_binary {
802 name: "myexports_mynativebinary@current",
803 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100804 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100805 device_supported: false,
806 host_supported: true,
807 installable: false,
808 stl: "none",
809 compile_multilib: "64",
810 target: {
811 host: {
812 enabled: false,
813 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100814 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900815 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100816 srcs: ["x86_64/bin/mynativebinary"],
817 },
818 },
819}
820
821cc_prebuilt_binary {
822 name: "mynativebinary",
823 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100824 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100825 device_supported: false,
826 host_supported: true,
827 stl: "none",
828 compile_multilib: "64",
829 target: {
830 host: {
831 enabled: false,
832 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100833 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900834 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100835 srcs: ["x86_64/bin/mynativebinary"],
836 },
837 },
838}
839
840cc_prebuilt_library_shared {
841 name: "myexports_mynativelib@current",
842 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100843 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100844 device_supported: false,
845 host_supported: true,
846 installable: false,
847 stl: "none",
848 compile_multilib: "64",
849 target: {
850 host: {
851 enabled: false,
852 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100853 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900854 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100855 srcs: ["x86_64/lib/mynativelib.so"],
856 },
857 },
858}
859
860cc_prebuilt_library_shared {
861 name: "mynativelib",
862 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100863 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100864 device_supported: false,
865 host_supported: true,
866 stl: "none",
867 compile_multilib: "64",
868 target: {
869 host: {
870 enabled: false,
871 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100872 linux_bionic_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900873 enabled: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100874 srcs: ["x86_64/lib/mynativelib.so"],
875 },
876 },
877}
878
879module_exports_snapshot {
880 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100881 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100882 device_supported: false,
883 host_supported: true,
884 native_binaries: ["myexports_mynativebinary@current"],
885 native_shared_libs: ["myexports_mynativelib@current"],
886 compile_multilib: "64",
887 target: {
888 host: {
889 enabled: false,
890 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900891 linux_bionic_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100892 enabled: true,
893 },
894 },
895}
896`),
897 checkAllCopyRules(`
898.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
899.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
900`),
901 )
902}
903
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100904// Test that we support the necessary flags for the linker binary, which is
905// special in several ways.
906func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100907 result := testSdkWithCc(t, `
908 module_exports {
909 name: "mymodule_exports",
910 host_supported: true,
911 device_supported: false,
912 native_binaries: ["linker"],
913 }
914
915 cc_binary {
916 name: "linker",
917 host_supported: true,
918 static_executable: true,
919 nocrt: true,
920 stl: "none",
921 srcs: [
922 "Test.cpp",
923 ],
924 compile_multilib: "both",
925 }
926 `)
927
928 result.CheckSnapshot("mymodule_exports", "",
929 checkAndroidBpContents(`
930// This is auto-generated. DO NOT EDIT.
931
932cc_prebuilt_binary {
933 name: "mymodule_exports_linker@current",
934 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +0100935 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100936 device_supported: false,
937 host_supported: true,
938 installable: false,
939 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100940 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100941 static_executable: true,
942 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100943 target: {
944 host: {
945 enabled: false,
946 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100947 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900948 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100949 srcs: ["x86_64/bin/linker"],
950 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100951 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900952 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100953 srcs: ["x86/bin/linker"],
954 },
955 },
956}
957
958cc_prebuilt_binary {
959 name: "linker",
960 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100961 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100962 device_supported: false,
963 host_supported: true,
964 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100965 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100966 static_executable: true,
967 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100968 target: {
969 host: {
970 enabled: false,
971 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100972 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900973 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100974 srcs: ["x86_64/bin/linker"],
975 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100976 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +0900977 enabled: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100978 srcs: ["x86/bin/linker"],
979 },
980 },
981}
982
983module_exports_snapshot {
984 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100985 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100986 device_supported: false,
987 host_supported: true,
988 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100989 target: {
990 host: {
991 enabled: false,
992 },
Jiyong Park8fe14e62020-10-19 22:47:34 +0900993 linux_glibc_x86_64: {
994 enabled: true,
995 },
996 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100997 enabled: true,
998 },
999 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001000}
1001`),
1002 checkAllCopyRules(`
1003.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1004.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1005`),
1006 )
1007}
1008
Paul Duffin9ab556f2019-12-11 18:42:17 +00001009func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001010 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001011 sdk {
1012 name: "mysdk",
1013 native_shared_libs: ["mynativelib"],
1014 }
1015
1016 cc_library_shared {
1017 name: "mynativelib",
1018 srcs: [
1019 "Test.cpp",
1020 "aidl/foo/bar/Test.aidl",
1021 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001022 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001023 export_include_dirs: ["include"],
1024 aidl: {
1025 export_aidl_headers: true,
1026 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001027 stl: "none",
1028 }
1029 `)
1030
Paul Duffin1356d8c2020-02-25 19:26:33 +00001031 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001032 checkAndroidBpContents(`
1033// This is auto-generated. DO NOT EDIT.
1034
1035cc_prebuilt_library_shared {
1036 name: "mysdk_mynativelib@current",
1037 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001038 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001039 apex_available: [
1040 "apex1",
1041 "apex2",
1042 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001043 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001044 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001045 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001046 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001047 arch: {
1048 arm64: {
1049 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001050 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001051 },
1052 arm: {
1053 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001054 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001055 },
1056 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001057}
1058
1059cc_prebuilt_library_shared {
1060 name: "mynativelib",
1061 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001062 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001063 apex_available: [
1064 "apex1",
1065 "apex2",
1066 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001067 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001068 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001069 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001070 arch: {
1071 arm64: {
1072 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001073 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001074 },
1075 arm: {
1076 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001077 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001078 },
1079 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001080}
1081
1082sdk_snapshot {
1083 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001084 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001085 native_shared_libs: ["mysdk_mynativelib@current"],
1086}
1087`),
1088 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001089include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001090.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1091.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1092.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1093.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1094.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1095.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1096.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1097.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001098`),
1099 )
1100}
1101
Paul Duffin13f02712020-03-06 12:30:43 +00001102func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
1103 result := testSdkWithCc(t, `
1104 sdk {
1105 name: "mysdk",
1106 native_shared_libs: [
1107 "mynativelib",
1108 "myothernativelib",
1109 "mysystemnativelib",
1110 ],
1111 }
1112
1113 cc_library {
1114 name: "mysystemnativelib",
1115 srcs: [
1116 "Test.cpp",
1117 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001118 stl: "none",
1119 }
1120
1121 cc_library_shared {
1122 name: "myothernativelib",
1123 srcs: [
1124 "Test.cpp",
1125 ],
1126 system_shared_libs: [
1127 // A reference to a library that is not an sdk member. Uses libm as that
1128 // is in the default set of modules available to this test and so is available
1129 // both here and also when the generated Android.bp file is tested in
1130 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1131 // handles references to modules that are not sdk members.
1132 "libm",
1133 ],
1134 stl: "none",
1135 }
1136
1137 cc_library {
1138 name: "mynativelib",
1139 srcs: [
1140 "Test.cpp",
1141 ],
1142 shared_libs: [
1143 // A reference to another sdk member.
1144 "myothernativelib",
1145 ],
1146 target: {
1147 android: {
1148 shared: {
1149 shared_libs: [
1150 // A reference to a library that is not an sdk member. The libc library
1151 // is used here to check that the shared_libs property is handled correctly
1152 // in a similar way to how libm is used to check system_shared_libs above.
1153 "libc",
1154 ],
1155 },
1156 },
1157 },
Paul Duffin13f02712020-03-06 12:30:43 +00001158 stl: "none",
1159 }
1160 `)
1161
1162 result.CheckSnapshot("mysdk", "",
1163 checkAndroidBpContents(`
1164// This is auto-generated. DO NOT EDIT.
1165
1166cc_prebuilt_library_shared {
1167 name: "mysdk_mynativelib@current",
1168 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001169 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001170 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001171 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001172 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001173 shared_libs: [
1174 "mysdk_myothernativelib@current",
1175 "libc",
1176 ],
1177 arch: {
1178 arm64: {
1179 srcs: ["arm64/lib/mynativelib.so"],
1180 },
1181 arm: {
1182 srcs: ["arm/lib/mynativelib.so"],
1183 },
1184 },
Paul Duffin13f02712020-03-06 12:30:43 +00001185}
1186
1187cc_prebuilt_library_shared {
1188 name: "mynativelib",
1189 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001190 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001191 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001192 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001193 shared_libs: [
1194 "myothernativelib",
1195 "libc",
1196 ],
1197 arch: {
1198 arm64: {
1199 srcs: ["arm64/lib/mynativelib.so"],
1200 },
1201 arm: {
1202 srcs: ["arm/lib/mynativelib.so"],
1203 },
1204 },
Paul Duffin13f02712020-03-06 12:30:43 +00001205}
1206
1207cc_prebuilt_library_shared {
1208 name: "mysdk_myothernativelib@current",
1209 sdk_member_name: "myothernativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001210 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001211 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001212 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001213 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001214 system_shared_libs: ["libm"],
1215 arch: {
1216 arm64: {
1217 srcs: ["arm64/lib/myothernativelib.so"],
1218 },
1219 arm: {
1220 srcs: ["arm/lib/myothernativelib.so"],
1221 },
1222 },
Paul Duffin13f02712020-03-06 12:30:43 +00001223}
1224
1225cc_prebuilt_library_shared {
1226 name: "myothernativelib",
1227 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001228 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001229 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001230 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001231 system_shared_libs: ["libm"],
1232 arch: {
1233 arm64: {
1234 srcs: ["arm64/lib/myothernativelib.so"],
1235 },
1236 arm: {
1237 srcs: ["arm/lib/myothernativelib.so"],
1238 },
1239 },
Paul Duffin13f02712020-03-06 12:30:43 +00001240}
1241
1242cc_prebuilt_library_shared {
1243 name: "mysdk_mysystemnativelib@current",
1244 sdk_member_name: "mysystemnativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001245 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001246 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001247 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001248 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001249 arch: {
1250 arm64: {
1251 srcs: ["arm64/lib/mysystemnativelib.so"],
1252 },
1253 arm: {
1254 srcs: ["arm/lib/mysystemnativelib.so"],
1255 },
1256 },
Paul Duffin13f02712020-03-06 12:30:43 +00001257}
1258
1259cc_prebuilt_library_shared {
1260 name: "mysystemnativelib",
1261 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001262 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001263 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001264 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001265 arch: {
1266 arm64: {
1267 srcs: ["arm64/lib/mysystemnativelib.so"],
1268 },
1269 arm: {
1270 srcs: ["arm/lib/mysystemnativelib.so"],
1271 },
1272 },
Paul Duffin13f02712020-03-06 12:30:43 +00001273}
1274
1275sdk_snapshot {
1276 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001277 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001278 native_shared_libs: [
1279 "mysdk_mynativelib@current",
1280 "mysdk_myothernativelib@current",
1281 "mysdk_mysystemnativelib@current",
1282 ],
1283}
1284`),
1285 checkAllCopyRules(`
1286.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1287.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1288.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1289.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1290.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1291.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1292`),
1293 )
1294}
1295
Paul Duffin9ab556f2019-12-11 18:42:17 +00001296func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffind835daa2019-11-30 17:49:09 +00001297 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001298 sdk {
1299 name: "mysdk",
1300 device_supported: false,
1301 host_supported: true,
1302 native_shared_libs: ["mynativelib"],
1303 }
1304
1305 cc_library_shared {
1306 name: "mynativelib",
1307 device_supported: false,
1308 host_supported: true,
1309 srcs: [
1310 "Test.cpp",
1311 "aidl/foo/bar/Test.aidl",
1312 ],
1313 export_include_dirs: ["include"],
1314 aidl: {
1315 export_aidl_headers: true,
1316 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001317 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001318 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001319 }
1320 `)
1321
Paul Duffin1356d8c2020-02-25 19:26:33 +00001322 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001323 checkAndroidBpContents(`
1324// This is auto-generated. DO NOT EDIT.
1325
1326cc_prebuilt_library_shared {
1327 name: "mysdk_mynativelib@current",
1328 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001329 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001330 device_supported: false,
1331 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001332 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001333 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001334 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001335 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001336 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001337 target: {
1338 host: {
1339 enabled: false,
1340 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001341 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001342 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001343 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001344 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001345 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001346 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001347 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001348 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001349 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001350 },
1351 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001352}
1353
1354cc_prebuilt_library_shared {
1355 name: "mynativelib",
1356 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001357 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001358 device_supported: false,
1359 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001360 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001361 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001362 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001363 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001364 target: {
1365 host: {
1366 enabled: false,
1367 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001368 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001369 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001370 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001371 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001372 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001373 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001374 enabled: true,
Paul Duffina80fdec2019-12-03 15:25:00 +00001375 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001376 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001377 },
1378 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001379}
1380
1381sdk_snapshot {
1382 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001383 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001384 device_supported: false,
1385 host_supported: true,
1386 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001387 target: {
1388 host: {
1389 enabled: false,
1390 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001391 linux_glibc_x86_64: {
1392 enabled: true,
1393 },
1394 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001395 enabled: true,
1396 },
1397 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001398}
1399`),
1400 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001401include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001402.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001403.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1404.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1405.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1406.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001407.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1408.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1409.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1410`),
1411 )
1412}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001413
Paul Duffina04c1072020-03-02 10:16:35 +00001414func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00001415 result := testSdkWithCc(t, `
1416 sdk {
1417 name: "mysdk",
1418 device_supported: false,
1419 host_supported: true,
1420 native_shared_libs: ["mynativelib"],
1421 target: {
1422 windows: {
1423 enabled: true,
1424 },
1425 },
1426 }
1427
1428 cc_library_shared {
1429 name: "mynativelib",
1430 device_supported: false,
1431 host_supported: true,
1432 srcs: [
1433 "Test.cpp",
1434 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001435 stl: "none",
1436 target: {
1437 windows: {
1438 enabled: true,
1439 },
1440 },
1441 }
1442 `)
1443
1444 result.CheckSnapshot("mysdk", "",
1445 checkAndroidBpContents(`
1446// This is auto-generated. DO NOT EDIT.
1447
1448cc_prebuilt_library_shared {
1449 name: "mysdk_mynativelib@current",
1450 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001451 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001452 device_supported: false,
1453 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001454 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001455 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001456 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001457 host: {
1458 enabled: false,
1459 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001460 linux_glibc: {
1461 compile_multilib: "both",
1462 },
Paul Duffina04c1072020-03-02 10:16:35 +00001463 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001464 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001465 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1466 },
1467 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001468 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001469 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1470 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001471 windows: {
1472 compile_multilib: "64",
1473 },
Paul Duffina04c1072020-03-02 10:16:35 +00001474 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001475 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001476 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1477 },
1478 },
Paul Duffina04c1072020-03-02 10:16:35 +00001479}
1480
1481cc_prebuilt_library_shared {
1482 name: "mynativelib",
1483 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001484 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001485 device_supported: false,
1486 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001487 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001488 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001489 host: {
1490 enabled: false,
1491 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001492 linux_glibc: {
1493 compile_multilib: "both",
1494 },
Paul Duffina04c1072020-03-02 10:16:35 +00001495 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001496 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001497 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1498 },
1499 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001500 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001501 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1502 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001503 windows: {
1504 compile_multilib: "64",
1505 },
Paul Duffina04c1072020-03-02 10:16:35 +00001506 windows_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001507 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +00001508 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1509 },
1510 },
Paul Duffina04c1072020-03-02 10:16:35 +00001511}
1512
1513sdk_snapshot {
1514 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001515 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001516 device_supported: false,
1517 host_supported: true,
1518 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001519 target: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001520 windows: {
1521 compile_multilib: "64",
1522 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001523 host: {
1524 enabled: false,
1525 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001526 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001527 enabled: true,
1528 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001529 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001530 enabled: true,
Jiyong Park8fe14e62020-10-19 22:47:34 +09001531 },
1532 windows_x86_64: {
1533 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001534 },
1535 },
Paul Duffina04c1072020-03-02 10:16:35 +00001536}
1537`),
1538 checkAllCopyRules(`
1539.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1540.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1541.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1542`),
1543 )
1544}
1545
Paul Duffin9ab556f2019-12-11 18:42:17 +00001546func TestSnapshotWithCcStaticLibrary(t *testing.T) {
1547 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001548 module_exports {
1549 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001550 native_static_libs: ["mynativelib"],
1551 }
1552
1553 cc_library_static {
1554 name: "mynativelib",
1555 srcs: [
1556 "Test.cpp",
1557 "aidl/foo/bar/Test.aidl",
1558 ],
1559 export_include_dirs: ["include"],
1560 aidl: {
1561 export_aidl_headers: true,
1562 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001563 stl: "none",
1564 }
1565 `)
1566
Paul Duffin1356d8c2020-02-25 19:26:33 +00001567 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001568 checkAndroidBpContents(`
1569// This is auto-generated. DO NOT EDIT.
1570
1571cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001572 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001573 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001574 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001575 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001576 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001577 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001578 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001579 arch: {
1580 arm64: {
1581 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001582 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001583 },
1584 arm: {
1585 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001586 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001587 },
1588 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001589}
1590
1591cc_prebuilt_library_static {
1592 name: "mynativelib",
1593 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001594 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001595 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001596 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001597 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001598 arch: {
1599 arm64: {
1600 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001601 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001602 },
1603 arm: {
1604 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001605 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001606 },
1607 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001608}
1609
Paul Duffine6029182019-12-16 17:43:48 +00001610module_exports_snapshot {
1611 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001612 visibility: ["//visibility:public"],
Paul Duffine6029182019-12-16 17:43:48 +00001613 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001614}
1615`),
1616 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001617include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001618.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1619.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1620.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1621.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1622.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1623.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1624.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1625.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001626`),
1627 )
1628}
1629
1630func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001631 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001632 module_exports {
1633 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001634 device_supported: false,
1635 host_supported: true,
1636 native_static_libs: ["mynativelib"],
1637 }
1638
1639 cc_library_static {
1640 name: "mynativelib",
1641 device_supported: false,
1642 host_supported: true,
1643 srcs: [
1644 "Test.cpp",
1645 "aidl/foo/bar/Test.aidl",
1646 ],
1647 export_include_dirs: ["include"],
1648 aidl: {
1649 export_aidl_headers: true,
1650 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001651 stl: "none",
1652 }
1653 `)
1654
Paul Duffin1356d8c2020-02-25 19:26:33 +00001655 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001656 checkAndroidBpContents(`
1657// This is auto-generated. DO NOT EDIT.
1658
1659cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001660 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001661 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001662 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001663 device_supported: false,
1664 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001665 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001666 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001667 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001668 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001669 target: {
1670 host: {
1671 enabled: false,
1672 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001673 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001674 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001675 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001676 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001677 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001678 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001679 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001680 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001681 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001682 },
1683 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001684}
1685
1686cc_prebuilt_library_static {
1687 name: "mynativelib",
1688 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001689 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001690 device_supported: false,
1691 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001692 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001693 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001694 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001695 target: {
1696 host: {
1697 enabled: false,
1698 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001699 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001700 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001701 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001702 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001703 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001704 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001705 enabled: true,
Paul Duffin9ab556f2019-12-11 18:42:17 +00001706 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001707 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001708 },
1709 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001710}
1711
Paul Duffine6029182019-12-16 17:43:48 +00001712module_exports_snapshot {
1713 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001714 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001715 device_supported: false,
1716 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001717 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001718 target: {
1719 host: {
1720 enabled: false,
1721 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001722 linux_glibc_x86_64: {
1723 enabled: true,
1724 },
1725 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001726 enabled: true,
1727 },
1728 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001729}
1730`),
1731 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001732include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001733.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001734.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1735.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1736.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1737.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001738.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1739.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1740.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1741`),
1742 )
1743}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001744
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001745func TestSnapshotWithCcLibrary(t *testing.T) {
1746 result := testSdkWithCc(t, `
1747 module_exports {
1748 name: "myexports",
1749 native_libs: ["mynativelib"],
1750 }
1751
1752 cc_library {
1753 name: "mynativelib",
1754 srcs: [
1755 "Test.cpp",
1756 ],
1757 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001758 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001759 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001760 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001761 }
1762 `)
1763
1764 result.CheckSnapshot("myexports", "",
1765 checkAndroidBpContents(`
1766// This is auto-generated. DO NOT EDIT.
1767
1768cc_prebuilt_library {
1769 name: "myexports_mynativelib@current",
1770 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001771 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001772 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001773 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001774 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001775 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001776 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001777 export_include_dirs: ["include/include"],
1778 arch: {
1779 arm64: {
1780 static: {
1781 srcs: ["arm64/lib/mynativelib.a"],
1782 },
1783 shared: {
1784 srcs: ["arm64/lib/mynativelib.so"],
1785 },
1786 },
1787 arm: {
1788 static: {
1789 srcs: ["arm/lib/mynativelib.a"],
1790 },
1791 shared: {
1792 srcs: ["arm/lib/mynativelib.so"],
1793 },
1794 },
1795 },
1796}
1797
1798cc_prebuilt_library {
1799 name: "mynativelib",
1800 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001801 visibility: ["//visibility:public"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001802 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001803 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001804 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001805 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001806 export_include_dirs: ["include/include"],
1807 arch: {
1808 arm64: {
1809 static: {
1810 srcs: ["arm64/lib/mynativelib.a"],
1811 },
1812 shared: {
1813 srcs: ["arm64/lib/mynativelib.so"],
1814 },
1815 },
1816 arm: {
1817 static: {
1818 srcs: ["arm/lib/mynativelib.a"],
1819 },
1820 shared: {
1821 srcs: ["arm/lib/mynativelib.so"],
1822 },
1823 },
1824 },
1825}
1826
1827module_exports_snapshot {
1828 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001829 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001830 native_libs: ["myexports_mynativelib@current"],
1831}
1832`),
1833 checkAllCopyRules(`
1834include/Test.h -> include/include/Test.h
1835.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1836.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1837.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1838.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1839 )
1840}
1841
Paul Duffin13ad94f2020-02-19 16:19:27 +00001842func TestHostSnapshotWithMultiLib64(t *testing.T) {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001843 result := testSdkWithCc(t, `
1844 module_exports {
1845 name: "myexports",
1846 device_supported: false,
1847 host_supported: true,
1848 target: {
1849 host: {
1850 compile_multilib: "64",
1851 },
1852 },
1853 native_static_libs: ["mynativelib"],
1854 }
1855
1856 cc_library_static {
1857 name: "mynativelib",
1858 device_supported: false,
1859 host_supported: true,
1860 srcs: [
1861 "Test.cpp",
1862 "aidl/foo/bar/Test.aidl",
1863 ],
1864 export_include_dirs: ["include"],
1865 aidl: {
1866 export_aidl_headers: true,
1867 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001868 stl: "none",
1869 }
1870 `)
1871
Paul Duffin1356d8c2020-02-25 19:26:33 +00001872 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001873 checkAndroidBpContents(`
1874// This is auto-generated. DO NOT EDIT.
1875
1876cc_prebuilt_library_static {
1877 name: "myexports_mynativelib@current",
1878 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001879 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001880 device_supported: false,
1881 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001882 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001883 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001884 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001885 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001886 target: {
1887 host: {
1888 enabled: false,
1889 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001890 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001891 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001892 srcs: ["x86_64/lib/mynativelib.a"],
1893 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1894 },
1895 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001896}
1897
1898cc_prebuilt_library_static {
1899 name: "mynativelib",
1900 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001901 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001902 device_supported: false,
1903 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001904 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001905 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001906 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001907 target: {
1908 host: {
1909 enabled: false,
1910 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001911 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09001912 enabled: true,
Paul Duffin13ad94f2020-02-19 16:19:27 +00001913 srcs: ["x86_64/lib/mynativelib.a"],
1914 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1915 },
1916 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001917}
1918
1919module_exports_snapshot {
1920 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001921 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001922 device_supported: false,
1923 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001924 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001925 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001926 target: {
1927 host: {
1928 enabled: false,
1929 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09001930 linux_glibc_x86_64: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001931 enabled: true,
1932 },
1933 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001934}`),
1935 checkAllCopyRules(`
1936include/Test.h -> include/include/Test.h
1937.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1938.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1939.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1940.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1941`),
1942 )
1943}
Paul Duffin91756d22020-02-21 16:29:57 +00001944
1945func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
1946 result := testSdkWithCc(t, `
1947 sdk {
1948 name: "mysdk",
1949 native_header_libs: ["mynativeheaders"],
1950 }
1951
1952 cc_library_headers {
1953 name: "mynativeheaders",
1954 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001955 stl: "none",
1956 }
1957 `)
1958
Paul Duffin1356d8c2020-02-25 19:26:33 +00001959 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001960 checkAndroidBpContents(`
1961// This is auto-generated. DO NOT EDIT.
1962
1963cc_prebuilt_library_headers {
1964 name: "mysdk_mynativeheaders@current",
1965 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01001966 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001967 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001968 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001969 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001970}
1971
1972cc_prebuilt_library_headers {
1973 name: "mynativeheaders",
1974 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001975 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001976 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001977 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001978 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001979}
1980
1981sdk_snapshot {
1982 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001983 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001984 native_header_libs: ["mysdk_mynativeheaders@current"],
1985}
1986`),
1987 checkAllCopyRules(`
1988include/Test.h -> include/include/Test.h
1989`),
1990 )
1991}
1992
1993func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffin91756d22020-02-21 16:29:57 +00001994 result := testSdkWithCc(t, `
1995 sdk {
1996 name: "mysdk",
1997 device_supported: false,
1998 host_supported: true,
1999 native_header_libs: ["mynativeheaders"],
2000 }
2001
2002 cc_library_headers {
2003 name: "mynativeheaders",
2004 device_supported: false,
2005 host_supported: true,
2006 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00002007 stl: "none",
2008 }
2009 `)
2010
Paul Duffin1356d8c2020-02-25 19:26:33 +00002011 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00002012 checkAndroidBpContents(`
2013// This is auto-generated. DO NOT EDIT.
2014
2015cc_prebuilt_library_headers {
2016 name: "mysdk_mynativeheaders@current",
2017 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002018 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002019 device_supported: false,
2020 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002021 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002022 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002023 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002024 target: {
2025 host: {
2026 enabled: false,
2027 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002028 linux_glibc_x86_64: {
2029 enabled: true,
2030 },
2031 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002032 enabled: true,
2033 },
2034 },
Paul Duffin91756d22020-02-21 16:29:57 +00002035}
2036
2037cc_prebuilt_library_headers {
2038 name: "mynativeheaders",
2039 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002040 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002041 device_supported: false,
2042 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002043 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002044 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002045 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002046 target: {
2047 host: {
2048 enabled: false,
2049 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002050 linux_glibc_x86_64: {
2051 enabled: true,
2052 },
2053 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002054 enabled: true,
2055 },
2056 },
Paul Duffin91756d22020-02-21 16:29:57 +00002057}
2058
2059sdk_snapshot {
2060 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002061 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002062 device_supported: false,
2063 host_supported: true,
2064 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002065 target: {
2066 host: {
2067 enabled: false,
2068 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002069 linux_glibc_x86_64: {
2070 enabled: true,
2071 },
2072 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002073 enabled: true,
2074 },
2075 },
Paul Duffin91756d22020-02-21 16:29:57 +00002076}
2077`),
2078 checkAllCopyRules(`
2079include/Test.h -> include/include/Test.h
2080`),
2081 )
2082}
Paul Duffina04c1072020-03-02 10:16:35 +00002083
2084func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Paul Duffina04c1072020-03-02 10:16:35 +00002085 result := testSdkWithCc(t, `
2086 sdk {
2087 name: "mysdk",
2088 host_supported: true,
2089 native_header_libs: ["mynativeheaders"],
2090 }
2091
2092 cc_library_headers {
2093 name: "mynativeheaders",
2094 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002095 stl: "none",
2096 export_system_include_dirs: ["include"],
2097 target: {
2098 android: {
2099 export_include_dirs: ["include-android"],
2100 },
2101 host: {
2102 export_include_dirs: ["include-host"],
2103 },
2104 },
2105 }
2106 `)
2107
2108 result.CheckSnapshot("mysdk", "",
2109 checkAndroidBpContents(`
2110// This is auto-generated. DO NOT EDIT.
2111
2112cc_prebuilt_library_headers {
2113 name: "mysdk_mynativeheaders@current",
2114 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002115 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002116 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002117 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002118 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002119 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002120 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002121 host: {
2122 enabled: false,
2123 },
Paul Duffina04c1072020-03-02 10:16:35 +00002124 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002125 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002126 },
2127 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002128 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002129 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002130 linux_glibc_x86_64: {
2131 enabled: true,
2132 },
2133 linux_glibc_x86: {
2134 enabled: true,
2135 },
Paul Duffina04c1072020-03-02 10:16:35 +00002136 },
Paul Duffina04c1072020-03-02 10:16:35 +00002137}
2138
2139cc_prebuilt_library_headers {
2140 name: "mynativeheaders",
2141 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002142 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002143 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002144 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002145 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002146 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002147 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002148 host: {
2149 enabled: false,
2150 },
Paul Duffina04c1072020-03-02 10:16:35 +00002151 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002152 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002153 },
2154 linux_glibc: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002155 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002156 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002157 linux_glibc_x86_64: {
2158 enabled: true,
2159 },
2160 linux_glibc_x86: {
2161 enabled: true,
2162 },
Paul Duffina04c1072020-03-02 10:16:35 +00002163 },
Paul Duffina04c1072020-03-02 10:16:35 +00002164}
2165
2166sdk_snapshot {
2167 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002168 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002169 host_supported: true,
2170 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002171 target: {
2172 host: {
2173 enabled: false,
2174 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002175 linux_glibc_x86_64: {
2176 enabled: true,
2177 },
2178 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002179 enabled: true,
2180 },
2181 },
Paul Duffina04c1072020-03-02 10:16:35 +00002182}
2183`),
2184 checkAllCopyRules(`
Paul Duffined62b9c2020-06-16 16:12:50 +01002185include/Test.h -> common_os/include/include/Test.h
2186include-android/AndroidTest.h -> android/include/include-android/AndroidTest.h
2187include-host/HostTest.h -> linux_glibc/include/include-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002188`),
2189 )
2190}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002191
2192func TestSystemSharedLibPropagation(t *testing.T) {
2193 result := testSdkWithCc(t, `
2194 sdk {
2195 name: "mysdk",
2196 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2197 }
2198
2199 cc_library {
2200 name: "sslnil",
2201 host_supported: true,
2202 }
2203
2204 cc_library {
2205 name: "sslempty",
2206 system_shared_libs: [],
2207 }
2208
2209 cc_library {
2210 name: "sslnonempty",
2211 system_shared_libs: ["sslnil"],
2212 }
2213 `)
2214
2215 result.CheckSnapshot("mysdk", "",
2216 checkAndroidBpContents(`
2217// This is auto-generated. DO NOT EDIT.
2218
2219cc_prebuilt_library_shared {
2220 name: "mysdk_sslnil@current",
2221 sdk_member_name: "sslnil",
Paul Duffind99d9972020-09-29 16:00:55 +01002222 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002223 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002224 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002225 arch: {
2226 arm64: {
2227 srcs: ["arm64/lib/sslnil.so"],
2228 },
2229 arm: {
2230 srcs: ["arm/lib/sslnil.so"],
2231 },
2232 },
2233}
2234
2235cc_prebuilt_library_shared {
2236 name: "sslnil",
2237 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002238 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002239 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002240 arch: {
2241 arm64: {
2242 srcs: ["arm64/lib/sslnil.so"],
2243 },
2244 arm: {
2245 srcs: ["arm/lib/sslnil.so"],
2246 },
2247 },
2248}
2249
2250cc_prebuilt_library_shared {
2251 name: "mysdk_sslempty@current",
2252 sdk_member_name: "sslempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002253 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002254 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002255 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002256 system_shared_libs: [],
2257 arch: {
2258 arm64: {
2259 srcs: ["arm64/lib/sslempty.so"],
2260 },
2261 arm: {
2262 srcs: ["arm/lib/sslempty.so"],
2263 },
2264 },
2265}
2266
2267cc_prebuilt_library_shared {
2268 name: "sslempty",
2269 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002270 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002271 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002272 system_shared_libs: [],
2273 arch: {
2274 arm64: {
2275 srcs: ["arm64/lib/sslempty.so"],
2276 },
2277 arm: {
2278 srcs: ["arm/lib/sslempty.so"],
2279 },
2280 },
2281}
2282
2283cc_prebuilt_library_shared {
2284 name: "mysdk_sslnonempty@current",
2285 sdk_member_name: "sslnonempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002286 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002287 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002288 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002289 system_shared_libs: ["mysdk_sslnil@current"],
2290 arch: {
2291 arm64: {
2292 srcs: ["arm64/lib/sslnonempty.so"],
2293 },
2294 arm: {
2295 srcs: ["arm/lib/sslnonempty.so"],
2296 },
2297 },
2298}
2299
2300cc_prebuilt_library_shared {
2301 name: "sslnonempty",
2302 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002303 visibility: ["//visibility:public"],
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}
2315
2316sdk_snapshot {
2317 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002318 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002319 native_shared_libs: [
2320 "mysdk_sslnil@current",
2321 "mysdk_sslempty@current",
2322 "mysdk_sslnonempty@current",
2323 ],
2324}
2325`))
2326
2327 result = testSdkWithCc(t, `
2328 sdk {
2329 name: "mysdk",
2330 host_supported: true,
2331 native_shared_libs: ["sslvariants"],
2332 }
2333
2334 cc_library {
2335 name: "sslvariants",
2336 host_supported: true,
2337 target: {
2338 android: {
2339 system_shared_libs: [],
2340 },
2341 },
2342 }
2343 `)
2344
2345 result.CheckSnapshot("mysdk", "",
2346 checkAndroidBpContents(`
2347// This is auto-generated. DO NOT EDIT.
2348
2349cc_prebuilt_library_shared {
2350 name: "mysdk_sslvariants@current",
2351 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002352 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002353 host_supported: true,
2354 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002355 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002356 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002357 host: {
2358 enabled: false,
2359 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002360 android: {
2361 system_shared_libs: [],
2362 },
2363 android_arm64: {
2364 srcs: ["android/arm64/lib/sslvariants.so"],
2365 },
2366 android_arm: {
2367 srcs: ["android/arm/lib/sslvariants.so"],
2368 },
2369 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002370 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002371 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2372 },
2373 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002374 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002375 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2376 },
2377 },
2378}
2379
2380cc_prebuilt_library_shared {
2381 name: "sslvariants",
2382 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002383 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002384 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002385 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002386 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002387 host: {
2388 enabled: false,
2389 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002390 android: {
2391 system_shared_libs: [],
2392 },
2393 android_arm64: {
2394 srcs: ["android/arm64/lib/sslvariants.so"],
2395 },
2396 android_arm: {
2397 srcs: ["android/arm/lib/sslvariants.so"],
2398 },
2399 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002400 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002401 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2402 },
2403 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002404 enabled: true,
Martin Stjernholm10566a02020-03-24 01:19:52 +00002405 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2406 },
2407 },
2408}
2409
2410sdk_snapshot {
2411 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002412 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002413 host_supported: true,
2414 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002415 target: {
2416 host: {
2417 enabled: false,
2418 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002419 linux_glibc_x86_64: {
2420 enabled: true,
2421 },
2422 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002423 enabled: true,
2424 },
2425 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002426}
2427`))
2428}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002429
2430func TestStubsLibrary(t *testing.T) {
2431 result := testSdkWithCc(t, `
2432 sdk {
2433 name: "mysdk",
2434 native_shared_libs: ["stubslib"],
2435 }
2436
2437 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002438 name: "internaldep",
2439 }
2440
2441 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002442 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002443 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002444 stubs: {
2445 symbol_file: "some/where/stubslib.map.txt",
2446 versions: ["1", "2", "3"],
2447 },
2448 }
2449 `)
2450
2451 result.CheckSnapshot("mysdk", "",
2452 checkAndroidBpContents(`
2453// This is auto-generated. DO NOT EDIT.
2454
2455cc_prebuilt_library_shared {
2456 name: "mysdk_stubslib@current",
2457 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002458 visibility: ["//visibility:public"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002459 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002460 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002461 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002462 versions: [
2463 "1",
2464 "2",
2465 "3",
2466 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002467 },
2468 arch: {
2469 arm64: {
2470 srcs: ["arm64/lib/stubslib.so"],
2471 },
2472 arm: {
2473 srcs: ["arm/lib/stubslib.so"],
2474 },
2475 },
2476}
2477
2478cc_prebuilt_library_shared {
2479 name: "stubslib",
2480 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002481 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002482 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002483 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002484 versions: [
2485 "1",
2486 "2",
2487 "3",
2488 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002489 },
2490 arch: {
2491 arm64: {
2492 srcs: ["arm64/lib/stubslib.so"],
2493 },
2494 arm: {
2495 srcs: ["arm/lib/stubslib.so"],
2496 },
2497 },
2498}
2499
2500sdk_snapshot {
2501 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002502 visibility: ["//visibility:public"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002503 native_shared_libs: ["mysdk_stubslib@current"],
2504}
2505`))
2506}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002507
2508func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002509 result := testSdkWithCc(t, `
2510 sdk {
2511 name: "mysdk",
2512 host_supported: true,
2513 native_shared_libs: ["stubslib"],
2514 }
2515
2516 cc_library {
2517 name: "internaldep",
2518 host_supported: true,
2519 }
2520
2521 cc_library {
2522 name: "stubslib",
2523 host_supported: true,
2524 shared_libs: ["internaldep"],
2525 stubs: {
2526 symbol_file: "some/where/stubslib.map.txt",
2527 versions: ["1", "2", "3"],
2528 },
2529 }
2530 `)
2531
2532 result.CheckSnapshot("mysdk", "",
2533 checkAndroidBpContents(`
2534// This is auto-generated. DO NOT EDIT.
2535
2536cc_prebuilt_library_shared {
2537 name: "mysdk_stubslib@current",
2538 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002539 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002540 host_supported: true,
2541 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002542 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002543 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002544 versions: [
2545 "1",
2546 "2",
2547 "3",
2548 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002549 },
2550 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002551 host: {
2552 enabled: false,
2553 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002554 android_arm64: {
2555 srcs: ["android/arm64/lib/stubslib.so"],
2556 },
2557 android_arm: {
2558 srcs: ["android/arm/lib/stubslib.so"],
2559 },
2560 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002561 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002562 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2563 },
2564 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002565 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002566 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2567 },
2568 },
2569}
2570
2571cc_prebuilt_library_shared {
2572 name: "stubslib",
2573 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002574 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002575 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002576 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002577 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002578 versions: [
2579 "1",
2580 "2",
2581 "3",
2582 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002583 },
2584 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002585 host: {
2586 enabled: false,
2587 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002588 android_arm64: {
2589 srcs: ["android/arm64/lib/stubslib.so"],
2590 },
2591 android_arm: {
2592 srcs: ["android/arm/lib/stubslib.so"],
2593 },
2594 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002595 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002596 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2597 },
2598 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002599 enabled: true,
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002600 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2601 },
2602 },
2603}
2604
2605sdk_snapshot {
2606 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002607 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002608 host_supported: true,
2609 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002610 target: {
2611 host: {
2612 enabled: false,
2613 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002614 linux_glibc_x86_64: {
2615 enabled: true,
2616 },
2617 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002618 enabled: true,
2619 },
2620 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002621}
2622`))
2623}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002624
2625func TestUniqueHostSoname(t *testing.T) {
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002626 result := testSdkWithCc(t, `
2627 sdk {
2628 name: "mysdk",
2629 host_supported: true,
2630 native_shared_libs: ["mylib"],
2631 }
2632
2633 cc_library {
2634 name: "mylib",
2635 host_supported: true,
2636 unique_host_soname: true,
2637 }
2638 `)
2639
2640 result.CheckSnapshot("mysdk", "",
2641 checkAndroidBpContents(`
2642// This is auto-generated. DO NOT EDIT.
2643
2644cc_prebuilt_library_shared {
2645 name: "mysdk_mylib@current",
2646 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002647 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002648 host_supported: true,
2649 installable: false,
2650 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002651 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002652 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002653 host: {
2654 enabled: false,
2655 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002656 android_arm64: {
2657 srcs: ["android/arm64/lib/mylib.so"],
2658 },
2659 android_arm: {
2660 srcs: ["android/arm/lib/mylib.so"],
2661 },
2662 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002663 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002664 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2665 },
2666 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002667 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002668 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2669 },
2670 },
2671}
2672
2673cc_prebuilt_library_shared {
2674 name: "mylib",
2675 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002676 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002677 host_supported: true,
2678 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002679 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002680 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002681 host: {
2682 enabled: false,
2683 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002684 android_arm64: {
2685 srcs: ["android/arm64/lib/mylib.so"],
2686 },
2687 android_arm: {
2688 srcs: ["android/arm/lib/mylib.so"],
2689 },
2690 linux_glibc_x86_64: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002691 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002692 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2693 },
2694 linux_glibc_x86: {
Jiyong Park8fe14e62020-10-19 22:47:34 +09002695 enabled: true,
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002696 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2697 },
2698 },
2699}
2700
2701sdk_snapshot {
2702 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002703 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002704 host_supported: true,
2705 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002706 target: {
2707 host: {
2708 enabled: false,
2709 },
Jiyong Park8fe14e62020-10-19 22:47:34 +09002710 linux_glibc_x86_64: {
2711 enabled: true,
2712 },
2713 linux_glibc_x86: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002714 enabled: true,
2715 },
2716 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002717}
2718`),
2719 checkAllCopyRules(`
2720.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2721.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2722.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2723.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2724`),
2725 )
2726}
Martin Stjernholm59e0c7a2020-10-28 23:38:33 +00002727
2728func TestNoSanitizerMembers(t *testing.T) {
2729 result := testSdkWithCc(t, `
2730 sdk {
2731 name: "mysdk",
2732 native_shared_libs: ["mynativelib"],
2733 }
2734
2735 cc_library_shared {
2736 name: "mynativelib",
2737 srcs: ["Test.cpp"],
2738 export_include_dirs: ["include"],
2739 arch: {
2740 arm64: {
2741 export_system_include_dirs: ["arm64/include"],
2742 sanitize: {
2743 hwaddress: true,
2744 },
2745 },
2746 },
2747 }
2748 `)
2749
2750 result.CheckSnapshot("mysdk", "",
2751 checkAndroidBpContents(`
2752// This is auto-generated. DO NOT EDIT.
2753
2754cc_prebuilt_library_shared {
2755 name: "mysdk_mynativelib@current",
2756 sdk_member_name: "mynativelib",
2757 visibility: ["//visibility:public"],
2758 installable: false,
2759 compile_multilib: "both",
2760 export_include_dirs: ["include/include"],
2761 arch: {
2762 arm64: {
2763 export_system_include_dirs: ["arm64/include/arm64/include"],
2764 },
2765 arm: {
2766 srcs: ["arm/lib/mynativelib.so"],
2767 },
2768 },
2769}
2770
2771cc_prebuilt_library_shared {
2772 name: "mynativelib",
2773 prefer: false,
2774 visibility: ["//visibility:public"],
2775 compile_multilib: "both",
2776 export_include_dirs: ["include/include"],
2777 arch: {
2778 arm64: {
2779 export_system_include_dirs: ["arm64/include/arm64/include"],
2780 },
2781 arm: {
2782 srcs: ["arm/lib/mynativelib.so"],
2783 },
2784 },
2785}
2786
2787sdk_snapshot {
2788 name: "mysdk@current",
2789 visibility: ["//visibility:public"],
2790 native_shared_libs: ["mysdk_mynativelib@current"],
2791}
2792`),
2793 checkAllCopyRules(`
2794include/Test.h -> include/include/Test.h
2795arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
2796.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
2797 )
2798}