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 | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 301 | stl: "none", |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 302 | export_include_dirs: ["include/include"], |
| 303 | arch: { |
| 304 | arm64: { |
| 305 | srcs: ["arm64/lib/mynativelib.so"], |
| 306 | export_system_include_dirs: ["arm64/include/arm64/include"], |
| 307 | }, |
| 308 | arm: { |
| 309 | srcs: ["arm/lib/mynativelib.so"], |
| 310 | }, |
| 311 | }, |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | cc_prebuilt_library_shared { |
| 315 | name: "mynativelib", |
| 316 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 317 | stl: "none", |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 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 | }, |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | sdk_snapshot { |
| 331 | name: "mysdk@current", |
| 332 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 333 | } |
| 334 | `), |
| 335 | checkAllCopyRules(` |
| 336 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 337 | .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] | 338 | arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 339 | .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] | 340 | ) |
| 341 | } |
| 342 | |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 343 | func TestSnapshotWithCcBinary(t *testing.T) { |
| 344 | result := testSdkWithCc(t, ` |
| 345 | module_exports { |
| 346 | name: "mymodule_exports", |
| 347 | native_binaries: ["mynativebinary"], |
| 348 | } |
| 349 | |
| 350 | cc_binary { |
| 351 | name: "mynativebinary", |
| 352 | srcs: [ |
| 353 | "Test.cpp", |
| 354 | ], |
| 355 | compile_multilib: "both", |
| 356 | system_shared_libs: [], |
| 357 | stl: "none", |
| 358 | } |
| 359 | `) |
| 360 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 361 | result.CheckSnapshot("mymodule_exports", "", |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 362 | checkAndroidBpContents(` |
| 363 | // This is auto-generated. DO NOT EDIT. |
| 364 | |
| 365 | cc_prebuilt_binary { |
| 366 | name: "mymodule_exports_mynativebinary@current", |
| 367 | sdk_member_name: "mynativebinary", |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 368 | installable: false, |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 369 | compile_multilib: "both", |
| 370 | arch: { |
| 371 | arm64: { |
| 372 | srcs: ["arm64/bin/mynativebinary"], |
| 373 | }, |
| 374 | arm: { |
| 375 | srcs: ["arm/bin/mynativebinary"], |
| 376 | }, |
| 377 | }, |
| 378 | } |
| 379 | |
| 380 | cc_prebuilt_binary { |
| 381 | name: "mynativebinary", |
| 382 | prefer: false, |
| 383 | compile_multilib: "both", |
| 384 | arch: { |
| 385 | arm64: { |
| 386 | srcs: ["arm64/bin/mynativebinary"], |
| 387 | }, |
| 388 | arm: { |
| 389 | srcs: ["arm/bin/mynativebinary"], |
| 390 | }, |
| 391 | }, |
| 392 | } |
| 393 | |
| 394 | module_exports_snapshot { |
| 395 | name: "mymodule_exports@current", |
| 396 | native_binaries: ["mymodule_exports_mynativebinary@current"], |
| 397 | } |
| 398 | `), |
| 399 | checkAllCopyRules(` |
| 400 | .intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary |
| 401 | .intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary |
| 402 | `), |
| 403 | ) |
| 404 | } |
| 405 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 406 | func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) { |
| 407 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 408 | SkipIfNotLinux(t) |
| 409 | |
| 410 | result := testSdkWithCc(t, ` |
| 411 | module_exports { |
| 412 | name: "myexports", |
| 413 | device_supported: false, |
| 414 | host_supported: true, |
| 415 | native_binaries: ["mynativebinary"], |
| 416 | target: { |
| 417 | windows: { |
| 418 | enabled: true, |
| 419 | }, |
| 420 | }, |
| 421 | } |
| 422 | |
| 423 | cc_binary { |
| 424 | name: "mynativebinary", |
| 425 | device_supported: false, |
| 426 | host_supported: true, |
| 427 | srcs: [ |
| 428 | "Test.cpp", |
| 429 | ], |
| 430 | compile_multilib: "both", |
| 431 | system_shared_libs: [], |
| 432 | stl: "none", |
| 433 | target: { |
| 434 | windows: { |
| 435 | enabled: true, |
| 436 | }, |
| 437 | }, |
| 438 | } |
| 439 | `) |
| 440 | |
| 441 | result.CheckSnapshot("myexports", "", |
| 442 | checkAndroidBpContents(` |
| 443 | // This is auto-generated. DO NOT EDIT. |
| 444 | |
| 445 | cc_prebuilt_binary { |
| 446 | name: "myexports_mynativebinary@current", |
| 447 | sdk_member_name: "mynativebinary", |
| 448 | device_supported: false, |
| 449 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 450 | installable: false, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 451 | target: { |
| 452 | linux_glibc: { |
| 453 | compile_multilib: "both", |
| 454 | }, |
| 455 | linux_glibc_x86_64: { |
| 456 | srcs: ["linux_glibc/x86_64/bin/mynativebinary"], |
| 457 | }, |
| 458 | linux_glibc_x86: { |
| 459 | srcs: ["linux_glibc/x86/bin/mynativebinary"], |
| 460 | }, |
| 461 | windows: { |
| 462 | compile_multilib: "64", |
| 463 | }, |
| 464 | windows_x86_64: { |
| 465 | srcs: ["windows/x86_64/bin/mynativebinary.exe"], |
| 466 | }, |
| 467 | }, |
| 468 | } |
| 469 | |
| 470 | cc_prebuilt_binary { |
| 471 | name: "mynativebinary", |
| 472 | prefer: false, |
| 473 | device_supported: false, |
| 474 | host_supported: true, |
| 475 | target: { |
| 476 | linux_glibc: { |
| 477 | compile_multilib: "both", |
| 478 | }, |
| 479 | linux_glibc_x86_64: { |
| 480 | srcs: ["linux_glibc/x86_64/bin/mynativebinary"], |
| 481 | }, |
| 482 | linux_glibc_x86: { |
| 483 | srcs: ["linux_glibc/x86/bin/mynativebinary"], |
| 484 | }, |
| 485 | windows: { |
| 486 | compile_multilib: "64", |
| 487 | }, |
| 488 | windows_x86_64: { |
| 489 | srcs: ["windows/x86_64/bin/mynativebinary.exe"], |
| 490 | }, |
| 491 | }, |
| 492 | } |
| 493 | |
| 494 | module_exports_snapshot { |
| 495 | name: "myexports@current", |
| 496 | device_supported: false, |
| 497 | host_supported: true, |
| 498 | native_binaries: ["myexports_mynativebinary@current"], |
| 499 | } |
| 500 | `), |
| 501 | checkAllCopyRules(` |
| 502 | .intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary |
| 503 | .intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary |
| 504 | .intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe |
| 505 | `), |
| 506 | ) |
| 507 | } |
| 508 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 509 | func TestSnapshotWithCcSharedLibrary(t *testing.T) { |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 510 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 511 | sdk { |
| 512 | name: "mysdk", |
| 513 | native_shared_libs: ["mynativelib"], |
| 514 | } |
| 515 | |
| 516 | cc_library_shared { |
| 517 | name: "mynativelib", |
| 518 | srcs: [ |
| 519 | "Test.cpp", |
| 520 | "aidl/foo/bar/Test.aidl", |
| 521 | ], |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 522 | apex_available: ["apex1", "apex2"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 523 | export_include_dirs: ["include"], |
| 524 | aidl: { |
| 525 | export_aidl_headers: true, |
| 526 | }, |
| 527 | system_shared_libs: [], |
| 528 | stl: "none", |
| 529 | } |
| 530 | `) |
| 531 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 532 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 533 | checkAndroidBpContents(` |
| 534 | // This is auto-generated. DO NOT EDIT. |
| 535 | |
| 536 | cc_prebuilt_library_shared { |
| 537 | name: "mysdk_mynativelib@current", |
| 538 | sdk_member_name: "mynativelib", |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 539 | apex_available: [ |
| 540 | "apex1", |
| 541 | "apex2", |
| 542 | ], |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 543 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 544 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 545 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 546 | arch: { |
| 547 | arm64: { |
| 548 | srcs: ["arm64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 549 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 550 | }, |
| 551 | arm: { |
| 552 | srcs: ["arm/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 553 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 554 | }, |
| 555 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | cc_prebuilt_library_shared { |
| 559 | name: "mynativelib", |
| 560 | prefer: false, |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 561 | apex_available: [ |
| 562 | "apex1", |
| 563 | "apex2", |
| 564 | ], |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 565 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 566 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 567 | arch: { |
| 568 | arm64: { |
| 569 | srcs: ["arm64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 570 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 571 | }, |
| 572 | arm: { |
| 573 | srcs: ["arm/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 574 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 575 | }, |
| 576 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | sdk_snapshot { |
| 580 | name: "mysdk@current", |
| 581 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 582 | } |
| 583 | `), |
| 584 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 585 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 586 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
| 587 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 588 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 589 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 590 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so |
| 591 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 592 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 593 | .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] | 594 | `), |
| 595 | ) |
| 596 | } |
| 597 | |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 598 | func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) { |
| 599 | result := testSdkWithCc(t, ` |
| 600 | sdk { |
| 601 | name: "mysdk", |
| 602 | native_shared_libs: [ |
| 603 | "mynativelib", |
| 604 | "myothernativelib", |
| 605 | "mysystemnativelib", |
| 606 | ], |
| 607 | } |
| 608 | |
| 609 | cc_library { |
| 610 | name: "mysystemnativelib", |
| 611 | srcs: [ |
| 612 | "Test.cpp", |
| 613 | ], |
| 614 | system_shared_libs: [], |
| 615 | stl: "none", |
| 616 | } |
| 617 | |
| 618 | cc_library_shared { |
| 619 | name: "myothernativelib", |
| 620 | srcs: [ |
| 621 | "Test.cpp", |
| 622 | ], |
| 623 | system_shared_libs: [ |
| 624 | // A reference to a library that is not an sdk member. Uses libm as that |
| 625 | // is in the default set of modules available to this test and so is available |
| 626 | // both here and also when the generated Android.bp file is tested in |
| 627 | // CheckSnapshot(). This ensures that the system_shared_libs property correctly |
| 628 | // handles references to modules that are not sdk members. |
| 629 | "libm", |
| 630 | ], |
| 631 | stl: "none", |
| 632 | } |
| 633 | |
| 634 | cc_library { |
| 635 | name: "mynativelib", |
| 636 | srcs: [ |
| 637 | "Test.cpp", |
| 638 | ], |
| 639 | shared_libs: [ |
| 640 | // A reference to another sdk member. |
| 641 | "myothernativelib", |
| 642 | ], |
| 643 | target: { |
| 644 | android: { |
| 645 | shared: { |
| 646 | shared_libs: [ |
| 647 | // A reference to a library that is not an sdk member. The libc library |
| 648 | // is used here to check that the shared_libs property is handled correctly |
| 649 | // in a similar way to how libm is used to check system_shared_libs above. |
| 650 | "libc", |
| 651 | ], |
| 652 | }, |
| 653 | }, |
| 654 | }, |
| 655 | system_shared_libs: [], |
| 656 | stl: "none", |
| 657 | } |
| 658 | `) |
| 659 | |
| 660 | result.CheckSnapshot("mysdk", "", |
| 661 | checkAndroidBpContents(` |
| 662 | // This is auto-generated. DO NOT EDIT. |
| 663 | |
| 664 | cc_prebuilt_library_shared { |
| 665 | name: "mysdk_mynativelib@current", |
| 666 | sdk_member_name: "mynativelib", |
| 667 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 668 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 669 | shared_libs: [ |
| 670 | "mysdk_myothernativelib@current", |
| 671 | "libc", |
| 672 | ], |
| 673 | arch: { |
| 674 | arm64: { |
| 675 | srcs: ["arm64/lib/mynativelib.so"], |
| 676 | }, |
| 677 | arm: { |
| 678 | srcs: ["arm/lib/mynativelib.so"], |
| 679 | }, |
| 680 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | cc_prebuilt_library_shared { |
| 684 | name: "mynativelib", |
| 685 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 686 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 687 | shared_libs: [ |
| 688 | "myothernativelib", |
| 689 | "libc", |
| 690 | ], |
| 691 | arch: { |
| 692 | arm64: { |
| 693 | srcs: ["arm64/lib/mynativelib.so"], |
| 694 | }, |
| 695 | arm: { |
| 696 | srcs: ["arm/lib/mynativelib.so"], |
| 697 | }, |
| 698 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | cc_prebuilt_library_shared { |
| 702 | name: "mysdk_myothernativelib@current", |
| 703 | sdk_member_name: "myothernativelib", |
| 704 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 705 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 706 | system_shared_libs: ["libm"], |
| 707 | arch: { |
| 708 | arm64: { |
| 709 | srcs: ["arm64/lib/myothernativelib.so"], |
| 710 | }, |
| 711 | arm: { |
| 712 | srcs: ["arm/lib/myothernativelib.so"], |
| 713 | }, |
| 714 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | cc_prebuilt_library_shared { |
| 718 | name: "myothernativelib", |
| 719 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 720 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 721 | system_shared_libs: ["libm"], |
| 722 | arch: { |
| 723 | arm64: { |
| 724 | srcs: ["arm64/lib/myothernativelib.so"], |
| 725 | }, |
| 726 | arm: { |
| 727 | srcs: ["arm/lib/myothernativelib.so"], |
| 728 | }, |
| 729 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | cc_prebuilt_library_shared { |
| 733 | name: "mysdk_mysystemnativelib@current", |
| 734 | sdk_member_name: "mysystemnativelib", |
| 735 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 736 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 737 | arch: { |
| 738 | arm64: { |
| 739 | srcs: ["arm64/lib/mysystemnativelib.so"], |
| 740 | }, |
| 741 | arm: { |
| 742 | srcs: ["arm/lib/mysystemnativelib.so"], |
| 743 | }, |
| 744 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | cc_prebuilt_library_shared { |
| 748 | name: "mysystemnativelib", |
| 749 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 750 | stl: "none", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 751 | arch: { |
| 752 | arm64: { |
| 753 | srcs: ["arm64/lib/mysystemnativelib.so"], |
| 754 | }, |
| 755 | arm: { |
| 756 | srcs: ["arm/lib/mysystemnativelib.so"], |
| 757 | }, |
| 758 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | sdk_snapshot { |
| 762 | name: "mysdk@current", |
| 763 | native_shared_libs: [ |
| 764 | "mysdk_mynativelib@current", |
| 765 | "mysdk_myothernativelib@current", |
| 766 | "mysdk_mysystemnativelib@current", |
| 767 | ], |
| 768 | } |
| 769 | `), |
| 770 | checkAllCopyRules(` |
| 771 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
| 772 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so |
| 773 | .intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so |
| 774 | .intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so |
| 775 | .intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so |
| 776 | .intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so |
| 777 | `), |
| 778 | ) |
| 779 | } |
| 780 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 781 | func TestHostSnapshotWithCcSharedLibrary(t *testing.T) { |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 782 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 783 | SkipIfNotLinux(t) |
| 784 | |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 785 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 786 | sdk { |
| 787 | name: "mysdk", |
| 788 | device_supported: false, |
| 789 | host_supported: true, |
| 790 | native_shared_libs: ["mynativelib"], |
| 791 | } |
| 792 | |
| 793 | cc_library_shared { |
| 794 | name: "mynativelib", |
| 795 | device_supported: false, |
| 796 | host_supported: true, |
| 797 | srcs: [ |
| 798 | "Test.cpp", |
| 799 | "aidl/foo/bar/Test.aidl", |
| 800 | ], |
| 801 | export_include_dirs: ["include"], |
| 802 | aidl: { |
| 803 | export_aidl_headers: true, |
| 804 | }, |
| 805 | system_shared_libs: [], |
| 806 | stl: "none", |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 807 | sdk_version: "minimum", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 808 | } |
| 809 | `) |
| 810 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 811 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 812 | checkAndroidBpContents(` |
| 813 | // This is auto-generated. DO NOT EDIT. |
| 814 | |
| 815 | cc_prebuilt_library_shared { |
| 816 | name: "mysdk_mynativelib@current", |
| 817 | sdk_member_name: "mynativelib", |
| 818 | device_supported: false, |
| 819 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 820 | installable: false, |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 821 | sdk_version: "minimum", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 822 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 823 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 824 | arch: { |
| 825 | x86_64: { |
| 826 | srcs: ["x86_64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 827 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 828 | }, |
| 829 | x86: { |
| 830 | srcs: ["x86/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 831 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 832 | }, |
| 833 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | cc_prebuilt_library_shared { |
| 837 | name: "mynativelib", |
| 838 | prefer: false, |
| 839 | device_supported: false, |
| 840 | host_supported: true, |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 841 | sdk_version: "minimum", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 842 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 843 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 844 | arch: { |
| 845 | x86_64: { |
| 846 | srcs: ["x86_64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 847 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 848 | }, |
| 849 | x86: { |
| 850 | srcs: ["x86/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 851 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 852 | }, |
| 853 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | sdk_snapshot { |
| 857 | name: "mysdk@current", |
| 858 | device_supported: false, |
| 859 | host_supported: true, |
| 860 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 861 | } |
| 862 | `), |
| 863 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 864 | include/Test.h -> include/include/Test.h |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 865 | .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] | 866 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 867 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 868 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 869 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 870 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 871 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 872 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 873 | `), |
| 874 | ) |
| 875 | } |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 876 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 877 | func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) { |
| 878 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 879 | SkipIfNotLinux(t) |
| 880 | |
| 881 | result := testSdkWithCc(t, ` |
| 882 | sdk { |
| 883 | name: "mysdk", |
| 884 | device_supported: false, |
| 885 | host_supported: true, |
| 886 | native_shared_libs: ["mynativelib"], |
| 887 | target: { |
| 888 | windows: { |
| 889 | enabled: true, |
| 890 | }, |
| 891 | }, |
| 892 | } |
| 893 | |
| 894 | cc_library_shared { |
| 895 | name: "mynativelib", |
| 896 | device_supported: false, |
| 897 | host_supported: true, |
| 898 | srcs: [ |
| 899 | "Test.cpp", |
| 900 | ], |
| 901 | system_shared_libs: [], |
| 902 | stl: "none", |
| 903 | target: { |
| 904 | windows: { |
| 905 | enabled: true, |
| 906 | }, |
| 907 | }, |
| 908 | } |
| 909 | `) |
| 910 | |
| 911 | result.CheckSnapshot("mysdk", "", |
| 912 | checkAndroidBpContents(` |
| 913 | // This is auto-generated. DO NOT EDIT. |
| 914 | |
| 915 | cc_prebuilt_library_shared { |
| 916 | name: "mysdk_mynativelib@current", |
| 917 | sdk_member_name: "mynativelib", |
| 918 | device_supported: false, |
| 919 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 920 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 921 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 922 | target: { |
| 923 | linux_glibc_x86_64: { |
| 924 | srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], |
| 925 | }, |
| 926 | linux_glibc_x86: { |
| 927 | srcs: ["linux_glibc/x86/lib/mynativelib.so"], |
| 928 | }, |
| 929 | windows_x86_64: { |
| 930 | srcs: ["windows/x86_64/lib/mynativelib.dll"], |
| 931 | }, |
| 932 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | cc_prebuilt_library_shared { |
| 936 | name: "mynativelib", |
| 937 | prefer: false, |
| 938 | device_supported: false, |
| 939 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 940 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 941 | target: { |
| 942 | linux_glibc_x86_64: { |
| 943 | srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], |
| 944 | }, |
| 945 | linux_glibc_x86: { |
| 946 | srcs: ["linux_glibc/x86/lib/mynativelib.so"], |
| 947 | }, |
| 948 | windows_x86_64: { |
| 949 | srcs: ["windows/x86_64/lib/mynativelib.dll"], |
| 950 | }, |
| 951 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | sdk_snapshot { |
| 955 | name: "mysdk@current", |
| 956 | device_supported: false, |
| 957 | host_supported: true, |
| 958 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 959 | } |
| 960 | `), |
| 961 | checkAllCopyRules(` |
| 962 | .intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so |
| 963 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so |
| 964 | .intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll |
| 965 | `), |
| 966 | ) |
| 967 | } |
| 968 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 969 | func TestSnapshotWithCcStaticLibrary(t *testing.T) { |
| 970 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 971 | module_exports { |
| 972 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 973 | native_static_libs: ["mynativelib"], |
| 974 | } |
| 975 | |
| 976 | cc_library_static { |
| 977 | name: "mynativelib", |
| 978 | srcs: [ |
| 979 | "Test.cpp", |
| 980 | "aidl/foo/bar/Test.aidl", |
| 981 | ], |
| 982 | export_include_dirs: ["include"], |
| 983 | aidl: { |
| 984 | export_aidl_headers: true, |
| 985 | }, |
| 986 | system_shared_libs: [], |
| 987 | stl: "none", |
| 988 | } |
| 989 | `) |
| 990 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 991 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 992 | checkAndroidBpContents(` |
| 993 | // This is auto-generated. DO NOT EDIT. |
| 994 | |
| 995 | cc_prebuilt_library_static { |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 996 | name: "myexports_mynativelib@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 997 | sdk_member_name: "mynativelib", |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 998 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 999 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1000 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1001 | arch: { |
| 1002 | arm64: { |
| 1003 | srcs: ["arm64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1004 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1005 | }, |
| 1006 | arm: { |
| 1007 | srcs: ["arm/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1008 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1009 | }, |
| 1010 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | cc_prebuilt_library_static { |
| 1014 | name: "mynativelib", |
| 1015 | prefer: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1016 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1017 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1018 | arch: { |
| 1019 | arm64: { |
| 1020 | srcs: ["arm64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1021 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1022 | }, |
| 1023 | arm: { |
| 1024 | srcs: ["arm/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1025 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1026 | }, |
| 1027 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1030 | module_exports_snapshot { |
| 1031 | name: "myexports@current", |
| 1032 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1033 | } |
| 1034 | `), |
| 1035 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1036 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 1037 | .intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a |
| 1038 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1039 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1040 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 1041 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a |
| 1042 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1043 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1044 | .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] | 1045 | `), |
| 1046 | ) |
| 1047 | } |
| 1048 | |
| 1049 | func TestHostSnapshotWithCcStaticLibrary(t *testing.T) { |
| 1050 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1051 | SkipIfNotLinux(t) |
| 1052 | |
| 1053 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1054 | module_exports { |
| 1055 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1056 | device_supported: false, |
| 1057 | host_supported: true, |
| 1058 | native_static_libs: ["mynativelib"], |
| 1059 | } |
| 1060 | |
| 1061 | cc_library_static { |
| 1062 | name: "mynativelib", |
| 1063 | device_supported: false, |
| 1064 | host_supported: true, |
| 1065 | srcs: [ |
| 1066 | "Test.cpp", |
| 1067 | "aidl/foo/bar/Test.aidl", |
| 1068 | ], |
| 1069 | export_include_dirs: ["include"], |
| 1070 | aidl: { |
| 1071 | export_aidl_headers: true, |
| 1072 | }, |
| 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("myexports", "", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1079 | checkAndroidBpContents(` |
| 1080 | // This is auto-generated. DO NOT EDIT. |
| 1081 | |
| 1082 | cc_prebuilt_library_static { |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1083 | name: "myexports_mynativelib@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1084 | sdk_member_name: "mynativelib", |
| 1085 | device_supported: false, |
| 1086 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 1087 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1088 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1089 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1090 | arch: { |
| 1091 | x86_64: { |
| 1092 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1093 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1094 | }, |
| 1095 | x86: { |
| 1096 | srcs: ["x86/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1097 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1098 | }, |
| 1099 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | cc_prebuilt_library_static { |
| 1103 | name: "mynativelib", |
| 1104 | prefer: false, |
| 1105 | device_supported: false, |
| 1106 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1107 | stl: "none", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1108 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1109 | arch: { |
| 1110 | x86_64: { |
| 1111 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1112 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1113 | }, |
| 1114 | x86: { |
| 1115 | srcs: ["x86/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1116 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1117 | }, |
| 1118 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1119 | } |
| 1120 | |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1121 | module_exports_snapshot { |
| 1122 | name: "myexports@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1123 | device_supported: false, |
| 1124 | host_supported: true, |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1125 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1126 | } |
| 1127 | `), |
| 1128 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 1129 | include/Test.h -> include/include/Test.h |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1130 | .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] | 1131 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1132 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1133 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 1134 | .intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1135 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1136 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1137 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 1138 | `), |
| 1139 | ) |
| 1140 | } |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1141 | |
| 1142 | func TestHostSnapshotWithMultiLib64(t *testing.T) { |
| 1143 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1144 | SkipIfNotLinux(t) |
| 1145 | |
| 1146 | result := testSdkWithCc(t, ` |
| 1147 | module_exports { |
| 1148 | name: "myexports", |
| 1149 | device_supported: false, |
| 1150 | host_supported: true, |
| 1151 | target: { |
| 1152 | host: { |
| 1153 | compile_multilib: "64", |
| 1154 | }, |
| 1155 | }, |
| 1156 | native_static_libs: ["mynativelib"], |
| 1157 | } |
| 1158 | |
| 1159 | cc_library_static { |
| 1160 | name: "mynativelib", |
| 1161 | device_supported: false, |
| 1162 | host_supported: true, |
| 1163 | srcs: [ |
| 1164 | "Test.cpp", |
| 1165 | "aidl/foo/bar/Test.aidl", |
| 1166 | ], |
| 1167 | export_include_dirs: ["include"], |
| 1168 | aidl: { |
| 1169 | export_aidl_headers: true, |
| 1170 | }, |
| 1171 | system_shared_libs: [], |
| 1172 | stl: "none", |
| 1173 | } |
| 1174 | `) |
| 1175 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1176 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1177 | checkAndroidBpContents(` |
| 1178 | // This is auto-generated. DO NOT EDIT. |
| 1179 | |
| 1180 | cc_prebuilt_library_static { |
| 1181 | name: "myexports_mynativelib@current", |
| 1182 | sdk_member_name: "mynativelib", |
| 1183 | device_supported: false, |
| 1184 | host_supported: true, |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 1185 | installable: false, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1186 | stl: "none", |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1187 | export_include_dirs: ["include/include"], |
| 1188 | arch: { |
| 1189 | x86_64: { |
| 1190 | srcs: ["x86_64/lib/mynativelib.a"], |
| 1191 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
| 1192 | }, |
| 1193 | }, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | cc_prebuilt_library_static { |
| 1197 | name: "mynativelib", |
| 1198 | prefer: false, |
| 1199 | device_supported: false, |
| 1200 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1201 | stl: "none", |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1202 | export_include_dirs: ["include/include"], |
| 1203 | arch: { |
| 1204 | x86_64: { |
| 1205 | srcs: ["x86_64/lib/mynativelib.a"], |
| 1206 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
| 1207 | }, |
| 1208 | }, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1209 | } |
| 1210 | |
| 1211 | module_exports_snapshot { |
| 1212 | name: "myexports@current", |
| 1213 | device_supported: false, |
| 1214 | host_supported: true, |
Paul Duffin | 07ef3cb | 2020-03-11 18:17:42 +0000 | [diff] [blame^] | 1215 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1216 | target: { |
| 1217 | host: { |
| 1218 | compile_multilib: "64", |
| 1219 | }, |
| 1220 | }, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1221 | }`), |
| 1222 | checkAllCopyRules(` |
| 1223 | include/Test.h -> include/include/Test.h |
| 1224 | .intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a |
| 1225 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 1226 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 1227 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 1228 | `), |
| 1229 | ) |
| 1230 | } |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1231 | |
| 1232 | func TestSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 1233 | result := testSdkWithCc(t, ` |
| 1234 | sdk { |
| 1235 | name: "mysdk", |
| 1236 | native_header_libs: ["mynativeheaders"], |
| 1237 | } |
| 1238 | |
| 1239 | cc_library_headers { |
| 1240 | name: "mynativeheaders", |
| 1241 | export_include_dirs: ["include"], |
| 1242 | system_shared_libs: [], |
| 1243 | stl: "none", |
| 1244 | } |
| 1245 | `) |
| 1246 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1247 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1248 | checkAndroidBpContents(` |
| 1249 | // This is auto-generated. DO NOT EDIT. |
| 1250 | |
| 1251 | cc_prebuilt_library_headers { |
| 1252 | name: "mysdk_mynativeheaders@current", |
| 1253 | sdk_member_name: "mynativeheaders", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1254 | stl: "none", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1255 | export_include_dirs: ["include/include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1256 | } |
| 1257 | |
| 1258 | cc_prebuilt_library_headers { |
| 1259 | name: "mynativeheaders", |
| 1260 | prefer: false, |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1261 | stl: "none", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1262 | export_include_dirs: ["include/include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | sdk_snapshot { |
| 1266 | name: "mysdk@current", |
| 1267 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 1268 | } |
| 1269 | `), |
| 1270 | checkAllCopyRules(` |
| 1271 | include/Test.h -> include/include/Test.h |
| 1272 | `), |
| 1273 | ) |
| 1274 | } |
| 1275 | |
| 1276 | func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 1277 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1278 | SkipIfNotLinux(t) |
| 1279 | |
| 1280 | result := testSdkWithCc(t, ` |
| 1281 | sdk { |
| 1282 | name: "mysdk", |
| 1283 | device_supported: false, |
| 1284 | host_supported: true, |
| 1285 | native_header_libs: ["mynativeheaders"], |
| 1286 | } |
| 1287 | |
| 1288 | cc_library_headers { |
| 1289 | name: "mynativeheaders", |
| 1290 | device_supported: false, |
| 1291 | host_supported: true, |
| 1292 | export_include_dirs: ["include"], |
| 1293 | system_shared_libs: [], |
| 1294 | stl: "none", |
| 1295 | } |
| 1296 | `) |
| 1297 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 1298 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1299 | checkAndroidBpContents(` |
| 1300 | // This is auto-generated. DO NOT EDIT. |
| 1301 | |
| 1302 | cc_prebuilt_library_headers { |
| 1303 | name: "mysdk_mynativeheaders@current", |
| 1304 | sdk_member_name: "mynativeheaders", |
| 1305 | device_supported: false, |
| 1306 | host_supported: true, |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1307 | stl: "none", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1308 | export_include_dirs: ["include/include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | cc_prebuilt_library_headers { |
| 1312 | name: "mynativeheaders", |
| 1313 | prefer: false, |
| 1314 | device_supported: false, |
| 1315 | host_supported: true, |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1316 | stl: "none", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1317 | export_include_dirs: ["include/include"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1318 | } |
| 1319 | |
| 1320 | sdk_snapshot { |
| 1321 | name: "mysdk@current", |
| 1322 | device_supported: false, |
| 1323 | host_supported: true, |
| 1324 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 1325 | } |
| 1326 | `), |
| 1327 | checkAllCopyRules(` |
| 1328 | include/Test.h -> include/include/Test.h |
| 1329 | `), |
| 1330 | ) |
| 1331 | } |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1332 | |
| 1333 | func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 1334 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 1335 | SkipIfNotLinux(t) |
| 1336 | |
| 1337 | result := testSdkWithCc(t, ` |
| 1338 | sdk { |
| 1339 | name: "mysdk", |
| 1340 | host_supported: true, |
| 1341 | native_header_libs: ["mynativeheaders"], |
| 1342 | } |
| 1343 | |
| 1344 | cc_library_headers { |
| 1345 | name: "mynativeheaders", |
| 1346 | host_supported: true, |
| 1347 | system_shared_libs: [], |
| 1348 | stl: "none", |
| 1349 | export_system_include_dirs: ["include"], |
| 1350 | target: { |
| 1351 | android: { |
| 1352 | export_include_dirs: ["include-android"], |
| 1353 | }, |
| 1354 | host: { |
| 1355 | export_include_dirs: ["include-host"], |
| 1356 | }, |
| 1357 | }, |
| 1358 | } |
| 1359 | `) |
| 1360 | |
| 1361 | result.CheckSnapshot("mysdk", "", |
| 1362 | checkAndroidBpContents(` |
| 1363 | // This is auto-generated. DO NOT EDIT. |
| 1364 | |
| 1365 | cc_prebuilt_library_headers { |
| 1366 | name: "mysdk_mynativeheaders@current", |
| 1367 | sdk_member_name: "mynativeheaders", |
| 1368 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1369 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1370 | export_system_include_dirs: ["include/include"], |
| 1371 | target: { |
| 1372 | android: { |
| 1373 | export_include_dirs: ["include/include-android"], |
| 1374 | }, |
| 1375 | linux_glibc: { |
| 1376 | export_include_dirs: ["include/include-host"], |
| 1377 | }, |
| 1378 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1379 | } |
| 1380 | |
| 1381 | cc_prebuilt_library_headers { |
| 1382 | name: "mynativeheaders", |
| 1383 | prefer: false, |
| 1384 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1385 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1386 | export_system_include_dirs: ["include/include"], |
| 1387 | target: { |
| 1388 | android: { |
| 1389 | export_include_dirs: ["include/include-android"], |
| 1390 | }, |
| 1391 | linux_glibc: { |
| 1392 | export_include_dirs: ["include/include-host"], |
| 1393 | }, |
| 1394 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1395 | } |
| 1396 | |
| 1397 | sdk_snapshot { |
| 1398 | name: "mysdk@current", |
| 1399 | host_supported: true, |
| 1400 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 1401 | } |
| 1402 | `), |
| 1403 | checkAllCopyRules(` |
| 1404 | include/Test.h -> include/include/Test.h |
| 1405 | include-android/AndroidTest.h -> include/include-android/AndroidTest.h |
| 1406 | include-host/HostTest.h -> include/include-host/HostTest.h |
| 1407 | `), |
| 1408 | ) |
| 1409 | } |