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