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