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