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 | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 28 | "Test.cpp": nil, |
| 29 | "include/Test.h": nil, |
| 30 | "arm64/include/Arm64Test.h": nil, |
| 31 | "libfoo.so": nil, |
| 32 | "aidl/foo/bar/Test.aidl": nil, |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 33 | } |
| 34 | return testSdkWithFs(t, bp, fs) |
| 35 | } |
| 36 | |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 37 | // Contains tests for SDK members provided by the cc package. |
| 38 | |
| 39 | func TestSdkIsCompileMultilibBoth(t *testing.T) { |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 40 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 41 | sdk { |
| 42 | name: "mysdk", |
| 43 | native_shared_libs: ["sdkmember"], |
| 44 | } |
| 45 | |
| 46 | cc_library_shared { |
| 47 | name: "sdkmember", |
| 48 | srcs: ["Test.cpp"], |
| 49 | system_shared_libs: [], |
| 50 | stl: "none", |
| 51 | } |
| 52 | `) |
| 53 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 54 | armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile() |
| 55 | arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile() |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 56 | |
| 57 | var inputs []string |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 58 | buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests() |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 59 | for _, bp := range buildParams { |
| 60 | if bp.Input != nil { |
| 61 | inputs = append(inputs, bp.Input.String()) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | // ensure that both 32/64 outputs are inputs of the sdk snapshot |
| 66 | ensureListContains(t, inputs, armOutput.String()) |
| 67 | ensureListContains(t, inputs, arm64Output.String()) |
| 68 | } |
| 69 | |
| 70 | func TestBasicSdkWithCc(t *testing.T) { |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 71 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 72 | sdk { |
| 73 | name: "mysdk", |
| 74 | native_shared_libs: ["sdkmember"], |
| 75 | } |
| 76 | |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 77 | cc_library_shared { |
| 78 | name: "sdkmember", |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 79 | system_shared_libs: [], |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 82 | sdk_snapshot { |
| 83 | name: "mysdk@1", |
| 84 | native_shared_libs: ["sdkmember_mysdk_1"], |
| 85 | } |
| 86 | |
| 87 | sdk_snapshot { |
| 88 | name: "mysdk@2", |
| 89 | native_shared_libs: ["sdkmember_mysdk_2"], |
| 90 | } |
| 91 | |
| 92 | cc_prebuilt_library_shared { |
| 93 | name: "sdkmember", |
| 94 | srcs: ["libfoo.so"], |
| 95 | prefer: false, |
| 96 | system_shared_libs: [], |
| 97 | stl: "none", |
| 98 | } |
| 99 | |
| 100 | cc_prebuilt_library_shared { |
| 101 | name: "sdkmember_mysdk_1", |
| 102 | sdk_member_name: "sdkmember", |
| 103 | srcs: ["libfoo.so"], |
| 104 | system_shared_libs: [], |
| 105 | stl: "none", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 106 | // TODO: remove //apex_available:platform |
| 107 | apex_available: [ |
| 108 | "//apex_available:platform", |
| 109 | "myapex", |
| 110 | ], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | cc_prebuilt_library_shared { |
| 114 | name: "sdkmember_mysdk_2", |
| 115 | sdk_member_name: "sdkmember", |
| 116 | srcs: ["libfoo.so"], |
| 117 | system_shared_libs: [], |
| 118 | stl: "none", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 119 | // TODO: remove //apex_available:platform |
| 120 | apex_available: [ |
| 121 | "//apex_available:platform", |
| 122 | "myapex2", |
| 123 | ], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | cc_library_shared { |
| 127 | name: "mycpplib", |
| 128 | srcs: ["Test.cpp"], |
| 129 | shared_libs: ["sdkmember"], |
| 130 | system_shared_libs: [], |
| 131 | stl: "none", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 132 | apex_available: [ |
| 133 | "myapex", |
| 134 | "myapex2", |
| 135 | ], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | apex { |
| 139 | name: "myapex", |
| 140 | native_shared_libs: ["mycpplib"], |
| 141 | uses_sdks: ["mysdk@1"], |
| 142 | key: "myapex.key", |
| 143 | certificate: ":myapex.cert", |
| 144 | } |
| 145 | |
| 146 | apex { |
| 147 | name: "myapex2", |
| 148 | native_shared_libs: ["mycpplib"], |
| 149 | uses_sdks: ["mysdk@2"], |
| 150 | key: "myapex.key", |
| 151 | certificate: ":myapex.cert", |
| 152 | } |
| 153 | `) |
| 154 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 155 | sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_myapex").Rule("toc").Output |
| 156 | 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] | 157 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 158 | cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex") |
| 159 | cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex2") |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 160 | |
| 161 | // Depending on the uses_sdks value, different libs are linked |
| 162 | ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String()) |
| 163 | ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String()) |
| 164 | } |
| 165 | |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 166 | // Make sure the sdk can use host specific cc libraries static/shared and both. |
| 167 | func TestHostSdkWithCc(t *testing.T) { |
| 168 | testSdkWithCc(t, ` |
| 169 | sdk { |
| 170 | name: "mysdk", |
| 171 | device_supported: false, |
| 172 | host_supported: true, |
| 173 | native_shared_libs: ["sdkshared"], |
| 174 | native_static_libs: ["sdkstatic"], |
| 175 | } |
| 176 | |
| 177 | cc_library_host_shared { |
| 178 | name: "sdkshared", |
| 179 | system_shared_libs: [], |
| 180 | stl: "none", |
| 181 | } |
| 182 | |
| 183 | cc_library_host_static { |
| 184 | name: "sdkstatic", |
| 185 | system_shared_libs: [], |
| 186 | stl: "none", |
| 187 | } |
| 188 | `) |
| 189 | } |
| 190 | |
| 191 | // Make sure the sdk can use cc libraries static/shared and both. |
| 192 | func TestSdkWithCc(t *testing.T) { |
| 193 | testSdkWithCc(t, ` |
| 194 | sdk { |
| 195 | name: "mysdk", |
| 196 | native_shared_libs: ["sdkshared", "sdkboth1"], |
| 197 | native_static_libs: ["sdkstatic", "sdkboth2"], |
| 198 | } |
| 199 | |
| 200 | cc_library_shared { |
| 201 | name: "sdkshared", |
| 202 | system_shared_libs: [], |
| 203 | stl: "none", |
| 204 | } |
| 205 | |
| 206 | cc_library_static { |
| 207 | name: "sdkstatic", |
| 208 | system_shared_libs: [], |
| 209 | stl: "none", |
| 210 | } |
| 211 | |
| 212 | cc_library { |
| 213 | name: "sdkboth1", |
| 214 | system_shared_libs: [], |
| 215 | stl: "none", |
| 216 | } |
| 217 | |
| 218 | cc_library { |
| 219 | name: "sdkboth2", |
| 220 | system_shared_libs: [], |
| 221 | stl: "none", |
| 222 | } |
| 223 | `) |
| 224 | } |
| 225 | |
Paul Duffin | c62a510 | 2019-12-11 18:34:15 +0000 | [diff] [blame] | 226 | func TestSnapshotWithCcDuplicateHeaders(t *testing.T) { |
| 227 | result := testSdkWithCc(t, ` |
| 228 | sdk { |
| 229 | name: "mysdk", |
| 230 | native_shared_libs: ["mynativelib1", "mynativelib2"], |
| 231 | } |
| 232 | |
| 233 | cc_library_shared { |
| 234 | name: "mynativelib1", |
| 235 | srcs: [ |
| 236 | "Test.cpp", |
| 237 | ], |
| 238 | export_include_dirs: ["include"], |
| 239 | system_shared_libs: [], |
| 240 | stl: "none", |
| 241 | } |
| 242 | |
| 243 | cc_library_shared { |
| 244 | name: "mynativelib2", |
| 245 | srcs: [ |
| 246 | "Test.cpp", |
| 247 | ], |
| 248 | export_include_dirs: ["include"], |
| 249 | system_shared_libs: [], |
| 250 | stl: "none", |
| 251 | } |
| 252 | `) |
| 253 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 254 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | c62a510 | 2019-12-11 18:34:15 +0000 | [diff] [blame] | 255 | checkAllCopyRules(` |
| 256 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 257 | .intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so |
| 258 | .intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so |
| 259 | .intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so |
| 260 | .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] | 261 | `), |
| 262 | ) |
| 263 | } |
| 264 | |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 265 | // Verify that when the shared library has some common and some arch specific properties that the generated |
| 266 | // snapshot is optimized properly. |
| 267 | func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) { |
| 268 | result := testSdkWithCc(t, ` |
| 269 | sdk { |
| 270 | name: "mysdk", |
| 271 | native_shared_libs: ["mynativelib"], |
| 272 | } |
| 273 | |
| 274 | cc_library_shared { |
| 275 | name: "mynativelib", |
| 276 | srcs: [ |
| 277 | "Test.cpp", |
| 278 | "aidl/foo/bar/Test.aidl", |
| 279 | ], |
| 280 | export_include_dirs: ["include"], |
| 281 | arch: { |
| 282 | arm64: { |
| 283 | export_system_include_dirs: ["arm64/include"], |
| 284 | }, |
| 285 | }, |
| 286 | system_shared_libs: [], |
| 287 | stl: "none", |
| 288 | } |
| 289 | `) |
| 290 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 291 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a7cd8c8 | 2019-12-11 20:00:57 +0000 | [diff] [blame] | 292 | checkAndroidBpContents(` |
| 293 | // This is auto-generated. DO NOT EDIT. |
| 294 | |
| 295 | cc_prebuilt_library_shared { |
| 296 | name: "mysdk_mynativelib@current", |
| 297 | sdk_member_name: "mynativelib", |
| 298 | export_include_dirs: ["include/include"], |
| 299 | arch: { |
| 300 | arm64: { |
| 301 | srcs: ["arm64/lib/mynativelib.so"], |
| 302 | export_system_include_dirs: ["arm64/include/arm64/include"], |
| 303 | }, |
| 304 | arm: { |
| 305 | srcs: ["arm/lib/mynativelib.so"], |
| 306 | }, |
| 307 | }, |
| 308 | stl: "none", |
| 309 | system_shared_libs: [], |
| 310 | } |
| 311 | |
| 312 | cc_prebuilt_library_shared { |
| 313 | name: "mynativelib", |
| 314 | prefer: false, |
| 315 | export_include_dirs: ["include/include"], |
| 316 | arch: { |
| 317 | arm64: { |
| 318 | srcs: ["arm64/lib/mynativelib.so"], |
| 319 | export_system_include_dirs: ["arm64/include/arm64/include"], |
| 320 | }, |
| 321 | arm: { |
| 322 | srcs: ["arm/lib/mynativelib.so"], |
| 323 | }, |
| 324 | }, |
| 325 | stl: "none", |
| 326 | system_shared_libs: [], |
| 327 | } |
| 328 | |
| 329 | sdk_snapshot { |
| 330 | name: "mysdk@current", |
| 331 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 332 | } |
| 333 | `), |
| 334 | checkAllCopyRules(` |
| 335 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 336 | .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] | 337 | arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 338 | .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] | 339 | ) |
| 340 | } |
| 341 | |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 342 | func TestSnapshotWithCcBinary(t *testing.T) { |
| 343 | result := testSdkWithCc(t, ` |
| 344 | module_exports { |
| 345 | name: "mymodule_exports", |
| 346 | native_binaries: ["mynativebinary"], |
| 347 | } |
| 348 | |
| 349 | cc_binary { |
| 350 | name: "mynativebinary", |
| 351 | srcs: [ |
| 352 | "Test.cpp", |
| 353 | ], |
| 354 | compile_multilib: "both", |
| 355 | system_shared_libs: [], |
| 356 | stl: "none", |
| 357 | } |
| 358 | `) |
| 359 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 360 | result.CheckSnapshot("mymodule_exports", "", |
Paul Duffin | 25ce04b | 2020-01-16 11:47:25 +0000 | [diff] [blame] | 361 | checkAndroidBpContents(` |
| 362 | // This is auto-generated. DO NOT EDIT. |
| 363 | |
| 364 | cc_prebuilt_binary { |
| 365 | name: "mymodule_exports_mynativebinary@current", |
| 366 | sdk_member_name: "mynativebinary", |
| 367 | compile_multilib: "both", |
| 368 | arch: { |
| 369 | arm64: { |
| 370 | srcs: ["arm64/bin/mynativebinary"], |
| 371 | }, |
| 372 | arm: { |
| 373 | srcs: ["arm/bin/mynativebinary"], |
| 374 | }, |
| 375 | }, |
| 376 | } |
| 377 | |
| 378 | cc_prebuilt_binary { |
| 379 | name: "mynativebinary", |
| 380 | prefer: false, |
| 381 | compile_multilib: "both", |
| 382 | arch: { |
| 383 | arm64: { |
| 384 | srcs: ["arm64/bin/mynativebinary"], |
| 385 | }, |
| 386 | arm: { |
| 387 | srcs: ["arm/bin/mynativebinary"], |
| 388 | }, |
| 389 | }, |
| 390 | } |
| 391 | |
| 392 | module_exports_snapshot { |
| 393 | name: "mymodule_exports@current", |
| 394 | native_binaries: ["mymodule_exports_mynativebinary@current"], |
| 395 | } |
| 396 | `), |
| 397 | checkAllCopyRules(` |
| 398 | .intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary |
| 399 | .intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary |
| 400 | `), |
| 401 | ) |
| 402 | } |
| 403 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 404 | func TestSnapshotWithCcSharedLibrary(t *testing.T) { |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 405 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 406 | sdk { |
| 407 | name: "mysdk", |
| 408 | native_shared_libs: ["mynativelib"], |
| 409 | } |
| 410 | |
| 411 | cc_library_shared { |
| 412 | name: "mynativelib", |
| 413 | srcs: [ |
| 414 | "Test.cpp", |
| 415 | "aidl/foo/bar/Test.aidl", |
| 416 | ], |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 417 | apex_available: ["apex1", "apex2"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 418 | export_include_dirs: ["include"], |
| 419 | aidl: { |
| 420 | export_aidl_headers: true, |
| 421 | }, |
| 422 | system_shared_libs: [], |
| 423 | stl: "none", |
| 424 | } |
| 425 | `) |
| 426 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 427 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 428 | checkAndroidBpContents(` |
| 429 | // This is auto-generated. DO NOT EDIT. |
| 430 | |
| 431 | cc_prebuilt_library_shared { |
| 432 | name: "mysdk_mynativelib@current", |
| 433 | sdk_member_name: "mynativelib", |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 434 | apex_available: [ |
| 435 | "apex1", |
| 436 | "apex2", |
| 437 | ], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 438 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 439 | arch: { |
| 440 | arm64: { |
| 441 | srcs: ["arm64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 442 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 443 | }, |
| 444 | arm: { |
| 445 | srcs: ["arm/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 446 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 447 | }, |
| 448 | }, |
| 449 | stl: "none", |
| 450 | system_shared_libs: [], |
| 451 | } |
| 452 | |
| 453 | cc_prebuilt_library_shared { |
| 454 | name: "mynativelib", |
| 455 | prefer: false, |
Paul Duffin | befa4b9 | 2020-03-04 14:22:45 +0000 | [diff] [blame] | 456 | apex_available: [ |
| 457 | "apex1", |
| 458 | "apex2", |
| 459 | ], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 460 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 461 | arch: { |
| 462 | arm64: { |
| 463 | srcs: ["arm64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 464 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 465 | }, |
| 466 | arm: { |
| 467 | srcs: ["arm/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 468 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 469 | }, |
| 470 | }, |
| 471 | stl: "none", |
| 472 | system_shared_libs: [], |
| 473 | } |
| 474 | |
| 475 | sdk_snapshot { |
| 476 | name: "mysdk@current", |
| 477 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 478 | } |
| 479 | `), |
| 480 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 481 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 482 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
| 483 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 484 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 485 | .intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 486 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so |
| 487 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 488 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 489 | .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] | 490 | `), |
| 491 | ) |
| 492 | } |
| 493 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 494 | func TestHostSnapshotWithCcSharedLibrary(t *testing.T) { |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 495 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 496 | SkipIfNotLinux(t) |
| 497 | |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 498 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 499 | sdk { |
| 500 | name: "mysdk", |
| 501 | device_supported: false, |
| 502 | host_supported: true, |
| 503 | native_shared_libs: ["mynativelib"], |
| 504 | } |
| 505 | |
| 506 | cc_library_shared { |
| 507 | name: "mynativelib", |
| 508 | device_supported: false, |
| 509 | host_supported: true, |
| 510 | srcs: [ |
| 511 | "Test.cpp", |
| 512 | "aidl/foo/bar/Test.aidl", |
| 513 | ], |
| 514 | export_include_dirs: ["include"], |
| 515 | aidl: { |
| 516 | export_aidl_headers: true, |
| 517 | }, |
| 518 | system_shared_libs: [], |
| 519 | stl: "none", |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 520 | sdk_version: "minimum", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 521 | } |
| 522 | `) |
| 523 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 524 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 525 | checkAndroidBpContents(` |
| 526 | // This is auto-generated. DO NOT EDIT. |
| 527 | |
| 528 | cc_prebuilt_library_shared { |
| 529 | name: "mysdk_mynativelib@current", |
| 530 | sdk_member_name: "mynativelib", |
| 531 | device_supported: false, |
| 532 | host_supported: true, |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 533 | sdk_version: "minimum", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 534 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 535 | arch: { |
| 536 | x86_64: { |
| 537 | srcs: ["x86_64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 538 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 539 | }, |
| 540 | x86: { |
| 541 | srcs: ["x86/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 542 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 543 | }, |
| 544 | }, |
| 545 | stl: "none", |
| 546 | system_shared_libs: [], |
| 547 | } |
| 548 | |
| 549 | cc_prebuilt_library_shared { |
| 550 | name: "mynativelib", |
| 551 | prefer: false, |
| 552 | device_supported: false, |
| 553 | host_supported: true, |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 554 | sdk_version: "minimum", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 555 | export_include_dirs: ["include/include"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 556 | arch: { |
| 557 | x86_64: { |
| 558 | srcs: ["x86_64/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 559 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 560 | }, |
| 561 | x86: { |
| 562 | srcs: ["x86/lib/mynativelib.so"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 563 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 564 | }, |
| 565 | }, |
| 566 | stl: "none", |
| 567 | system_shared_libs: [], |
| 568 | } |
| 569 | |
| 570 | sdk_snapshot { |
| 571 | name: "mysdk@current", |
| 572 | device_supported: false, |
| 573 | host_supported: true, |
| 574 | native_shared_libs: ["mysdk_mynativelib@current"], |
| 575 | } |
| 576 | `), |
| 577 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 578 | include/Test.h -> include/include/Test.h |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 579 | .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] | 580 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 581 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 582 | .intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 583 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 584 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 585 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 586 | .intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 587 | `), |
| 588 | ) |
| 589 | } |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 590 | |
| 591 | func TestSnapshotWithCcStaticLibrary(t *testing.T) { |
| 592 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 593 | module_exports { |
| 594 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 595 | native_static_libs: ["mynativelib"], |
| 596 | } |
| 597 | |
| 598 | cc_library_static { |
| 599 | name: "mynativelib", |
| 600 | srcs: [ |
| 601 | "Test.cpp", |
| 602 | "aidl/foo/bar/Test.aidl", |
| 603 | ], |
| 604 | export_include_dirs: ["include"], |
| 605 | aidl: { |
| 606 | export_aidl_headers: true, |
| 607 | }, |
| 608 | system_shared_libs: [], |
| 609 | stl: "none", |
| 610 | } |
| 611 | `) |
| 612 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 613 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 614 | checkAndroidBpContents(` |
| 615 | // This is auto-generated. DO NOT EDIT. |
| 616 | |
| 617 | cc_prebuilt_library_static { |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 618 | name: "myexports_mynativelib@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 619 | sdk_member_name: "mynativelib", |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 620 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 621 | arch: { |
| 622 | arm64: { |
| 623 | srcs: ["arm64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 624 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 625 | }, |
| 626 | arm: { |
| 627 | srcs: ["arm/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 628 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 629 | }, |
| 630 | }, |
| 631 | stl: "none", |
| 632 | system_shared_libs: [], |
| 633 | } |
| 634 | |
| 635 | cc_prebuilt_library_static { |
| 636 | name: "mynativelib", |
| 637 | prefer: false, |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 638 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 639 | arch: { |
| 640 | arm64: { |
| 641 | srcs: ["arm64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 642 | export_include_dirs: ["arm64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 643 | }, |
| 644 | arm: { |
| 645 | srcs: ["arm/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 646 | export_include_dirs: ["arm/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 647 | }, |
| 648 | }, |
| 649 | stl: "none", |
| 650 | system_shared_libs: [], |
| 651 | } |
| 652 | |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 653 | module_exports_snapshot { |
| 654 | name: "myexports@current", |
| 655 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 656 | } |
| 657 | `), |
| 658 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 659 | include/Test.h -> include/include/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 660 | .intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a |
| 661 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 662 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 663 | .intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 664 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a |
| 665 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 666 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 667 | .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] | 668 | `), |
| 669 | ) |
| 670 | } |
| 671 | |
| 672 | func TestHostSnapshotWithCcStaticLibrary(t *testing.T) { |
| 673 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 674 | SkipIfNotLinux(t) |
| 675 | |
| 676 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 677 | module_exports { |
| 678 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 679 | device_supported: false, |
| 680 | host_supported: true, |
| 681 | native_static_libs: ["mynativelib"], |
| 682 | } |
| 683 | |
| 684 | cc_library_static { |
| 685 | name: "mynativelib", |
| 686 | device_supported: false, |
| 687 | host_supported: true, |
| 688 | srcs: [ |
| 689 | "Test.cpp", |
| 690 | "aidl/foo/bar/Test.aidl", |
| 691 | ], |
| 692 | export_include_dirs: ["include"], |
| 693 | aidl: { |
| 694 | export_aidl_headers: true, |
| 695 | }, |
| 696 | system_shared_libs: [], |
| 697 | stl: "none", |
| 698 | } |
| 699 | `) |
| 700 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 701 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 702 | checkAndroidBpContents(` |
| 703 | // This is auto-generated. DO NOT EDIT. |
| 704 | |
| 705 | cc_prebuilt_library_static { |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 706 | name: "myexports_mynativelib@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 707 | sdk_member_name: "mynativelib", |
| 708 | device_supported: false, |
| 709 | host_supported: true, |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 710 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 711 | arch: { |
| 712 | x86_64: { |
| 713 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 714 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 715 | }, |
| 716 | x86: { |
| 717 | srcs: ["x86/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 718 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 719 | }, |
| 720 | }, |
| 721 | stl: "none", |
| 722 | system_shared_libs: [], |
| 723 | } |
| 724 | |
| 725 | cc_prebuilt_library_static { |
| 726 | name: "mynativelib", |
| 727 | prefer: false, |
| 728 | device_supported: false, |
| 729 | host_supported: true, |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 730 | export_include_dirs: ["include/include"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 731 | arch: { |
| 732 | x86_64: { |
| 733 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 734 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 735 | }, |
| 736 | x86: { |
| 737 | srcs: ["x86/lib/mynativelib.a"], |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 738 | export_include_dirs: ["x86/include_gen/mynativelib"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 739 | }, |
| 740 | }, |
| 741 | stl: "none", |
| 742 | system_shared_libs: [], |
| 743 | } |
| 744 | |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 745 | module_exports_snapshot { |
| 746 | name: "myexports@current", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 747 | device_supported: false, |
| 748 | host_supported: true, |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 749 | native_static_libs: ["myexports_mynativelib@current"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 750 | } |
| 751 | `), |
| 752 | checkAllCopyRules(` |
Paul Duffin | 57b9e1d | 2019-12-13 00:03:35 +0000 | [diff] [blame] | 753 | include/Test.h -> include/include/Test.h |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 754 | .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] | 755 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 756 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 757 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 758 | .intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 759 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 760 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 761 | .intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 762 | `), |
| 763 | ) |
| 764 | } |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 765 | |
| 766 | func TestHostSnapshotWithMultiLib64(t *testing.T) { |
| 767 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 768 | SkipIfNotLinux(t) |
| 769 | |
| 770 | result := testSdkWithCc(t, ` |
| 771 | module_exports { |
| 772 | name: "myexports", |
| 773 | device_supported: false, |
| 774 | host_supported: true, |
| 775 | target: { |
| 776 | host: { |
| 777 | compile_multilib: "64", |
| 778 | }, |
| 779 | }, |
| 780 | native_static_libs: ["mynativelib"], |
| 781 | } |
| 782 | |
| 783 | cc_library_static { |
| 784 | name: "mynativelib", |
| 785 | device_supported: false, |
| 786 | host_supported: true, |
| 787 | srcs: [ |
| 788 | "Test.cpp", |
| 789 | "aidl/foo/bar/Test.aidl", |
| 790 | ], |
| 791 | export_include_dirs: ["include"], |
| 792 | aidl: { |
| 793 | export_aidl_headers: true, |
| 794 | }, |
| 795 | system_shared_libs: [], |
| 796 | stl: "none", |
| 797 | } |
| 798 | `) |
| 799 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 800 | result.CheckSnapshot("myexports", "", |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 801 | checkAndroidBpContents(` |
| 802 | // This is auto-generated. DO NOT EDIT. |
| 803 | |
| 804 | cc_prebuilt_library_static { |
| 805 | name: "myexports_mynativelib@current", |
| 806 | sdk_member_name: "mynativelib", |
| 807 | device_supported: false, |
| 808 | host_supported: true, |
| 809 | export_include_dirs: ["include/include"], |
| 810 | arch: { |
| 811 | x86_64: { |
| 812 | srcs: ["x86_64/lib/mynativelib.a"], |
| 813 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
| 814 | }, |
| 815 | }, |
| 816 | stl: "none", |
| 817 | system_shared_libs: [], |
| 818 | } |
| 819 | |
| 820 | cc_prebuilt_library_static { |
| 821 | name: "mynativelib", |
| 822 | prefer: false, |
| 823 | device_supported: false, |
| 824 | host_supported: true, |
| 825 | export_include_dirs: ["include/include"], |
| 826 | arch: { |
| 827 | x86_64: { |
| 828 | srcs: ["x86_64/lib/mynativelib.a"], |
| 829 | export_include_dirs: ["x86_64/include_gen/mynativelib"], |
| 830 | }, |
| 831 | }, |
| 832 | stl: "none", |
| 833 | system_shared_libs: [], |
| 834 | } |
| 835 | |
| 836 | module_exports_snapshot { |
| 837 | name: "myexports@current", |
| 838 | device_supported: false, |
| 839 | host_supported: true, |
| 840 | target: { |
| 841 | host: { |
| 842 | compile_multilib: "64", |
| 843 | }, |
| 844 | }, |
| 845 | native_static_libs: ["myexports_mynativelib@current"], |
| 846 | }`), |
| 847 | checkAllCopyRules(` |
| 848 | include/Test.h -> include/include/Test.h |
| 849 | .intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a |
| 850 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h |
| 851 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h |
| 852 | .intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h |
| 853 | `), |
| 854 | ) |
| 855 | } |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 856 | |
| 857 | func TestSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 858 | result := testSdkWithCc(t, ` |
| 859 | sdk { |
| 860 | name: "mysdk", |
| 861 | native_header_libs: ["mynativeheaders"], |
| 862 | } |
| 863 | |
| 864 | cc_library_headers { |
| 865 | name: "mynativeheaders", |
| 866 | export_include_dirs: ["include"], |
| 867 | system_shared_libs: [], |
| 868 | stl: "none", |
| 869 | } |
| 870 | `) |
| 871 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 872 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 873 | checkAndroidBpContents(` |
| 874 | // This is auto-generated. DO NOT EDIT. |
| 875 | |
| 876 | cc_prebuilt_library_headers { |
| 877 | name: "mysdk_mynativeheaders@current", |
| 878 | sdk_member_name: "mynativeheaders", |
| 879 | export_include_dirs: ["include/include"], |
| 880 | stl: "none", |
| 881 | system_shared_libs: [], |
| 882 | } |
| 883 | |
| 884 | cc_prebuilt_library_headers { |
| 885 | name: "mynativeheaders", |
| 886 | prefer: false, |
| 887 | export_include_dirs: ["include/include"], |
| 888 | stl: "none", |
| 889 | system_shared_libs: [], |
| 890 | } |
| 891 | |
| 892 | sdk_snapshot { |
| 893 | name: "mysdk@current", |
| 894 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 895 | } |
| 896 | `), |
| 897 | checkAllCopyRules(` |
| 898 | include/Test.h -> include/include/Test.h |
| 899 | `), |
| 900 | ) |
| 901 | } |
| 902 | |
| 903 | func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) { |
| 904 | // b/145598135 - Generating host snapshots for anything other than linux is not supported. |
| 905 | SkipIfNotLinux(t) |
| 906 | |
| 907 | result := testSdkWithCc(t, ` |
| 908 | sdk { |
| 909 | name: "mysdk", |
| 910 | device_supported: false, |
| 911 | host_supported: true, |
| 912 | native_header_libs: ["mynativeheaders"], |
| 913 | } |
| 914 | |
| 915 | cc_library_headers { |
| 916 | name: "mynativeheaders", |
| 917 | device_supported: false, |
| 918 | host_supported: true, |
| 919 | export_include_dirs: ["include"], |
| 920 | system_shared_libs: [], |
| 921 | stl: "none", |
| 922 | } |
| 923 | `) |
| 924 | |
Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 925 | result.CheckSnapshot("mysdk", "", |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 926 | checkAndroidBpContents(` |
| 927 | // This is auto-generated. DO NOT EDIT. |
| 928 | |
| 929 | cc_prebuilt_library_headers { |
| 930 | name: "mysdk_mynativeheaders@current", |
| 931 | sdk_member_name: "mynativeheaders", |
| 932 | device_supported: false, |
| 933 | host_supported: true, |
| 934 | export_include_dirs: ["include/include"], |
| 935 | stl: "none", |
| 936 | system_shared_libs: [], |
| 937 | } |
| 938 | |
| 939 | cc_prebuilt_library_headers { |
| 940 | name: "mynativeheaders", |
| 941 | prefer: false, |
| 942 | device_supported: false, |
| 943 | host_supported: true, |
| 944 | export_include_dirs: ["include/include"], |
| 945 | stl: "none", |
| 946 | system_shared_libs: [], |
| 947 | } |
| 948 | |
| 949 | sdk_snapshot { |
| 950 | name: "mysdk@current", |
| 951 | device_supported: false, |
| 952 | host_supported: true, |
| 953 | native_header_libs: ["mysdk_mynativeheaders@current"], |
| 954 | } |
| 955 | `), |
| 956 | checkAllCopyRules(` |
| 957 | include/Test.h -> include/include/Test.h |
| 958 | `), |
| 959 | ) |
| 960 | } |