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