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 | |
| 808 | cc_library_shared { |
| 809 | name: "mynativelib", |
| 810 | srcs: [ |
| 811 | "Test.cpp", |
| 812 | "aidl/foo/bar/Test.aidl", |
| 813 | ], |
Chaitanya Cheemala (xWF) | 7a57092 | 2025-02-07 01:37:56 -0800 | [diff] [blame] | 814 | apex_available: ["apex1", "apex2"], |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 815 | export_include_dirs: ["myinclude"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 816 | aidl: { |
| 817 | export_aidl_headers: true, |
| 818 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 819 | stl: "none", |
| 820 | } |
| 821 | `) |
| 822 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 823 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 824 | checkAndroidBpContents(` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 825 | // This is auto-generated. DO NOT EDIT. |
| 826 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 827 | apex_contributions_defaults { |
| 828 | name: "mysdk.contributions", |
| 829 | contents: ["prebuilt_mynativelib"], |
| 830 | } |
| 831 | |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 832 | cc_prebuilt_library_shared { |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 833 | name: "mynativelib", |
| 834 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 835 | visibility: ["//visibility:public"], |
Chaitanya Cheemala (xWF) | 7a57092 | 2025-02-07 01:37:56 -0800 | [diff] [blame] | 836 | apex_available: [ |
| 837 | "apex1", |
| 838 | "apex2", |
| 839 | ], |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 840 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 841 | compile_multilib: "both", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 842 | export_include_dirs: ["include/myinclude"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 843 | arch: { |
| 844 | arm64: { |
| 845 | srcs: ["arm64/lib/mynativelib.so"], |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 846 | 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] | 847 | }, |
| 848 | arm: { |
| 849 | srcs: ["arm/lib/mynativelib.so"], |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 850 | 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] | 851 | }, |
| 852 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 853 | strip: { |
| 854 | none: true, |
| 855 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 856 | } |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 857 | `), |
| 858 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 859 | myinclude/Test.h -> include/myinclude/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 860 | .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] | 861 | .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 |
| 862 | .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 |
| 863 | .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] | 864 | .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] | 865 | .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 |
| 866 | .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 |
| 867 | .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] | 868 | `), |
| 869 | ) |
| 870 | } |
| 871 | |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 872 | func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 873 | t.Parallel() |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 874 | result := testSdkWithCc(t, ` |
| 875 | sdk { |
| 876 | name: "mysdk", |
| 877 | native_shared_libs: [ |
| 878 | "mynativelib", |
| 879 | "myothernativelib", |
| 880 | "mysystemnativelib", |
| 881 | ], |
| 882 | } |
| 883 | |
| 884 | cc_library { |
| 885 | name: "mysystemnativelib", |
| 886 | srcs: [ |
| 887 | "Test.cpp", |
| 888 | ], |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 889 | stl: "none", |
| 890 | } |
| 891 | |
| 892 | cc_library_shared { |
| 893 | name: "myothernativelib", |
| 894 | srcs: [ |
| 895 | "Test.cpp", |
| 896 | ], |
| 897 | system_shared_libs: [ |
| 898 | // A reference to a library that is not an sdk member. Uses libm as that |
| 899 | // is in the default set of modules available to this test and so is available |
| 900 | // both here and also when the generated Android.bp file is tested in |
| 901 | // CheckSnapshot(). This ensures that the system_shared_libs property correctly |
| 902 | // handles references to modules that are not sdk members. |
| 903 | "libm", |
| 904 | ], |
| 905 | stl: "none", |
| 906 | } |
| 907 | |
| 908 | cc_library { |
| 909 | name: "mynativelib", |
| 910 | srcs: [ |
| 911 | "Test.cpp", |
| 912 | ], |
| 913 | shared_libs: [ |
| 914 | // A reference to another sdk member. |
| 915 | "myothernativelib", |
| 916 | ], |
| 917 | target: { |
| 918 | android: { |
| 919 | shared: { |
| 920 | shared_libs: [ |
| 921 | // A reference to a library that is not an sdk member. The libc library |
| 922 | // is used here to check that the shared_libs property is handled correctly |
| 923 | // in a similar way to how libm is used to check system_shared_libs above. |
| 924 | "libc", |
| 925 | ], |
| 926 | }, |
| 927 | }, |
| 928 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 929 | stl: "none", |
| 930 | } |
| 931 | `) |
| 932 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 933 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 934 | checkAndroidBpContents(` |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 935 | // This is auto-generated. DO NOT EDIT. |
| 936 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 937 | apex_contributions_defaults { |
| 938 | name: "mysdk.contributions", |
| 939 | contents: [ |
| 940 | "prebuilt_mynativelib", |
| 941 | "prebuilt_myothernativelib", |
| 942 | "prebuilt_mysystemnativelib", |
| 943 | ], |
| 944 | } |
| 945 | |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 946 | cc_prebuilt_library_shared { |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 947 | name: "mynativelib", |
| 948 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 949 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 950 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 951 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 952 | compile_multilib: "both", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 953 | shared_libs: [ |
| 954 | "myothernativelib", |
| 955 | "libc", |
| 956 | ], |
| 957 | arch: { |
| 958 | arm64: { |
| 959 | srcs: ["arm64/lib/mynativelib.so"], |
| 960 | }, |
| 961 | arm: { |
| 962 | srcs: ["arm/lib/mynativelib.so"], |
| 963 | }, |
| 964 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 965 | strip: { |
| 966 | none: true, |
| 967 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | cc_prebuilt_library_shared { |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 971 | name: "myothernativelib", |
| 972 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 973 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 974 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 975 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 976 | compile_multilib: "both", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 977 | system_shared_libs: ["libm"], |
| 978 | arch: { |
| 979 | arm64: { |
| 980 | srcs: ["arm64/lib/myothernativelib.so"], |
| 981 | }, |
| 982 | arm: { |
| 983 | srcs: ["arm/lib/myothernativelib.so"], |
| 984 | }, |
| 985 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 986 | strip: { |
| 987 | none: true, |
| 988 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | cc_prebuilt_library_shared { |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 992 | name: "mysystemnativelib", |
| 993 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 994 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 995 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 996 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 997 | compile_multilib: "both", |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 998 | arch: { |
| 999 | arm64: { |
| 1000 | srcs: ["arm64/lib/mysystemnativelib.so"], |
| 1001 | }, |
| 1002 | arm: { |
| 1003 | srcs: ["arm/lib/mysystemnativelib.so"], |
| 1004 | }, |
| 1005 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 1006 | strip: { |
| 1007 | none: true, |
| 1008 | }, |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 1009 | } |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 1010 | `), |
| 1011 | checkAllCopyRules(` |
| 1012 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
| 1013 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so |
| 1014 | .intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so |
| 1015 | .intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so |
| 1016 | .intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so |
| 1017 | .intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so |
| 1018 | `), |
| 1019 | ) |
| 1020 | } |
| 1021 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1022 | func TestHostSnapshotWithCcSharedLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1023 | t.Parallel() |
Paul Duffin | d835daa | 2019-11-30 17:49:09 +0000 | [diff] [blame] | 1024 | result := testSdkWithCc(t, ` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1025 | sdk { |
| 1026 | name: "mysdk", |
| 1027 | device_supported: false, |
| 1028 | host_supported: true, |
| 1029 | native_shared_libs: ["mynativelib"], |
| 1030 | } |
| 1031 | |
| 1032 | cc_library_shared { |
| 1033 | name: "mynativelib", |
| 1034 | device_supported: false, |
| 1035 | host_supported: true, |
| 1036 | srcs: [ |
| 1037 | "Test.cpp", |
| 1038 | "aidl/foo/bar/Test.aidl", |
| 1039 | ], |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1040 | export_include_dirs: ["myinclude"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1041 | aidl: { |
| 1042 | export_aidl_headers: true, |
| 1043 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1044 | stl: "none", |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 1045 | sdk_version: "minimum", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1046 | } |
| 1047 | `) |
| 1048 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1049 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1050 | checkAndroidBpContents(` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1051 | // This is auto-generated. DO NOT EDIT. |
| 1052 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1053 | apex_contributions_defaults { |
| 1054 | name: "mysdk.contributions", |
| 1055 | contents: ["prebuilt_mynativelib"], |
| 1056 | } |
| 1057 | |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1058 | cc_prebuilt_library_shared { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1059 | name: "mynativelib", |
| 1060 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1061 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1062 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1063 | device_supported: false, |
| 1064 | host_supported: true, |
Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 1065 | sdk_version: "minimum", |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1066 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 1067 | compile_multilib: "both", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1068 | export_include_dirs: ["include/myinclude"], |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1069 | target: { |
| 1070 | host: { |
| 1071 | enabled: false, |
| 1072 | }, |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1073 | linux_glibc_x86_64: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 1074 | enabled: true, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1075 | srcs: ["x86_64/lib/mynativelib.so"], |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 1076 | 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] | 1077 | }, |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1078 | linux_glibc_x86: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 1079 | enabled: true, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1080 | srcs: ["x86/lib/mynativelib.so"], |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 1081 | 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] | 1082 | }, |
| 1083 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 1084 | strip: { |
| 1085 | none: true, |
| 1086 | }, |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1087 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1088 | `), |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1089 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1090 | myinclude/Test.h -> include/myinclude/Test.h |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1091 | .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] | 1092 | .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 |
| 1093 | .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 |
| 1094 | .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] | 1095 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 1096 | .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 |
| 1097 | .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 |
| 1098 | .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] | 1099 | `), |
| 1100 | ) |
| 1101 | } |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1102 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1103 | func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1104 | t.Parallel() |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1105 | result := testSdkWithCc(t, ` |
| 1106 | sdk { |
| 1107 | name: "mysdk", |
| 1108 | device_supported: false, |
| 1109 | host_supported: true, |
| 1110 | native_shared_libs: ["mynativelib"], |
| 1111 | target: { |
| 1112 | windows: { |
| 1113 | enabled: true, |
| 1114 | }, |
| 1115 | }, |
| 1116 | } |
| 1117 | |
| 1118 | cc_library_shared { |
| 1119 | name: "mynativelib", |
| 1120 | device_supported: false, |
| 1121 | host_supported: true, |
| 1122 | srcs: [ |
| 1123 | "Test.cpp", |
| 1124 | ], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1125 | stl: "none", |
| 1126 | target: { |
| 1127 | windows: { |
| 1128 | enabled: true, |
| 1129 | }, |
| 1130 | }, |
| 1131 | } |
| 1132 | `) |
| 1133 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1134 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1135 | checkAndroidBpContents(` |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1136 | // This is auto-generated. DO NOT EDIT. |
| 1137 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1138 | apex_contributions_defaults { |
| 1139 | name: "mysdk.contributions", |
| 1140 | contents: ["prebuilt_mynativelib"], |
| 1141 | } |
| 1142 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1143 | cc_prebuilt_library_shared { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1144 | name: "mynativelib", |
| 1145 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1146 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1147 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1148 | device_supported: false, |
| 1149 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1150 | stl: "none", |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1151 | target: { |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1152 | host: { |
| 1153 | enabled: false, |
| 1154 | }, |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 1155 | linux_glibc: { |
| 1156 | compile_multilib: "both", |
| 1157 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1158 | linux_glibc_x86_64: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 1159 | enabled: true, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1160 | srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], |
| 1161 | }, |
| 1162 | linux_glibc_x86: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 1163 | enabled: true, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1164 | srcs: ["linux_glibc/x86/lib/mynativelib.so"], |
| 1165 | }, |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 1166 | windows: { |
| 1167 | compile_multilib: "64", |
| 1168 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1169 | windows_x86_64: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 1170 | enabled: true, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1171 | srcs: ["windows/x86_64/lib/mynativelib.dll"], |
| 1172 | }, |
| 1173 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 1174 | strip: { |
| 1175 | none: true, |
| 1176 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1177 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1178 | `), |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1179 | checkAllCopyRules(` |
| 1180 | .intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so |
| 1181 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so |
| 1182 | .intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll |
| 1183 | `), |
| 1184 | ) |
| 1185 | } |
| 1186 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1187 | func TestSnapshotWithCcStaticLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1188 | t.Parallel() |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1189 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1190 | module_exports { |
| 1191 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1192 | native_static_libs: ["mynativelib"], |
| 1193 | } |
| 1194 | |
| 1195 | cc_library_static { |
| 1196 | name: "mynativelib", |
| 1197 | srcs: [ |
| 1198 | "Test.cpp", |
| 1199 | "aidl/foo/bar/Test.aidl", |
| 1200 | ], |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1201 | export_include_dirs: ["myinclude"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1202 | aidl: { |
| 1203 | export_aidl_headers: true, |
| 1204 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1205 | stl: "none", |
| 1206 | } |
| 1207 | `) |
| 1208 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1209 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1210 | checkAndroidBpContents(` |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1211 | // This is auto-generated. DO NOT EDIT. |
| 1212 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1213 | apex_contributions_defaults { |
| 1214 | name: "myexports.contributions", |
| 1215 | contents: ["prebuilt_mynativelib"], |
| 1216 | } |
| 1217 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1218 | cc_prebuilt_library_static { |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1219 | name: "mynativelib", |
| 1220 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1221 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1222 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1223 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 1224 | compile_multilib: "both", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1225 | export_include_dirs: ["include/myinclude"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1226 | arch: { |
| 1227 | arm64: { |
| 1228 | srcs: ["arm64/lib/mynativelib.a"], |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 1229 | 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] | 1230 | }, |
| 1231 | arm: { |
| 1232 | srcs: ["arm/lib/mynativelib.a"], |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 1233 | 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] | 1234 | }, |
| 1235 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1236 | } |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1237 | `), |
| 1238 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1239 | myinclude/Test.h -> include/myinclude/Test.h |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 1240 | .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] | 1241 | .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 |
| 1242 | .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 |
| 1243 | .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] | 1244 | .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] | 1245 | .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 |
| 1246 | .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 |
| 1247 | .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] | 1248 | `), |
| 1249 | ) |
| 1250 | } |
| 1251 | |
| 1252 | func TestHostSnapshotWithCcStaticLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1253 | t.Parallel() |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1254 | result := testSdkWithCc(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 1255 | module_exports { |
| 1256 | name: "myexports", |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1257 | device_supported: false, |
| 1258 | host_supported: true, |
| 1259 | native_static_libs: ["mynativelib"], |
| 1260 | } |
| 1261 | |
| 1262 | cc_library_static { |
| 1263 | name: "mynativelib", |
| 1264 | device_supported: false, |
| 1265 | host_supported: true, |
| 1266 | srcs: [ |
| 1267 | "Test.cpp", |
| 1268 | "aidl/foo/bar/Test.aidl", |
| 1269 | ], |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1270 | export_include_dirs: ["myinclude"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1271 | aidl: { |
| 1272 | export_aidl_headers: true, |
| 1273 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1274 | stl: "none", |
| 1275 | } |
| 1276 | `) |
| 1277 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1278 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1279 | checkAndroidBpContents(` |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1280 | // This is auto-generated. DO NOT EDIT. |
| 1281 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1282 | apex_contributions_defaults { |
| 1283 | name: "myexports.contributions", |
| 1284 | contents: ["prebuilt_mynativelib"], |
| 1285 | } |
| 1286 | |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1287 | cc_prebuilt_library_static { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1288 | name: "mynativelib", |
| 1289 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1290 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1291 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1292 | device_supported: false, |
| 1293 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1294 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 1295 | compile_multilib: "both", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1296 | export_include_dirs: ["include/myinclude"], |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1297 | target: { |
| 1298 | host: { |
| 1299 | enabled: false, |
| 1300 | }, |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1301 | linux_glibc_x86_64: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 1302 | enabled: true, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1303 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 1304 | 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] | 1305 | }, |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1306 | linux_glibc_x86: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 1307 | enabled: true, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1308 | srcs: ["x86/lib/mynativelib.a"], |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 1309 | 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] | 1310 | }, |
| 1311 | }, |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1312 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1313 | `), |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1314 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1315 | myinclude/Test.h -> include/myinclude/Test.h |
Paul Duffin | 9ab556f | 2019-12-11 18:42:17 +0000 | [diff] [blame] | 1316 | .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] | 1317 | .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 |
| 1318 | .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 |
| 1319 | .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] | 1320 | .intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a |
Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 1321 | .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 |
| 1322 | .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 |
| 1323 | .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] | 1324 | `), |
| 1325 | ) |
| 1326 | } |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1327 | |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1328 | func TestSnapshotWithCcLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1329 | t.Parallel() |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1330 | result := testSdkWithCc(t, ` |
| 1331 | module_exports { |
| 1332 | name: "myexports", |
| 1333 | native_libs: ["mynativelib"], |
| 1334 | } |
| 1335 | |
| 1336 | cc_library { |
| 1337 | name: "mynativelib", |
| 1338 | srcs: [ |
| 1339 | "Test.cpp", |
| 1340 | ], |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1341 | export_include_dirs: ["myinclude"], |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1342 | stl: "none", |
Paul Duffin | d6abaa7 | 2020-09-07 16:39:22 +0100 | [diff] [blame] | 1343 | recovery_available: true, |
Paul Duffin | d1edbd4 | 2020-08-13 19:45:31 +0100 | [diff] [blame] | 1344 | vendor_available: true, |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1345 | } |
| 1346 | `) |
| 1347 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1348 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1349 | checkAndroidBpContents(` |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1350 | // This is auto-generated. DO NOT EDIT. |
| 1351 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1352 | apex_contributions_defaults { |
| 1353 | name: "myexports.contributions", |
| 1354 | contents: ["prebuilt_mynativelib"], |
| 1355 | } |
| 1356 | |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1357 | cc_prebuilt_library { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1358 | name: "mynativelib", |
| 1359 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1360 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1361 | apex_available: ["//apex_available:platform"], |
Paul Duffin | d1edbd4 | 2020-08-13 19:45:31 +0100 | [diff] [blame] | 1362 | vendor_available: true, |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1363 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 1364 | compile_multilib: "both", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1365 | export_include_dirs: ["include/myinclude"], |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1366 | arch: { |
| 1367 | arm64: { |
| 1368 | static: { |
| 1369 | srcs: ["arm64/lib/mynativelib.a"], |
| 1370 | }, |
| 1371 | shared: { |
| 1372 | srcs: ["arm64/lib/mynativelib.so"], |
| 1373 | }, |
| 1374 | }, |
| 1375 | arm: { |
| 1376 | static: { |
| 1377 | srcs: ["arm/lib/mynativelib.a"], |
| 1378 | }, |
| 1379 | shared: { |
| 1380 | srcs: ["arm/lib/mynativelib.so"], |
| 1381 | }, |
| 1382 | }, |
| 1383 | }, |
| 1384 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1385 | `), |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1386 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1387 | myinclude/Test.h -> include/myinclude/Test.h |
Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 1388 | .intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a |
| 1389 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so |
| 1390 | .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] | 1391 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so |
| 1392 | `), |
| 1393 | // TODO(b/183315522): Remove this and fix the issue. |
| 1394 | 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] | 1395 | ) |
| 1396 | } |
| 1397 | |
Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 1398 | func TestSnapshotSameLibraryWithNativeLibsAndNativeSharedLib(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1399 | t.Parallel() |
Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 1400 | result := testSdkWithCc(t, ` |
| 1401 | module_exports { |
| 1402 | host_supported: true, |
| 1403 | name: "myexports", |
| 1404 | target: { |
| 1405 | android: { |
| 1406 | native_shared_libs: [ |
| 1407 | "mynativelib", |
| 1408 | ], |
| 1409 | }, |
| 1410 | not_windows: { |
| 1411 | native_libs: [ |
| 1412 | "mynativelib", |
| 1413 | ], |
| 1414 | }, |
| 1415 | }, |
| 1416 | } |
| 1417 | |
| 1418 | cc_library { |
| 1419 | name: "mynativelib", |
| 1420 | host_supported: true, |
| 1421 | srcs: [ |
| 1422 | "Test.cpp", |
| 1423 | ], |
| 1424 | stl: "none", |
| 1425 | recovery_available: true, |
| 1426 | vendor_available: true, |
| 1427 | } |
| 1428 | `) |
| 1429 | |
| 1430 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1431 | checkAndroidBpContents(` |
Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 1432 | // This is auto-generated. DO NOT EDIT. |
| 1433 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1434 | apex_contributions_defaults { |
| 1435 | name: "myexports.contributions", |
| 1436 | contents: ["prebuilt_mynativelib"], |
| 1437 | } |
| 1438 | |
Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 1439 | cc_prebuilt_library { |
| 1440 | name: "mynativelib", |
| 1441 | prefer: false, |
| 1442 | visibility: ["//visibility:public"], |
| 1443 | apex_available: ["//apex_available:platform"], |
| 1444 | host_supported: true, |
| 1445 | vendor_available: true, |
| 1446 | stl: "none", |
| 1447 | compile_multilib: "both", |
| 1448 | target: { |
| 1449 | host: { |
| 1450 | enabled: false, |
| 1451 | }, |
| 1452 | android_arm64: { |
| 1453 | shared: { |
| 1454 | srcs: ["android/arm64/lib/mynativelib.so"], |
| 1455 | }, |
| 1456 | static: { |
| 1457 | enabled: false, |
| 1458 | }, |
| 1459 | }, |
| 1460 | android_arm: { |
| 1461 | shared: { |
| 1462 | srcs: ["android/arm/lib/mynativelib.so"], |
| 1463 | }, |
| 1464 | static: { |
| 1465 | enabled: false, |
| 1466 | }, |
| 1467 | }, |
| 1468 | linux_glibc_x86_64: { |
| 1469 | enabled: true, |
| 1470 | static: { |
| 1471 | srcs: ["linux_glibc/x86_64/lib/mynativelib.a"], |
| 1472 | }, |
| 1473 | shared: { |
| 1474 | srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], |
| 1475 | }, |
| 1476 | }, |
| 1477 | linux_glibc_x86: { |
| 1478 | enabled: true, |
| 1479 | static: { |
| 1480 | srcs: ["linux_glibc/x86/lib/mynativelib.a"], |
| 1481 | }, |
| 1482 | shared: { |
| 1483 | srcs: ["linux_glibc/x86/lib/mynativelib.so"], |
| 1484 | }, |
| 1485 | }, |
| 1486 | }, |
| 1487 | } |
| 1488 | `), |
| 1489 | checkAllCopyRules(` |
| 1490 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> android/arm64/lib/mynativelib.so |
| 1491 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> android/arm/lib/mynativelib.so |
| 1492 | .intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> linux_glibc/x86_64/lib/mynativelib.a |
| 1493 | .intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so |
| 1494 | .intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> linux_glibc/x86/lib/mynativelib.a |
| 1495 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so |
| 1496 | `), |
| 1497 | ) |
| 1498 | } |
| 1499 | |
| 1500 | func TestSnapshotSameLibraryWithAndroidNativeLibsAndHostNativeSharedLib(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1501 | t.Parallel() |
Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 1502 | result := testSdkWithCc(t, ` |
| 1503 | module_exports { |
| 1504 | host_supported: true, |
| 1505 | name: "myexports", |
| 1506 | target: { |
| 1507 | android: { |
| 1508 | native_libs: [ |
| 1509 | "mynativelib", |
| 1510 | ], |
| 1511 | }, |
| 1512 | not_windows: { |
| 1513 | native_shared_libs: [ |
| 1514 | "mynativelib", |
| 1515 | ], |
| 1516 | }, |
| 1517 | }, |
| 1518 | } |
| 1519 | |
| 1520 | cc_library { |
| 1521 | name: "mynativelib", |
| 1522 | host_supported: true, |
| 1523 | srcs: [ |
| 1524 | "Test.cpp", |
| 1525 | ], |
| 1526 | stl: "none", |
| 1527 | recovery_available: true, |
| 1528 | vendor_available: true, |
| 1529 | } |
| 1530 | `) |
| 1531 | |
| 1532 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1533 | checkAndroidBpContents(` |
Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 1534 | // This is auto-generated. DO NOT EDIT. |
| 1535 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1536 | apex_contributions_defaults { |
| 1537 | name: "myexports.contributions", |
| 1538 | contents: ["prebuilt_mynativelib"], |
| 1539 | } |
| 1540 | |
Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 1541 | cc_prebuilt_library { |
| 1542 | name: "mynativelib", |
| 1543 | prefer: false, |
| 1544 | visibility: ["//visibility:public"], |
| 1545 | apex_available: ["//apex_available:platform"], |
| 1546 | host_supported: true, |
| 1547 | vendor_available: true, |
| 1548 | stl: "none", |
| 1549 | compile_multilib: "both", |
| 1550 | target: { |
| 1551 | host: { |
| 1552 | enabled: false, |
| 1553 | }, |
| 1554 | android_arm64: { |
| 1555 | static: { |
| 1556 | srcs: ["android/arm64/lib/mynativelib.a"], |
| 1557 | }, |
| 1558 | shared: { |
| 1559 | srcs: ["android/arm64/lib/mynativelib.so"], |
| 1560 | }, |
| 1561 | }, |
| 1562 | android_arm: { |
| 1563 | static: { |
| 1564 | srcs: ["android/arm/lib/mynativelib.a"], |
| 1565 | }, |
| 1566 | shared: { |
| 1567 | srcs: ["android/arm/lib/mynativelib.so"], |
| 1568 | }, |
| 1569 | }, |
| 1570 | linux_glibc_x86_64: { |
| 1571 | enabled: true, |
| 1572 | shared: { |
| 1573 | srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], |
| 1574 | }, |
| 1575 | static: { |
| 1576 | enabled: false, |
| 1577 | }, |
| 1578 | }, |
| 1579 | linux_glibc_x86: { |
| 1580 | enabled: true, |
| 1581 | shared: { |
| 1582 | srcs: ["linux_glibc/x86/lib/mynativelib.so"], |
| 1583 | }, |
| 1584 | static: { |
| 1585 | enabled: false, |
| 1586 | }, |
| 1587 | }, |
| 1588 | }, |
| 1589 | } |
| 1590 | `), |
| 1591 | checkAllCopyRules(` |
| 1592 | .intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> android/arm64/lib/mynativelib.a |
| 1593 | .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> android/arm64/lib/mynativelib.so |
| 1594 | .intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> android/arm/lib/mynativelib.a |
| 1595 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> android/arm/lib/mynativelib.so |
| 1596 | .intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so |
| 1597 | .intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so |
| 1598 | `), |
| 1599 | ) |
| 1600 | } |
| 1601 | |
| 1602 | func TestSnapshotSameLibraryWithNativeStaticLibsAndNativeSharedLib(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1603 | t.Parallel() |
Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 1604 | testSdkError(t, "Incompatible member types", ` |
| 1605 | module_exports { |
| 1606 | host_supported: true, |
| 1607 | name: "myexports", |
| 1608 | target: { |
| 1609 | android: { |
| 1610 | native_shared_libs: [ |
| 1611 | "mynativelib", |
| 1612 | ], |
| 1613 | }, |
| 1614 | not_windows: { |
| 1615 | native_static_libs: [ |
| 1616 | "mynativelib", |
| 1617 | ], |
| 1618 | }, |
| 1619 | }, |
| 1620 | } |
| 1621 | |
| 1622 | cc_library { |
| 1623 | name: "mynativelib", |
| 1624 | host_supported: true, |
| 1625 | srcs: [ |
| 1626 | ], |
| 1627 | stl: "none", |
| 1628 | recovery_available: true, |
| 1629 | vendor_available: true, |
| 1630 | } |
| 1631 | `) |
| 1632 | } |
| 1633 | |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1634 | func TestHostSnapshotWithMultiLib64(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1635 | t.Parallel() |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1636 | result := testSdkWithCc(t, ` |
| 1637 | module_exports { |
| 1638 | name: "myexports", |
| 1639 | device_supported: false, |
| 1640 | host_supported: true, |
| 1641 | target: { |
| 1642 | host: { |
| 1643 | compile_multilib: "64", |
| 1644 | }, |
| 1645 | }, |
| 1646 | native_static_libs: ["mynativelib"], |
| 1647 | } |
| 1648 | |
| 1649 | cc_library_static { |
| 1650 | name: "mynativelib", |
| 1651 | device_supported: false, |
| 1652 | host_supported: true, |
| 1653 | srcs: [ |
| 1654 | "Test.cpp", |
| 1655 | "aidl/foo/bar/Test.aidl", |
| 1656 | ], |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1657 | export_include_dirs: ["myinclude"], |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1658 | aidl: { |
| 1659 | export_aidl_headers: true, |
| 1660 | }, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1661 | stl: "none", |
| 1662 | } |
| 1663 | `) |
| 1664 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1665 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1666 | checkAndroidBpContents(` |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1667 | // This is auto-generated. DO NOT EDIT. |
| 1668 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1669 | apex_contributions_defaults { |
| 1670 | name: "myexports.contributions", |
| 1671 | contents: ["prebuilt_mynativelib"], |
| 1672 | } |
| 1673 | |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1674 | cc_prebuilt_library_static { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1675 | name: "mynativelib", |
| 1676 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1677 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1678 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1679 | device_supported: false, |
| 1680 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 1681 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 1682 | compile_multilib: "64", |
Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 1683 | export_include_dirs: [ |
| 1684 | "include/myinclude", |
| 1685 | "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl", |
| 1686 | ], |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1687 | target: { |
| 1688 | host: { |
| 1689 | enabled: false, |
| 1690 | }, |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1691 | linux_glibc_x86_64: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 1692 | enabled: true, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1693 | srcs: ["x86_64/lib/mynativelib.a"], |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1694 | }, |
| 1695 | }, |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1696 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1697 | `), |
Paul Duffin | 13ad94f | 2020-02-19 16:19:27 +0000 | [diff] [blame] | 1698 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1699 | myinclude/Test.h -> include/myinclude/Test.h |
Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 1700 | .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 |
| 1701 | .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 |
| 1702 | .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] | 1703 | .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] | 1704 | `), |
| 1705 | ) |
| 1706 | } |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1707 | |
| 1708 | func TestSnapshotWithCcHeadersLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1709 | t.Parallel() |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1710 | result := testSdkWithCc(t, ` |
| 1711 | sdk { |
| 1712 | name: "mysdk", |
| 1713 | native_header_libs: ["mynativeheaders"], |
| 1714 | } |
| 1715 | |
| 1716 | cc_library_headers { |
| 1717 | name: "mynativeheaders", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1718 | export_include_dirs: ["myinclude"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1719 | stl: "none", |
| 1720 | } |
| 1721 | `) |
| 1722 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1723 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1724 | checkAndroidBpContents(` |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1725 | // This is auto-generated. DO NOT EDIT. |
| 1726 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1727 | apex_contributions_defaults { |
| 1728 | name: "mysdk.contributions", |
| 1729 | contents: ["prebuilt_mynativeheaders"], |
| 1730 | } |
| 1731 | |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1732 | cc_prebuilt_library_headers { |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1733 | name: "mynativeheaders", |
| 1734 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1735 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1736 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1737 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 1738 | compile_multilib: "both", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1739 | export_include_dirs: ["include/myinclude"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1740 | } |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1741 | `), |
| 1742 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1743 | myinclude/Test.h -> include/myinclude/Test.h |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1744 | `), |
| 1745 | ) |
| 1746 | } |
| 1747 | |
Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 1748 | func TestSnapshotWithCcHeadersLibraryAndNativeBridgeSupport(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1749 | t.Parallel() |
Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 1750 | result := android.GroupFixturePreparers( |
| 1751 | cc.PrepareForTestWithCcDefaultModules, |
| 1752 | PrepareForTestWithSdkBuildComponents, |
| 1753 | ccTestFs.AddToFixture(), |
| 1754 | prepareForTestWithNativeBridgeTarget, |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1755 | android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { |
| 1756 | android.RegisterApexContributionsBuildComponents(ctx) |
| 1757 | }), |
Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 1758 | ).RunTestWithBp(t, ` |
| 1759 | sdk { |
| 1760 | name: "mysdk", |
| 1761 | native_header_libs: ["mynativeheaders"], |
| 1762 | traits: { |
| 1763 | native_bridge_support: ["mynativeheaders"], |
| 1764 | }, |
| 1765 | } |
| 1766 | |
| 1767 | cc_library_headers { |
| 1768 | name: "mynativeheaders", |
| 1769 | export_include_dirs: ["myinclude"], |
| 1770 | stl: "none", |
| 1771 | system_shared_libs: [], |
| 1772 | native_bridge_supported: true, |
| 1773 | } |
| 1774 | `) |
| 1775 | |
| 1776 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1777 | checkAndroidBpContents(` |
Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 1778 | // This is auto-generated. DO NOT EDIT. |
| 1779 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1780 | apex_contributions_defaults { |
| 1781 | name: "mysdk.contributions", |
| 1782 | contents: ["prebuilt_mynativeheaders"], |
| 1783 | } |
| 1784 | |
Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 1785 | cc_prebuilt_library_headers { |
| 1786 | name: "mynativeheaders", |
| 1787 | prefer: false, |
| 1788 | visibility: ["//visibility:public"], |
| 1789 | apex_available: ["//apex_available:platform"], |
| 1790 | native_bridge_supported: true, |
| 1791 | stl: "none", |
| 1792 | compile_multilib: "both", |
| 1793 | system_shared_libs: [], |
| 1794 | export_include_dirs: ["include/myinclude"], |
| 1795 | } |
| 1796 | `), |
| 1797 | checkAllCopyRules(` |
| 1798 | myinclude/Test.h -> include/myinclude/Test.h |
| 1799 | `), |
| 1800 | ) |
| 1801 | } |
| 1802 | |
| 1803 | // TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties verifies that when a |
| 1804 | // module that has different output files for a native bridge target requests the native bridge |
| 1805 | // variants are copied into the sdk snapshot that it reports an error. |
| 1806 | func TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1807 | t.Parallel() |
Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 1808 | android.GroupFixturePreparers( |
| 1809 | cc.PrepareForTestWithCcDefaultModules, |
| 1810 | PrepareForTestWithSdkBuildComponents, |
| 1811 | ccTestFs.AddToFixture(), |
| 1812 | prepareForTestWithNativeBridgeTarget, |
| 1813 | ).ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern( |
| 1814 | `\QArchitecture variant "arm64_native_bridge" of sdk member "mynativeheaders" has properties distinct from other variants; this is not yet supported. The properties are: |
| 1815 | export_include_dirs: [ |
| 1816 | "arm64_native_bridge/include/myinclude_nativebridge", |
| 1817 | "arm64_native_bridge/include/myinclude", |
| 1818 | ],\E`)). |
| 1819 | RunTestWithBp(t, ` |
| 1820 | sdk { |
| 1821 | name: "mysdk", |
| 1822 | native_header_libs: ["mynativeheaders"], |
| 1823 | traits: { |
| 1824 | native_bridge_support: ["mynativeheaders"], |
| 1825 | }, |
| 1826 | } |
| 1827 | |
| 1828 | cc_library_headers { |
| 1829 | name: "mynativeheaders", |
| 1830 | export_include_dirs: ["myinclude"], |
| 1831 | stl: "none", |
| 1832 | system_shared_libs: [], |
| 1833 | native_bridge_supported: true, |
| 1834 | target: { |
| 1835 | native_bridge: { |
| 1836 | export_include_dirs: ["myinclude_nativebridge"], |
| 1837 | }, |
| 1838 | }, |
| 1839 | } |
| 1840 | `) |
| 1841 | } |
| 1842 | |
Paul Duffin | 6369622 | 2021-09-06 10:28:34 +0100 | [diff] [blame] | 1843 | func TestSnapshotWithCcHeadersLibraryAndImageVariants(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1844 | t.Parallel() |
Paul Duffin | 6369622 | 2021-09-06 10:28:34 +0100 | [diff] [blame] | 1845 | testImageVariant := func(t *testing.T, property, trait string) { |
| 1846 | result := android.GroupFixturePreparers( |
| 1847 | cc.PrepareForTestWithCcDefaultModules, |
| 1848 | PrepareForTestWithSdkBuildComponents, |
| 1849 | ccTestFs.AddToFixture(), |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1850 | android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { |
| 1851 | android.RegisterApexContributionsBuildComponents(ctx) |
| 1852 | }), |
Paul Duffin | 6369622 | 2021-09-06 10:28:34 +0100 | [diff] [blame] | 1853 | ).RunTestWithBp(t, fmt.Sprintf(` |
| 1854 | sdk { |
| 1855 | name: "mysdk", |
| 1856 | native_header_libs: ["mynativeheaders"], |
| 1857 | traits: { |
| 1858 | %s: ["mynativeheaders"], |
| 1859 | }, |
| 1860 | } |
| 1861 | |
| 1862 | cc_library_headers { |
| 1863 | name: "mynativeheaders", |
| 1864 | export_include_dirs: ["myinclude"], |
| 1865 | stl: "none", |
| 1866 | system_shared_libs: [], |
| 1867 | %s: true, |
| 1868 | } |
| 1869 | `, trait, property)) |
| 1870 | |
| 1871 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1872 | checkAndroidBpContents(fmt.Sprintf(` |
Paul Duffin | 6369622 | 2021-09-06 10:28:34 +0100 | [diff] [blame] | 1873 | // This is auto-generated. DO NOT EDIT. |
| 1874 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1875 | apex_contributions_defaults { |
| 1876 | name: "mysdk.contributions", |
| 1877 | contents: ["prebuilt_mynativeheaders"], |
| 1878 | } |
| 1879 | |
Paul Duffin | 6369622 | 2021-09-06 10:28:34 +0100 | [diff] [blame] | 1880 | cc_prebuilt_library_headers { |
| 1881 | name: "mynativeheaders", |
| 1882 | prefer: false, |
| 1883 | visibility: ["//visibility:public"], |
| 1884 | apex_available: ["//apex_available:platform"], |
| 1885 | %s: true, |
| 1886 | stl: "none", |
| 1887 | compile_multilib: "both", |
| 1888 | system_shared_libs: [], |
| 1889 | export_include_dirs: ["include/myinclude"], |
| 1890 | } |
| 1891 | `, property)), |
| 1892 | checkAllCopyRules(` |
| 1893 | myinclude/Test.h -> include/myinclude/Test.h |
| 1894 | `), |
| 1895 | ) |
| 1896 | } |
| 1897 | |
Paul Duffin | 12a0a31 | 2021-09-15 17:25:10 +0100 | [diff] [blame] | 1898 | t.Run("ramdisk", func(t *testing.T) { |
| 1899 | testImageVariant(t, "ramdisk_available", "ramdisk_image_required") |
| 1900 | }) |
| 1901 | |
Paul Duffin | 6369622 | 2021-09-06 10:28:34 +0100 | [diff] [blame] | 1902 | t.Run("recovery", func(t *testing.T) { |
| 1903 | testImageVariant(t, "recovery_available", "recovery_image_required") |
| 1904 | }) |
| 1905 | } |
| 1906 | |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1907 | func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1908 | t.Parallel() |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1909 | result := testSdkWithCc(t, ` |
| 1910 | sdk { |
| 1911 | name: "mysdk", |
| 1912 | device_supported: false, |
| 1913 | host_supported: true, |
| 1914 | native_header_libs: ["mynativeheaders"], |
| 1915 | } |
| 1916 | |
| 1917 | cc_library_headers { |
| 1918 | name: "mynativeheaders", |
| 1919 | device_supported: false, |
| 1920 | host_supported: true, |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1921 | export_include_dirs: ["myinclude"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1922 | stl: "none", |
| 1923 | } |
| 1924 | `) |
| 1925 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1926 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1927 | checkAndroidBpContents(` |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1928 | // This is auto-generated. DO NOT EDIT. |
| 1929 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1930 | apex_contributions_defaults { |
| 1931 | name: "mysdk.contributions", |
| 1932 | contents: ["prebuilt_mynativeheaders"], |
| 1933 | } |
| 1934 | |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1935 | cc_prebuilt_library_headers { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1936 | name: "mynativeheaders", |
| 1937 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1938 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1939 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1940 | device_supported: false, |
| 1941 | host_supported: true, |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1942 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 1943 | compile_multilib: "both", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1944 | export_include_dirs: ["include/myinclude"], |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1945 | target: { |
| 1946 | host: { |
| 1947 | enabled: false, |
| 1948 | }, |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 1949 | linux_glibc_x86_64: { |
| 1950 | enabled: true, |
| 1951 | }, |
| 1952 | linux_glibc_x86: { |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 1953 | enabled: true, |
| 1954 | }, |
| 1955 | }, |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1956 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1957 | `), |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1958 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1959 | myinclude/Test.h -> include/myinclude/Test.h |
Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 1960 | `), |
| 1961 | ) |
| 1962 | } |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1963 | |
| 1964 | func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 1965 | t.Parallel() |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1966 | result := testSdkWithCc(t, ` |
| 1967 | sdk { |
| 1968 | name: "mysdk", |
| 1969 | host_supported: true, |
| 1970 | native_header_libs: ["mynativeheaders"], |
| 1971 | } |
| 1972 | |
| 1973 | cc_library_headers { |
| 1974 | name: "mynativeheaders", |
| 1975 | host_supported: true, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1976 | stl: "none", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1977 | export_system_include_dirs: ["myinclude"], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1978 | target: { |
| 1979 | android: { |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1980 | export_include_dirs: ["myinclude-android"], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1981 | }, |
| 1982 | host: { |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 1983 | export_include_dirs: ["myinclude-host"], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1984 | }, |
| 1985 | }, |
| 1986 | } |
| 1987 | `) |
| 1988 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1989 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1990 | checkAndroidBpContents(` |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1991 | // This is auto-generated. DO NOT EDIT. |
| 1992 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1993 | apex_contributions_defaults { |
| 1994 | name: "mysdk.contributions", |
| 1995 | contents: ["prebuilt_mynativeheaders"], |
| 1996 | } |
| 1997 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1998 | cc_prebuilt_library_headers { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 1999 | name: "mynativeheaders", |
| 2000 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 2001 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 2002 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 2003 | host_supported: true, |
Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 2004 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 2005 | compile_multilib: "both", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 2006 | export_system_include_dirs: ["common_os/include/myinclude"], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 2007 | target: { |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 2008 | host: { |
| 2009 | enabled: false, |
| 2010 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 2011 | android: { |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 2012 | export_include_dirs: ["android/include/myinclude-android"], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 2013 | }, |
| 2014 | linux_glibc: { |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 2015 | export_include_dirs: ["linux_glibc/include/myinclude-host"], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 2016 | }, |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 2017 | linux_glibc_x86_64: { |
| 2018 | enabled: true, |
| 2019 | }, |
| 2020 | linux_glibc_x86: { |
| 2021 | enabled: true, |
| 2022 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 2023 | }, |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 2024 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 2025 | `), |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 2026 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 2027 | myinclude/Test.h -> common_os/include/myinclude/Test.h |
| 2028 | myinclude-android/AndroidTest.h -> android/include/myinclude-android/AndroidTest.h |
| 2029 | myinclude-host/HostTest.h -> linux_glibc/include/myinclude-host/HostTest.h |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 2030 | `), |
| 2031 | ) |
| 2032 | } |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2033 | |
| 2034 | func TestSystemSharedLibPropagation(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 2035 | t.Parallel() |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2036 | result := testSdkWithCc(t, ` |
| 2037 | sdk { |
| 2038 | name: "mysdk", |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 2039 | native_shared_libs: ["sslnil", "sslempty", "sslnonempty"], |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2040 | } |
| 2041 | |
| 2042 | cc_library { |
| 2043 | name: "sslnil", |
| 2044 | host_supported: true, |
| 2045 | } |
| 2046 | |
| 2047 | cc_library { |
| 2048 | name: "sslempty", |
| 2049 | system_shared_libs: [], |
| 2050 | } |
| 2051 | |
| 2052 | cc_library { |
| 2053 | name: "sslnonempty", |
| 2054 | system_shared_libs: ["sslnil"], |
| 2055 | } |
| 2056 | `) |
| 2057 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 2058 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 2059 | checkAndroidBpContents(` |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2060 | // This is auto-generated. DO NOT EDIT. |
| 2061 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 2062 | apex_contributions_defaults { |
| 2063 | name: "mysdk.contributions", |
| 2064 | contents: [ |
| 2065 | "prebuilt_sslnil", |
| 2066 | "prebuilt_sslempty", |
| 2067 | "prebuilt_sslnonempty", |
| 2068 | ], |
| 2069 | } |
| 2070 | |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2071 | cc_prebuilt_library_shared { |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2072 | name: "sslnil", |
| 2073 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 2074 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 2075 | apex_available: ["//apex_available:platform"], |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 2076 | compile_multilib: "both", |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2077 | arch: { |
| 2078 | arm64: { |
| 2079 | srcs: ["arm64/lib/sslnil.so"], |
| 2080 | }, |
| 2081 | arm: { |
| 2082 | srcs: ["arm/lib/sslnil.so"], |
| 2083 | }, |
| 2084 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 2085 | strip: { |
| 2086 | none: true, |
| 2087 | }, |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2088 | } |
| 2089 | |
| 2090 | cc_prebuilt_library_shared { |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2091 | name: "sslempty", |
| 2092 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 2093 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 2094 | apex_available: ["//apex_available:platform"], |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 2095 | compile_multilib: "both", |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2096 | system_shared_libs: [], |
| 2097 | arch: { |
| 2098 | arm64: { |
| 2099 | srcs: ["arm64/lib/sslempty.so"], |
| 2100 | }, |
| 2101 | arm: { |
| 2102 | srcs: ["arm/lib/sslempty.so"], |
| 2103 | }, |
| 2104 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 2105 | strip: { |
| 2106 | none: true, |
| 2107 | }, |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2108 | } |
| 2109 | |
| 2110 | cc_prebuilt_library_shared { |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2111 | name: "sslnonempty", |
| 2112 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 2113 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 2114 | apex_available: ["//apex_available:platform"], |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 2115 | compile_multilib: "both", |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2116 | system_shared_libs: ["sslnil"], |
| 2117 | arch: { |
| 2118 | arm64: { |
| 2119 | srcs: ["arm64/lib/sslnonempty.so"], |
| 2120 | }, |
| 2121 | arm: { |
| 2122 | srcs: ["arm/lib/sslnonempty.so"], |
| 2123 | }, |
| 2124 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 2125 | strip: { |
| 2126 | none: true, |
| 2127 | }, |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2128 | } |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 2129 | `)) |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2130 | |
| 2131 | result = testSdkWithCc(t, ` |
| 2132 | sdk { |
| 2133 | name: "mysdk", |
| 2134 | host_supported: true, |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 2135 | native_shared_libs: ["sslvariants"], |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2136 | } |
| 2137 | |
| 2138 | cc_library { |
| 2139 | name: "sslvariants", |
| 2140 | host_supported: true, |
| 2141 | target: { |
| 2142 | android: { |
| 2143 | system_shared_libs: [], |
| 2144 | }, |
| 2145 | }, |
| 2146 | } |
| 2147 | `) |
| 2148 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 2149 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 2150 | checkAndroidBpContents(` |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2151 | // This is auto-generated. DO NOT EDIT. |
| 2152 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 2153 | apex_contributions_defaults { |
| 2154 | name: "mysdk.contributions", |
| 2155 | contents: ["prebuilt_sslvariants"], |
| 2156 | } |
| 2157 | |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2158 | cc_prebuilt_library_shared { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 2159 | name: "sslvariants", |
| 2160 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 2161 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 2162 | apex_available: ["//apex_available:platform"], |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2163 | host_supported: true, |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 2164 | compile_multilib: "both", |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2165 | target: { |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 2166 | host: { |
| 2167 | enabled: false, |
| 2168 | }, |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2169 | android: { |
| 2170 | system_shared_libs: [], |
| 2171 | }, |
| 2172 | android_arm64: { |
| 2173 | srcs: ["android/arm64/lib/sslvariants.so"], |
| 2174 | }, |
| 2175 | android_arm: { |
| 2176 | srcs: ["android/arm/lib/sslvariants.so"], |
| 2177 | }, |
| 2178 | linux_glibc_x86_64: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 2179 | enabled: true, |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2180 | srcs: ["linux_glibc/x86_64/lib/sslvariants.so"], |
| 2181 | }, |
| 2182 | linux_glibc_x86: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 2183 | enabled: true, |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2184 | srcs: ["linux_glibc/x86/lib/sslvariants.so"], |
| 2185 | }, |
| 2186 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 2187 | strip: { |
| 2188 | none: true, |
| 2189 | }, |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2190 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 2191 | `), |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 2192 | ) |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 2193 | } |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2194 | |
| 2195 | func TestStubsLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 2196 | t.Parallel() |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2197 | result := testSdkWithCc(t, ` |
| 2198 | sdk { |
| 2199 | name: "mysdk", |
| 2200 | native_shared_libs: ["stubslib"], |
| 2201 | } |
| 2202 | |
| 2203 | cc_library { |
Martin Stjernholm | cc330d6 | 2020-04-21 20:45:35 +0100 | [diff] [blame] | 2204 | name: "internaldep", |
| 2205 | } |
| 2206 | |
| 2207 | cc_library { |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2208 | name: "stubslib", |
Martin Stjernholm | cc330d6 | 2020-04-21 20:45:35 +0100 | [diff] [blame] | 2209 | shared_libs: ["internaldep"], |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2210 | stubs: { |
| 2211 | symbol_file: "some/where/stubslib.map.txt", |
| 2212 | versions: ["1", "2", "3"], |
| 2213 | }, |
| 2214 | } |
| 2215 | `) |
| 2216 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 2217 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 2218 | checkAndroidBpContents(` |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2219 | // This is auto-generated. DO NOT EDIT. |
| 2220 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 2221 | apex_contributions_defaults { |
| 2222 | name: "mysdk.contributions", |
| 2223 | contents: ["prebuilt_stubslib"], |
| 2224 | } |
| 2225 | |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2226 | cc_prebuilt_library_shared { |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2227 | name: "stubslib", |
| 2228 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 2229 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 2230 | apex_available: ["//apex_available:platform"], |
Colin Cross | 694fced | 2024-06-25 14:56:42 -0700 | [diff] [blame] | 2231 | stl: "none", |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 2232 | compile_multilib: "both", |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2233 | stubs: { |
Martin Stjernholm | 618b671 | 2020-09-24 16:53:04 +0100 | [diff] [blame] | 2234 | versions: [ |
| 2235 | "1", |
| 2236 | "2", |
| 2237 | "3", |
Jiyong Park | d4a3a13 | 2021-03-17 20:21:35 +0900 | [diff] [blame] | 2238 | "current", |
Martin Stjernholm | 618b671 | 2020-09-24 16:53:04 +0100 | [diff] [blame] | 2239 | ], |
Spandan Das | e20c56c | 2024-07-23 21:34:24 +0000 | [diff] [blame] | 2240 | symbol_file: "stubslib.map.txt", |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2241 | }, |
| 2242 | arch: { |
| 2243 | arm64: { |
| 2244 | srcs: ["arm64/lib/stubslib.so"], |
| 2245 | }, |
| 2246 | arm: { |
| 2247 | srcs: ["arm/lib/stubslib.so"], |
| 2248 | }, |
| 2249 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 2250 | strip: { |
| 2251 | none: true, |
| 2252 | }, |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2253 | } |
Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 2254 | `)) |
| 2255 | } |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2256 | |
| 2257 | func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 2258 | t.Parallel() |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2259 | result := testSdkWithCc(t, ` |
| 2260 | sdk { |
| 2261 | name: "mysdk", |
| 2262 | host_supported: true, |
| 2263 | native_shared_libs: ["stubslib"], |
| 2264 | } |
| 2265 | |
| 2266 | cc_library { |
| 2267 | name: "internaldep", |
| 2268 | host_supported: true, |
| 2269 | } |
| 2270 | |
| 2271 | cc_library { |
| 2272 | name: "stubslib", |
| 2273 | host_supported: true, |
| 2274 | shared_libs: ["internaldep"], |
| 2275 | stubs: { |
| 2276 | symbol_file: "some/where/stubslib.map.txt", |
| 2277 | versions: ["1", "2", "3"], |
| 2278 | }, |
| 2279 | } |
| 2280 | `) |
| 2281 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 2282 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 2283 | checkAndroidBpContents(` |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2284 | // This is auto-generated. DO NOT EDIT. |
| 2285 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 2286 | apex_contributions_defaults { |
| 2287 | name: "mysdk.contributions", |
| 2288 | contents: ["prebuilt_stubslib"], |
| 2289 | } |
| 2290 | |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2291 | cc_prebuilt_library_shared { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 2292 | name: "stubslib", |
| 2293 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 2294 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 2295 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2296 | host_supported: true, |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 2297 | compile_multilib: "both", |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2298 | stubs: { |
Martin Stjernholm | 618b671 | 2020-09-24 16:53:04 +0100 | [diff] [blame] | 2299 | versions: [ |
| 2300 | "1", |
| 2301 | "2", |
| 2302 | "3", |
Jiyong Park | d4a3a13 | 2021-03-17 20:21:35 +0900 | [diff] [blame] | 2303 | "current", |
Martin Stjernholm | 618b671 | 2020-09-24 16:53:04 +0100 | [diff] [blame] | 2304 | ], |
Spandan Das | e20c56c | 2024-07-23 21:34:24 +0000 | [diff] [blame] | 2305 | symbol_file: "stubslib.map.txt", |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2306 | }, |
| 2307 | target: { |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 2308 | host: { |
| 2309 | enabled: false, |
| 2310 | }, |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2311 | android_arm64: { |
| 2312 | srcs: ["android/arm64/lib/stubslib.so"], |
| 2313 | }, |
| 2314 | android_arm: { |
| 2315 | srcs: ["android/arm/lib/stubslib.so"], |
| 2316 | }, |
| 2317 | linux_glibc_x86_64: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 2318 | enabled: true, |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2319 | srcs: ["linux_glibc/x86_64/lib/stubslib.so"], |
| 2320 | }, |
| 2321 | linux_glibc_x86: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 2322 | enabled: true, |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2323 | srcs: ["linux_glibc/x86/lib/stubslib.so"], |
| 2324 | }, |
| 2325 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 2326 | strip: { |
| 2327 | none: true, |
| 2328 | }, |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2329 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 2330 | `), |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 2331 | ) |
Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 2332 | } |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2333 | |
| 2334 | func TestUniqueHostSoname(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 2335 | t.Parallel() |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2336 | result := testSdkWithCc(t, ` |
| 2337 | sdk { |
| 2338 | name: "mysdk", |
| 2339 | host_supported: true, |
| 2340 | native_shared_libs: ["mylib"], |
| 2341 | } |
| 2342 | |
| 2343 | cc_library { |
| 2344 | name: "mylib", |
| 2345 | host_supported: true, |
| 2346 | unique_host_soname: true, |
| 2347 | } |
| 2348 | `) |
| 2349 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 2350 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 2351 | checkAndroidBpContents(` |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2352 | // This is auto-generated. DO NOT EDIT. |
| 2353 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 2354 | apex_contributions_defaults { |
| 2355 | name: "mysdk.contributions", |
| 2356 | contents: ["prebuilt_mylib"], |
| 2357 | } |
| 2358 | |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2359 | cc_prebuilt_library_shared { |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 2360 | name: "mylib", |
| 2361 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 2362 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 2363 | apex_available: ["//apex_available:platform"], |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2364 | host_supported: true, |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2365 | unique_host_soname: true, |
Martin Stjernholm | 89238f4 | 2020-07-10 00:14:03 +0100 | [diff] [blame] | 2366 | compile_multilib: "both", |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2367 | target: { |
Martin Stjernholm | caa47d7 | 2020-07-11 04:52:24 +0100 | [diff] [blame] | 2368 | host: { |
| 2369 | enabled: false, |
| 2370 | }, |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2371 | android_arm64: { |
| 2372 | srcs: ["android/arm64/lib/mylib.so"], |
| 2373 | }, |
| 2374 | android_arm: { |
| 2375 | srcs: ["android/arm/lib/mylib.so"], |
| 2376 | }, |
| 2377 | linux_glibc_x86_64: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 2378 | enabled: true, |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2379 | srcs: ["linux_glibc/x86_64/lib/mylib-host.so"], |
| 2380 | }, |
| 2381 | linux_glibc_x86: { |
Jiyong Park | 8fe14e6 | 2020-10-19 22:47:34 +0900 | [diff] [blame] | 2382 | enabled: true, |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2383 | srcs: ["linux_glibc/x86/lib/mylib-host.so"], |
| 2384 | }, |
| 2385 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 2386 | strip: { |
| 2387 | none: true, |
| 2388 | }, |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2389 | } |
Paul Duffin | 75b902a | 2021-02-22 12:13:13 +0000 | [diff] [blame] | 2390 | `), |
Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 2391 | checkAllCopyRules(` |
| 2392 | .intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so |
| 2393 | .intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so |
| 2394 | .intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so |
| 2395 | .intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so |
| 2396 | `), |
| 2397 | ) |
| 2398 | } |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2399 | |
| 2400 | func TestNoSanitizerMembers(t *testing.T) { |
Colin Cross | aba8cd9 | 2025-02-05 16:39:18 -0800 | [diff] [blame] | 2401 | t.Parallel() |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2402 | result := testSdkWithCc(t, ` |
| 2403 | sdk { |
| 2404 | name: "mysdk", |
| 2405 | native_shared_libs: ["mynativelib"], |
| 2406 | } |
| 2407 | |
| 2408 | cc_library_shared { |
| 2409 | name: "mynativelib", |
| 2410 | srcs: ["Test.cpp"], |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 2411 | export_include_dirs: ["myinclude"], |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2412 | arch: { |
| 2413 | arm64: { |
| 2414 | export_system_include_dirs: ["arm64/include"], |
| 2415 | sanitize: { |
| 2416 | hwaddress: true, |
| 2417 | }, |
| 2418 | }, |
| 2419 | }, |
| 2420 | } |
| 2421 | `) |
| 2422 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 2423 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 2424 | checkAndroidBpContents(` |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2425 | // This is auto-generated. DO NOT EDIT. |
| 2426 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 2427 | apex_contributions_defaults { |
| 2428 | name: "mysdk.contributions", |
| 2429 | contents: ["prebuilt_mynativelib"], |
| 2430 | } |
| 2431 | |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2432 | cc_prebuilt_library_shared { |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2433 | name: "mynativelib", |
| 2434 | prefer: false, |
| 2435 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 2436 | apex_available: ["//apex_available:platform"], |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2437 | compile_multilib: "both", |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 2438 | export_include_dirs: ["include/myinclude"], |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2439 | arch: { |
| 2440 | arm64: { |
| 2441 | export_system_include_dirs: ["arm64/include/arm64/include"], |
| 2442 | }, |
| 2443 | arm: { |
| 2444 | srcs: ["arm/lib/mynativelib.so"], |
| 2445 | }, |
| 2446 | }, |
Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 2447 | strip: { |
| 2448 | none: true, |
| 2449 | }, |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2450 | } |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2451 | `), |
| 2452 | checkAllCopyRules(` |
Paul Duffin | 86b02a7 | 2021-02-22 11:50:04 +0000 | [diff] [blame] | 2453 | myinclude/Test.h -> include/myinclude/Test.h |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2454 | arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h |
Paul Duffin | 1822a0a | 2021-03-21 12:56:33 +0000 | [diff] [blame] | 2455 | .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so |
| 2456 | `), |
Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 2457 | ) |
| 2458 | } |