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