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