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