blob: e0cba098f40e9212159dd65c054429908a813047 [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) {
Colin Cross323dc602020-09-18 14:25:31 -070043 t.Parallel()
Martin Stjernholmcaa47d72020-07-11 04:52:24 +010044 // Mock a module with DeviceSupported() == true.
45 s := &sdk{}
46 android.InitAndroidArchModule(s, android.DeviceSupported, android.MultilibCommon)
47
48 osTypes := s.getPossibleOsTypes()
49 if len(osTypes) != 1 {
50 // The snapshot generation assumes there is a single device OS. If more are
51 // added it might need to disable them by default, like it does for host
52 // OS'es.
53 t.Errorf("expected a single device OS, got %v", osTypes)
54 }
55}
56
Paul Duffina80fdec2019-12-03 15:25:00 +000057func TestSdkIsCompileMultilibBoth(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070058 t.Parallel()
Paul Duffind835daa2019-11-30 17:49:09 +000059 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +000060 sdk {
61 name: "mysdk",
62 native_shared_libs: ["sdkmember"],
63 }
64
65 cc_library_shared {
66 name: "sdkmember",
67 srcs: ["Test.cpp"],
Paul Duffina80fdec2019-12-03 15:25:00 +000068 stl: "none",
69 }
70 `)
71
Colin Cross7113d202019-11-20 16:39:12 -080072 armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile()
73 arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile()
Paul Duffina80fdec2019-12-03 15:25:00 +000074
75 var inputs []string
Paul Duffin1356d8c2020-02-25 19:26:33 +000076 buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests()
Paul Duffina80fdec2019-12-03 15:25:00 +000077 for _, bp := range buildParams {
78 if bp.Input != nil {
79 inputs = append(inputs, bp.Input.String())
80 }
81 }
82
83 // ensure that both 32/64 outputs are inputs of the sdk snapshot
84 ensureListContains(t, inputs, armOutput.String())
85 ensureListContains(t, inputs, arm64Output.String())
86}
87
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010088func TestSdkCompileMultilibOverride(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070089 t.Parallel()
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010090 result := testSdkWithCc(t, `
91 sdk {
92 name: "mysdk",
Martin Stjernholm89238f42020-07-10 00:14:03 +010093 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +010094 native_shared_libs: ["sdkmember"],
95 compile_multilib: "64",
96 }
97
98 cc_library_shared {
99 name: "sdkmember",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100100 host_supported: true,
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100101 srcs: ["Test.cpp"],
102 stl: "none",
103 compile_multilib: "64",
104 }
105 `)
106
107 result.CheckSnapshot("mysdk", "",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100108 checkAndroidBpContents(`
109// This is auto-generated. DO NOT EDIT.
110
111cc_prebuilt_library_shared {
112 name: "mysdk_sdkmember@current",
113 sdk_member_name: "sdkmember",
Paul Duffind99d9972020-09-29 16:00:55 +0100114 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100115 host_supported: true,
116 installable: false,
117 stl: "none",
118 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100119 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100120 host: {
121 enabled: false,
122 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100123 android_arm64: {
124 srcs: ["android/arm64/lib/sdkmember.so"],
125 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100126 linux_glibc: {
127 enabled: true,
128 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100129 linux_glibc_x86_64: {
130 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100131 },
132 },
133}
134
135cc_prebuilt_library_shared {
136 name: "sdkmember",
137 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100138 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100139 host_supported: true,
140 stl: "none",
141 compile_multilib: "64",
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100142 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100143 host: {
144 enabled: false,
145 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100146 android_arm64: {
147 srcs: ["android/arm64/lib/sdkmember.so"],
148 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100149 linux_glibc: {
150 enabled: true,
151 },
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100152 linux_glibc_x86_64: {
153 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100154 },
155 },
156}
157
158sdk_snapshot {
159 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100160 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +0100161 host_supported: true,
162 native_shared_libs: ["mysdk_sdkmember@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100163 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100164 target: {
165 host: {
166 enabled: false,
167 },
168 linux_glibc: {
169 enabled: true,
170 },
171 },
Martin Stjernholm89238f42020-07-10 00:14:03 +0100172}
173`),
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100174 checkAllCopyRules(`
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +0100175.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
176.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
Martin Stjernholm26ab8e82020-06-30 20:34:00 +0100177`))
178}
179
Paul Duffina80fdec2019-12-03 15:25:00 +0000180func TestBasicSdkWithCc(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700181 t.Parallel()
Paul Duffind835daa2019-11-30 17:49:09 +0000182 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +0000183 sdk {
184 name: "mysdk",
185 native_shared_libs: ["sdkmember"],
186 }
187
Paul Duffina0843f62019-12-13 19:50:38 +0000188 cc_library_shared {
189 name: "sdkmember",
Colin Crossf9aabd72020-02-15 11:29:50 -0800190 system_shared_libs: [],
Martin Stjernholmcc776012020-07-07 03:22:21 +0100191 stl: "none",
192 apex_available: ["mysdkapex"],
Paul Duffina0843f62019-12-13 19:50:38 +0000193 }
194
Paul Duffina80fdec2019-12-03 15:25:00 +0000195 sdk_snapshot {
196 name: "mysdk@1",
197 native_shared_libs: ["sdkmember_mysdk_1"],
198 }
199
200 sdk_snapshot {
201 name: "mysdk@2",
202 native_shared_libs: ["sdkmember_mysdk_2"],
203 }
204
205 cc_prebuilt_library_shared {
206 name: "sdkmember",
207 srcs: ["libfoo.so"],
208 prefer: false,
209 system_shared_libs: [],
210 stl: "none",
211 }
212
213 cc_prebuilt_library_shared {
214 name: "sdkmember_mysdk_1",
215 sdk_member_name: "sdkmember",
216 srcs: ["libfoo.so"],
217 system_shared_libs: [],
218 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000219 // TODO: remove //apex_available:platform
220 apex_available: [
221 "//apex_available:platform",
222 "myapex",
223 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000224 }
225
226 cc_prebuilt_library_shared {
227 name: "sdkmember_mysdk_2",
228 sdk_member_name: "sdkmember",
229 srcs: ["libfoo.so"],
230 system_shared_libs: [],
231 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000232 // TODO: remove //apex_available:platform
233 apex_available: [
234 "//apex_available:platform",
235 "myapex2",
236 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000237 }
238
239 cc_library_shared {
240 name: "mycpplib",
241 srcs: ["Test.cpp"],
242 shared_libs: ["sdkmember"],
243 system_shared_libs: [],
244 stl: "none",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000245 apex_available: [
246 "myapex",
247 "myapex2",
248 ],
Paul Duffina80fdec2019-12-03 15:25:00 +0000249 }
250
251 apex {
252 name: "myapex",
253 native_shared_libs: ["mycpplib"],
254 uses_sdks: ["mysdk@1"],
255 key: "myapex.key",
256 certificate: ":myapex.cert",
257 }
258
259 apex {
260 name: "myapex2",
261 native_shared_libs: ["mycpplib"],
262 uses_sdks: ["mysdk@2"],
263 key: "myapex.key",
264 certificate: ":myapex.cert",
265 }
Martin Stjernholmcc776012020-07-07 03:22:21 +0100266
267 apex {
268 name: "mysdkapex",
269 native_shared_libs: ["sdkmember"],
270 key: "myapex.key",
271 certificate: ":myapex.cert",
272 }
Paul Duffina80fdec2019-12-03 15:25:00 +0000273 `)
274
Colin Crossaede88c2020-08-11 12:17:01 -0700275 sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
276 sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
Paul Duffina80fdec2019-12-03 15:25:00 +0000277
Colin Crossaede88c2020-08-11 12:17:01 -0700278 cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1")
279 cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2")
Paul Duffina80fdec2019-12-03 15:25:00 +0000280
281 // Depending on the uses_sdks value, different libs are linked
282 ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
283 ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
284}
285
Paul Duffina0843f62019-12-13 19:50:38 +0000286// Make sure the sdk can use host specific cc libraries static/shared and both.
287func TestHostSdkWithCc(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700288 t.Parallel()
Paul Duffina0843f62019-12-13 19:50:38 +0000289 testSdkWithCc(t, `
290 sdk {
291 name: "mysdk",
292 device_supported: false,
293 host_supported: true,
294 native_shared_libs: ["sdkshared"],
295 native_static_libs: ["sdkstatic"],
296 }
297
298 cc_library_host_shared {
299 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000300 stl: "none",
301 }
302
303 cc_library_host_static {
304 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000305 stl: "none",
306 }
307 `)
308}
309
310// Make sure the sdk can use cc libraries static/shared and both.
311func TestSdkWithCc(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700312 t.Parallel()
Paul Duffina0843f62019-12-13 19:50:38 +0000313 testSdkWithCc(t, `
314 sdk {
315 name: "mysdk",
316 native_shared_libs: ["sdkshared", "sdkboth1"],
317 native_static_libs: ["sdkstatic", "sdkboth2"],
318 }
319
320 cc_library_shared {
321 name: "sdkshared",
Paul Duffina0843f62019-12-13 19:50:38 +0000322 stl: "none",
323 }
324
325 cc_library_static {
326 name: "sdkstatic",
Paul Duffina0843f62019-12-13 19:50:38 +0000327 stl: "none",
328 }
329
330 cc_library {
331 name: "sdkboth1",
Paul Duffina0843f62019-12-13 19:50:38 +0000332 stl: "none",
333 }
334
335 cc_library {
336 name: "sdkboth2",
Paul Duffina0843f62019-12-13 19:50:38 +0000337 stl: "none",
338 }
339 `)
340}
341
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000342func TestSnapshotWithObject(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700343 t.Parallel()
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000344 result := testSdkWithCc(t, `
345 sdk {
346 name: "mysdk",
347 native_objects: ["crtobj"],
348 }
349
350 cc_object {
351 name: "crtobj",
352 stl: "none",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100353 sanitize: {
354 never: true,
355 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000356 }
357 `)
358
359 result.CheckSnapshot("mysdk", "",
360 checkAndroidBpContents(`
361// This is auto-generated. DO NOT EDIT.
362
363cc_prebuilt_object {
364 name: "mysdk_crtobj@current",
365 sdk_member_name: "crtobj",
Paul Duffind99d9972020-09-29 16:00:55 +0100366 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000367 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100368 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100369 sanitize: {
370 never: true,
371 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000372 arch: {
373 arm64: {
374 srcs: ["arm64/lib/crtobj.o"],
375 },
376 arm: {
377 srcs: ["arm/lib/crtobj.o"],
378 },
379 },
380}
381
382cc_prebuilt_object {
383 name: "crtobj",
384 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100385 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000386 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100387 compile_multilib: "both",
Martin Stjernholmfbb486f2020-08-21 18:43:51 +0100388 sanitize: {
389 never: true,
390 },
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000391 arch: {
392 arm64: {
393 srcs: ["arm64/lib/crtobj.o"],
394 },
395 arm: {
396 srcs: ["arm/lib/crtobj.o"],
397 },
398 },
399}
400
401sdk_snapshot {
402 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100403 visibility: ["//visibility:public"],
Martin Stjernholmcd07bce2020-03-10 22:37:59 +0000404 native_objects: ["mysdk_crtobj@current"],
405}
406`),
407 checkAllCopyRules(`
408.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
409.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
410`),
411 )
412}
413
Paul Duffinc62a5102019-12-11 18:34:15 +0000414func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700415 t.Parallel()
Paul Duffinc62a5102019-12-11 18:34:15 +0000416 result := testSdkWithCc(t, `
417 sdk {
418 name: "mysdk",
419 native_shared_libs: ["mynativelib1", "mynativelib2"],
420 }
421
422 cc_library_shared {
423 name: "mynativelib1",
424 srcs: [
425 "Test.cpp",
426 ],
427 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000428 stl: "none",
429 }
430
431 cc_library_shared {
432 name: "mynativelib2",
433 srcs: [
434 "Test.cpp",
435 ],
436 export_include_dirs: ["include"],
Paul Duffinc62a5102019-12-11 18:34:15 +0000437 stl: "none",
438 }
439 `)
440
Paul Duffin1356d8c2020-02-25 19:26:33 +0000441 result.CheckSnapshot("mysdk", "",
Paul Duffinc62a5102019-12-11 18:34:15 +0000442 checkAllCopyRules(`
443include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800444.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
445.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
446.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
447.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
Paul Duffinc62a5102019-12-11 18:34:15 +0000448`),
449 )
450}
451
Martin Stjernholmb0249572020-09-15 02:32:35 +0100452// Verify that when the shared library has some common and some arch specific
453// properties that the generated snapshot is optimized properly. Substruct
454// handling is tested with the sanitize clauses (but note there's a lot of
455// built-in logic in sanitize.go that can affect those flags).
Paul Duffina7cd8c82019-12-11 20:00:57 +0000456func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700457 t.Parallel()
Paul Duffina7cd8c82019-12-11 20:00:57 +0000458 result := testSdkWithCc(t, `
459 sdk {
460 name: "mysdk",
461 native_shared_libs: ["mynativelib"],
462 }
463
464 cc_library_shared {
465 name: "mynativelib",
466 srcs: [
467 "Test.cpp",
468 "aidl/foo/bar/Test.aidl",
469 ],
470 export_include_dirs: ["include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100471 sanitize: {
472 fuzzer: false,
473 integer_overflow: true,
474 diag: { undefined: false },
475 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000476 arch: {
477 arm64: {
478 export_system_include_dirs: ["arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100479 sanitize: {
480 hwaddress: true,
481 integer_overflow: false,
482 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000483 },
484 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000485 stl: "none",
486 }
487 `)
488
Paul Duffin1356d8c2020-02-25 19:26:33 +0000489 result.CheckSnapshot("mysdk", "",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000490 checkAndroidBpContents(`
491// This is auto-generated. DO NOT EDIT.
492
493cc_prebuilt_library_shared {
494 name: "mysdk_mynativelib@current",
495 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100496 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000497 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +0000498 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100499 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000500 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100501 sanitize: {
502 fuzzer: false,
503 diag: {
504 undefined: false,
505 },
506 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000507 arch: {
508 arm64: {
509 srcs: ["arm64/lib/mynativelib.so"],
510 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100511 sanitize: {
512 hwaddress: true,
513 integer_overflow: false,
514 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000515 },
516 arm: {
517 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100518 sanitize: {
519 integer_overflow: true,
520 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000521 },
522 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000523}
524
525cc_prebuilt_library_shared {
526 name: "mynativelib",
527 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100528 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +0000529 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100530 compile_multilib: "both",
Paul Duffina7cd8c82019-12-11 20:00:57 +0000531 export_include_dirs: ["include/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100532 sanitize: {
533 fuzzer: false,
534 diag: {
535 undefined: false,
536 },
537 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000538 arch: {
539 arm64: {
540 srcs: ["arm64/lib/mynativelib.so"],
541 export_system_include_dirs: ["arm64/include/arm64/include"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100542 sanitize: {
543 hwaddress: true,
544 integer_overflow: false,
545 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000546 },
547 arm: {
548 srcs: ["arm/lib/mynativelib.so"],
Martin Stjernholmb0249572020-09-15 02:32:35 +0100549 sanitize: {
550 integer_overflow: true,
551 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000552 },
553 },
Paul Duffina7cd8c82019-12-11 20:00:57 +0000554}
555
556sdk_snapshot {
557 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100558 visibility: ["//visibility:public"],
Paul Duffina7cd8c82019-12-11 20:00:57 +0000559 native_shared_libs: ["mysdk_mynativelib@current"],
560}
561`),
562 checkAllCopyRules(`
563include/Test.h -> include/include/Test.h
Martin Stjernholmb0249572020-09-15 02:32:35 +0100564.intermediates/mynativelib/android_arm64_armv8-a_shared_hwasan/mynativelib.so -> arm64/lib/mynativelib.so
Paul Duffina7cd8c82019-12-11 20:00:57 +0000565arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
Colin Cross7113d202019-11-20 16:39:12 -0800566.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
Paul Duffina7cd8c82019-12-11 20:00:57 +0000567 )
568}
569
Paul Duffin25ce04b2020-01-16 11:47:25 +0000570func TestSnapshotWithCcBinary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700571 t.Parallel()
Paul Duffin25ce04b2020-01-16 11:47:25 +0000572 result := testSdkWithCc(t, `
573 module_exports {
574 name: "mymodule_exports",
575 native_binaries: ["mynativebinary"],
576 }
577
578 cc_binary {
579 name: "mynativebinary",
580 srcs: [
581 "Test.cpp",
582 ],
583 compile_multilib: "both",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000584 }
585 `)
586
Paul Duffin1356d8c2020-02-25 19:26:33 +0000587 result.CheckSnapshot("mymodule_exports", "",
Paul Duffin25ce04b2020-01-16 11:47:25 +0000588 checkAndroidBpContents(`
589// This is auto-generated. DO NOT EDIT.
590
591cc_prebuilt_binary {
592 name: "mymodule_exports_mynativebinary@current",
593 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100594 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +0000595 installable: false,
Paul Duffin25ce04b2020-01-16 11:47:25 +0000596 compile_multilib: "both",
597 arch: {
598 arm64: {
599 srcs: ["arm64/bin/mynativebinary"],
600 },
601 arm: {
602 srcs: ["arm/bin/mynativebinary"],
603 },
604 },
605}
606
607cc_prebuilt_binary {
608 name: "mynativebinary",
609 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100610 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000611 compile_multilib: "both",
612 arch: {
613 arm64: {
614 srcs: ["arm64/bin/mynativebinary"],
615 },
616 arm: {
617 srcs: ["arm/bin/mynativebinary"],
618 },
619 },
620}
621
622module_exports_snapshot {
623 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100624 visibility: ["//visibility:public"],
Paul Duffin25ce04b2020-01-16 11:47:25 +0000625 native_binaries: ["mymodule_exports_mynativebinary@current"],
626}
627`),
628 checkAllCopyRules(`
629.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
630.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
631`),
632 )
633}
634
Paul Duffina04c1072020-03-02 10:16:35 +0000635func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700636 t.Parallel()
Paul Duffina04c1072020-03-02 10:16:35 +0000637 result := testSdkWithCc(t, `
638 module_exports {
639 name: "myexports",
640 device_supported: false,
641 host_supported: true,
642 native_binaries: ["mynativebinary"],
643 target: {
644 windows: {
645 enabled: true,
646 },
647 },
648 }
649
650 cc_binary {
651 name: "mynativebinary",
652 device_supported: false,
653 host_supported: true,
654 srcs: [
655 "Test.cpp",
656 ],
657 compile_multilib: "both",
Paul Duffina04c1072020-03-02 10:16:35 +0000658 stl: "none",
659 target: {
660 windows: {
661 enabled: true,
662 },
663 },
664 }
665 `)
666
667 result.CheckSnapshot("myexports", "",
668 checkAndroidBpContents(`
669// This is auto-generated. DO NOT EDIT.
670
671cc_prebuilt_binary {
672 name: "myexports_mynativebinary@current",
673 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100674 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000675 device_supported: false,
676 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +0000677 installable: false,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100678 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000679 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100680 host: {
681 enabled: false,
682 },
Paul Duffina04c1072020-03-02 10:16:35 +0000683 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100684 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000685 compile_multilib: "both",
686 },
687 linux_glibc_x86_64: {
688 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
689 },
690 linux_glibc_x86: {
691 srcs: ["linux_glibc/x86/bin/mynativebinary"],
692 },
693 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100694 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000695 compile_multilib: "64",
696 },
697 windows_x86_64: {
698 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
699 },
700 },
701}
702
703cc_prebuilt_binary {
704 name: "mynativebinary",
705 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100706 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000707 device_supported: false,
708 host_supported: true,
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100709 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +0000710 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100711 host: {
712 enabled: false,
713 },
Paul Duffina04c1072020-03-02 10:16:35 +0000714 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100715 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000716 compile_multilib: "both",
717 },
718 linux_glibc_x86_64: {
719 srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
720 },
721 linux_glibc_x86: {
722 srcs: ["linux_glibc/x86/bin/mynativebinary"],
723 },
724 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100725 enabled: true,
Paul Duffina04c1072020-03-02 10:16:35 +0000726 compile_multilib: "64",
727 },
728 windows_x86_64: {
729 srcs: ["windows/x86_64/bin/mynativebinary.exe"],
730 },
731 },
732}
733
734module_exports_snapshot {
735 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100736 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +0000737 device_supported: false,
738 host_supported: true,
739 native_binaries: ["myexports_mynativebinary@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +0000740 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100741 host: {
742 enabled: false,
743 },
744 linux_glibc: {
745 enabled: true,
746 },
Paul Duffin6a7e9532020-03-20 17:50:07 +0000747 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100748 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +0000749 compile_multilib: "64",
750 },
751 },
Paul Duffina04c1072020-03-02 10:16:35 +0000752}
753`),
754 checkAllCopyRules(`
755.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
756.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
757.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe
758`),
759 )
760}
761
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100762func TestSnapshotWithSingleHostOsType(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700763 t.Parallel()
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100764 ctx, config := testSdkContext(`
765 cc_defaults {
766 name: "mydefaults",
767 device_supported: false,
768 host_supported: true,
769 compile_multilib: "64",
770 target: {
771 host: {
772 enabled: false,
773 },
774 linux_bionic: {
775 enabled: true,
776 },
777 },
778 }
779
780 module_exports {
781 name: "myexports",
782 defaults: ["mydefaults"],
783 native_shared_libs: ["mynativelib"],
784 native_binaries: ["mynativebinary"],
785 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
786 }
787
788 cc_library {
789 name: "mynativelib",
790 defaults: ["mydefaults"],
791 srcs: [
792 "Test.cpp",
793 ],
794 stl: "none",
795 }
796
797 cc_binary {
798 name: "mynativebinary",
799 defaults: ["mydefaults"],
800 srcs: [
801 "Test.cpp",
802 ],
803 stl: "none",
804 }
805 `, ccTestFs, []android.OsType{android.LinuxBionic})
806
807 result := runTests(t, ctx, config)
808
809 result.CheckSnapshot("myexports", "",
810 checkAndroidBpContents(`
811// This is auto-generated. DO NOT EDIT.
812
813cc_prebuilt_binary {
814 name: "myexports_mynativebinary@current",
815 sdk_member_name: "mynativebinary",
Paul Duffind99d9972020-09-29 16:00:55 +0100816 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100817 device_supported: false,
818 host_supported: true,
819 installable: false,
820 stl: "none",
821 compile_multilib: "64",
822 target: {
823 host: {
824 enabled: false,
825 },
826 linux_bionic: {
827 enabled: true,
828 },
829 linux_bionic_x86_64: {
830 srcs: ["x86_64/bin/mynativebinary"],
831 },
832 },
833}
834
835cc_prebuilt_binary {
836 name: "mynativebinary",
837 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100838 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100839 device_supported: false,
840 host_supported: true,
841 stl: "none",
842 compile_multilib: "64",
843 target: {
844 host: {
845 enabled: false,
846 },
847 linux_bionic: {
848 enabled: true,
849 },
850 linux_bionic_x86_64: {
851 srcs: ["x86_64/bin/mynativebinary"],
852 },
853 },
854}
855
856cc_prebuilt_library_shared {
857 name: "myexports_mynativelib@current",
858 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +0100859 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100860 device_supported: false,
861 host_supported: true,
862 installable: false,
863 stl: "none",
864 compile_multilib: "64",
865 target: {
866 host: {
867 enabled: false,
868 },
869 linux_bionic: {
870 enabled: true,
871 },
872 linux_bionic_x86_64: {
873 srcs: ["x86_64/lib/mynativelib.so"],
874 },
875 },
876}
877
878cc_prebuilt_library_shared {
879 name: "mynativelib",
880 prefer: false,
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 stl: "none",
885 compile_multilib: "64",
886 target: {
887 host: {
888 enabled: false,
889 },
890 linux_bionic: {
891 enabled: true,
892 },
893 linux_bionic_x86_64: {
894 srcs: ["x86_64/lib/mynativelib.so"],
895 },
896 },
897}
898
899module_exports_snapshot {
900 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +0100901 visibility: ["//visibility:public"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100902 device_supported: false,
903 host_supported: true,
904 native_binaries: ["myexports_mynativebinary@current"],
905 native_shared_libs: ["myexports_mynativelib@current"],
906 compile_multilib: "64",
907 target: {
908 host: {
909 enabled: false,
910 },
911 linux_bionic: {
912 enabled: true,
913 },
914 },
915}
916`),
917 checkAllCopyRules(`
918.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
919.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
920`),
921 )
922}
923
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100924// Test that we support the necessary flags for the linker binary, which is
925// special in several ways.
926func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -0700927 t.Parallel()
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100928 result := testSdkWithCc(t, `
929 module_exports {
930 name: "mymodule_exports",
931 host_supported: true,
932 device_supported: false,
933 native_binaries: ["linker"],
934 }
935
936 cc_binary {
937 name: "linker",
938 host_supported: true,
939 static_executable: true,
940 nocrt: true,
941 stl: "none",
942 srcs: [
943 "Test.cpp",
944 ],
945 compile_multilib: "both",
946 }
947 `)
948
949 result.CheckSnapshot("mymodule_exports", "",
950 checkAndroidBpContents(`
951// This is auto-generated. DO NOT EDIT.
952
953cc_prebuilt_binary {
954 name: "mymodule_exports_linker@current",
955 sdk_member_name: "linker",
Paul Duffind99d9972020-09-29 16:00:55 +0100956 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100957 device_supported: false,
958 host_supported: true,
959 installable: false,
960 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100961 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100962 static_executable: true,
963 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100964 target: {
965 host: {
966 enabled: false,
967 },
968 linux_glibc: {
969 enabled: true,
970 },
971 linux_glibc_x86_64: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100972 srcs: ["x86_64/bin/linker"],
973 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100974 linux_glibc_x86: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100975 srcs: ["x86/bin/linker"],
976 },
977 },
978}
979
980cc_prebuilt_binary {
981 name: "linker",
982 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +0100983 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100984 device_supported: false,
985 host_supported: true,
986 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +0100987 compile_multilib: "both",
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100988 static_executable: true,
989 nocrt: true,
Martin Stjernholmcaa47d72020-07-11 04:52:24 +0100990 target: {
991 host: {
992 enabled: false,
993 },
994 linux_glibc: {
995 enabled: true,
996 },
997 linux_glibc_x86_64: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +0100998 srcs: ["x86_64/bin/linker"],
999 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001000 linux_glibc_x86: {
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001001 srcs: ["x86/bin/linker"],
1002 },
1003 },
1004}
1005
1006module_exports_snapshot {
1007 name: "mymodule_exports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001008 visibility: ["//visibility:public"],
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001009 device_supported: false,
1010 host_supported: true,
1011 native_binaries: ["mymodule_exports_linker@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001012 target: {
1013 host: {
1014 enabled: false,
1015 },
1016 linux_glibc: {
1017 enabled: true,
1018 },
1019 },
Martin Stjernholm7130fab2020-05-28 22:58:01 +01001020}
1021`),
1022 checkAllCopyRules(`
1023.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
1024.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
1025`),
1026 )
1027}
1028
Paul Duffin9ab556f2019-12-11 18:42:17 +00001029func TestSnapshotWithCcSharedLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07001030 t.Parallel()
Paul Duffind835daa2019-11-30 17:49:09 +00001031 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001032 sdk {
1033 name: "mysdk",
1034 native_shared_libs: ["mynativelib"],
1035 }
1036
1037 cc_library_shared {
1038 name: "mynativelib",
1039 srcs: [
1040 "Test.cpp",
1041 "aidl/foo/bar/Test.aidl",
1042 ],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001043 apex_available: ["apex1", "apex2"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001044 export_include_dirs: ["include"],
1045 aidl: {
1046 export_aidl_headers: true,
1047 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001048 stl: "none",
1049 }
1050 `)
1051
Paul Duffin1356d8c2020-02-25 19:26:33 +00001052 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001053 checkAndroidBpContents(`
1054// This is auto-generated. DO NOT EDIT.
1055
1056cc_prebuilt_library_shared {
1057 name: "mysdk_mynativelib@current",
1058 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001059 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001060 apex_available: [
1061 "apex1",
1062 "apex2",
1063 ],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001064 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001065 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001066 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001067 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001068 arch: {
1069 arm64: {
1070 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001071 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001072 },
1073 arm: {
1074 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001075 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001076 },
1077 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001078}
1079
1080cc_prebuilt_library_shared {
1081 name: "mynativelib",
1082 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001083 visibility: ["//visibility:public"],
Paul Duffinbefa4b92020-03-04 14:22:45 +00001084 apex_available: [
1085 "apex1",
1086 "apex2",
1087 ],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001088 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001089 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001090 export_include_dirs: ["include/include"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001091 arch: {
1092 arm64: {
1093 srcs: ["arm64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001094 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001095 },
1096 arm: {
1097 srcs: ["arm/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001098 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001099 },
1100 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001101}
1102
1103sdk_snapshot {
1104 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001105 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001106 native_shared_libs: ["mysdk_mynativelib@current"],
1107}
1108`),
1109 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001110include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001111.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1112.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1113.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1114.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1115.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1116.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1117.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1118.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 +00001119`),
1120 )
1121}
1122
Paul Duffin13f02712020-03-06 12:30:43 +00001123func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07001124 t.Parallel()
Paul Duffin13f02712020-03-06 12:30:43 +00001125 result := testSdkWithCc(t, `
1126 sdk {
1127 name: "mysdk",
1128 native_shared_libs: [
1129 "mynativelib",
1130 "myothernativelib",
1131 "mysystemnativelib",
1132 ],
1133 }
1134
1135 cc_library {
1136 name: "mysystemnativelib",
1137 srcs: [
1138 "Test.cpp",
1139 ],
Paul Duffin13f02712020-03-06 12:30:43 +00001140 stl: "none",
1141 }
1142
1143 cc_library_shared {
1144 name: "myothernativelib",
1145 srcs: [
1146 "Test.cpp",
1147 ],
1148 system_shared_libs: [
1149 // A reference to a library that is not an sdk member. Uses libm as that
1150 // is in the default set of modules available to this test and so is available
1151 // both here and also when the generated Android.bp file is tested in
1152 // CheckSnapshot(). This ensures that the system_shared_libs property correctly
1153 // handles references to modules that are not sdk members.
1154 "libm",
1155 ],
1156 stl: "none",
1157 }
1158
1159 cc_library {
1160 name: "mynativelib",
1161 srcs: [
1162 "Test.cpp",
1163 ],
1164 shared_libs: [
1165 // A reference to another sdk member.
1166 "myothernativelib",
1167 ],
1168 target: {
1169 android: {
1170 shared: {
1171 shared_libs: [
1172 // A reference to a library that is not an sdk member. The libc library
1173 // is used here to check that the shared_libs property is handled correctly
1174 // in a similar way to how libm is used to check system_shared_libs above.
1175 "libc",
1176 ],
1177 },
1178 },
1179 },
Paul Duffin13f02712020-03-06 12:30:43 +00001180 stl: "none",
1181 }
1182 `)
1183
1184 result.CheckSnapshot("mysdk", "",
1185 checkAndroidBpContents(`
1186// This is auto-generated. DO NOT EDIT.
1187
1188cc_prebuilt_library_shared {
1189 name: "mysdk_mynativelib@current",
1190 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001191 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001192 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001193 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001194 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001195 shared_libs: [
1196 "mysdk_myothernativelib@current",
1197 "libc",
1198 ],
1199 arch: {
1200 arm64: {
1201 srcs: ["arm64/lib/mynativelib.so"],
1202 },
1203 arm: {
1204 srcs: ["arm/lib/mynativelib.so"],
1205 },
1206 },
Paul Duffin13f02712020-03-06 12:30:43 +00001207}
1208
1209cc_prebuilt_library_shared {
1210 name: "mynativelib",
1211 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001212 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001213 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001214 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001215 shared_libs: [
1216 "myothernativelib",
1217 "libc",
1218 ],
1219 arch: {
1220 arm64: {
1221 srcs: ["arm64/lib/mynativelib.so"],
1222 },
1223 arm: {
1224 srcs: ["arm/lib/mynativelib.so"],
1225 },
1226 },
Paul Duffin13f02712020-03-06 12:30:43 +00001227}
1228
1229cc_prebuilt_library_shared {
1230 name: "mysdk_myothernativelib@current",
1231 sdk_member_name: "myothernativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001232 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001233 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001234 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001235 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001236 system_shared_libs: ["libm"],
1237 arch: {
1238 arm64: {
1239 srcs: ["arm64/lib/myothernativelib.so"],
1240 },
1241 arm: {
1242 srcs: ["arm/lib/myothernativelib.so"],
1243 },
1244 },
Paul Duffin13f02712020-03-06 12:30:43 +00001245}
1246
1247cc_prebuilt_library_shared {
1248 name: "myothernativelib",
1249 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001250 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001251 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001252 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001253 system_shared_libs: ["libm"],
1254 arch: {
1255 arm64: {
1256 srcs: ["arm64/lib/myothernativelib.so"],
1257 },
1258 arm: {
1259 srcs: ["arm/lib/myothernativelib.so"],
1260 },
1261 },
Paul Duffin13f02712020-03-06 12:30:43 +00001262}
1263
1264cc_prebuilt_library_shared {
1265 name: "mysdk_mysystemnativelib@current",
1266 sdk_member_name: "mysystemnativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001267 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001268 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001269 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001270 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001271 arch: {
1272 arm64: {
1273 srcs: ["arm64/lib/mysystemnativelib.so"],
1274 },
1275 arm: {
1276 srcs: ["arm/lib/mysystemnativelib.so"],
1277 },
1278 },
Paul Duffin13f02712020-03-06 12:30:43 +00001279}
1280
1281cc_prebuilt_library_shared {
1282 name: "mysystemnativelib",
1283 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001284 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001285 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001286 compile_multilib: "both",
Paul Duffin13f02712020-03-06 12:30:43 +00001287 arch: {
1288 arm64: {
1289 srcs: ["arm64/lib/mysystemnativelib.so"],
1290 },
1291 arm: {
1292 srcs: ["arm/lib/mysystemnativelib.so"],
1293 },
1294 },
Paul Duffin13f02712020-03-06 12:30:43 +00001295}
1296
1297sdk_snapshot {
1298 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001299 visibility: ["//visibility:public"],
Paul Duffin13f02712020-03-06 12:30:43 +00001300 native_shared_libs: [
1301 "mysdk_mynativelib@current",
1302 "mysdk_myothernativelib@current",
1303 "mysdk_mysystemnativelib@current",
1304 ],
1305}
1306`),
1307 checkAllCopyRules(`
1308.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1309.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
1310.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so
1311.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so
1312.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so
1313.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so
1314`),
1315 )
1316}
1317
Paul Duffin9ab556f2019-12-11 18:42:17 +00001318func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07001319 t.Parallel()
Paul Duffind835daa2019-11-30 17:49:09 +00001320 result := testSdkWithCc(t, `
Paul Duffina80fdec2019-12-03 15:25:00 +00001321 sdk {
1322 name: "mysdk",
1323 device_supported: false,
1324 host_supported: true,
1325 native_shared_libs: ["mynativelib"],
1326 }
1327
1328 cc_library_shared {
1329 name: "mynativelib",
1330 device_supported: false,
1331 host_supported: true,
1332 srcs: [
1333 "Test.cpp",
1334 "aidl/foo/bar/Test.aidl",
1335 ],
1336 export_include_dirs: ["include"],
1337 aidl: {
1338 export_aidl_headers: true,
1339 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001340 stl: "none",
Paul Duffin0c394f32020-03-05 14:09:58 +00001341 sdk_version: "minimum",
Paul Duffina80fdec2019-12-03 15:25:00 +00001342 }
1343 `)
1344
Paul Duffin1356d8c2020-02-25 19:26:33 +00001345 result.CheckSnapshot("mysdk", "",
Paul Duffina80fdec2019-12-03 15:25:00 +00001346 checkAndroidBpContents(`
1347// This is auto-generated. DO NOT EDIT.
1348
1349cc_prebuilt_library_shared {
1350 name: "mysdk_mynativelib@current",
1351 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001352 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001353 device_supported: false,
1354 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001355 installable: false,
Paul Duffin0c394f32020-03-05 14:09:58 +00001356 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001357 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001358 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001359 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001360 target: {
1361 host: {
1362 enabled: false,
1363 },
1364 linux_glibc: {
1365 enabled: true,
1366 },
1367 linux_glibc_x86_64: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001368 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001369 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001370 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001371 linux_glibc_x86: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001372 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001373 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001374 },
1375 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001376}
1377
1378cc_prebuilt_library_shared {
1379 name: "mynativelib",
1380 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001381 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001382 device_supported: false,
1383 host_supported: true,
Paul Duffin0c394f32020-03-05 14:09:58 +00001384 sdk_version: "minimum",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001385 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001386 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001387 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001388 target: {
1389 host: {
1390 enabled: false,
1391 },
1392 linux_glibc: {
1393 enabled: true,
1394 },
1395 linux_glibc_x86_64: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001396 srcs: ["x86_64/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001397 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001398 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001399 linux_glibc_x86: {
Paul Duffina80fdec2019-12-03 15:25:00 +00001400 srcs: ["x86/lib/mynativelib.so"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001401 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001402 },
1403 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001404}
1405
1406sdk_snapshot {
1407 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001408 visibility: ["//visibility:public"],
Paul Duffina80fdec2019-12-03 15:25:00 +00001409 device_supported: false,
1410 host_supported: true,
1411 native_shared_libs: ["mysdk_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001412 target: {
1413 host: {
1414 enabled: false,
1415 },
1416 linux_glibc: {
1417 enabled: true,
1418 },
1419 },
Paul Duffina80fdec2019-12-03 15:25:00 +00001420}
1421`),
1422 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001423include/Test.h -> include/include/Test.h
Paul Duffina80fdec2019-12-03 15:25:00 +00001424.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001425.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1426.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1427.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1428.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
Paul Duffina80fdec2019-12-03 15:25:00 +00001429.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1430.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1431.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1432`),
1433 )
1434}
Paul Duffin9ab556f2019-12-11 18:42:17 +00001435
Paul Duffina04c1072020-03-02 10:16:35 +00001436func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07001437 t.Parallel()
Paul Duffina04c1072020-03-02 10:16:35 +00001438 result := testSdkWithCc(t, `
1439 sdk {
1440 name: "mysdk",
1441 device_supported: false,
1442 host_supported: true,
1443 native_shared_libs: ["mynativelib"],
1444 target: {
1445 windows: {
1446 enabled: true,
1447 },
1448 },
1449 }
1450
1451 cc_library_shared {
1452 name: "mynativelib",
1453 device_supported: false,
1454 host_supported: true,
1455 srcs: [
1456 "Test.cpp",
1457 ],
Paul Duffina04c1072020-03-02 10:16:35 +00001458 stl: "none",
1459 target: {
1460 windows: {
1461 enabled: true,
1462 },
1463 },
1464 }
1465 `)
1466
1467 result.CheckSnapshot("mysdk", "",
1468 checkAndroidBpContents(`
1469// This is auto-generated. DO NOT EDIT.
1470
1471cc_prebuilt_library_shared {
1472 name: "mysdk_mynativelib@current",
1473 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001474 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001475 device_supported: false,
1476 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001477 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001478 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001479 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001480 host: {
1481 enabled: false,
1482 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001483 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001484 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001485 compile_multilib: "both",
1486 },
Paul Duffina04c1072020-03-02 10:16:35 +00001487 linux_glibc_x86_64: {
1488 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1489 },
1490 linux_glibc_x86: {
1491 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1492 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001493 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001494 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001495 compile_multilib: "64",
1496 },
Paul Duffina04c1072020-03-02 10:16:35 +00001497 windows_x86_64: {
1498 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1499 },
1500 },
Paul Duffina04c1072020-03-02 10:16:35 +00001501}
1502
1503cc_prebuilt_library_shared {
1504 name: "mynativelib",
1505 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001506 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001507 device_supported: false,
1508 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001509 stl: "none",
Paul Duffina04c1072020-03-02 10:16:35 +00001510 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001511 host: {
1512 enabled: false,
1513 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001514 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001515 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001516 compile_multilib: "both",
1517 },
Paul Duffina04c1072020-03-02 10:16:35 +00001518 linux_glibc_x86_64: {
1519 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
1520 },
1521 linux_glibc_x86: {
1522 srcs: ["linux_glibc/x86/lib/mynativelib.so"],
1523 },
Martin Stjernholm89238f42020-07-10 00:14:03 +01001524 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001525 enabled: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01001526 compile_multilib: "64",
1527 },
Paul Duffina04c1072020-03-02 10:16:35 +00001528 windows_x86_64: {
1529 srcs: ["windows/x86_64/lib/mynativelib.dll"],
1530 },
1531 },
Paul Duffina04c1072020-03-02 10:16:35 +00001532}
1533
1534sdk_snapshot {
1535 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001536 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00001537 device_supported: false,
1538 host_supported: true,
1539 native_shared_libs: ["mysdk_mynativelib@current"],
Paul Duffin6a7e9532020-03-20 17:50:07 +00001540 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001541 host: {
1542 enabled: false,
1543 },
1544 linux_glibc: {
1545 enabled: true,
1546 },
Paul Duffin6a7e9532020-03-20 17:50:07 +00001547 windows: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001548 enabled: true,
Paul Duffin6a7e9532020-03-20 17:50:07 +00001549 compile_multilib: "64",
1550 },
1551 },
Paul Duffina04c1072020-03-02 10:16:35 +00001552}
1553`),
1554 checkAllCopyRules(`
1555.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
1556.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
1557.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll
1558`),
1559 )
1560}
1561
Paul Duffin9ab556f2019-12-11 18:42:17 +00001562func TestSnapshotWithCcStaticLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07001563 t.Parallel()
Paul Duffin9ab556f2019-12-11 18:42:17 +00001564 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001565 module_exports {
1566 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001567 native_static_libs: ["mynativelib"],
1568 }
1569
1570 cc_library_static {
1571 name: "mynativelib",
1572 srcs: [
1573 "Test.cpp",
1574 "aidl/foo/bar/Test.aidl",
1575 ],
1576 export_include_dirs: ["include"],
1577 aidl: {
1578 export_aidl_headers: true,
1579 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001580 stl: "none",
1581 }
1582 `)
1583
Paul Duffin1356d8c2020-02-25 19:26:33 +00001584 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001585 checkAndroidBpContents(`
1586// This is auto-generated. DO NOT EDIT.
1587
1588cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001589 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001590 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001591 visibility: ["//visibility:public"],
Paul Duffin0cb37b92020-03-04 14:52:46 +00001592 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001593 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001594 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001595 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001596 arch: {
1597 arm64: {
1598 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001599 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001600 },
1601 arm: {
1602 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001603 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001604 },
1605 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001606}
1607
1608cc_prebuilt_library_static {
1609 name: "mynativelib",
1610 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001611 visibility: ["//visibility:public"],
Paul Duffin0174d8d2020-03-11 18:42:08 +00001612 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001613 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001614 export_include_dirs: ["include/include"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001615 arch: {
1616 arm64: {
1617 srcs: ["arm64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001618 export_include_dirs: ["arm64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001619 },
1620 arm: {
1621 srcs: ["arm/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001622 export_include_dirs: ["arm/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001623 },
1624 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001625}
1626
Paul Duffine6029182019-12-16 17:43:48 +00001627module_exports_snapshot {
1628 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001629 visibility: ["//visibility:public"],
Paul Duffine6029182019-12-16 17:43:48 +00001630 native_static_libs: ["myexports_mynativelib@current"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001631}
1632`),
1633 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001634include/Test.h -> include/include/Test.h
Colin Cross7113d202019-11-20 16:39:12 -08001635.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1636.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
1637.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1638.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1639.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1640.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
1641.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1642.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 +00001643`),
1644 )
1645}
1646
1647func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07001648 t.Parallel()
Paul Duffin9ab556f2019-12-11 18:42:17 +00001649 result := testSdkWithCc(t, `
Paul Duffine6029182019-12-16 17:43:48 +00001650 module_exports {
1651 name: "myexports",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001652 device_supported: false,
1653 host_supported: true,
1654 native_static_libs: ["mynativelib"],
1655 }
1656
1657 cc_library_static {
1658 name: "mynativelib",
1659 device_supported: false,
1660 host_supported: true,
1661 srcs: [
1662 "Test.cpp",
1663 "aidl/foo/bar/Test.aidl",
1664 ],
1665 export_include_dirs: ["include"],
1666 aidl: {
1667 export_aidl_headers: true,
1668 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001669 stl: "none",
1670 }
1671 `)
1672
Paul Duffin1356d8c2020-02-25 19:26:33 +00001673 result.CheckSnapshot("myexports", "",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001674 checkAndroidBpContents(`
1675// This is auto-generated. DO NOT EDIT.
1676
1677cc_prebuilt_library_static {
Paul Duffine6029182019-12-16 17:43:48 +00001678 name: "myexports_mynativelib@current",
Paul Duffin9ab556f2019-12-11 18:42:17 +00001679 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001680 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001681 device_supported: false,
1682 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001683 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001684 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001685 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001686 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001687 target: {
1688 host: {
1689 enabled: false,
1690 },
1691 linux_glibc: {
1692 enabled: true,
1693 },
1694 linux_glibc_x86_64: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001695 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001696 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001697 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001698 linux_glibc_x86: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001699 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001700 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001701 },
1702 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001703}
1704
1705cc_prebuilt_library_static {
1706 name: "mynativelib",
1707 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001708 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001709 device_supported: false,
1710 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001711 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001712 compile_multilib: "both",
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001713 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001714 target: {
1715 host: {
1716 enabled: false,
1717 },
1718 linux_glibc: {
1719 enabled: true,
1720 },
1721 linux_glibc_x86_64: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001722 srcs: ["x86_64/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001723 export_include_dirs: ["x86_64/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001724 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001725 linux_glibc_x86: {
Paul Duffin9ab556f2019-12-11 18:42:17 +00001726 srcs: ["x86/lib/mynativelib.a"],
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001727 export_include_dirs: ["x86/include_gen/mynativelib"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001728 },
1729 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001730}
1731
Paul Duffine6029182019-12-16 17:43:48 +00001732module_exports_snapshot {
1733 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001734 visibility: ["//visibility:public"],
Paul Duffin9ab556f2019-12-11 18:42:17 +00001735 device_supported: false,
1736 host_supported: true,
Paul Duffine6029182019-12-16 17:43:48 +00001737 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001738 target: {
1739 host: {
1740 enabled: false,
1741 },
1742 linux_glibc: {
1743 enabled: true,
1744 },
1745 },
Paul Duffin9ab556f2019-12-11 18:42:17 +00001746}
1747`),
1748 checkAllCopyRules(`
Paul Duffin57b9e1d2019-12-13 00:03:35 +00001749include/Test.h -> include/include/Test.h
Paul Duffin9ab556f2019-12-11 18:42:17 +00001750.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001751.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1752.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1753.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1754.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
Paul Duffin9ab556f2019-12-11 18:42:17 +00001755.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
1756.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1757.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1758`),
1759 )
1760}
Paul Duffin13ad94f2020-02-19 16:19:27 +00001761
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001762func TestSnapshotWithCcLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07001763 t.Parallel()
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001764 result := testSdkWithCc(t, `
1765 module_exports {
1766 name: "myexports",
1767 native_libs: ["mynativelib"],
1768 }
1769
1770 cc_library {
1771 name: "mynativelib",
1772 srcs: [
1773 "Test.cpp",
1774 ],
1775 export_include_dirs: ["include"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001776 stl: "none",
Paul Duffind6abaa72020-09-07 16:39:22 +01001777 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001778 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001779 }
1780 `)
1781
1782 result.CheckSnapshot("myexports", "",
1783 checkAndroidBpContents(`
1784// This is auto-generated. DO NOT EDIT.
1785
1786cc_prebuilt_library {
1787 name: "myexports_mynativelib@current",
1788 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001789 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001790 installable: false,
Paul Duffind6abaa72020-09-07 16:39:22 +01001791 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001792 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001793 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001794 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001795 export_include_dirs: ["include/include"],
1796 arch: {
1797 arm64: {
1798 static: {
1799 srcs: ["arm64/lib/mynativelib.a"],
1800 },
1801 shared: {
1802 srcs: ["arm64/lib/mynativelib.so"],
1803 },
1804 },
1805 arm: {
1806 static: {
1807 srcs: ["arm/lib/mynativelib.a"],
1808 },
1809 shared: {
1810 srcs: ["arm/lib/mynativelib.so"],
1811 },
1812 },
1813 },
1814}
1815
1816cc_prebuilt_library {
1817 name: "mynativelib",
1818 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001819 visibility: ["//visibility:public"],
Paul Duffind6abaa72020-09-07 16:39:22 +01001820 recovery_available: true,
Paul Duffind1edbd42020-08-13 19:45:31 +01001821 vendor_available: true,
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001822 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001823 compile_multilib: "both",
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001824 export_include_dirs: ["include/include"],
1825 arch: {
1826 arm64: {
1827 static: {
1828 srcs: ["arm64/lib/mynativelib.a"],
1829 },
1830 shared: {
1831 srcs: ["arm64/lib/mynativelib.so"],
1832 },
1833 },
1834 arm: {
1835 static: {
1836 srcs: ["arm/lib/mynativelib.a"],
1837 },
1838 shared: {
1839 srcs: ["arm/lib/mynativelib.so"],
1840 },
1841 },
1842 },
1843}
1844
1845module_exports_snapshot {
1846 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001847 visibility: ["//visibility:public"],
Paul Duffin9b76c0b2020-03-12 10:24:35 +00001848 native_libs: ["myexports_mynativelib@current"],
1849}
1850`),
1851 checkAllCopyRules(`
1852include/Test.h -> include/include/Test.h
1853.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
1854.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
1855.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
1856.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
1857 )
1858}
1859
Paul Duffin13ad94f2020-02-19 16:19:27 +00001860func TestHostSnapshotWithMultiLib64(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07001861 t.Parallel()
Paul Duffin13ad94f2020-02-19 16:19:27 +00001862 result := testSdkWithCc(t, `
1863 module_exports {
1864 name: "myexports",
1865 device_supported: false,
1866 host_supported: true,
1867 target: {
1868 host: {
1869 compile_multilib: "64",
1870 },
1871 },
1872 native_static_libs: ["mynativelib"],
1873 }
1874
1875 cc_library_static {
1876 name: "mynativelib",
1877 device_supported: false,
1878 host_supported: true,
1879 srcs: [
1880 "Test.cpp",
1881 "aidl/foo/bar/Test.aidl",
1882 ],
1883 export_include_dirs: ["include"],
1884 aidl: {
1885 export_aidl_headers: true,
1886 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001887 stl: "none",
1888 }
1889 `)
1890
Paul Duffin1356d8c2020-02-25 19:26:33 +00001891 result.CheckSnapshot("myexports", "",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001892 checkAndroidBpContents(`
1893// This is auto-generated. DO NOT EDIT.
1894
1895cc_prebuilt_library_static {
1896 name: "myexports_mynativelib@current",
1897 sdk_member_name: "mynativelib",
Paul Duffind99d9972020-09-29 16:00:55 +01001898 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001899 device_supported: false,
1900 host_supported: true,
Paul Duffin0cb37b92020-03-04 14:52:46 +00001901 installable: false,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001902 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001903 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001904 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001905 target: {
1906 host: {
1907 enabled: false,
1908 },
1909 linux_glibc: {
1910 enabled: true,
1911 },
1912 linux_glibc_x86_64: {
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
1919cc_prebuilt_library_static {
1920 name: "mynativelib",
1921 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001922 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001923 device_supported: false,
1924 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00001925 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001926 compile_multilib: "64",
Paul Duffin13ad94f2020-02-19 16:19:27 +00001927 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001928 target: {
1929 host: {
1930 enabled: false,
1931 },
1932 linux_glibc: {
1933 enabled: true,
1934 },
1935 linux_glibc_x86_64: {
Paul Duffin13ad94f2020-02-19 16:19:27 +00001936 srcs: ["x86_64/lib/mynativelib.a"],
1937 export_include_dirs: ["x86_64/include_gen/mynativelib"],
1938 },
1939 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001940}
1941
1942module_exports_snapshot {
1943 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +01001944 visibility: ["//visibility:public"],
Paul Duffin13ad94f2020-02-19 16:19:27 +00001945 device_supported: false,
1946 host_supported: true,
Paul Duffin07ef3cb2020-03-11 18:17:42 +00001947 native_static_libs: ["myexports_mynativelib@current"],
Martin Stjernholm4cfa2c62020-07-10 19:55:36 +01001948 compile_multilib: "64",
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01001949 target: {
1950 host: {
1951 enabled: false,
1952 },
1953 linux_glibc: {
1954 enabled: true,
1955 },
1956 },
Paul Duffin13ad94f2020-02-19 16:19:27 +00001957}`),
1958 checkAllCopyRules(`
1959include/Test.h -> include/include/Test.h
1960.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
1961.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
1962.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
1963.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
1964`),
1965 )
1966}
Paul Duffin91756d22020-02-21 16:29:57 +00001967
1968func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07001969 t.Parallel()
Paul Duffin91756d22020-02-21 16:29:57 +00001970 result := testSdkWithCc(t, `
1971 sdk {
1972 name: "mysdk",
1973 native_header_libs: ["mynativeheaders"],
1974 }
1975
1976 cc_library_headers {
1977 name: "mynativeheaders",
1978 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001979 stl: "none",
1980 }
1981 `)
1982
Paul Duffin1356d8c2020-02-25 19:26:33 +00001983 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00001984 checkAndroidBpContents(`
1985// This is auto-generated. DO NOT EDIT.
1986
1987cc_prebuilt_library_headers {
1988 name: "mysdk_mynativeheaders@current",
1989 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01001990 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00001991 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01001992 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00001993 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00001994}
1995
1996cc_prebuilt_library_headers {
1997 name: "mynativeheaders",
1998 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01001999 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002000 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002001 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002002 export_include_dirs: ["include/include"],
Paul Duffin91756d22020-02-21 16:29:57 +00002003}
2004
2005sdk_snapshot {
2006 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002007 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002008 native_header_libs: ["mysdk_mynativeheaders@current"],
2009}
2010`),
2011 checkAllCopyRules(`
2012include/Test.h -> include/include/Test.h
2013`),
2014 )
2015}
2016
2017func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07002018 t.Parallel()
Paul Duffin91756d22020-02-21 16:29:57 +00002019 result := testSdkWithCc(t, `
2020 sdk {
2021 name: "mysdk",
2022 device_supported: false,
2023 host_supported: true,
2024 native_header_libs: ["mynativeheaders"],
2025 }
2026
2027 cc_library_headers {
2028 name: "mynativeheaders",
2029 device_supported: false,
2030 host_supported: true,
2031 export_include_dirs: ["include"],
Paul Duffin91756d22020-02-21 16:29:57 +00002032 stl: "none",
2033 }
2034 `)
2035
Paul Duffin1356d8c2020-02-25 19:26:33 +00002036 result.CheckSnapshot("mysdk", "",
Paul Duffin91756d22020-02-21 16:29:57 +00002037 checkAndroidBpContents(`
2038// This is auto-generated. DO NOT EDIT.
2039
2040cc_prebuilt_library_headers {
2041 name: "mysdk_mynativeheaders@current",
2042 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002043 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002044 device_supported: false,
2045 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002046 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002047 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002048 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002049 target: {
2050 host: {
2051 enabled: false,
2052 },
2053 linux_glibc: {
2054 enabled: true,
2055 },
2056 },
Paul Duffin91756d22020-02-21 16:29:57 +00002057}
2058
2059cc_prebuilt_library_headers {
2060 name: "mynativeheaders",
2061 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002062 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002063 device_supported: false,
2064 host_supported: true,
Paul Duffin91756d22020-02-21 16:29:57 +00002065 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002066 compile_multilib: "both",
Paul Duffin0174d8d2020-03-11 18:42:08 +00002067 export_include_dirs: ["include/include"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002068 target: {
2069 host: {
2070 enabled: false,
2071 },
2072 linux_glibc: {
2073 enabled: true,
2074 },
2075 },
Paul Duffin91756d22020-02-21 16:29:57 +00002076}
2077
2078sdk_snapshot {
2079 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002080 visibility: ["//visibility:public"],
Paul Duffin91756d22020-02-21 16:29:57 +00002081 device_supported: false,
2082 host_supported: true,
2083 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002084 target: {
2085 host: {
2086 enabled: false,
2087 },
2088 linux_glibc: {
2089 enabled: true,
2090 },
2091 },
Paul Duffin91756d22020-02-21 16:29:57 +00002092}
2093`),
2094 checkAllCopyRules(`
2095include/Test.h -> include/include/Test.h
2096`),
2097 )
2098}
Paul Duffina04c1072020-03-02 10:16:35 +00002099
2100func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07002101 t.Parallel()
Paul Duffina04c1072020-03-02 10:16:35 +00002102 result := testSdkWithCc(t, `
2103 sdk {
2104 name: "mysdk",
2105 host_supported: true,
2106 native_header_libs: ["mynativeheaders"],
2107 }
2108
2109 cc_library_headers {
2110 name: "mynativeheaders",
2111 host_supported: true,
Paul Duffina04c1072020-03-02 10:16:35 +00002112 stl: "none",
2113 export_system_include_dirs: ["include"],
2114 target: {
2115 android: {
2116 export_include_dirs: ["include-android"],
2117 },
2118 host: {
2119 export_include_dirs: ["include-host"],
2120 },
2121 },
2122 }
2123 `)
2124
2125 result.CheckSnapshot("mysdk", "",
2126 checkAndroidBpContents(`
2127// This is auto-generated. DO NOT EDIT.
2128
2129cc_prebuilt_library_headers {
2130 name: "mysdk_mynativeheaders@current",
2131 sdk_member_name: "mynativeheaders",
Paul Duffind99d9972020-09-29 16:00:55 +01002132 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002133 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002134 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002135 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002136 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002137 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002138 host: {
2139 enabled: false,
2140 },
Paul Duffina04c1072020-03-02 10:16:35 +00002141 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002142 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002143 },
2144 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002145 enabled: true,
Paul Duffined62b9c2020-06-16 16:12:50 +01002146 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002147 },
2148 },
Paul Duffina04c1072020-03-02 10:16:35 +00002149}
2150
2151cc_prebuilt_library_headers {
2152 name: "mynativeheaders",
2153 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002154 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002155 host_supported: true,
Paul Duffin0174d8d2020-03-11 18:42:08 +00002156 stl: "none",
Martin Stjernholm89238f42020-07-10 00:14:03 +01002157 compile_multilib: "both",
Paul Duffined62b9c2020-06-16 16:12:50 +01002158 export_system_include_dirs: ["common_os/include/include"],
Paul Duffina04c1072020-03-02 10:16:35 +00002159 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002160 host: {
2161 enabled: false,
2162 },
Paul Duffina04c1072020-03-02 10:16:35 +00002163 android: {
Paul Duffined62b9c2020-06-16 16:12:50 +01002164 export_include_dirs: ["android/include/include-android"],
Paul Duffina04c1072020-03-02 10:16:35 +00002165 },
2166 linux_glibc: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002167 enabled: true,
Paul Duffined62b9c2020-06-16 16:12:50 +01002168 export_include_dirs: ["linux_glibc/include/include-host"],
Paul Duffina04c1072020-03-02 10:16:35 +00002169 },
2170 },
Paul Duffina04c1072020-03-02 10:16:35 +00002171}
2172
2173sdk_snapshot {
2174 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002175 visibility: ["//visibility:public"],
Paul Duffina04c1072020-03-02 10:16:35 +00002176 host_supported: true,
2177 native_header_libs: ["mysdk_mynativeheaders@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002178 target: {
2179 host: {
2180 enabled: false,
2181 },
2182 linux_glibc: {
2183 enabled: true,
2184 },
2185 },
Paul Duffina04c1072020-03-02 10:16:35 +00002186}
2187`),
2188 checkAllCopyRules(`
Paul Duffined62b9c2020-06-16 16:12:50 +01002189include/Test.h -> common_os/include/include/Test.h
2190include-android/AndroidTest.h -> android/include/include-android/AndroidTest.h
2191include-host/HostTest.h -> linux_glibc/include/include-host/HostTest.h
Paul Duffina04c1072020-03-02 10:16:35 +00002192`),
2193 )
2194}
Martin Stjernholm10566a02020-03-24 01:19:52 +00002195
2196func TestSystemSharedLibPropagation(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07002197 t.Parallel()
Martin Stjernholm10566a02020-03-24 01:19:52 +00002198 result := testSdkWithCc(t, `
2199 sdk {
2200 name: "mysdk",
2201 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
2202 }
2203
2204 cc_library {
2205 name: "sslnil",
2206 host_supported: true,
2207 }
2208
2209 cc_library {
2210 name: "sslempty",
2211 system_shared_libs: [],
2212 }
2213
2214 cc_library {
2215 name: "sslnonempty",
2216 system_shared_libs: ["sslnil"],
2217 }
2218 `)
2219
2220 result.CheckSnapshot("mysdk", "",
2221 checkAndroidBpContents(`
2222// This is auto-generated. DO NOT EDIT.
2223
2224cc_prebuilt_library_shared {
2225 name: "mysdk_sslnil@current",
2226 sdk_member_name: "sslnil",
Paul Duffind99d9972020-09-29 16:00:55 +01002227 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002228 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002229 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002230 arch: {
2231 arm64: {
2232 srcs: ["arm64/lib/sslnil.so"],
2233 },
2234 arm: {
2235 srcs: ["arm/lib/sslnil.so"],
2236 },
2237 },
2238}
2239
2240cc_prebuilt_library_shared {
2241 name: "sslnil",
2242 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002243 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002244 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002245 arch: {
2246 arm64: {
2247 srcs: ["arm64/lib/sslnil.so"],
2248 },
2249 arm: {
2250 srcs: ["arm/lib/sslnil.so"],
2251 },
2252 },
2253}
2254
2255cc_prebuilt_library_shared {
2256 name: "mysdk_sslempty@current",
2257 sdk_member_name: "sslempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002258 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002259 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002260 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002261 system_shared_libs: [],
2262 arch: {
2263 arm64: {
2264 srcs: ["arm64/lib/sslempty.so"],
2265 },
2266 arm: {
2267 srcs: ["arm/lib/sslempty.so"],
2268 },
2269 },
2270}
2271
2272cc_prebuilt_library_shared {
2273 name: "sslempty",
2274 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002275 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002276 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002277 system_shared_libs: [],
2278 arch: {
2279 arm64: {
2280 srcs: ["arm64/lib/sslempty.so"],
2281 },
2282 arm: {
2283 srcs: ["arm/lib/sslempty.so"],
2284 },
2285 },
2286}
2287
2288cc_prebuilt_library_shared {
2289 name: "mysdk_sslnonempty@current",
2290 sdk_member_name: "sslnonempty",
Paul Duffind99d9972020-09-29 16:00:55 +01002291 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002292 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002293 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002294 system_shared_libs: ["mysdk_sslnil@current"],
2295 arch: {
2296 arm64: {
2297 srcs: ["arm64/lib/sslnonempty.so"],
2298 },
2299 arm: {
2300 srcs: ["arm/lib/sslnonempty.so"],
2301 },
2302 },
2303}
2304
2305cc_prebuilt_library_shared {
2306 name: "sslnonempty",
2307 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002308 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002309 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002310 system_shared_libs: ["sslnil"],
2311 arch: {
2312 arm64: {
2313 srcs: ["arm64/lib/sslnonempty.so"],
2314 },
2315 arm: {
2316 srcs: ["arm/lib/sslnonempty.so"],
2317 },
2318 },
2319}
2320
2321sdk_snapshot {
2322 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002323 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002324 native_shared_libs: [
2325 "mysdk_sslnil@current",
2326 "mysdk_sslempty@current",
2327 "mysdk_sslnonempty@current",
2328 ],
2329}
2330`))
2331
2332 result = testSdkWithCc(t, `
2333 sdk {
2334 name: "mysdk",
2335 host_supported: true,
2336 native_shared_libs: ["sslvariants"],
2337 }
2338
2339 cc_library {
2340 name: "sslvariants",
2341 host_supported: true,
2342 target: {
2343 android: {
2344 system_shared_libs: [],
2345 },
2346 },
2347 }
2348 `)
2349
2350 result.CheckSnapshot("mysdk", "",
2351 checkAndroidBpContents(`
2352// This is auto-generated. DO NOT EDIT.
2353
2354cc_prebuilt_library_shared {
2355 name: "mysdk_sslvariants@current",
2356 sdk_member_name: "sslvariants",
Paul Duffind99d9972020-09-29 16:00:55 +01002357 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002358 host_supported: true,
2359 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002360 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002361 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002362 host: {
2363 enabled: false,
2364 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002365 android: {
2366 system_shared_libs: [],
2367 },
2368 android_arm64: {
2369 srcs: ["android/arm64/lib/sslvariants.so"],
2370 },
2371 android_arm: {
2372 srcs: ["android/arm/lib/sslvariants.so"],
2373 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002374 linux_glibc: {
2375 enabled: true,
2376 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002377 linux_glibc_x86_64: {
2378 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2379 },
2380 linux_glibc_x86: {
2381 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2382 },
2383 },
2384}
2385
2386cc_prebuilt_library_shared {
2387 name: "sslvariants",
2388 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002389 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002390 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002391 compile_multilib: "both",
Martin Stjernholm10566a02020-03-24 01:19:52 +00002392 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002393 host: {
2394 enabled: false,
2395 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002396 android: {
2397 system_shared_libs: [],
2398 },
2399 android_arm64: {
2400 srcs: ["android/arm64/lib/sslvariants.so"],
2401 },
2402 android_arm: {
2403 srcs: ["android/arm/lib/sslvariants.so"],
2404 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002405 linux_glibc: {
2406 enabled: true,
2407 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002408 linux_glibc_x86_64: {
2409 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
2410 },
2411 linux_glibc_x86: {
2412 srcs: ["linux_glibc/x86/lib/sslvariants.so"],
2413 },
2414 },
2415}
2416
2417sdk_snapshot {
2418 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002419 visibility: ["//visibility:public"],
Martin Stjernholm10566a02020-03-24 01:19:52 +00002420 host_supported: true,
2421 native_shared_libs: ["mysdk_sslvariants@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002422 target: {
2423 host: {
2424 enabled: false,
2425 },
2426 linux_glibc: {
2427 enabled: true,
2428 },
2429 },
Martin Stjernholm10566a02020-03-24 01:19:52 +00002430}
2431`))
2432}
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002433
2434func TestStubsLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07002435 t.Parallel()
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002436 result := testSdkWithCc(t, `
2437 sdk {
2438 name: "mysdk",
2439 native_shared_libs: ["stubslib"],
2440 }
2441
2442 cc_library {
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002443 name: "internaldep",
2444 }
2445
2446 cc_library {
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002447 name: "stubslib",
Martin Stjernholmcc330d62020-04-21 20:45:35 +01002448 shared_libs: ["internaldep"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002449 stubs: {
2450 symbol_file: "some/where/stubslib.map.txt",
2451 versions: ["1", "2", "3"],
2452 },
2453 }
2454 `)
2455
2456 result.CheckSnapshot("mysdk", "",
2457 checkAndroidBpContents(`
2458// This is auto-generated. DO NOT EDIT.
2459
2460cc_prebuilt_library_shared {
2461 name: "mysdk_stubslib@current",
2462 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002463 visibility: ["//visibility:public"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002464 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002465 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002466 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002467 versions: [
2468 "1",
2469 "2",
2470 "3",
2471 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002472 },
2473 arch: {
2474 arm64: {
2475 srcs: ["arm64/lib/stubslib.so"],
2476 },
2477 arm: {
2478 srcs: ["arm/lib/stubslib.so"],
2479 },
2480 },
2481}
2482
2483cc_prebuilt_library_shared {
2484 name: "stubslib",
2485 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002486 visibility: ["//visibility:public"],
Martin Stjernholm89238f42020-07-10 00:14:03 +01002487 compile_multilib: "both",
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002488 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002489 versions: [
2490 "1",
2491 "2",
2492 "3",
2493 ],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002494 },
2495 arch: {
2496 arm64: {
2497 srcs: ["arm64/lib/stubslib.so"],
2498 },
2499 arm: {
2500 srcs: ["arm/lib/stubslib.so"],
2501 },
2502 },
2503}
2504
2505sdk_snapshot {
2506 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002507 visibility: ["//visibility:public"],
Martin Stjernholmc5dd4f72020-04-01 20:38:01 +01002508 native_shared_libs: ["mysdk_stubslib@current"],
2509}
2510`))
2511}
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002512
2513func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07002514 t.Parallel()
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002515 result := testSdkWithCc(t, `
2516 sdk {
2517 name: "mysdk",
2518 host_supported: true,
2519 native_shared_libs: ["stubslib"],
2520 }
2521
2522 cc_library {
2523 name: "internaldep",
2524 host_supported: true,
2525 }
2526
2527 cc_library {
2528 name: "stubslib",
2529 host_supported: true,
2530 shared_libs: ["internaldep"],
2531 stubs: {
2532 symbol_file: "some/where/stubslib.map.txt",
2533 versions: ["1", "2", "3"],
2534 },
2535 }
2536 `)
2537
2538 result.CheckSnapshot("mysdk", "",
2539 checkAndroidBpContents(`
2540// This is auto-generated. DO NOT EDIT.
2541
2542cc_prebuilt_library_shared {
2543 name: "mysdk_stubslib@current",
2544 sdk_member_name: "stubslib",
Paul Duffind99d9972020-09-29 16:00:55 +01002545 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002546 host_supported: true,
2547 installable: false,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002548 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002549 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002550 versions: [
2551 "1",
2552 "2",
2553 "3",
2554 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002555 },
2556 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002557 host: {
2558 enabled: false,
2559 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002560 android_arm64: {
2561 srcs: ["android/arm64/lib/stubslib.so"],
2562 },
2563 android_arm: {
2564 srcs: ["android/arm/lib/stubslib.so"],
2565 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002566 linux_glibc: {
2567 enabled: true,
2568 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002569 linux_glibc_x86_64: {
2570 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2571 },
2572 linux_glibc_x86: {
2573 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2574 },
2575 },
2576}
2577
2578cc_prebuilt_library_shared {
2579 name: "stubslib",
2580 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002581 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002582 host_supported: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002583 compile_multilib: "both",
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002584 stubs: {
Martin Stjernholm618b6712020-09-24 16:53:04 +01002585 versions: [
2586 "1",
2587 "2",
2588 "3",
2589 ],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002590 },
2591 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002592 host: {
2593 enabled: false,
2594 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002595 android_arm64: {
2596 srcs: ["android/arm64/lib/stubslib.so"],
2597 },
2598 android_arm: {
2599 srcs: ["android/arm/lib/stubslib.so"],
2600 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002601 linux_glibc: {
2602 enabled: true,
2603 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002604 linux_glibc_x86_64: {
2605 srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
2606 },
2607 linux_glibc_x86: {
2608 srcs: ["linux_glibc/x86/lib/stubslib.so"],
2609 },
2610 },
2611}
2612
2613sdk_snapshot {
2614 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002615 visibility: ["//visibility:public"],
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002616 host_supported: true,
2617 native_shared_libs: ["mysdk_stubslib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002618 target: {
2619 host: {
2620 enabled: false,
2621 },
2622 linux_glibc: {
2623 enabled: true,
2624 },
2625 },
Paul Duffin7a1f7f32020-05-04 15:32:08 +01002626}
2627`))
2628}
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002629
2630func TestUniqueHostSoname(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -07002631 t.Parallel()
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002632 result := testSdkWithCc(t, `
2633 sdk {
2634 name: "mysdk",
2635 host_supported: true,
2636 native_shared_libs: ["mylib"],
2637 }
2638
2639 cc_library {
2640 name: "mylib",
2641 host_supported: true,
2642 unique_host_soname: true,
2643 }
2644 `)
2645
2646 result.CheckSnapshot("mysdk", "",
2647 checkAndroidBpContents(`
2648// This is auto-generated. DO NOT EDIT.
2649
2650cc_prebuilt_library_shared {
2651 name: "mysdk_mylib@current",
2652 sdk_member_name: "mylib",
Paul Duffind99d9972020-09-29 16:00:55 +01002653 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002654 host_supported: true,
2655 installable: false,
2656 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002657 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002658 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002659 host: {
2660 enabled: false,
2661 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002662 android_arm64: {
2663 srcs: ["android/arm64/lib/mylib.so"],
2664 },
2665 android_arm: {
2666 srcs: ["android/arm/lib/mylib.so"],
2667 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002668 linux_glibc: {
2669 enabled: true,
2670 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002671 linux_glibc_x86_64: {
2672 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2673 },
2674 linux_glibc_x86: {
2675 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2676 },
2677 },
2678}
2679
2680cc_prebuilt_library_shared {
2681 name: "mylib",
2682 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +01002683 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002684 host_supported: true,
2685 unique_host_soname: true,
Martin Stjernholm89238f42020-07-10 00:14:03 +01002686 compile_multilib: "both",
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002687 target: {
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002688 host: {
2689 enabled: false,
2690 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002691 android_arm64: {
2692 srcs: ["android/arm64/lib/mylib.so"],
2693 },
2694 android_arm: {
2695 srcs: ["android/arm/lib/mylib.so"],
2696 },
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002697 linux_glibc: {
2698 enabled: true,
2699 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002700 linux_glibc_x86_64: {
2701 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
2702 },
2703 linux_glibc_x86: {
2704 srcs: ["linux_glibc/x86/lib/mylib-host.so"],
2705 },
2706 },
2707}
2708
2709sdk_snapshot {
2710 name: "mysdk@current",
Paul Duffind99d9972020-09-29 16:00:55 +01002711 visibility: ["//visibility:public"],
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002712 host_supported: true,
2713 native_shared_libs: ["mysdk_mylib@current"],
Martin Stjernholmcaa47d72020-07-11 04:52:24 +01002714 target: {
2715 host: {
2716 enabled: false,
2717 },
2718 linux_glibc: {
2719 enabled: true,
2720 },
2721 },
Martin Stjernholm47ed3522020-06-17 22:52:25 +01002722}
2723`),
2724 checkAllCopyRules(`
2725.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
2726.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
2727.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
2728.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
2729`),
2730 )
2731}