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