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, |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 35 | } |
| 36 | return testSdkWithFs(t, bp, fs) |
| 37 | } |
| 38 | |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 39 | // Contains tests for SDK members provided by the cc package. |
| 40 | |
| 41 | func TestSdkIsCompileMultilibBoth(t *testing.T) { |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 42 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 43 | sdk { |
| 44 | name: "mysdk", |
| 45 | native_shared_libs: ["sdkmember"], |
| 46 | } |
| 47 | |
| 48 | cc_library_shared { |
| 49 | name: "sdkmember", |
| 50 | srcs: ["Test.cpp"], |
| 51 | system_shared_libs: [], |
| 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", |
| 181 | system_shared_libs: [], |
| 182 | stl: "none", |
| 183 | } |
| 184 | |
| 185 | cc_library_host_static { |
| 186 | name: "sdkstatic", |
| 187 | system_shared_libs: [], |
| 188 | stl: "none", |
| 189 | } |
| 190 | `) |
| 191 | } |
| 192 | |
| 193 | // Make sure the sdk can use cc libraries static/shared and both. |
| 194 | func TestSdkWithCc(t *testing.T) { |
| 195 | testSdkWithCc(t, ` |
| 196 | sdk { |
| 197 | name: "mysdk", |
| 198 | native_shared_libs: ["sdkshared", "sdkboth1"], |
| 199 | native_static_libs: ["sdkstatic", "sdkboth2"], |
| 200 | } |
| 201 | |
| 202 | cc_library_shared { |
| 203 | name: "sdkshared", |
| 204 | system_shared_libs: [], |
| 205 | stl: "none", |
| 206 | } |
| 207 | |
| 208 | cc_library_static { |
| 209 | name: "sdkstatic", |
| 210 | system_shared_libs: [], |
| 211 | stl: "none", |
| 212 | } |
| 213 | |
| 214 | cc_library { |
| 215 | name: "sdkboth1", |
| 216 | system_shared_libs: [], |
| 217 | stl: "none", |
| 218 | } |
| 219 | |
| 220 | cc_library { |
| 221 | name: "sdkboth2", |
| 222 | system_shared_libs: [], |
| 223 | stl: "none", |
| 224 | } |
| 225 | `) |
| 226 | } |
| 227 | |
Paul Duffin | c62a510 | 2019-12-11 18:34:15 +0000 | [diff] [blame] | 228 | func TestSnapshotWithCcDuplicateHeaders(t *testing.T) { |
| 229 | result := testSdkWithCc(t, ` |
| 230 | sdk { |
| 231 | name: "mysdk", |
| 232 | native_shared_libs: ["mynativelib1", "mynativelib2"], |
| 233 | } |
| 234 | |
| 235 | cc_library_shared { |
| 236 | name: "mynativelib1", |
| 237 | srcs: [ |
| 238 | "Test.cpp", |
| 239 | ], |
| 240 | export_include_dirs: ["include"], |
| 241 | system_shared_libs: [], |
| 242 | stl: "none", |
| 243 | } |
| 244 | |
| 245 | cc_library_shared { |
| 246 | name: "mynativelib2", |
| 247 | srcs: [ |
| 248 | "Test.cpp", |
| 249 | ], |
| 250 | export_include_dirs: ["include"], |
| 251 | system_shared_libs: [], |
| 252 | stl: "none", |
| 253 | } |
| 254 | `) |
| 255 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 256 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | c62a510 | 2019-12-11 18:34:15 +0000 | [diff] [blame] | 257 | checkAllCopyRules(` |
| 258 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 259 | .intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so |
| 260 | .intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so |
| 261 | .intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so |
| 262 | .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] | 263 | `), |
| 264 | ) |
| 265 | } |
| 266 | |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 267 | // Verify that when the shared library has some common and some arch specific properties that the generated |
| 268 | // snapshot is optimized properly. |
| 269 | func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) { |
| 270 | result := testSdkWithCc(t, ` |
| 271 | sdk { |
| 272 | name: "mysdk", |
| 273 | native_shared_libs: ["mynativelib"], |
| 274 | } |
| 275 | |
| 276 | cc_library_shared { |
| 277 | name: "mynativelib", |
| 278 | srcs: [ |
| 279 | "Test.cpp", |
| 280 | "aidl/foo/bar/Test.aidl", |
| 281 | ], |
| 282 | export_include_dirs: ["include"], |
| 283 | arch: { |
| 284 | arm64: { |
| 285 | export_system_include_dirs: ["arm64/include"], |
| 286 | }, |
| 287 | }, |
| 288 | system_shared_libs: [], |
| 289 | stl: "none", |
| 290 | } |
| 291 | `) |
| 292 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 293 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 294 | checkAndroidBpContents(` |
| 295 | // This is auto-generated. DO NOT EDIT. |
| 296 | |
| 297 | cc_prebuilt_library_shared { |
| 298 | name: "mysdk_mynativelib@current", |
| 299 | sdk_member_name: "mynativelib", |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 300 | installable: false, |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 301 | export_include_dirs: ["include/include"], |
| 302 | arch: { |
| 303 | arm64: { |
| 304 | srcs: ["arm64/lib/mynativelib.so"], |
| 305 | export_system_include_dirs: ["arm64/include/arm64/include"], |
| 306 | }, |
| 307 | arm: { |
| 308 | srcs: ["arm/lib/mynativelib.so"], |
| 309 | }, |
| 310 | }, |
| 311 | stl: "none", |
| 312 | system_shared_libs: [], |
| 313 | } |
| 314 | |
| 315 | cc_prebuilt_library_shared { |
| 316 | name: "mynativelib", |
| 317 | prefer: false, |
| 318 | export_include_dirs: ["include/include"], |
| 319 | arch: { |
| 320 | arm64: { |
| 321 | srcs: ["arm64/lib/mynativelib.so"], |
| 322 | export_system_include_dirs: ["arm64/include/arm64/include"], |
| 323 | }, |
| 324 | arm: { |
| 325 | srcs: ["arm/lib/mynativelib.so"], |
| 326 | }, |
| 327 | }, |
| 328 | stl: "none", |
| 329 | system_shared_libs: [], |
| 330 | } |
| 331 | |
| 332 | sdk_snapshot { |
| 333 | name: "mysdk@current", |
| 334 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 335 | } |
| 336 | `), |
| 337 | checkAllCopyRules(` |
| 338 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 339 | .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] | 340 | arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 341 | .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] | 342 | ) |
| 343 | } |
| 344 | |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 345 | func TestSnapshotWithCcBinary(t *testing.T) { |
| 346 | result := testSdkWithCc(t, ` |
| 347 | module_exports { |
| 348 | name: "mymodule_exports", |
| 349 | native_binaries: ["mynativebinary"], |
| 350 | } |
| 351 | |
| 352 | cc_binary { |
| 353 | name: "mynativebinary", |
| 354 | srcs: [ |
| 355 | "Test.cpp", |
| 356 | ], |
| 357 | compile_multilib: "both", |
| 358 | system_shared_libs: [], |
| 359 | stl: "none", |
| 360 | } |
| 361 | `) |
| 362 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 363 | result.CheckSnapshot("mymodule_exports", "", |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 364 | checkAndroidBpContents(` |
| 365 | // This is auto-generated. DO NOT EDIT. |
| 366 | |
| 367 | cc_prebuilt_binary { |
| 368 | name: "mymodule_exports_mynativebinary@current", |
| 369 | sdk_member_name: "mynativebinary", |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 370 | installable: false, |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 371 | compile_multilib: "both", |
| 372 | arch: { |
| 373 | arm64: { |
| 374 | srcs: ["arm64/bin/mynativebinary"], |
| 375 | }, |
| 376 | arm: { |
| 377 | srcs: ["arm/bin/mynativebinary"], |
| 378 | }, |
| 379 | }, |
| 380 | } |
| 381 | |
| 382 | cc_prebuilt_binary { |
| 383 | name: "mynativebinary", |
| 384 | prefer: false, |
| 385 | compile_multilib: "both", |
| 386 | arch: { |
| 387 | arm64: { |
| 388 | srcs: ["arm64/bin/mynativebinary"], |
| 389 | }, |
| 390 | arm: { |
| 391 | srcs: ["arm/bin/mynativebinary"], |
| 392 | }, |
| 393 | }, |
| 394 | } |
| 395 | |
| 396 | module_exports_snapshot { |
| 397 | name: "mymodule_exports@current", |
| 398 | native_binaries: ["mymodule_exports_mynativebinary@current"], |
| 399 | } |
| 400 | `), |
| 401 | checkAllCopyRules(` |
| 402 | .intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary |
| 403 | .intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary |
| 404 | `), |
| 405 | ) |
| 406 | } |
| 407 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 408 | func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) { |
| 409 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 410 | SkipIfNotLinux(t) |
| 411 | |
| 412 | result := testSdkWithCc(t, ` |
| 413 | module_exports { |
| 414 | name: "myexports", |
| 415 | device_supported: false, |
| 416 | host_supported: true, |
| 417 | native_binaries: ["mynativebinary"], |
| 418 | target: { |
| 419 | windows: { |
| 420 | enabled: true, |
| 421 | }, |
| 422 | }, |
| 423 | } |
| 424 | |
| 425 | cc_binary { |
| 426 | name: "mynativebinary", |
| 427 | device_supported: false, |
| 428 | host_supported: true, |
| 429 | srcs: [ |
| 430 | "Test.cpp", |
| 431 | ], |
| 432 | compile_multilib: "both", |
| 433 | system_shared_libs: [], |
| 434 | stl: "none", |
| 435 | target: { |
| 436 | windows: { |
| 437 | enabled: true, |
| 438 | }, |
| 439 | }, |
| 440 | } |
| 441 | `) |
| 442 | |
| 443 | result.CheckSnapshot("myexports", "", |
| 444 | checkAndroidBpContents(` |
| 445 | // This is auto-generated. DO NOT EDIT. |
| 446 | |
| 447 | cc_prebuilt_binary { |
| 448 | name: "myexports_mynativebinary@current", |
| 449 | sdk_member_name: "mynativebinary", |
| 450 | device_supported: false, |
| 451 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 452 | installable: false, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 453 | target: { |
| 454 | linux_glibc: { |
| 455 | compile_multilib: "both", |
| 456 | }, |
| 457 | linux_glibc_x86_64: { |
| 458 | srcs: ["linux_glibc/x86_64/bin/mynativebinary"], |
| 459 | }, |
| 460 | linux_glibc_x86: { |
| 461 | srcs: ["linux_glibc/x86/bin/mynativebinary"], |
| 462 | }, |
| 463 | windows: { |
| 464 | compile_multilib: "64", |
| 465 | }, |
| 466 | windows_x86_64: { |
| 467 | srcs: ["windows/x86_64/bin/mynativebinary.exe"], |
| 468 | }, |
| 469 | }, |
| 470 | } |
| 471 | |
| 472 | cc_prebuilt_binary { |
| 473 | name: "mynativebinary", |
| 474 | prefer: false, |
| 475 | device_supported: false, |
| 476 | host_supported: true, |
| 477 | target: { |
| 478 | linux_glibc: { |
| 479 | compile_multilib: "both", |
| 480 | }, |
| 481 | linux_glibc_x86_64: { |
| 482 | srcs: ["linux_glibc/x86_64/bin/mynativebinary"], |
| 483 | }, |
| 484 | linux_glibc_x86: { |
| 485 | srcs: ["linux_glibc/x86/bin/mynativebinary"], |
| 486 | }, |
| 487 | windows: { |
| 488 | compile_multilib: "64", |
| 489 | }, |
| 490 | windows_x86_64: { |
| 491 | srcs: ["windows/x86_64/bin/mynativebinary.exe"], |
| 492 | }, |
| 493 | }, |
| 494 | } |
| 495 | |
| 496 | module_exports_snapshot { |
| 497 | name: "myexports@current", |
| 498 | device_supported: false, |
| 499 | host_supported: true, |
| 500 | native_binaries: ["myexports_mynativebinary@current"], |
| 501 | } |
| 502 | `), |
| 503 | checkAllCopyRules(` |
| 504 | .intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary |
| 505 | .intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary |
| 506 | .intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe |
| 507 | `), |
| 508 | ) |
| 509 | } |
| 510 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 511 | func TestSnapshotWithCcSharedLibrary(t *testing.T) { |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 512 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 513 | sdk { |
| 514 | name: "mysdk", |
| 515 | native_shared_libs: ["mynativelib"], |
| 516 | } |
| 517 | |
| 518 | cc_library_shared { |
| 519 | name: "mynativelib", |
| 520 | srcs: [ |
| 521 | "Test.cpp", |
| 522 | "aidl/foo/bar/Test.aidl", |
| 523 | ], |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 524 | apex_available: ["apex1", "apex2"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 525 | export_include_dirs: ["include"], |
| 526 | aidl: { |
| 527 | export_aidl_headers: true, |
| 528 | }, |
| 529 | system_shared_libs: [], |
| 530 | stl: "none", |
| 531 | } |
| 532 | `) |
| 533 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 534 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 535 | checkAndroidBpContents(` |
| 536 | // This is auto-generated. DO NOT EDIT. |
| 537 | |
| 538 | cc_prebuilt_library_shared { |
| 539 | name: "mysdk_mynativelib@current", |
| 540 | sdk_member_name: "mynativelib", |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 541 | apex_available: [ |
| 542 | "apex1", |
| 543 | "apex2", |
| 544 | ], |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 545 | installable: false, |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 546 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 547 | arch: { |
| 548 | arm64: { |
| 549 | srcs: ["arm64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 550 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 551 | }, |
| 552 | arm: { |
| 553 | srcs: ["arm/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 554 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 555 | }, |
| 556 | }, |
| 557 | stl: "none", |
| 558 | system_shared_libs: [], |
| 559 | } |
| 560 | |
| 561 | cc_prebuilt_library_shared { |
| 562 | name: "mynativelib", |
| 563 | prefer: false, |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 564 | apex_available: [ |
| 565 | "apex1", |
| 566 | "apex2", |
| 567 | ], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 568 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 569 | arch: { |
| 570 | arm64: { |
| 571 | srcs: ["arm64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 572 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 573 | }, |
| 574 | arm: { |
| 575 | srcs: ["arm/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 576 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 577 | }, |
| 578 | }, |
| 579 | stl: "none", |
| 580 | system_shared_libs: [], |
| 581 | } |
| 582 | |
| 583 | sdk_snapshot { |
| 584 | name: "mysdk@current", |
| 585 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 586 | } |
| 587 | `), |
| 588 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 589 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 590 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
| 591 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 592 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 593 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 594 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so |
| 595 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 596 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 597 | .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] | 598 | `), |
| 599 | ) |
| 600 | } |
| 601 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 602 | func TestHostSnapshotWithCcSharedLibrary(t *testing.T) { |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 603 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 604 | SkipIfNotLinux(t) |
| 605 | |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 606 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 607 | sdk { |
| 608 | name: "mysdk", |
| 609 | device_supported: false, |
| 610 | host_supported: true, |
| 611 | native_shared_libs: ["mynativelib"], |
| 612 | } |
| 613 | |
| 614 | cc_library_shared { |
| 615 | name: "mynativelib", |
| 616 | device_supported: false, |
| 617 | host_supported: true, |
| 618 | srcs: [ |
| 619 | "Test.cpp", |
| 620 | "aidl/foo/bar/Test.aidl", |
| 621 | ], |
| 622 | export_include_dirs: ["include"], |
| 623 | aidl: { |
| 624 | export_aidl_headers: true, |
| 625 | }, |
| 626 | system_shared_libs: [], |
| 627 | stl: "none", |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 628 | sdk_version: "minimum", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 629 | } |
| 630 | `) |
| 631 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 632 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 633 | checkAndroidBpContents(` |
| 634 | // This is auto-generated. DO NOT EDIT. |
| 635 | |
| 636 | cc_prebuilt_library_shared { |
| 637 | name: "mysdk_mynativelib@current", |
| 638 | sdk_member_name: "mynativelib", |
| 639 | device_supported: false, |
| 640 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 641 | installable: false, |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 642 | sdk_version: "minimum", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 643 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 644 | arch: { |
| 645 | x86_64: { |
| 646 | srcs: ["x86_64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 647 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 648 | }, |
| 649 | x86: { |
| 650 | srcs: ["x86/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 651 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 652 | }, |
| 653 | }, |
| 654 | stl: "none", |
| 655 | system_shared_libs: [], |
| 656 | } |
| 657 | |
| 658 | cc_prebuilt_library_shared { |
| 659 | name: "mynativelib", |
| 660 | prefer: false, |
| 661 | device_supported: false, |
| 662 | host_supported: true, |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 663 | sdk_version: "minimum", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 664 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 665 | arch: { |
| 666 | x86_64: { |
| 667 | srcs: ["x86_64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 668 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 669 | }, |
| 670 | x86: { |
| 671 | srcs: ["x86/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 672 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 673 | }, |
| 674 | }, |
| 675 | stl: "none", |
| 676 | system_shared_libs: [], |
| 677 | } |
| 678 | |
| 679 | sdk_snapshot { |
| 680 | name: "mysdk@current", |
| 681 | device_supported: false, |
| 682 | host_supported: true, |
| 683 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 684 | } |
| 685 | `), |
| 686 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 687 | include/Test.h -> include/include/Test.h |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 688 | .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] | 689 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 690 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 691 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 692 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 693 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 694 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 695 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 696 | `), |
| 697 | ) |
| 698 | } |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 699 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 700 | func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) { |
| 701 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 702 | SkipIfNotLinux(t) |
| 703 | |
| 704 | result := testSdkWithCc(t, ` |
| 705 | sdk { |
| 706 | name: "mysdk", |
| 707 | device_supported: false, |
| 708 | host_supported: true, |
| 709 | native_shared_libs: ["mynativelib"], |
| 710 | target: { |
| 711 | windows: { |
| 712 | enabled: true, |
| 713 | }, |
| 714 | }, |
| 715 | } |
| 716 | |
| 717 | cc_library_shared { |
| 718 | name: "mynativelib", |
| 719 | device_supported: false, |
| 720 | host_supported: true, |
| 721 | srcs: [ |
| 722 | "Test.cpp", |
| 723 | ], |
| 724 | system_shared_libs: [], |
| 725 | stl: "none", |
| 726 | target: { |
| 727 | windows: { |
| 728 | enabled: true, |
| 729 | }, |
| 730 | }, |
| 731 | } |
| 732 | `) |
| 733 | |
| 734 | result.CheckSnapshot("mysdk", "", |
| 735 | checkAndroidBpContents(` |
| 736 | // This is auto-generated. DO NOT EDIT. |
| 737 | |
| 738 | cc_prebuilt_library_shared { |
| 739 | name: "mysdk_mynativelib@current", |
| 740 | sdk_member_name: "mynativelib", |
| 741 | device_supported: false, |
| 742 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 743 | installable: false, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 744 | target: { |
| 745 | linux_glibc_x86_64: { |
| 746 | srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], |
| 747 | }, |
| 748 | linux_glibc_x86: { |
| 749 | srcs: ["linux_glibc/x86/lib/mynativelib.so"], |
| 750 | }, |
| 751 | windows_x86_64: { |
| 752 | srcs: ["windows/x86_64/lib/mynativelib.dll"], |
| 753 | }, |
| 754 | }, |
| 755 | stl: "none", |
| 756 | system_shared_libs: [], |
| 757 | } |
| 758 | |
| 759 | cc_prebuilt_library_shared { |
| 760 | name: "mynativelib", |
| 761 | prefer: false, |
| 762 | device_supported: false, |
| 763 | host_supported: true, |
| 764 | target: { |
| 765 | linux_glibc_x86_64: { |
| 766 | srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], |
| 767 | }, |
| 768 | linux_glibc_x86: { |
| 769 | srcs: ["linux_glibc/x86/lib/mynativelib.so"], |
| 770 | }, |
| 771 | windows_x86_64: { |
| 772 | srcs: ["windows/x86_64/lib/mynativelib.dll"], |
| 773 | }, |
| 774 | }, |
| 775 | stl: "none", |
| 776 | system_shared_libs: [], |
| 777 | } |
| 778 | |
| 779 | sdk_snapshot { |
| 780 | name: "mysdk@current", |
| 781 | device_supported: false, |
| 782 | host_supported: true, |
| 783 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 784 | } |
| 785 | `), |
| 786 | checkAllCopyRules(` |
| 787 | .intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so |
| 788 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so |
| 789 | .intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll |
| 790 | `), |
| 791 | ) |
| 792 | } |
| 793 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 794 | func TestSnapshotWithCcStaticLibrary(t *testing.T) { |
| 795 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 796 | module_exports { |
| 797 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 798 | native_static_libs: ["mynativelib"], |
| 799 | } |
| 800 | |
| 801 | cc_library_static { |
| 802 | name: "mynativelib", |
| 803 | srcs: [ |
| 804 | "Test.cpp", |
| 805 | "aidl/foo/bar/Test.aidl", |
| 806 | ], |
| 807 | export_include_dirs: ["include"], |
| 808 | aidl: { |
| 809 | export_aidl_headers: true, |
| 810 | }, |
| 811 | system_shared_libs: [], |
| 812 | stl: "none", |
| 813 | } |
| 814 | `) |
| 815 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 816 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 817 | checkAndroidBpContents(` |
| 818 | // This is auto-generated. DO NOT EDIT. |
| 819 | |
| 820 | cc_prebuilt_library_static { |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 821 | name: "myexports_mynativelib@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 822 | sdk_member_name: "mynativelib", |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 823 | installable: false, |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 824 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 825 | arch: { |
| 826 | arm64: { |
| 827 | srcs: ["arm64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 828 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 829 | }, |
| 830 | arm: { |
| 831 | srcs: ["arm/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 832 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 833 | }, |
| 834 | }, |
| 835 | stl: "none", |
| 836 | system_shared_libs: [], |
| 837 | } |
| 838 | |
| 839 | cc_prebuilt_library_static { |
| 840 | name: "mynativelib", |
| 841 | prefer: false, |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 842 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 843 | arch: { |
| 844 | arm64: { |
| 845 | srcs: ["arm64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 846 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 847 | }, |
| 848 | arm: { |
| 849 | srcs: ["arm/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 850 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 851 | }, |
| 852 | }, |
| 853 | stl: "none", |
| 854 | system_shared_libs: [], |
| 855 | } |
| 856 | |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 857 | module_exports_snapshot { |
| 858 | name: "myexports@current", |
| 859 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 860 | } |
| 861 | `), |
| 862 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 863 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 864 | .intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a |
| 865 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 866 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 867 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 868 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a |
| 869 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 870 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 871 | .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] | 872 | `), |
| 873 | ) |
| 874 | } |
| 875 | |
| 876 | func TestHostSnapshotWithCcStaticLibrary(t *testing.T) { |
| 877 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 878 | SkipIfNotLinux(t) |
| 879 | |
| 880 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 881 | module_exports { |
| 882 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 883 | device_supported: false, |
| 884 | host_supported: true, |
| 885 | native_static_libs: ["mynativelib"], |
| 886 | } |
| 887 | |
| 888 | cc_library_static { |
| 889 | name: "mynativelib", |
| 890 | device_supported: false, |
| 891 | host_supported: true, |
| 892 | srcs: [ |
| 893 | "Test.cpp", |
| 894 | "aidl/foo/bar/Test.aidl", |
| 895 | ], |
| 896 | export_include_dirs: ["include"], |
| 897 | aidl: { |
| 898 | export_aidl_headers: true, |
| 899 | }, |
| 900 | system_shared_libs: [], |
| 901 | stl: "none", |
| 902 | } |
| 903 | `) |
| 904 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 905 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 906 | checkAndroidBpContents(` |
| 907 | // This is auto-generated. DO NOT EDIT. |
| 908 | |
| 909 | cc_prebuilt_library_static { |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 910 | name: "myexports_mynativelib@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 911 | sdk_member_name: "mynativelib", |
| 912 | device_supported: false, |
| 913 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 914 | installable: false, |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 915 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 916 | arch: { |
| 917 | x86_64: { |
| 918 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 919 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 920 | }, |
| 921 | x86: { |
| 922 | srcs: ["x86/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 923 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 924 | }, |
| 925 | }, |
| 926 | stl: "none", |
| 927 | system_shared_libs: [], |
| 928 | } |
| 929 | |
| 930 | cc_prebuilt_library_static { |
| 931 | name: "mynativelib", |
| 932 | prefer: false, |
| 933 | device_supported: false, |
| 934 | host_supported: true, |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 935 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 936 | arch: { |
| 937 | x86_64: { |
| 938 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 939 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 940 | }, |
| 941 | x86: { |
| 942 | srcs: ["x86/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 943 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 944 | }, |
| 945 | }, |
| 946 | stl: "none", |
| 947 | system_shared_libs: [], |
| 948 | } |
| 949 | |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 950 | module_exports_snapshot { |
| 951 | name: "myexports@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 952 | device_supported: false, |
| 953 | host_supported: true, |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 954 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 955 | } |
| 956 | `), |
| 957 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 958 | include/Test.h -> include/include/Test.h |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 959 | .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] | 960 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 961 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 962 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 963 | .intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 964 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 965 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 966 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 967 | `), |
| 968 | ) |
| 969 | } |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 970 | |
| 971 | func TestHostSnapshotWithMultiLib64(t *testing.T) { |
| 972 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 973 | SkipIfNotLinux(t) |
| 974 | |
| 975 | result := testSdkWithCc(t, ` |
| 976 | module_exports { |
| 977 | name: "myexports", |
| 978 | device_supported: false, |
| 979 | host_supported: true, |
| 980 | target: { |
| 981 | host: { |
| 982 | compile_multilib: "64", |
| 983 | }, |
| 984 | }, |
| 985 | native_static_libs: ["mynativelib"], |
| 986 | } |
| 987 | |
| 988 | cc_library_static { |
| 989 | name: "mynativelib", |
| 990 | device_supported: false, |
| 991 | host_supported: true, |
| 992 | srcs: [ |
| 993 | "Test.cpp", |
| 994 | "aidl/foo/bar/Test.aidl", |
| 995 | ], |
| 996 | export_include_dirs: ["include"], |
| 997 | aidl: { |
| 998 | export_aidl_headers: true, |
| 999 | }, |
| 1000 | system_shared_libs: [], |
| 1001 | stl: "none", |
| 1002 | } |
| 1003 | `) |
| 1004 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1005 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1006 | checkAndroidBpContents(` |
| 1007 | // This is auto-generated. DO NOT EDIT. |
| 1008 | |
| 1009 | cc_prebuilt_library_static { |
| 1010 | name: "myexports_mynativelib@current", |
| 1011 | sdk_member_name: "mynativelib", |
| 1012 | device_supported: false, |
| 1013 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 1014 | installable: false, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1015 | export_include_dirs: ["include/include"], |
| 1016 | arch: { |
| 1017 | x86_64: { |
| 1018 | srcs: ["x86_64/lib/mynativelib.a"], |
| 1019 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
| 1020 | }, |
| 1021 | }, |
| 1022 | stl: "none", |
| 1023 | system_shared_libs: [], |
| 1024 | } |
| 1025 | |
| 1026 | cc_prebuilt_library_static { |
| 1027 | name: "mynativelib", |
| 1028 | prefer: false, |
| 1029 | device_supported: false, |
| 1030 | host_supported: true, |
| 1031 | export_include_dirs: ["include/include"], |
| 1032 | arch: { |
| 1033 | x86_64: { |
| 1034 | srcs: ["x86_64/lib/mynativelib.a"], |
| 1035 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
| 1036 | }, |
| 1037 | }, |
| 1038 | stl: "none", |
| 1039 | system_shared_libs: [], |
| 1040 | } |
| 1041 | |
| 1042 | module_exports_snapshot { |
| 1043 | name: "myexports@current", |
| 1044 | device_supported: false, |
| 1045 | host_supported: true, |
| 1046 | target: { |
| 1047 | host: { |
| 1048 | compile_multilib: "64", |
| 1049 | }, |
| 1050 | }, |
| 1051 | native_static_libs: ["myexports_mynativelib@current"], |
| 1052 | }`), |
| 1053 | checkAllCopyRules(` |
| 1054 | include/Test.h -> include/include/Test.h |
| 1055 | .intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a |
| 1056 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1057 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1058 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 1059 | `), |
| 1060 | ) |
| 1061 | } |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1062 | |
| 1063 | func TestSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 1064 | result := testSdkWithCc(t, ` |
| 1065 | sdk { |
| 1066 | name: "mysdk", |
| 1067 | native_header_libs: ["mynativeheaders"], |
| 1068 | } |
| 1069 | |
| 1070 | cc_library_headers { |
| 1071 | name: "mynativeheaders", |
| 1072 | export_include_dirs: ["include"], |
| 1073 | system_shared_libs: [], |
| 1074 | stl: "none", |
| 1075 | } |
| 1076 | `) |
| 1077 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1078 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1079 | checkAndroidBpContents(` |
| 1080 | // This is auto-generated. DO NOT EDIT. |
| 1081 | |
| 1082 | cc_prebuilt_library_headers { |
| 1083 | name: "mysdk_mynativeheaders@current", |
| 1084 | sdk_member_name: "mynativeheaders", |
| 1085 | export_include_dirs: ["include/include"], |
| 1086 | stl: "none", |
| 1087 | system_shared_libs: [], |
| 1088 | } |
| 1089 | |
| 1090 | cc_prebuilt_library_headers { |
| 1091 | name: "mynativeheaders", |
| 1092 | prefer: false, |
| 1093 | export_include_dirs: ["include/include"], |
| 1094 | stl: "none", |
| 1095 | system_shared_libs: [], |
| 1096 | } |
| 1097 | |
| 1098 | sdk_snapshot { |
| 1099 | name: "mysdk@current", |
| 1100 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 1101 | } |
| 1102 | `), |
| 1103 | checkAllCopyRules(` |
| 1104 | include/Test.h -> include/include/Test.h |
| 1105 | `), |
| 1106 | ) |
| 1107 | } |
| 1108 | |
| 1109 | func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 1110 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1111 | SkipIfNotLinux(t) |
| 1112 | |
| 1113 | result := testSdkWithCc(t, ` |
| 1114 | sdk { |
| 1115 | name: "mysdk", |
| 1116 | device_supported: false, |
| 1117 | host_supported: true, |
| 1118 | native_header_libs: ["mynativeheaders"], |
| 1119 | } |
| 1120 | |
| 1121 | cc_library_headers { |
| 1122 | name: "mynativeheaders", |
| 1123 | device_supported: false, |
| 1124 | host_supported: true, |
| 1125 | export_include_dirs: ["include"], |
| 1126 | system_shared_libs: [], |
| 1127 | stl: "none", |
| 1128 | } |
| 1129 | `) |
| 1130 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1131 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1132 | checkAndroidBpContents(` |
| 1133 | // This is auto-generated. DO NOT EDIT. |
| 1134 | |
| 1135 | cc_prebuilt_library_headers { |
| 1136 | name: "mysdk_mynativeheaders@current", |
| 1137 | sdk_member_name: "mynativeheaders", |
| 1138 | device_supported: false, |
| 1139 | host_supported: true, |
| 1140 | export_include_dirs: ["include/include"], |
| 1141 | stl: "none", |
| 1142 | system_shared_libs: [], |
| 1143 | } |
| 1144 | |
| 1145 | cc_prebuilt_library_headers { |
| 1146 | name: "mynativeheaders", |
| 1147 | prefer: false, |
| 1148 | device_supported: false, |
| 1149 | host_supported: true, |
| 1150 | export_include_dirs: ["include/include"], |
| 1151 | stl: "none", |
| 1152 | system_shared_libs: [], |
| 1153 | } |
| 1154 | |
| 1155 | sdk_snapshot { |
| 1156 | name: "mysdk@current", |
| 1157 | device_supported: false, |
| 1158 | host_supported: true, |
| 1159 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 1160 | } |
| 1161 | `), |
| 1162 | checkAllCopyRules(` |
| 1163 | include/Test.h -> include/include/Test.h |
| 1164 | `), |
| 1165 | ) |
| 1166 | } |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1167 | |
| 1168 | func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 1169 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1170 | SkipIfNotLinux(t) |
| 1171 | |
| 1172 | result := testSdkWithCc(t, ` |
| 1173 | sdk { |
| 1174 | name: "mysdk", |
| 1175 | host_supported: true, |
| 1176 | native_header_libs: ["mynativeheaders"], |
| 1177 | } |
| 1178 | |
| 1179 | cc_library_headers { |
| 1180 | name: "mynativeheaders", |
| 1181 | host_supported: true, |
| 1182 | system_shared_libs: [], |
| 1183 | stl: "none", |
| 1184 | export_system_include_dirs: ["include"], |
| 1185 | target: { |
| 1186 | android: { |
| 1187 | export_include_dirs: ["include-android"], |
| 1188 | }, |
| 1189 | host: { |
| 1190 | export_include_dirs: ["include-host"], |
| 1191 | }, |
| 1192 | }, |
| 1193 | } |
| 1194 | `) |
| 1195 | |
| 1196 | result.CheckSnapshot("mysdk", "", |
| 1197 | checkAndroidBpContents(` |
| 1198 | // This is auto-generated. DO NOT EDIT. |
| 1199 | |
| 1200 | cc_prebuilt_library_headers { |
| 1201 | name: "mysdk_mynativeheaders@current", |
| 1202 | sdk_member_name: "mynativeheaders", |
| 1203 | host_supported: true, |
| 1204 | export_system_include_dirs: ["include/include"], |
| 1205 | target: { |
| 1206 | android: { |
| 1207 | export_include_dirs: ["include/include-android"], |
| 1208 | }, |
| 1209 | linux_glibc: { |
| 1210 | export_include_dirs: ["include/include-host"], |
| 1211 | }, |
| 1212 | }, |
| 1213 | stl: "none", |
| 1214 | system_shared_libs: [], |
| 1215 | } |
| 1216 | |
| 1217 | cc_prebuilt_library_headers { |
| 1218 | name: "mynativeheaders", |
| 1219 | prefer: false, |
| 1220 | host_supported: true, |
| 1221 | export_system_include_dirs: ["include/include"], |
| 1222 | target: { |
| 1223 | android: { |
| 1224 | export_include_dirs: ["include/include-android"], |
| 1225 | }, |
| 1226 | linux_glibc: { |
| 1227 | export_include_dirs: ["include/include-host"], |
| 1228 | }, |
| 1229 | }, |
| 1230 | stl: "none", |
| 1231 | system_shared_libs: [], |
| 1232 | } |
| 1233 | |
| 1234 | sdk_snapshot { |
| 1235 | name: "mysdk@current", |
| 1236 | host_supported: true, |
| 1237 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 1238 | } |
| 1239 | `), |
| 1240 | checkAllCopyRules(` |
| 1241 | include/Test.h -> include/include/Test.h |
| 1242 | include-android/AndroidTest.h -> include/include-android/AndroidTest.h |
| 1243 | include-host/HostTest.h -> include/include-host/HostTest.h |
| 1244 | `), |
| 1245 | ) |
| 1246 | } |