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