Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [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 sysprop |
| 16 | |
| 17 | import ( |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 18 | "reflect" |
| 19 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 20 | "android/soong/android" |
| 21 | "android/soong/cc" |
| 22 | "android/soong/java" |
| 23 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 24 | "io/ioutil" |
| 25 | "os" |
| 26 | "strings" |
| 27 | "testing" |
| 28 | |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 29 | "github.com/google/blueprint" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 30 | "github.com/google/blueprint/proptools" |
| 31 | ) |
| 32 | |
| 33 | var buildDir string |
| 34 | |
| 35 | func setUp() { |
| 36 | var err error |
| 37 | buildDir, err = ioutil.TempDir("", "soong_sysprop_test") |
| 38 | if err != nil { |
| 39 | panic(err) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func tearDown() { |
| 44 | os.RemoveAll(buildDir) |
| 45 | } |
| 46 | |
| 47 | func TestMain(m *testing.M) { |
| 48 | run := func() int { |
| 49 | setUp() |
| 50 | defer tearDown() |
| 51 | |
| 52 | return m.Run() |
| 53 | } |
| 54 | |
| 55 | os.Exit(run()) |
| 56 | } |
| 57 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 58 | func testContext(config android.Config) *android.TestContext { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 59 | |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 60 | ctx := android.NewTestArchContext(config) |
Paul Duffin | f9b1da0 | 2019-12-18 19:51:55 +0000 | [diff] [blame] | 61 | java.RegisterJavaBuildComponents(ctx) |
| 62 | java.RegisterAppBuildComponents(ctx) |
Paul Duffin | 43dc1cc | 2019-12-19 11:18:54 +0000 | [diff] [blame] | 63 | java.RegisterSystemModulesBuildComponents(ctx) |
| 64 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 65 | ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 66 | ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) { |
| 67 | ctx.BottomUp("sysprop_deps", syspropDepsMutator).Parallel() |
| 68 | }) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 69 | |
Paul Duffin | 021f4e5 | 2020-07-30 16:04:17 +0100 | [diff] [blame] | 70 | android.RegisterPrebuiltMutators(ctx) |
| 71 | |
Paul Duffin | 77980a8 | 2019-12-19 16:01:36 +0000 | [diff] [blame] | 72 | cc.RegisterRequiredBuildComponentsForTest(ctx) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 73 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 74 | ctx.BottomUp("sysprop_java", java.SyspropMutator).Parallel() |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 75 | }) |
| 76 | |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 77 | ctx.RegisterModuleType("sysprop_library", syspropLibraryFactory) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 78 | |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 79 | ctx.Register() |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 80 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 81 | return ctx |
| 82 | } |
| 83 | |
| 84 | func run(t *testing.T, ctx *android.TestContext, config android.Config) { |
| 85 | t.Helper() |
| 86 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 87 | android.FailIfErrored(t, errs) |
| 88 | _, errs = ctx.PrepareBuildActions(config) |
| 89 | android.FailIfErrored(t, errs) |
| 90 | } |
| 91 | |
| 92 | func testConfig(env map[string]string, bp string, fs map[string][]byte) android.Config { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 93 | bp += cc.GatherRequiredDepsForTest(android.Android) |
| 94 | |
| 95 | mockFS := map[string][]byte{ |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 96 | "a.java": nil, |
| 97 | "b.java": nil, |
| 98 | "c.java": nil, |
| 99 | "d.cpp": nil, |
| 100 | "api/sysprop-platform-current.txt": nil, |
| 101 | "api/sysprop-platform-latest.txt": nil, |
| 102 | "api/sysprop-platform-on-product-current.txt": nil, |
| 103 | "api/sysprop-platform-on-product-latest.txt": nil, |
| 104 | "api/sysprop-vendor-current.txt": nil, |
| 105 | "api/sysprop-vendor-latest.txt": nil, |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 106 | "api/sysprop-vendor-on-product-current.txt": nil, |
| 107 | "api/sysprop-vendor-on-product-latest.txt": nil, |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 108 | "api/sysprop-odm-current.txt": nil, |
| 109 | "api/sysprop-odm-latest.txt": nil, |
| 110 | "framework/aidl/a.aidl": nil, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 111 | |
| 112 | // For framework-res, which is an implicit dependency for framework |
Dan Willemsen | 412160e | 2019-04-09 21:36:26 -0700 | [diff] [blame] | 113 | "AndroidManifest.xml": nil, |
| 114 | "build/make/target/product/security/testkey": nil, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 115 | |
| 116 | "build/soong/scripts/jar-wrapper.sh": nil, |
| 117 | |
| 118 | "build/make/core/proguard.flags": nil, |
| 119 | "build/make/core/proguard_basic_keeps.flags": nil, |
| 120 | |
| 121 | "jdk8/jre/lib/jce.jar": nil, |
| 122 | "jdk8/jre/lib/rt.jar": nil, |
| 123 | "jdk8/lib/tools.jar": nil, |
| 124 | |
| 125 | "bar-doc/a.java": nil, |
| 126 | "bar-doc/b.java": nil, |
| 127 | "bar-doc/IFoo.aidl": nil, |
| 128 | "bar-doc/known_oj_tags.txt": nil, |
| 129 | "external/doclava/templates-sdk": nil, |
| 130 | |
| 131 | "cert/new_cert.x509.pem": nil, |
| 132 | "cert/new_cert.pk8": nil, |
| 133 | |
| 134 | "android/sysprop/PlatformProperties.sysprop": nil, |
| 135 | "com/android/VendorProperties.sysprop": nil, |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 136 | "com/android2/OdmProperties.sysprop": nil, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | for k, v := range fs { |
| 140 | mockFS[k] = v |
| 141 | } |
| 142 | |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 143 | config := java.TestConfig(buildDir, env, bp, mockFS) |
Colin Cross | e4759b9 | 2019-02-15 10:37:39 -0800 | [diff] [blame] | 144 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 145 | config.TestProductVariables.DeviceSystemSdkVersions = []string{"28"} |
| 146 | config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current") |
| 147 | config.TestProductVariables.Platform_vndk_version = proptools.StringPtr("VER") |
Colin Cross | e4759b9 | 2019-02-15 10:37:39 -0800 | [diff] [blame] | 148 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 149 | return config |
| 150 | |
| 151 | } |
| 152 | |
| 153 | func test(t *testing.T, bp string) *android.TestContext { |
| 154 | t.Helper() |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 155 | config := testConfig(nil, bp, nil) |
| 156 | ctx := testContext(config) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 157 | run(t, ctx, config) |
| 158 | |
| 159 | return ctx |
| 160 | } |
| 161 | |
| 162 | func TestSyspropLibrary(t *testing.T) { |
| 163 | ctx := test(t, ` |
| 164 | sysprop_library { |
| 165 | name: "sysprop-platform", |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 166 | apex_available: ["//apex_available:platform"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 167 | srcs: ["android/sysprop/PlatformProperties.sysprop"], |
| 168 | api_packages: ["android.sysprop"], |
| 169 | property_owner: "Platform", |
| 170 | vendor_available: true, |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 171 | host_supported: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | sysprop_library { |
| 175 | name: "sysprop-platform-on-product", |
| 176 | srcs: ["android/sysprop/PlatformProperties.sysprop"], |
| 177 | api_packages: ["android.sysprop"], |
| 178 | property_owner: "Platform", |
| 179 | product_specific: true, |
| 180 | } |
| 181 | |
| 182 | sysprop_library { |
| 183 | name: "sysprop-vendor", |
| 184 | srcs: ["com/android/VendorProperties.sysprop"], |
| 185 | api_packages: ["com.android"], |
| 186 | property_owner: "Vendor", |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 187 | vendor: true, |
| 188 | } |
| 189 | |
| 190 | sysprop_library { |
| 191 | name: "sysprop-vendor-on-product", |
| 192 | srcs: ["com/android/VendorProperties.sysprop"], |
| 193 | api_packages: ["com.android"], |
| 194 | property_owner: "Vendor", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 195 | product_specific: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 196 | } |
| 197 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 198 | sysprop_library { |
| 199 | name: "sysprop-odm", |
| 200 | srcs: ["com/android2/OdmProperties.sysprop"], |
| 201 | api_packages: ["com.android2"], |
| 202 | property_owner: "Odm", |
| 203 | device_specific: true, |
| 204 | } |
| 205 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 206 | java_library { |
| 207 | name: "java-platform", |
| 208 | srcs: ["c.java"], |
| 209 | sdk_version: "system_current", |
| 210 | libs: ["sysprop-platform"], |
| 211 | } |
| 212 | |
| 213 | java_library { |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 214 | name: "java-platform-private", |
| 215 | srcs: ["c.java"], |
| 216 | platform_apis: true, |
| 217 | libs: ["sysprop-platform"], |
| 218 | } |
| 219 | |
| 220 | java_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 221 | name: "java-product", |
| 222 | srcs: ["c.java"], |
| 223 | sdk_version: "system_current", |
| 224 | product_specific: true, |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 225 | libs: ["sysprop-platform", "sysprop-vendor-on-product"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | java_library { |
| 229 | name: "java-vendor", |
| 230 | srcs: ["c.java"], |
| 231 | sdk_version: "system_current", |
| 232 | soc_specific: true, |
| 233 | libs: ["sysprop-platform", "sysprop-vendor"], |
| 234 | } |
| 235 | |
| 236 | cc_library { |
| 237 | name: "cc-client-platform", |
| 238 | srcs: ["d.cpp"], |
| 239 | static_libs: ["sysprop-platform"], |
| 240 | } |
| 241 | |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 242 | cc_library_static { |
| 243 | name: "cc-client-platform-static", |
| 244 | srcs: ["d.cpp"], |
| 245 | whole_static_libs: ["sysprop-platform"], |
| 246 | } |
| 247 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 248 | cc_library { |
| 249 | name: "cc-client-product", |
| 250 | srcs: ["d.cpp"], |
| 251 | product_specific: true, |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 252 | static_libs: ["sysprop-platform-on-product", "sysprop-vendor-on-product"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | cc_library { |
| 256 | name: "cc-client-vendor", |
| 257 | srcs: ["d.cpp"], |
| 258 | soc_specific: true, |
| 259 | static_libs: ["sysprop-platform", "sysprop-vendor"], |
| 260 | } |
Inseob Kim | 1f95976 | 2019-03-27 17:20:37 +0900 | [diff] [blame] | 261 | |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 262 | cc_library { |
| 263 | name: "libbase", |
| 264 | host_supported: true, |
| 265 | } |
| 266 | |
Inseob Kim | 1f95976 | 2019-03-27 17:20:37 +0900 | [diff] [blame] | 267 | cc_library_headers { |
| 268 | name: "libbase_headers", |
| 269 | vendor_available: true, |
| 270 | recovery_available: true, |
| 271 | } |
| 272 | |
| 273 | cc_library { |
| 274 | name: "liblog", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 275 | no_libcrt: true, |
Inseob Kim | 1f95976 | 2019-03-27 17:20:37 +0900 | [diff] [blame] | 276 | nocrt: true, |
| 277 | system_shared_libs: [], |
| 278 | recovery_available: true, |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 279 | host_supported: true, |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 280 | llndk_stubs: "liblog.llndk", |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | cc_binary_host { |
| 284 | name: "hostbin", |
| 285 | static_libs: ["sysprop-platform"], |
Inseob Kim | 1f95976 | 2019-03-27 17:20:37 +0900 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | llndk_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 289 | name: "liblog.llndk", |
Inseob Kim | 1f95976 | 2019-03-27 17:20:37 +0900 | [diff] [blame] | 290 | symbol_file: "", |
| 291 | } |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 292 | |
| 293 | java_library { |
| 294 | name: "sysprop-library-stub-platform", |
| 295 | sdk_version: "core_current", |
| 296 | } |
| 297 | |
| 298 | java_library { |
| 299 | name: "sysprop-library-stub-vendor", |
| 300 | soc_specific: true, |
| 301 | sdk_version: "core_current", |
| 302 | } |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 303 | |
| 304 | java_library { |
| 305 | name: "sysprop-library-stub-product", |
| 306 | product_specific: true, |
| 307 | sdk_version: "core_current", |
| 308 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 309 | `) |
| 310 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 311 | // Check for generated cc_library |
| 312 | for _, variant := range []string{ |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 313 | "android_vendor.VER_arm_armv7-a-neon_shared", |
| 314 | "android_vendor.VER_arm_armv7-a-neon_static", |
| 315 | "android_vendor.VER_arm64_armv8-a_shared", |
| 316 | "android_vendor.VER_arm64_armv8-a_static", |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 317 | } { |
| 318 | ctx.ModuleForTests("libsysprop-platform", variant) |
| 319 | ctx.ModuleForTests("libsysprop-vendor", variant) |
| 320 | ctx.ModuleForTests("libsysprop-odm", variant) |
| 321 | } |
| 322 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 323 | for _, variant := range []string{ |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 324 | "android_arm_armv7-a-neon_shared", |
| 325 | "android_arm_armv7-a-neon_static", |
| 326 | "android_arm64_armv8-a_shared", |
| 327 | "android_arm64_armv8-a_static", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 328 | } { |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 329 | library := ctx.ModuleForTests("libsysprop-platform", variant).Module().(*cc.Module) |
| 330 | expectedApexAvailableOnLibrary := []string{"//apex_available:platform"} |
| 331 | if !reflect.DeepEqual(library.ApexProperties.Apex_available, expectedApexAvailableOnLibrary) { |
| 332 | t.Errorf("apex available property on libsysprop-platform must be %#v, but was %#v.", |
| 333 | expectedApexAvailableOnLibrary, library.ApexProperties.Apex_available) |
| 334 | } |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 335 | |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 336 | // product variant of vendor-owned sysprop_library |
| 337 | ctx.ModuleForTests("libsysprop-vendor-on-product", variant) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | ctx.ModuleForTests("sysprop-platform", "android_common") |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 341 | ctx.ModuleForTests("sysprop-platform_public", "android_common") |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 342 | ctx.ModuleForTests("sysprop-vendor", "android_common") |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 343 | ctx.ModuleForTests("sysprop-vendor-on-product", "android_common") |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 344 | |
| 345 | // Check for exported includes |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 346 | coreVariant := "android_arm64_armv8-a_static" |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 347 | vendorVariant := "android_vendor.VER_arm64_armv8-a_static" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 348 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 349 | platformInternalPath := "libsysprop-platform/android_arm64_armv8-a_static/gen/sysprop/include" |
| 350 | platformPublicCorePath := "libsysprop-platform/android_arm64_armv8-a_static/gen/sysprop/public/include" |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 351 | platformPublicVendorPath := "libsysprop-platform/android_vendor.VER_arm64_armv8-a_static/gen/sysprop/public/include" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 352 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 353 | platformOnProductPath := "libsysprop-platform-on-product/android_arm64_armv8-a_static/gen/sysprop/public/include" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 354 | |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 355 | vendorInternalPath := "libsysprop-vendor/android_vendor.VER_arm64_armv8-a_static/gen/sysprop/include" |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 356 | vendorPublicPath := "libsysprop-vendor-on-product/android_arm64_armv8-a_static/gen/sysprop/public/include" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 357 | |
| 358 | platformClient := ctx.ModuleForTests("cc-client-platform", coreVariant) |
| 359 | platformFlags := platformClient.Rule("cc").Args["cFlags"] |
| 360 | |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 361 | // platform should use platform's internal header |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 362 | if !strings.Contains(platformFlags, platformInternalPath) { |
| 363 | t.Errorf("flags for platform must contain %#v, but was %#v.", |
| 364 | platformInternalPath, platformFlags) |
| 365 | } |
| 366 | |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 367 | platformStaticClient := ctx.ModuleForTests("cc-client-platform-static", coreVariant) |
| 368 | platformStaticFlags := platformStaticClient.Rule("cc").Args["cFlags"] |
| 369 | |
| 370 | // platform-static should use platform's internal header |
| 371 | if !strings.Contains(platformStaticFlags, platformInternalPath) { |
| 372 | t.Errorf("flags for platform-static must contain %#v, but was %#v.", |
| 373 | platformInternalPath, platformStaticFlags) |
| 374 | } |
| 375 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 376 | productClient := ctx.ModuleForTests("cc-client-product", coreVariant) |
| 377 | productFlags := productClient.Rule("cc").Args["cFlags"] |
| 378 | |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 379 | // Product should use platform's and vendor's public headers |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 380 | if !strings.Contains(productFlags, platformOnProductPath) || |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 381 | !strings.Contains(productFlags, vendorPublicPath) { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 382 | t.Errorf("flags for product must contain %#v and %#v, but was %#v.", |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 383 | platformPublicCorePath, vendorPublicPath, productFlags) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | vendorClient := ctx.ModuleForTests("cc-client-vendor", vendorVariant) |
| 387 | vendorFlags := vendorClient.Rule("cc").Args["cFlags"] |
| 388 | |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 389 | // Vendor should use platform's public header and vendor's internal header |
| 390 | if !strings.Contains(vendorFlags, platformPublicVendorPath) || |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 391 | !strings.Contains(vendorFlags, vendorInternalPath) { |
| 392 | t.Errorf("flags for vendor must contain %#v and %#v, but was %#v.", |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 393 | platformPublicVendorPath, vendorInternalPath, vendorFlags) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 394 | } |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 395 | |
| 396 | // Java modules linking against system API should use public stub |
| 397 | javaSystemApiClient := ctx.ModuleForTests("java-platform", "android_common") |
| 398 | publicStubFound := false |
| 399 | ctx.VisitDirectDeps(javaSystemApiClient.Module(), func(dep blueprint.Module) { |
| 400 | if dep.Name() == "sysprop-platform_public" { |
| 401 | publicStubFound = true |
| 402 | } |
| 403 | }) |
| 404 | if !publicStubFound { |
| 405 | t.Errorf("system api client should use public stub") |
| 406 | } |
| 407 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 408 | } |