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