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