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