Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1 | // 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 | |
| 15 | package sdk |
| 16 | |
| 17 | import ( |
| 18 | "testing" |
| 19 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 20 | "android/soong/android" |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 21 | "android/soong/cc" |
| 22 | ) |
| 23 | |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 24 | func testSdkWithCc(t *testing.T, bp string) *testSdkResult { |
| 25 | t.Helper() |
| 26 | |
| 27 | fs := map[string][]byte{ |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 28 | "Test.cpp": nil, |
| 29 | "include/Test.h": nil, |
| 30 | "include-android/AndroidTest.h": nil, |
| 31 | "include-host/HostTest.h": nil, |
| 32 | "arm64/include/Arm64Test.h": nil, |
| 33 | "libfoo.so": nil, |
| 34 | "aidl/foo/bar/Test.aidl": nil, |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 35 | "some/where/stubslib.map.txt": nil, |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 36 | } |
| 37 | return testSdkWithFs(t, bp, fs) |
| 38 | } |
| 39 | |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 40 | // Contains tests for SDK members provided by the cc package. |
| 41 | |
| 42 | func TestSdkIsCompileMultilibBoth(t *testing.T) { |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 43 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 44 | sdk { |
| 45 | name: "mysdk", |
| 46 | native_shared_libs: ["sdkmember"], |
| 47 | } |
| 48 | |
| 49 | cc_library_shared { |
| 50 | name: "sdkmember", |
| 51 | srcs: ["Test.cpp"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 52 | stl: "none", |
| 53 | } |
| 54 | `) |
| 55 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 56 | armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile() |
| 57 | arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile() |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 58 | |
| 59 | var inputs []string |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 60 | buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests() |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 61 | for _, bp := range buildParams { |
| 62 | if bp.Input != nil { |
| 63 | inputs = append(inputs, bp.Input.String()) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // ensure that both 32/64 outputs are inputs of the sdk snapshot |
| 68 | ensureListContains(t, inputs, armOutput.String()) |
| 69 | ensureListContains(t, inputs, arm64Output.String()) |
| 70 | } |
| 71 | |
| 72 | func TestBasicSdkWithCc(t *testing.T) { |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 73 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 74 | sdk { |
| 75 | name: "mysdk", |
| 76 | native_shared_libs: ["sdkmember"], |
| 77 | } |
| 78 | |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 79 | cc_library_shared { |
| 80 | name: "sdkmember", |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 81 | system_shared_libs: [], |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 84 | sdk_snapshot { |
| 85 | name: "mysdk@1", |
| 86 | native_shared_libs: ["sdkmember_mysdk_1"], |
| 87 | } |
| 88 | |
| 89 | sdk_snapshot { |
| 90 | name: "mysdk@2", |
| 91 | native_shared_libs: ["sdkmember_mysdk_2"], |
| 92 | } |
| 93 | |
| 94 | cc_prebuilt_library_shared { |
| 95 | name: "sdkmember", |
| 96 | srcs: ["libfoo.so"], |
| 97 | prefer: false, |
| 98 | system_shared_libs: [], |
| 99 | stl: "none", |
| 100 | } |
| 101 | |
| 102 | cc_prebuilt_library_shared { |
| 103 | name: "sdkmember_mysdk_1", |
| 104 | sdk_member_name: "sdkmember", |
| 105 | srcs: ["libfoo.so"], |
| 106 | system_shared_libs: [], |
| 107 | stl: "none", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 108 | // TODO: remove //apex_available:platform |
| 109 | apex_available: [ |
| 110 | "//apex_available:platform", |
| 111 | "myapex", |
| 112 | ], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | cc_prebuilt_library_shared { |
| 116 | name: "sdkmember_mysdk_2", |
| 117 | sdk_member_name: "sdkmember", |
| 118 | srcs: ["libfoo.so"], |
| 119 | system_shared_libs: [], |
| 120 | stl: "none", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 121 | // TODO: remove //apex_available:platform |
| 122 | apex_available: [ |
| 123 | "//apex_available:platform", |
| 124 | "myapex2", |
| 125 | ], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | cc_library_shared { |
| 129 | name: "mycpplib", |
| 130 | srcs: ["Test.cpp"], |
| 131 | shared_libs: ["sdkmember"], |
| 132 | system_shared_libs: [], |
| 133 | stl: "none", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 134 | apex_available: [ |
| 135 | "myapex", |
| 136 | "myapex2", |
| 137 | ], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | apex { |
| 141 | name: "myapex", |
| 142 | native_shared_libs: ["mycpplib"], |
| 143 | uses_sdks: ["mysdk@1"], |
| 144 | key: "myapex.key", |
| 145 | certificate: ":myapex.cert", |
| 146 | } |
| 147 | |
| 148 | apex { |
| 149 | name: "myapex2", |
| 150 | native_shared_libs: ["mycpplib"], |
| 151 | uses_sdks: ["mysdk@2"], |
| 152 | key: "myapex.key", |
| 153 | certificate: ":myapex.cert", |
| 154 | } |
| 155 | `) |
| 156 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 157 | sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_myapex").Rule("toc").Output |
| 158 | sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_myapex2").Rule("toc").Output |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 159 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 160 | cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex") |
| 161 | cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex2") |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 162 | |
| 163 | // Depending on the uses_sdks value, different libs are linked |
| 164 | ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String()) |
| 165 | ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String()) |
| 166 | } |
| 167 | |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 168 | // Make sure the sdk can use host specific cc libraries static/shared and both. |
| 169 | func TestHostSdkWithCc(t *testing.T) { |
| 170 | testSdkWithCc(t, ` |
| 171 | sdk { |
| 172 | name: "mysdk", |
| 173 | device_supported: false, |
| 174 | host_supported: true, |
| 175 | native_shared_libs: ["sdkshared"], |
| 176 | native_static_libs: ["sdkstatic"], |
| 177 | } |
| 178 | |
| 179 | cc_library_host_shared { |
| 180 | name: "sdkshared", |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 181 | stl: "none", |
| 182 | } |
| 183 | |
| 184 | cc_library_host_static { |
| 185 | name: "sdkstatic", |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 186 | stl: "none", |
| 187 | } |
| 188 | `) |
| 189 | } |
| 190 | |
| 191 | // Make sure the sdk can use cc libraries static/shared and both. |
| 192 | func TestSdkWithCc(t *testing.T) { |
| 193 | testSdkWithCc(t, ` |
| 194 | sdk { |
| 195 | name: "mysdk", |
| 196 | native_shared_libs: ["sdkshared", "sdkboth1"], |
| 197 | native_static_libs: ["sdkstatic", "sdkboth2"], |
| 198 | } |
| 199 | |
| 200 | cc_library_shared { |
| 201 | name: "sdkshared", |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 202 | stl: "none", |
| 203 | } |
| 204 | |
| 205 | cc_library_static { |
| 206 | name: "sdkstatic", |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 207 | stl: "none", |
| 208 | } |
| 209 | |
| 210 | cc_library { |
| 211 | name: "sdkboth1", |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 212 | stl: "none", |
| 213 | } |
| 214 | |
| 215 | cc_library { |
| 216 | name: "sdkboth2", |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 217 | stl: "none", |
| 218 | } |
| 219 | `) |
| 220 | } |
| 221 | |
Martin Stjernholm | cd07bce | 2020-03-10 22:37:59 +0000 | [diff] [blame] | 222 | func TestSnapshotWithObject(t *testing.T) { |
| 223 | result := testSdkWithCc(t, ` |
| 224 | sdk { |
| 225 | name: "mysdk", |
| 226 | native_objects: ["crtobj"], |
| 227 | } |
| 228 | |
| 229 | cc_object { |
| 230 | name: "crtobj", |
| 231 | stl: "none", |
| 232 | } |
| 233 | `) |
| 234 | |
| 235 | result.CheckSnapshot("mysdk", "", |
| 236 | checkAndroidBpContents(` |
| 237 | // This is auto-generated. DO NOT EDIT. |
| 238 | |
| 239 | cc_prebuilt_object { |
| 240 | name: "mysdk_crtobj@current", |
| 241 | sdk_member_name: "crtobj", |
| 242 | stl: "none", |
| 243 | arch: { |
| 244 | arm64: { |
| 245 | srcs: ["arm64/lib/crtobj.o"], |
| 246 | }, |
| 247 | arm: { |
| 248 | srcs: ["arm/lib/crtobj.o"], |
| 249 | }, |
| 250 | }, |
| 251 | } |
| 252 | |
| 253 | cc_prebuilt_object { |
| 254 | name: "crtobj", |
| 255 | prefer: false, |
| 256 | stl: "none", |
| 257 | arch: { |
| 258 | arm64: { |
| 259 | srcs: ["arm64/lib/crtobj.o"], |
| 260 | }, |
| 261 | arm: { |
| 262 | srcs: ["arm/lib/crtobj.o"], |
| 263 | }, |
| 264 | }, |
| 265 | } |
| 266 | |
| 267 | sdk_snapshot { |
| 268 | name: "mysdk@current", |
| 269 | native_objects: ["mysdk_crtobj@current"], |
| 270 | } |
| 271 | `), |
| 272 | checkAllCopyRules(` |
| 273 | .intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o |
| 274 | .intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o |
| 275 | `), |
| 276 | ) |
| 277 | } |
| 278 | |
Paul Duffin | c62a510 | 2019-12-11 18:34:15 +0000 | [diff] [blame] | 279 | func TestSnapshotWithCcDuplicateHeaders(t *testing.T) { |
| 280 | result := testSdkWithCc(t, ` |
| 281 | sdk { |
| 282 | name: "mysdk", |
| 283 | native_shared_libs: ["mynativelib1", "mynativelib2"], |
| 284 | } |
| 285 | |
| 286 | cc_library_shared { |
| 287 | name: "mynativelib1", |
| 288 | srcs: [ |
| 289 | "Test.cpp", |
| 290 | ], |
| 291 | export_include_dirs: ["include"], |
Paul Duffin | c62a510 | 2019-12-11 18:34:15 +0000 | [diff] [blame] | 292 | stl: "none", |
| 293 | } |
| 294 | |
| 295 | cc_library_shared { |
| 296 | name: "mynativelib2", |
| 297 | srcs: [ |
| 298 | "Test.cpp", |
| 299 | ], |
| 300 | export_include_dirs: ["include"], |
Paul Duffin | c62a510 | 2019-12-11 18:34:15 +0000 | [diff] [blame] | 301 | stl: "none", |
| 302 | } |
| 303 | `) |
| 304 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 305 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | c62a510 | 2019-12-11 18:34:15 +0000 | [diff] [blame] | 306 | checkAllCopyRules(` |
| 307 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 308 | .intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so |
| 309 | .intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so |
| 310 | .intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so |
| 311 | .intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so |
Paul Duffin | c62a510 | 2019-12-11 18:34:15 +0000 | [diff] [blame] | 312 | `), |
| 313 | ) |
| 314 | } |
| 315 | |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 316 | // Verify that when the shared library has some common and some arch specific properties that the generated |
| 317 | // snapshot is optimized properly. |
| 318 | func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) { |
| 319 | result := testSdkWithCc(t, ` |
| 320 | sdk { |
| 321 | name: "mysdk", |
| 322 | native_shared_libs: ["mynativelib"], |
| 323 | } |
| 324 | |
| 325 | cc_library_shared { |
| 326 | name: "mynativelib", |
| 327 | srcs: [ |
| 328 | "Test.cpp", |
| 329 | "aidl/foo/bar/Test.aidl", |
| 330 | ], |
| 331 | export_include_dirs: ["include"], |
| 332 | arch: { |
| 333 | arm64: { |
| 334 | export_system_include_dirs: ["arm64/include"], |
| 335 | }, |
| 336 | }, |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 337 | stl: "none", |
| 338 | } |
| 339 | `) |
| 340 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 341 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 342 | checkAndroidBpContents(` |
| 343 | // This is auto-generated. DO NOT EDIT. |
| 344 | |
| 345 | cc_prebuilt_library_shared { |
| 346 | name: "mysdk_mynativelib@current", |
| 347 | sdk_member_name: "mynativelib", |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 348 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 349 | stl: "none", |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 350 | export_include_dirs: ["include/include"], |
| 351 | arch: { |
| 352 | arm64: { |
| 353 | srcs: ["arm64/lib/mynativelib.so"], |
| 354 | export_system_include_dirs: ["arm64/include/arm64/include"], |
| 355 | }, |
| 356 | arm: { |
| 357 | srcs: ["arm/lib/mynativelib.so"], |
| 358 | }, |
| 359 | }, |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | cc_prebuilt_library_shared { |
| 363 | name: "mynativelib", |
| 364 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 365 | stl: "none", |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 366 | export_include_dirs: ["include/include"], |
| 367 | arch: { |
| 368 | arm64: { |
| 369 | srcs: ["arm64/lib/mynativelib.so"], |
| 370 | export_system_include_dirs: ["arm64/include/arm64/include"], |
| 371 | }, |
| 372 | arm: { |
| 373 | srcs: ["arm/lib/mynativelib.so"], |
| 374 | }, |
| 375 | }, |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | sdk_snapshot { |
| 379 | name: "mysdk@current", |
| 380 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 381 | } |
| 382 | `), |
| 383 | checkAllCopyRules(` |
| 384 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 385 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 386 | arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 387 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`), |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 388 | ) |
| 389 | } |
| 390 | |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 391 | func TestSnapshotWithCcBinary(t *testing.T) { |
| 392 | result := testSdkWithCc(t, ` |
| 393 | module_exports { |
| 394 | name: "mymodule_exports", |
| 395 | native_binaries: ["mynativebinary"], |
| 396 | } |
| 397 | |
| 398 | cc_binary { |
| 399 | name: "mynativebinary", |
| 400 | srcs: [ |
| 401 | "Test.cpp", |
| 402 | ], |
| 403 | compile_multilib: "both", |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 404 | stl: "none", |
| 405 | } |
| 406 | `) |
| 407 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 408 | result.CheckSnapshot("mymodule_exports", "", |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 409 | checkAndroidBpContents(` |
| 410 | // This is auto-generated. DO NOT EDIT. |
| 411 | |
| 412 | cc_prebuilt_binary { |
| 413 | name: "mymodule_exports_mynativebinary@current", |
| 414 | sdk_member_name: "mynativebinary", |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 415 | installable: false, |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 416 | compile_multilib: "both", |
| 417 | arch: { |
| 418 | arm64: { |
| 419 | srcs: ["arm64/bin/mynativebinary"], |
| 420 | }, |
| 421 | arm: { |
| 422 | srcs: ["arm/bin/mynativebinary"], |
| 423 | }, |
| 424 | }, |
| 425 | } |
| 426 | |
| 427 | cc_prebuilt_binary { |
| 428 | name: "mynativebinary", |
| 429 | prefer: false, |
| 430 | compile_multilib: "both", |
| 431 | arch: { |
| 432 | arm64: { |
| 433 | srcs: ["arm64/bin/mynativebinary"], |
| 434 | }, |
| 435 | arm: { |
| 436 | srcs: ["arm/bin/mynativebinary"], |
| 437 | }, |
| 438 | }, |
| 439 | } |
| 440 | |
| 441 | module_exports_snapshot { |
| 442 | name: "mymodule_exports@current", |
| 443 | native_binaries: ["mymodule_exports_mynativebinary@current"], |
| 444 | } |
| 445 | `), |
| 446 | checkAllCopyRules(` |
| 447 | .intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary |
| 448 | .intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary |
| 449 | `), |
| 450 | ) |
| 451 | } |
| 452 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 453 | func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) { |
| 454 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 455 | SkipIfNotLinux(t) |
| 456 | |
| 457 | result := testSdkWithCc(t, ` |
| 458 | module_exports { |
| 459 | name: "myexports", |
| 460 | device_supported: false, |
| 461 | host_supported: true, |
| 462 | native_binaries: ["mynativebinary"], |
| 463 | target: { |
| 464 | windows: { |
| 465 | enabled: true, |
| 466 | }, |
| 467 | }, |
| 468 | } |
| 469 | |
| 470 | cc_binary { |
| 471 | name: "mynativebinary", |
| 472 | device_supported: false, |
| 473 | host_supported: true, |
| 474 | srcs: [ |
| 475 | "Test.cpp", |
| 476 | ], |
| 477 | compile_multilib: "both", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 478 | stl: "none", |
| 479 | target: { |
| 480 | windows: { |
| 481 | enabled: true, |
| 482 | }, |
| 483 | }, |
| 484 | } |
| 485 | `) |
| 486 | |
| 487 | result.CheckSnapshot("myexports", "", |
| 488 | checkAndroidBpContents(` |
| 489 | // This is auto-generated. DO NOT EDIT. |
| 490 | |
| 491 | cc_prebuilt_binary { |
| 492 | name: "myexports_mynativebinary@current", |
| 493 | sdk_member_name: "mynativebinary", |
| 494 | device_supported: false, |
| 495 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 496 | installable: false, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 497 | target: { |
| 498 | linux_glibc: { |
| 499 | compile_multilib: "both", |
| 500 | }, |
| 501 | linux_glibc_x86_64: { |
| 502 | srcs: ["linux_glibc/x86_64/bin/mynativebinary"], |
| 503 | }, |
| 504 | linux_glibc_x86: { |
| 505 | srcs: ["linux_glibc/x86/bin/mynativebinary"], |
| 506 | }, |
| 507 | windows: { |
| 508 | compile_multilib: "64", |
| 509 | }, |
| 510 | windows_x86_64: { |
| 511 | srcs: ["windows/x86_64/bin/mynativebinary.exe"], |
| 512 | }, |
| 513 | }, |
| 514 | } |
| 515 | |
| 516 | cc_prebuilt_binary { |
| 517 | name: "mynativebinary", |
| 518 | prefer: false, |
| 519 | device_supported: false, |
| 520 | host_supported: true, |
| 521 | target: { |
| 522 | linux_glibc: { |
| 523 | compile_multilib: "both", |
| 524 | }, |
| 525 | linux_glibc_x86_64: { |
| 526 | srcs: ["linux_glibc/x86_64/bin/mynativebinary"], |
| 527 | }, |
| 528 | linux_glibc_x86: { |
| 529 | srcs: ["linux_glibc/x86/bin/mynativebinary"], |
| 530 | }, |
| 531 | windows: { |
| 532 | compile_multilib: "64", |
| 533 | }, |
| 534 | windows_x86_64: { |
| 535 | srcs: ["windows/x86_64/bin/mynativebinary.exe"], |
| 536 | }, |
| 537 | }, |
| 538 | } |
| 539 | |
| 540 | module_exports_snapshot { |
| 541 | name: "myexports@current", |
| 542 | device_supported: false, |
| 543 | host_supported: true, |
| 544 | native_binaries: ["myexports_mynativebinary@current"], |
Paul Duffin | 6a7e953 | 2020-03-20 17:50:07 +0000 | [diff] [blame] | 545 | target: { |
| 546 | windows: { |
| 547 | compile_multilib: "64", |
| 548 | }, |
| 549 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 550 | } |
| 551 | `), |
| 552 | checkAllCopyRules(` |
| 553 | .intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary |
| 554 | .intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary |
| 555 | .intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe |
| 556 | `), |
| 557 | ) |
| 558 | } |
| 559 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 560 | func TestSnapshotWithCcSharedLibrary(t *testing.T) { |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 561 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 562 | sdk { |
| 563 | name: "mysdk", |
| 564 | native_shared_libs: ["mynativelib"], |
| 565 | } |
| 566 | |
| 567 | cc_library_shared { |
| 568 | name: "mynativelib", |
| 569 | srcs: [ |
| 570 | "Test.cpp", |
| 571 | "aidl/foo/bar/Test.aidl", |
| 572 | ], |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 573 | apex_available: ["apex1", "apex2"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 574 | export_include_dirs: ["include"], |
| 575 | aidl: { |
| 576 | export_aidl_headers: true, |
| 577 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 578 | stl: "none", |
| 579 | } |
| 580 | `) |
| 581 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 582 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 583 | checkAndroidBpContents(` |
| 584 | // This is auto-generated. DO NOT EDIT. |
| 585 | |
| 586 | cc_prebuilt_library_shared { |
| 587 | name: "mysdk_mynativelib@current", |
| 588 | sdk_member_name: "mynativelib", |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 589 | apex_available: [ |
| 590 | "apex1", |
| 591 | "apex2", |
| 592 | ], |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 593 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 594 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 595 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 596 | arch: { |
| 597 | arm64: { |
| 598 | srcs: ["arm64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 599 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 600 | }, |
| 601 | arm: { |
| 602 | srcs: ["arm/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 603 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 604 | }, |
| 605 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | cc_prebuilt_library_shared { |
| 609 | name: "mynativelib", |
| 610 | prefer: false, |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 611 | apex_available: [ |
| 612 | "apex1", |
| 613 | "apex2", |
| 614 | ], |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 615 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 616 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 617 | arch: { |
| 618 | arm64: { |
| 619 | srcs: ["arm64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 620 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 621 | }, |
| 622 | arm: { |
| 623 | srcs: ["arm/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 624 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 625 | }, |
| 626 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | sdk_snapshot { |
| 630 | name: "mysdk@current", |
| 631 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 632 | } |
| 633 | `), |
| 634 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 635 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 636 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
| 637 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 638 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 639 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 640 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so |
| 641 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 642 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 643 | .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 Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 644 | `), |
| 645 | ) |
| 646 | } |
| 647 | |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 648 | func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) { |
| 649 | result := testSdkWithCc(t, ` |
| 650 | sdk { |
| 651 | name: "mysdk", |
| 652 | native_shared_libs: [ |
| 653 | "mynativelib", |
| 654 | "myothernativelib", |
| 655 | "mysystemnativelib", |
| 656 | ], |
| 657 | } |
| 658 | |
| 659 | cc_library { |
| 660 | name: "mysystemnativelib", |
| 661 | srcs: [ |
| 662 | "Test.cpp", |
| 663 | ], |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 664 | stl: "none", |
| 665 | } |
| 666 | |
| 667 | cc_library_shared { |
| 668 | name: "myothernativelib", |
| 669 | srcs: [ |
| 670 | "Test.cpp", |
| 671 | ], |
| 672 | system_shared_libs: [ |
| 673 | // A reference to a library that is not an sdk member. Uses libm as that |
| 674 | // is in the default set of modules available to this test and so is available |
| 675 | // both here and also when the generated Android.bp file is tested in |
| 676 | // CheckSnapshot(). This ensures that the system_shared_libs property correctly |
| 677 | // handles references to modules that are not sdk members. |
| 678 | "libm", |
| 679 | ], |
| 680 | stl: "none", |
| 681 | } |
| 682 | |
| 683 | cc_library { |
| 684 | name: "mynativelib", |
| 685 | srcs: [ |
| 686 | "Test.cpp", |
| 687 | ], |
| 688 | shared_libs: [ |
| 689 | // A reference to another sdk member. |
| 690 | "myothernativelib", |
| 691 | ], |
| 692 | target: { |
| 693 | android: { |
| 694 | shared: { |
| 695 | shared_libs: [ |
| 696 | // A reference to a library that is not an sdk member. The libc library |
| 697 | // is used here to check that the shared_libs property is handled correctly |
| 698 | // in a similar way to how libm is used to check system_shared_libs above. |
| 699 | "libc", |
| 700 | ], |
| 701 | }, |
| 702 | }, |
| 703 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 704 | stl: "none", |
| 705 | } |
| 706 | `) |
| 707 | |
| 708 | result.CheckSnapshot("mysdk", "", |
| 709 | checkAndroidBpContents(` |
| 710 | // This is auto-generated. DO NOT EDIT. |
| 711 | |
| 712 | cc_prebuilt_library_shared { |
| 713 | name: "mysdk_mynativelib@current", |
| 714 | sdk_member_name: "mynativelib", |
| 715 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 716 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 717 | shared_libs: [ |
| 718 | "mysdk_myothernativelib@current", |
| 719 | "libc", |
| 720 | ], |
| 721 | arch: { |
| 722 | arm64: { |
| 723 | srcs: ["arm64/lib/mynativelib.so"], |
| 724 | }, |
| 725 | arm: { |
| 726 | srcs: ["arm/lib/mynativelib.so"], |
| 727 | }, |
| 728 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | cc_prebuilt_library_shared { |
| 732 | name: "mynativelib", |
| 733 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 734 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 735 | shared_libs: [ |
| 736 | "myothernativelib", |
| 737 | "libc", |
| 738 | ], |
| 739 | arch: { |
| 740 | arm64: { |
| 741 | srcs: ["arm64/lib/mynativelib.so"], |
| 742 | }, |
| 743 | arm: { |
| 744 | srcs: ["arm/lib/mynativelib.so"], |
| 745 | }, |
| 746 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | cc_prebuilt_library_shared { |
| 750 | name: "mysdk_myothernativelib@current", |
| 751 | sdk_member_name: "myothernativelib", |
| 752 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 753 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 754 | system_shared_libs: ["libm"], |
| 755 | arch: { |
| 756 | arm64: { |
| 757 | srcs: ["arm64/lib/myothernativelib.so"], |
| 758 | }, |
| 759 | arm: { |
| 760 | srcs: ["arm/lib/myothernativelib.so"], |
| 761 | }, |
| 762 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 763 | } |
| 764 | |
| 765 | cc_prebuilt_library_shared { |
| 766 | name: "myothernativelib", |
| 767 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 768 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 769 | system_shared_libs: ["libm"], |
| 770 | arch: { |
| 771 | arm64: { |
| 772 | srcs: ["arm64/lib/myothernativelib.so"], |
| 773 | }, |
| 774 | arm: { |
| 775 | srcs: ["arm/lib/myothernativelib.so"], |
| 776 | }, |
| 777 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | cc_prebuilt_library_shared { |
| 781 | name: "mysdk_mysystemnativelib@current", |
| 782 | sdk_member_name: "mysystemnativelib", |
| 783 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 784 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 785 | arch: { |
| 786 | arm64: { |
| 787 | srcs: ["arm64/lib/mysystemnativelib.so"], |
| 788 | }, |
| 789 | arm: { |
| 790 | srcs: ["arm/lib/mysystemnativelib.so"], |
| 791 | }, |
| 792 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | cc_prebuilt_library_shared { |
| 796 | name: "mysystemnativelib", |
| 797 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 798 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 799 | arch: { |
| 800 | arm64: { |
| 801 | srcs: ["arm64/lib/mysystemnativelib.so"], |
| 802 | }, |
| 803 | arm: { |
| 804 | srcs: ["arm/lib/mysystemnativelib.so"], |
| 805 | }, |
| 806 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | sdk_snapshot { |
| 810 | name: "mysdk@current", |
| 811 | native_shared_libs: [ |
| 812 | "mysdk_mynativelib@current", |
| 813 | "mysdk_myothernativelib@current", |
| 814 | "mysdk_mysystemnativelib@current", |
| 815 | ], |
| 816 | } |
| 817 | `), |
| 818 | checkAllCopyRules(` |
| 819 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
| 820 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so |
| 821 | .intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so |
| 822 | .intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so |
| 823 | .intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so |
| 824 | .intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so |
| 825 | `), |
| 826 | ) |
| 827 | } |
| 828 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 829 | func TestHostSnapshotWithCcSharedLibrary(t *testing.T) { |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 830 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 831 | SkipIfNotLinux(t) |
| 832 | |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 833 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 834 | sdk { |
| 835 | name: "mysdk", |
| 836 | device_supported: false, |
| 837 | host_supported: true, |
| 838 | native_shared_libs: ["mynativelib"], |
| 839 | } |
| 840 | |
| 841 | cc_library_shared { |
| 842 | name: "mynativelib", |
| 843 | device_supported: false, |
| 844 | host_supported: true, |
| 845 | srcs: [ |
| 846 | "Test.cpp", |
| 847 | "aidl/foo/bar/Test.aidl", |
| 848 | ], |
| 849 | export_include_dirs: ["include"], |
| 850 | aidl: { |
| 851 | export_aidl_headers: true, |
| 852 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 853 | stl: "none", |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 854 | sdk_version: "minimum", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 855 | } |
| 856 | `) |
| 857 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 858 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 859 | checkAndroidBpContents(` |
| 860 | // This is auto-generated. DO NOT EDIT. |
| 861 | |
| 862 | cc_prebuilt_library_shared { |
| 863 | name: "mysdk_mynativelib@current", |
| 864 | sdk_member_name: "mynativelib", |
| 865 | device_supported: false, |
| 866 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 867 | installable: false, |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 868 | sdk_version: "minimum", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 869 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 870 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 871 | arch: { |
| 872 | x86_64: { |
| 873 | srcs: ["x86_64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 874 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 875 | }, |
| 876 | x86: { |
| 877 | srcs: ["x86/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 878 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 879 | }, |
| 880 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | cc_prebuilt_library_shared { |
| 884 | name: "mynativelib", |
| 885 | prefer: false, |
| 886 | device_supported: false, |
| 887 | host_supported: true, |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 888 | sdk_version: "minimum", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 889 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 890 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 891 | arch: { |
| 892 | x86_64: { |
| 893 | srcs: ["x86_64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 894 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 895 | }, |
| 896 | x86: { |
| 897 | srcs: ["x86/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 898 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 899 | }, |
| 900 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | sdk_snapshot { |
| 904 | name: "mysdk@current", |
| 905 | device_supported: false, |
| 906 | host_supported: true, |
| 907 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 908 | } |
| 909 | `), |
| 910 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 911 | include/Test.h -> include/include/Test.h |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 912 | .intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 913 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 914 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 915 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 916 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 917 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 918 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 919 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 920 | `), |
| 921 | ) |
| 922 | } |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 923 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 924 | func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) { |
| 925 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 926 | SkipIfNotLinux(t) |
| 927 | |
| 928 | result := testSdkWithCc(t, ` |
| 929 | sdk { |
| 930 | name: "mysdk", |
| 931 | device_supported: false, |
| 932 | host_supported: true, |
| 933 | native_shared_libs: ["mynativelib"], |
| 934 | target: { |
| 935 | windows: { |
| 936 | enabled: true, |
| 937 | }, |
| 938 | }, |
| 939 | } |
| 940 | |
| 941 | cc_library_shared { |
| 942 | name: "mynativelib", |
| 943 | device_supported: false, |
| 944 | host_supported: true, |
| 945 | srcs: [ |
| 946 | "Test.cpp", |
| 947 | ], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 948 | stl: "none", |
| 949 | target: { |
| 950 | windows: { |
| 951 | enabled: true, |
| 952 | }, |
| 953 | }, |
| 954 | } |
| 955 | `) |
| 956 | |
| 957 | result.CheckSnapshot("mysdk", "", |
| 958 | checkAndroidBpContents(` |
| 959 | // This is auto-generated. DO NOT EDIT. |
| 960 | |
| 961 | cc_prebuilt_library_shared { |
| 962 | name: "mysdk_mynativelib@current", |
| 963 | sdk_member_name: "mynativelib", |
| 964 | device_supported: false, |
| 965 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 966 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 967 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 968 | target: { |
| 969 | linux_glibc_x86_64: { |
| 970 | srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], |
| 971 | }, |
| 972 | linux_glibc_x86: { |
| 973 | srcs: ["linux_glibc/x86/lib/mynativelib.so"], |
| 974 | }, |
| 975 | windows_x86_64: { |
| 976 | srcs: ["windows/x86_64/lib/mynativelib.dll"], |
| 977 | }, |
| 978 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | cc_prebuilt_library_shared { |
| 982 | name: "mynativelib", |
| 983 | prefer: false, |
| 984 | device_supported: false, |
| 985 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 986 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 987 | target: { |
| 988 | linux_glibc_x86_64: { |
| 989 | srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], |
| 990 | }, |
| 991 | linux_glibc_x86: { |
| 992 | srcs: ["linux_glibc/x86/lib/mynativelib.so"], |
| 993 | }, |
| 994 | windows_x86_64: { |
| 995 | srcs: ["windows/x86_64/lib/mynativelib.dll"], |
| 996 | }, |
| 997 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | sdk_snapshot { |
| 1001 | name: "mysdk@current", |
| 1002 | device_supported: false, |
| 1003 | host_supported: true, |
| 1004 | native_shared_libs: ["mysdk_mynativelib@current"], |
Paul Duffin | 6a7e953 | 2020-03-20 17:50:07 +0000 | [diff] [blame] | 1005 | target: { |
| 1006 | windows: { |
| 1007 | compile_multilib: "64", |
| 1008 | }, |
| 1009 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1010 | } |
| 1011 | `), |
| 1012 | checkAllCopyRules(` |
| 1013 | .intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so |
| 1014 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so |
| 1015 | .intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll |
| 1016 | `), |
| 1017 | ) |
| 1018 | } |
| 1019 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1020 | func TestSnapshotWithCcStaticLibrary(t *testing.T) { |
| 1021 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1022 | module_exports { |
| 1023 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1024 | native_static_libs: ["mynativelib"], |
| 1025 | } |
| 1026 | |
| 1027 | cc_library_static { |
| 1028 | name: "mynativelib", |
| 1029 | srcs: [ |
| 1030 | "Test.cpp", |
| 1031 | "aidl/foo/bar/Test.aidl", |
| 1032 | ], |
| 1033 | export_include_dirs: ["include"], |
| 1034 | aidl: { |
| 1035 | export_aidl_headers: true, |
| 1036 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1037 | stl: "none", |
| 1038 | } |
| 1039 | `) |
| 1040 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1041 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1042 | checkAndroidBpContents(` |
| 1043 | // This is auto-generated. DO NOT EDIT. |
| 1044 | |
| 1045 | cc_prebuilt_library_static { |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1046 | name: "myexports_mynativelib@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1047 | sdk_member_name: "mynativelib", |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 1048 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1049 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1050 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1051 | arch: { |
| 1052 | arm64: { |
| 1053 | srcs: ["arm64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1054 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1055 | }, |
| 1056 | arm: { |
| 1057 | srcs: ["arm/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1058 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1059 | }, |
| 1060 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1061 | } |
| 1062 | |
| 1063 | cc_prebuilt_library_static { |
| 1064 | name: "mynativelib", |
| 1065 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1066 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1067 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1068 | arch: { |
| 1069 | arm64: { |
| 1070 | srcs: ["arm64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1071 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1072 | }, |
| 1073 | arm: { |
| 1074 | srcs: ["arm/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1075 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1076 | }, |
| 1077 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1078 | } |
| 1079 | |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1080 | module_exports_snapshot { |
| 1081 | name: "myexports@current", |
| 1082 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1083 | } |
| 1084 | `), |
| 1085 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1086 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 1087 | .intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a |
| 1088 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1089 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1090 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 1091 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a |
| 1092 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1093 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1094 | .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 Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1095 | `), |
| 1096 | ) |
| 1097 | } |
| 1098 | |
| 1099 | func TestHostSnapshotWithCcStaticLibrary(t *testing.T) { |
| 1100 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1101 | SkipIfNotLinux(t) |
| 1102 | |
| 1103 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1104 | module_exports { |
| 1105 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1106 | device_supported: false, |
| 1107 | host_supported: true, |
| 1108 | native_static_libs: ["mynativelib"], |
| 1109 | } |
| 1110 | |
| 1111 | cc_library_static { |
| 1112 | name: "mynativelib", |
| 1113 | device_supported: false, |
| 1114 | host_supported: true, |
| 1115 | srcs: [ |
| 1116 | "Test.cpp", |
| 1117 | "aidl/foo/bar/Test.aidl", |
| 1118 | ], |
| 1119 | export_include_dirs: ["include"], |
| 1120 | aidl: { |
| 1121 | export_aidl_headers: true, |
| 1122 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1123 | stl: "none", |
| 1124 | } |
| 1125 | `) |
| 1126 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1127 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1128 | checkAndroidBpContents(` |
| 1129 | // This is auto-generated. DO NOT EDIT. |
| 1130 | |
| 1131 | cc_prebuilt_library_static { |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1132 | name: "myexports_mynativelib@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1133 | sdk_member_name: "mynativelib", |
| 1134 | device_supported: false, |
| 1135 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 1136 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1137 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1138 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1139 | arch: { |
| 1140 | x86_64: { |
| 1141 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1142 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1143 | }, |
| 1144 | x86: { |
| 1145 | srcs: ["x86/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1146 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1147 | }, |
| 1148 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
| 1151 | cc_prebuilt_library_static { |
| 1152 | name: "mynativelib", |
| 1153 | prefer: false, |
| 1154 | device_supported: false, |
| 1155 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1156 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1157 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1158 | arch: { |
| 1159 | x86_64: { |
| 1160 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1161 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1162 | }, |
| 1163 | x86: { |
| 1164 | srcs: ["x86/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1165 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1166 | }, |
| 1167 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1170 | module_exports_snapshot { |
| 1171 | name: "myexports@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1172 | device_supported: false, |
| 1173 | host_supported: true, |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1174 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1175 | } |
| 1176 | `), |
| 1177 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1178 | include/Test.h -> include/include/Test.h |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1179 | .intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1180 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1181 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1182 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 1183 | .intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1184 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1185 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1186 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 1187 | `), |
| 1188 | ) |
| 1189 | } |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1190 | |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1191 | func TestSnapshotWithCcLibrary(t *testing.T) { |
| 1192 | result := testSdkWithCc(t, ` |
| 1193 | module_exports { |
| 1194 | name: "myexports", |
| 1195 | native_libs: ["mynativelib"], |
| 1196 | } |
| 1197 | |
| 1198 | cc_library { |
| 1199 | name: "mynativelib", |
| 1200 | srcs: [ |
| 1201 | "Test.cpp", |
| 1202 | ], |
| 1203 | export_include_dirs: ["include"], |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1204 | stl: "none", |
| 1205 | } |
| 1206 | `) |
| 1207 | |
| 1208 | result.CheckSnapshot("myexports", "", |
| 1209 | checkAndroidBpContents(` |
| 1210 | // This is auto-generated. DO NOT EDIT. |
| 1211 | |
| 1212 | cc_prebuilt_library { |
| 1213 | name: "myexports_mynativelib@current", |
| 1214 | sdk_member_name: "mynativelib", |
| 1215 | installable: false, |
| 1216 | stl: "none", |
| 1217 | export_include_dirs: ["include/include"], |
| 1218 | arch: { |
| 1219 | arm64: { |
| 1220 | static: { |
| 1221 | srcs: ["arm64/lib/mynativelib.a"], |
| 1222 | }, |
| 1223 | shared: { |
| 1224 | srcs: ["arm64/lib/mynativelib.so"], |
| 1225 | }, |
| 1226 | }, |
| 1227 | arm: { |
| 1228 | static: { |
| 1229 | srcs: ["arm/lib/mynativelib.a"], |
| 1230 | }, |
| 1231 | shared: { |
| 1232 | srcs: ["arm/lib/mynativelib.so"], |
| 1233 | }, |
| 1234 | }, |
| 1235 | }, |
| 1236 | } |
| 1237 | |
| 1238 | cc_prebuilt_library { |
| 1239 | name: "mynativelib", |
| 1240 | prefer: false, |
| 1241 | stl: "none", |
| 1242 | export_include_dirs: ["include/include"], |
| 1243 | arch: { |
| 1244 | arm64: { |
| 1245 | static: { |
| 1246 | srcs: ["arm64/lib/mynativelib.a"], |
| 1247 | }, |
| 1248 | shared: { |
| 1249 | srcs: ["arm64/lib/mynativelib.so"], |
| 1250 | }, |
| 1251 | }, |
| 1252 | arm: { |
| 1253 | static: { |
| 1254 | srcs: ["arm/lib/mynativelib.a"], |
| 1255 | }, |
| 1256 | shared: { |
| 1257 | srcs: ["arm/lib/mynativelib.so"], |
| 1258 | }, |
| 1259 | }, |
| 1260 | }, |
| 1261 | } |
| 1262 | |
| 1263 | module_exports_snapshot { |
| 1264 | name: "myexports@current", |
| 1265 | native_libs: ["myexports_mynativelib@current"], |
| 1266 | } |
| 1267 | `), |
| 1268 | checkAllCopyRules(` |
| 1269 | include/Test.h -> include/include/Test.h |
| 1270 | .intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a |
| 1271 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
| 1272 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a |
| 1273 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`), |
| 1274 | ) |
| 1275 | } |
| 1276 | |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1277 | func TestHostSnapshotWithMultiLib64(t *testing.T) { |
| 1278 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1279 | SkipIfNotLinux(t) |
| 1280 | |
| 1281 | result := testSdkWithCc(t, ` |
| 1282 | module_exports { |
| 1283 | name: "myexports", |
| 1284 | device_supported: false, |
| 1285 | host_supported: true, |
| 1286 | target: { |
| 1287 | host: { |
| 1288 | compile_multilib: "64", |
| 1289 | }, |
| 1290 | }, |
| 1291 | native_static_libs: ["mynativelib"], |
| 1292 | } |
| 1293 | |
| 1294 | cc_library_static { |
| 1295 | name: "mynativelib", |
| 1296 | device_supported: false, |
| 1297 | host_supported: true, |
| 1298 | srcs: [ |
| 1299 | "Test.cpp", |
| 1300 | "aidl/foo/bar/Test.aidl", |
| 1301 | ], |
| 1302 | export_include_dirs: ["include"], |
| 1303 | aidl: { |
| 1304 | export_aidl_headers: true, |
| 1305 | }, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1306 | stl: "none", |
| 1307 | } |
| 1308 | `) |
| 1309 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1310 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1311 | checkAndroidBpContents(` |
| 1312 | // This is auto-generated. DO NOT EDIT. |
| 1313 | |
| 1314 | cc_prebuilt_library_static { |
| 1315 | name: "myexports_mynativelib@current", |
| 1316 | sdk_member_name: "mynativelib", |
| 1317 | device_supported: false, |
| 1318 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 1319 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1320 | stl: "none", |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1321 | export_include_dirs: ["include/include"], |
| 1322 | arch: { |
| 1323 | x86_64: { |
| 1324 | srcs: ["x86_64/lib/mynativelib.a"], |
| 1325 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
| 1326 | }, |
| 1327 | }, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1328 | } |
| 1329 | |
| 1330 | cc_prebuilt_library_static { |
| 1331 | name: "mynativelib", |
| 1332 | prefer: false, |
| 1333 | device_supported: false, |
| 1334 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1335 | stl: "none", |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1336 | export_include_dirs: ["include/include"], |
| 1337 | arch: { |
| 1338 | x86_64: { |
| 1339 | srcs: ["x86_64/lib/mynativelib.a"], |
| 1340 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
| 1341 | }, |
| 1342 | }, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1343 | } |
| 1344 | |
| 1345 | module_exports_snapshot { |
| 1346 | name: "myexports@current", |
| 1347 | device_supported: false, |
| 1348 | host_supported: true, |
Paul Duffin | 07ef3cb | 2020-03-11 18:17:42 +0000 | [diff] [blame] | 1349 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1350 | target: { |
Paul Duffin | 6a7e953 | 2020-03-20 17:50:07 +0000 | [diff] [blame] | 1351 | linux_glibc: { |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1352 | compile_multilib: "64", |
| 1353 | }, |
| 1354 | }, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1355 | }`), |
| 1356 | checkAllCopyRules(` |
| 1357 | include/Test.h -> include/include/Test.h |
| 1358 | .intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a |
| 1359 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1360 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1361 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 1362 | `), |
| 1363 | ) |
| 1364 | } |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1365 | |
| 1366 | func TestSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 1367 | result := testSdkWithCc(t, ` |
| 1368 | sdk { |
| 1369 | name: "mysdk", |
| 1370 | native_header_libs: ["mynativeheaders"], |
| 1371 | } |
| 1372 | |
| 1373 | cc_library_headers { |
| 1374 | name: "mynativeheaders", |
| 1375 | export_include_dirs: ["include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1376 | stl: "none", |
| 1377 | } |
| 1378 | `) |
| 1379 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1380 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1381 | checkAndroidBpContents(` |
| 1382 | // This is auto-generated. DO NOT EDIT. |
| 1383 | |
| 1384 | cc_prebuilt_library_headers { |
| 1385 | name: "mysdk_mynativeheaders@current", |
| 1386 | sdk_member_name: "mynativeheaders", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1387 | stl: "none", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1388 | export_include_dirs: ["include/include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1389 | } |
| 1390 | |
| 1391 | cc_prebuilt_library_headers { |
| 1392 | name: "mynativeheaders", |
| 1393 | prefer: false, |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1394 | stl: "none", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1395 | export_include_dirs: ["include/include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1396 | } |
| 1397 | |
| 1398 | sdk_snapshot { |
| 1399 | name: "mysdk@current", |
| 1400 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 1401 | } |
| 1402 | `), |
| 1403 | checkAllCopyRules(` |
| 1404 | include/Test.h -> include/include/Test.h |
| 1405 | `), |
| 1406 | ) |
| 1407 | } |
| 1408 | |
| 1409 | func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 1410 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1411 | SkipIfNotLinux(t) |
| 1412 | |
| 1413 | result := testSdkWithCc(t, ` |
| 1414 | sdk { |
| 1415 | name: "mysdk", |
| 1416 | device_supported: false, |
| 1417 | host_supported: true, |
| 1418 | native_header_libs: ["mynativeheaders"], |
| 1419 | } |
| 1420 | |
| 1421 | cc_library_headers { |
| 1422 | name: "mynativeheaders", |
| 1423 | device_supported: false, |
| 1424 | host_supported: true, |
| 1425 | export_include_dirs: ["include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1426 | stl: "none", |
| 1427 | } |
| 1428 | `) |
| 1429 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1430 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1431 | checkAndroidBpContents(` |
| 1432 | // This is auto-generated. DO NOT EDIT. |
| 1433 | |
| 1434 | cc_prebuilt_library_headers { |
| 1435 | name: "mysdk_mynativeheaders@current", |
| 1436 | sdk_member_name: "mynativeheaders", |
| 1437 | device_supported: false, |
| 1438 | host_supported: true, |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1439 | stl: "none", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1440 | export_include_dirs: ["include/include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1441 | } |
| 1442 | |
| 1443 | cc_prebuilt_library_headers { |
| 1444 | name: "mynativeheaders", |
| 1445 | prefer: false, |
| 1446 | device_supported: false, |
| 1447 | host_supported: true, |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1448 | stl: "none", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1449 | export_include_dirs: ["include/include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1450 | } |
| 1451 | |
| 1452 | sdk_snapshot { |
| 1453 | name: "mysdk@current", |
| 1454 | device_supported: false, |
| 1455 | host_supported: true, |
| 1456 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 1457 | } |
| 1458 | `), |
| 1459 | checkAllCopyRules(` |
| 1460 | include/Test.h -> include/include/Test.h |
| 1461 | `), |
| 1462 | ) |
| 1463 | } |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1464 | |
| 1465 | func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 1466 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1467 | SkipIfNotLinux(t) |
| 1468 | |
| 1469 | result := testSdkWithCc(t, ` |
| 1470 | sdk { |
| 1471 | name: "mysdk", |
| 1472 | host_supported: true, |
| 1473 | native_header_libs: ["mynativeheaders"], |
| 1474 | } |
| 1475 | |
| 1476 | cc_library_headers { |
| 1477 | name: "mynativeheaders", |
| 1478 | host_supported: true, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1479 | stl: "none", |
| 1480 | export_system_include_dirs: ["include"], |
| 1481 | target: { |
| 1482 | android: { |
| 1483 | export_include_dirs: ["include-android"], |
| 1484 | }, |
| 1485 | host: { |
| 1486 | export_include_dirs: ["include-host"], |
| 1487 | }, |
| 1488 | }, |
| 1489 | } |
| 1490 | `) |
| 1491 | |
| 1492 | result.CheckSnapshot("mysdk", "", |
| 1493 | checkAndroidBpContents(` |
| 1494 | // This is auto-generated. DO NOT EDIT. |
| 1495 | |
| 1496 | cc_prebuilt_library_headers { |
| 1497 | name: "mysdk_mynativeheaders@current", |
| 1498 | sdk_member_name: "mynativeheaders", |
| 1499 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1500 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1501 | export_system_include_dirs: ["include/include"], |
| 1502 | target: { |
| 1503 | android: { |
| 1504 | export_include_dirs: ["include/include-android"], |
| 1505 | }, |
| 1506 | linux_glibc: { |
| 1507 | export_include_dirs: ["include/include-host"], |
| 1508 | }, |
| 1509 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1510 | } |
| 1511 | |
| 1512 | cc_prebuilt_library_headers { |
| 1513 | name: "mynativeheaders", |
| 1514 | prefer: false, |
| 1515 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1516 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1517 | export_system_include_dirs: ["include/include"], |
| 1518 | target: { |
| 1519 | android: { |
| 1520 | export_include_dirs: ["include/include-android"], |
| 1521 | }, |
| 1522 | linux_glibc: { |
| 1523 | export_include_dirs: ["include/include-host"], |
| 1524 | }, |
| 1525 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1526 | } |
| 1527 | |
| 1528 | sdk_snapshot { |
| 1529 | name: "mysdk@current", |
| 1530 | host_supported: true, |
| 1531 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 1532 | } |
| 1533 | `), |
| 1534 | checkAllCopyRules(` |
| 1535 | include/Test.h -> include/include/Test.h |
| 1536 | include-android/AndroidTest.h -> include/include-android/AndroidTest.h |
| 1537 | include-host/HostTest.h -> include/include-host/HostTest.h |
| 1538 | `), |
| 1539 | ) |
| 1540 | } |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 1541 | |
| 1542 | func TestSystemSharedLibPropagation(t *testing.T) { |
Martin Stjernholm | 66a0694 | 2020-03-26 17:39:30 +0000 | [diff] [blame] | 1543 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1544 | SkipIfNotLinux(t) |
| 1545 | |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 1546 | result := testSdkWithCc(t, ` |
| 1547 | sdk { |
| 1548 | name: "mysdk", |
| 1549 | native_shared_libs: ["sslnil", "sslempty", "sslnonempty"], |
| 1550 | } |
| 1551 | |
| 1552 | cc_library { |
| 1553 | name: "sslnil", |
| 1554 | host_supported: true, |
| 1555 | } |
| 1556 | |
| 1557 | cc_library { |
| 1558 | name: "sslempty", |
| 1559 | system_shared_libs: [], |
| 1560 | } |
| 1561 | |
| 1562 | cc_library { |
| 1563 | name: "sslnonempty", |
| 1564 | system_shared_libs: ["sslnil"], |
| 1565 | } |
| 1566 | `) |
| 1567 | |
| 1568 | result.CheckSnapshot("mysdk", "", |
| 1569 | checkAndroidBpContents(` |
| 1570 | // This is auto-generated. DO NOT EDIT. |
| 1571 | |
| 1572 | cc_prebuilt_library_shared { |
| 1573 | name: "mysdk_sslnil@current", |
| 1574 | sdk_member_name: "sslnil", |
| 1575 | installable: false, |
| 1576 | arch: { |
| 1577 | arm64: { |
| 1578 | srcs: ["arm64/lib/sslnil.so"], |
| 1579 | }, |
| 1580 | arm: { |
| 1581 | srcs: ["arm/lib/sslnil.so"], |
| 1582 | }, |
| 1583 | }, |
| 1584 | } |
| 1585 | |
| 1586 | cc_prebuilt_library_shared { |
| 1587 | name: "sslnil", |
| 1588 | prefer: false, |
| 1589 | arch: { |
| 1590 | arm64: { |
| 1591 | srcs: ["arm64/lib/sslnil.so"], |
| 1592 | }, |
| 1593 | arm: { |
| 1594 | srcs: ["arm/lib/sslnil.so"], |
| 1595 | }, |
| 1596 | }, |
| 1597 | } |
| 1598 | |
| 1599 | cc_prebuilt_library_shared { |
| 1600 | name: "mysdk_sslempty@current", |
| 1601 | sdk_member_name: "sslempty", |
| 1602 | installable: false, |
| 1603 | system_shared_libs: [], |
| 1604 | arch: { |
| 1605 | arm64: { |
| 1606 | srcs: ["arm64/lib/sslempty.so"], |
| 1607 | }, |
| 1608 | arm: { |
| 1609 | srcs: ["arm/lib/sslempty.so"], |
| 1610 | }, |
| 1611 | }, |
| 1612 | } |
| 1613 | |
| 1614 | cc_prebuilt_library_shared { |
| 1615 | name: "sslempty", |
| 1616 | prefer: false, |
| 1617 | system_shared_libs: [], |
| 1618 | arch: { |
| 1619 | arm64: { |
| 1620 | srcs: ["arm64/lib/sslempty.so"], |
| 1621 | }, |
| 1622 | arm: { |
| 1623 | srcs: ["arm/lib/sslempty.so"], |
| 1624 | }, |
| 1625 | }, |
| 1626 | } |
| 1627 | |
| 1628 | cc_prebuilt_library_shared { |
| 1629 | name: "mysdk_sslnonempty@current", |
| 1630 | sdk_member_name: "sslnonempty", |
| 1631 | installable: false, |
| 1632 | system_shared_libs: ["mysdk_sslnil@current"], |
| 1633 | arch: { |
| 1634 | arm64: { |
| 1635 | srcs: ["arm64/lib/sslnonempty.so"], |
| 1636 | }, |
| 1637 | arm: { |
| 1638 | srcs: ["arm/lib/sslnonempty.so"], |
| 1639 | }, |
| 1640 | }, |
| 1641 | } |
| 1642 | |
| 1643 | cc_prebuilt_library_shared { |
| 1644 | name: "sslnonempty", |
| 1645 | prefer: false, |
| 1646 | system_shared_libs: ["sslnil"], |
| 1647 | arch: { |
| 1648 | arm64: { |
| 1649 | srcs: ["arm64/lib/sslnonempty.so"], |
| 1650 | }, |
| 1651 | arm: { |
| 1652 | srcs: ["arm/lib/sslnonempty.so"], |
| 1653 | }, |
| 1654 | }, |
| 1655 | } |
| 1656 | |
| 1657 | sdk_snapshot { |
| 1658 | name: "mysdk@current", |
| 1659 | native_shared_libs: [ |
| 1660 | "mysdk_sslnil@current", |
| 1661 | "mysdk_sslempty@current", |
| 1662 | "mysdk_sslnonempty@current", |
| 1663 | ], |
| 1664 | } |
| 1665 | `)) |
| 1666 | |
| 1667 | result = testSdkWithCc(t, ` |
| 1668 | sdk { |
| 1669 | name: "mysdk", |
| 1670 | host_supported: true, |
| 1671 | native_shared_libs: ["sslvariants"], |
| 1672 | } |
| 1673 | |
| 1674 | cc_library { |
| 1675 | name: "sslvariants", |
| 1676 | host_supported: true, |
| 1677 | target: { |
| 1678 | android: { |
| 1679 | system_shared_libs: [], |
| 1680 | }, |
| 1681 | }, |
| 1682 | } |
| 1683 | `) |
| 1684 | |
| 1685 | result.CheckSnapshot("mysdk", "", |
| 1686 | checkAndroidBpContents(` |
| 1687 | // This is auto-generated. DO NOT EDIT. |
| 1688 | |
| 1689 | cc_prebuilt_library_shared { |
| 1690 | name: "mysdk_sslvariants@current", |
| 1691 | sdk_member_name: "sslvariants", |
| 1692 | host_supported: true, |
| 1693 | installable: false, |
| 1694 | target: { |
| 1695 | android: { |
| 1696 | system_shared_libs: [], |
| 1697 | }, |
| 1698 | android_arm64: { |
| 1699 | srcs: ["android/arm64/lib/sslvariants.so"], |
| 1700 | }, |
| 1701 | android_arm: { |
| 1702 | srcs: ["android/arm/lib/sslvariants.so"], |
| 1703 | }, |
| 1704 | linux_glibc_x86_64: { |
| 1705 | srcs: ["linux_glibc/x86_64/lib/sslvariants.so"], |
| 1706 | }, |
| 1707 | linux_glibc_x86: { |
| 1708 | srcs: ["linux_glibc/x86/lib/sslvariants.so"], |
| 1709 | }, |
| 1710 | }, |
| 1711 | } |
| 1712 | |
| 1713 | cc_prebuilt_library_shared { |
| 1714 | name: "sslvariants", |
| 1715 | prefer: false, |
| 1716 | host_supported: true, |
| 1717 | target: { |
| 1718 | android: { |
| 1719 | system_shared_libs: [], |
| 1720 | }, |
| 1721 | android_arm64: { |
| 1722 | srcs: ["android/arm64/lib/sslvariants.so"], |
| 1723 | }, |
| 1724 | android_arm: { |
| 1725 | srcs: ["android/arm/lib/sslvariants.so"], |
| 1726 | }, |
| 1727 | linux_glibc_x86_64: { |
| 1728 | srcs: ["linux_glibc/x86_64/lib/sslvariants.so"], |
| 1729 | }, |
| 1730 | linux_glibc_x86: { |
| 1731 | srcs: ["linux_glibc/x86/lib/sslvariants.so"], |
| 1732 | }, |
| 1733 | }, |
| 1734 | } |
| 1735 | |
| 1736 | sdk_snapshot { |
| 1737 | name: "mysdk@current", |
| 1738 | host_supported: true, |
| 1739 | native_shared_libs: ["mysdk_sslvariants@current"], |
| 1740 | } |
| 1741 | `)) |
| 1742 | } |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 1743 | |
| 1744 | func TestStubsLibrary(t *testing.T) { |
| 1745 | result := testSdkWithCc(t, ` |
| 1746 | sdk { |
| 1747 | name: "mysdk", |
| 1748 | native_shared_libs: ["stubslib"], |
| 1749 | } |
| 1750 | |
| 1751 | cc_library { |
| 1752 | name: "stubslib", |
| 1753 | stubs: { |
| 1754 | symbol_file: "some/where/stubslib.map.txt", |
| 1755 | versions: ["1", "2", "3"], |
| 1756 | }, |
| 1757 | } |
| 1758 | `) |
| 1759 | |
| 1760 | result.CheckSnapshot("mysdk", "", |
| 1761 | checkAndroidBpContents(` |
| 1762 | // This is auto-generated. DO NOT EDIT. |
| 1763 | |
| 1764 | cc_prebuilt_library_shared { |
| 1765 | name: "mysdk_stubslib@current", |
| 1766 | sdk_member_name: "stubslib", |
| 1767 | installable: false, |
| 1768 | stubs: { |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 1769 | versions: ["3"], |
| 1770 | }, |
| 1771 | arch: { |
| 1772 | arm64: { |
| 1773 | srcs: ["arm64/lib/stubslib.so"], |
| 1774 | }, |
| 1775 | arm: { |
| 1776 | srcs: ["arm/lib/stubslib.so"], |
| 1777 | }, |
| 1778 | }, |
| 1779 | } |
| 1780 | |
| 1781 | cc_prebuilt_library_shared { |
| 1782 | name: "stubslib", |
| 1783 | prefer: false, |
| 1784 | stubs: { |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 1785 | versions: ["3"], |
| 1786 | }, |
| 1787 | arch: { |
| 1788 | arm64: { |
| 1789 | srcs: ["arm64/lib/stubslib.so"], |
| 1790 | }, |
| 1791 | arm: { |
| 1792 | srcs: ["arm/lib/stubslib.so"], |
| 1793 | }, |
| 1794 | }, |
| 1795 | } |
| 1796 | |
| 1797 | sdk_snapshot { |
| 1798 | name: "mysdk@current", |
| 1799 | native_shared_libs: ["mysdk_stubslib@current"], |
| 1800 | } |
| 1801 | `)) |
| 1802 | } |