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