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 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 15 | // sysprop package defines a module named sysprop_library that can implement sysprop as API |
| 16 | // See https://source.android.com/devices/architecture/sysprops-apis for details |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 17 | package sysprop |
| 18 | |
| 19 | import ( |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 20 | "fmt" |
| 21 | "io" |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 22 | "os" |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 23 | "path" |
Inseob Kim | 628d7ef | 2020-03-21 03:38:32 +0900 | [diff] [blame] | 24 | "sync" |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 25 | |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 26 | "android/soong/bazel" |
Liz Kammer | 12dc96e | 2023-08-11 14:16:05 -0400 | [diff] [blame] | 27 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 28 | "github.com/google/blueprint" |
| 29 | "github.com/google/blueprint/proptools" |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 30 | |
| 31 | "android/soong/android" |
| 32 | "android/soong/cc" |
| 33 | "android/soong/java" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 34 | ) |
| 35 | |
| 36 | type dependencyTag struct { |
| 37 | blueprint.BaseDependencyTag |
| 38 | name string |
| 39 | } |
| 40 | |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 41 | type syspropGenProperties struct { |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 42 | Srcs []string `android:"path"` |
| 43 | Scope string |
| 44 | Name *string |
| 45 | Check_api *string |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | type syspropJavaGenRule struct { |
| 49 | android.ModuleBase |
| 50 | |
| 51 | properties syspropGenProperties |
| 52 | |
| 53 | genSrcjars android.Paths |
| 54 | } |
| 55 | |
| 56 | var _ android.OutputFileProducer = (*syspropJavaGenRule)(nil) |
| 57 | |
| 58 | var ( |
| 59 | syspropJava = pctx.AndroidStaticRule("syspropJava", |
| 60 | blueprint.RuleParams{ |
| 61 | Command: `rm -rf $out.tmp && mkdir -p $out.tmp && ` + |
| 62 | `$syspropJavaCmd --scope $scope --java-output-dir $out.tmp $in && ` + |
| 63 | `$soongZipCmd -jar -o $out -C $out.tmp -D $out.tmp && rm -rf $out.tmp`, |
| 64 | CommandDeps: []string{ |
| 65 | "$syspropJavaCmd", |
| 66 | "$soongZipCmd", |
| 67 | }, |
| 68 | }, "scope") |
| 69 | ) |
| 70 | |
| 71 | func init() { |
| 72 | pctx.HostBinToolVariable("soongZipCmd", "soong_zip") |
| 73 | pctx.HostBinToolVariable("syspropJavaCmd", "sysprop_java") |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 74 | } |
| 75 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 76 | // syspropJavaGenRule module generates srcjar containing generated java APIs. |
| 77 | // It also depends on check api rule, so api check has to pass to use sysprop_library. |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 78 | func (g *syspropJavaGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 79 | var checkApiFileTimeStamp android.WritablePath |
| 80 | |
| 81 | ctx.VisitDirectDeps(func(dep android.Module) { |
| 82 | if m, ok := dep.(*syspropLibrary); ok { |
| 83 | checkApiFileTimeStamp = m.checkApiFileTimeStamp |
| 84 | } |
| 85 | }) |
| 86 | |
| 87 | for _, syspropFile := range android.PathsForModuleSrc(ctx, g.properties.Srcs) { |
| 88 | srcJarFile := android.GenPathWithExt(ctx, "sysprop", syspropFile, "srcjar") |
| 89 | |
| 90 | ctx.Build(pctx, android.BuildParams{ |
| 91 | Rule: syspropJava, |
| 92 | Description: "sysprop_java " + syspropFile.Rel(), |
| 93 | Output: srcJarFile, |
| 94 | Input: syspropFile, |
| 95 | Implicit: checkApiFileTimeStamp, |
| 96 | Args: map[string]string{ |
| 97 | "scope": g.properties.Scope, |
| 98 | }, |
| 99 | }) |
| 100 | |
| 101 | g.genSrcjars = append(g.genSrcjars, srcJarFile) |
| 102 | } |
| 103 | } |
| 104 | |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 105 | func (g *syspropJavaGenRule) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 106 | // Add a dependency from the stubs to sysprop library so that the generator rule can depend on |
| 107 | // the check API rule of the sysprop library. |
| 108 | ctx.AddFarVariationDependencies(nil, nil, proptools.String(g.properties.Check_api)) |
| 109 | } |
| 110 | |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 111 | func (g *syspropJavaGenRule) OutputFiles(tag string) (android.Paths, error) { |
| 112 | switch tag { |
| 113 | case "": |
| 114 | return g.genSrcjars, nil |
| 115 | default: |
| 116 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | func syspropJavaGenFactory() android.Module { |
| 121 | g := &syspropJavaGenRule{} |
| 122 | g.AddProperties(&g.properties) |
| 123 | android.InitAndroidModule(g) |
| 124 | return g |
| 125 | } |
| 126 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 127 | type syspropLibrary struct { |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 128 | android.ModuleBase |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 129 | android.ApexModuleBase |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 130 | android.BazelModuleBase |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 131 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 132 | properties syspropLibraryProperties |
| 133 | |
| 134 | checkApiFileTimeStamp android.WritablePath |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 135 | latestApiFile android.OptionalPath |
| 136 | currentApiFile android.OptionalPath |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 137 | dumpedApiFile android.WritablePath |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | type syspropLibraryProperties struct { |
| 141 | // Determine who owns this sysprop library. Possible values are |
| 142 | // "Platform", "Vendor", or "Odm" |
| 143 | Property_owner string |
Inseob Kim | f63c2fb | 2019-03-05 14:22:30 +0900 | [diff] [blame] | 144 | |
| 145 | // list of package names that will be documented and publicized as API |
| 146 | Api_packages []string |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 147 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 148 | // If set to true, allow this module to be dexed and installed on devices. |
| 149 | Installable *bool |
| 150 | |
Inseob Kim | 9da1f81 | 2021-06-14 12:03:59 +0900 | [diff] [blame] | 151 | // Make this module available when building for ramdisk |
| 152 | Ramdisk_available *bool |
| 153 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 154 | // Make this module available when building for recovery |
Jiyong Park | 854a944 | 2019-02-26 10:27:13 +0900 | [diff] [blame] | 155 | Recovery_available *bool |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 156 | |
| 157 | // Make this module available when building for vendor |
| 158 | Vendor_available *bool |
| 159 | |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 160 | // Make this module available when building for product |
| 161 | Product_available *bool |
| 162 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 163 | // list of .sysprop files which defines the properties. |
| 164 | Srcs []string `android:"path"` |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 165 | |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 166 | // If set to true, build a variant of the module for the host. Defaults to false. |
| 167 | Host_supported *bool |
| 168 | |
Jooyung Han | 379660c | 2020-04-21 15:24:00 +0900 | [diff] [blame] | 169 | Cpp struct { |
| 170 | // Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX). |
| 171 | // Forwarded to cc_library.min_sdk_version |
| 172 | Min_sdk_version *string |
| 173 | } |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 174 | |
| 175 | Java struct { |
| 176 | // Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX). |
| 177 | // Forwarded to java_library.min_sdk_version |
| 178 | Min_sdk_version *string |
| 179 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | var ( |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 183 | pctx = android.NewPackageContext("android/soong/sysprop") |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 184 | syspropCcTag = dependencyTag{name: "syspropCc"} |
Inseob Kim | 628d7ef | 2020-03-21 03:38:32 +0900 | [diff] [blame] | 185 | |
| 186 | syspropLibrariesKey = android.NewOnceKey("syspropLibraries") |
| 187 | syspropLibrariesLock sync.Mutex |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 188 | ) |
| 189 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 190 | // List of sysprop_library used by property_contexts to perform type check. |
Inseob Kim | 628d7ef | 2020-03-21 03:38:32 +0900 | [diff] [blame] | 191 | func syspropLibraries(config android.Config) *[]string { |
| 192 | return config.Once(syspropLibrariesKey, func() interface{} { |
| 193 | return &[]string{} |
| 194 | }).(*[]string) |
| 195 | } |
| 196 | |
| 197 | func SyspropLibraries(config android.Config) []string { |
| 198 | return append([]string{}, *syspropLibraries(config)...) |
| 199 | } |
| 200 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 201 | func init() { |
Paul Duffin | 6e3ce72 | 2021-03-18 00:20:11 +0000 | [diff] [blame] | 202 | registerSyspropBuildComponents(android.InitRegistrationContext) |
| 203 | } |
| 204 | |
| 205 | func registerSyspropBuildComponents(ctx android.RegistrationContext) { |
| 206 | ctx.RegisterModuleType("sysprop_library", syspropLibraryFactory) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 207 | } |
| 208 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 209 | func (m *syspropLibrary) Name() string { |
| 210 | return m.BaseModuleName() + "_sysprop_library" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 211 | } |
| 212 | |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 213 | func (m *syspropLibrary) Owner() string { |
| 214 | return m.properties.Property_owner |
| 215 | } |
| 216 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 217 | func (m *syspropLibrary) CcImplementationModuleName() string { |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 218 | return "lib" + m.BaseModuleName() |
| 219 | } |
| 220 | |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 221 | func (m *syspropLibrary) javaPublicStubName() string { |
| 222 | return m.BaseModuleName() + "_public" |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 223 | } |
| 224 | |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 225 | func (m *syspropLibrary) javaGenModuleName() string { |
| 226 | return m.BaseModuleName() + "_java_gen" |
| 227 | } |
| 228 | |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 229 | func (m *syspropLibrary) javaGenPublicStubName() string { |
| 230 | return m.BaseModuleName() + "_java_gen_public" |
| 231 | } |
| 232 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 233 | func (m *syspropLibrary) BaseModuleName() string { |
| 234 | return m.ModuleBase.Name() |
| 235 | } |
| 236 | |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 237 | func (m *syspropLibrary) CurrentSyspropApiFile() android.OptionalPath { |
Inseob Kim | 628d7ef | 2020-03-21 03:38:32 +0900 | [diff] [blame] | 238 | return m.currentApiFile |
| 239 | } |
| 240 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 241 | // GenerateAndroidBuildActions of sysprop_library handles API dump and API check. |
| 242 | // generated java_library will depend on these API files. |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 243 | func (m *syspropLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 244 | baseModuleName := m.BaseModuleName() |
| 245 | |
| 246 | for _, syspropFile := range android.PathsForModuleSrc(ctx, m.properties.Srcs) { |
| 247 | if syspropFile.Ext() != ".sysprop" { |
| 248 | ctx.PropertyErrorf("srcs", "srcs contains non-sysprop file %q", syspropFile.String()) |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | if ctx.Failed() { |
| 253 | return |
| 254 | } |
| 255 | |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 256 | apiDirectoryPath := path.Join(ctx.ModuleDir(), "api") |
| 257 | currentApiFilePath := path.Join(apiDirectoryPath, baseModuleName+"-current.txt") |
| 258 | latestApiFilePath := path.Join(apiDirectoryPath, baseModuleName+"-latest.txt") |
| 259 | m.currentApiFile = android.ExistentPathForSource(ctx, currentApiFilePath) |
| 260 | m.latestApiFile = android.ExistentPathForSource(ctx, latestApiFilePath) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 261 | |
| 262 | // dump API rule |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 263 | rule := android.NewRuleBuilder(pctx, ctx) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 264 | m.dumpedApiFile = android.PathForModuleOut(ctx, "api-dump.txt") |
| 265 | rule.Command(). |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 266 | BuiltTool("sysprop_api_dump"). |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 267 | Output(m.dumpedApiFile). |
| 268 | Inputs(android.PathsForModuleSrc(ctx, m.properties.Srcs)) |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 269 | rule.Build(baseModuleName+"_api_dump", baseModuleName+" api dump") |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 270 | |
| 271 | // check API rule |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 272 | rule = android.NewRuleBuilder(pctx, ctx) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 273 | |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 274 | // We allow that the API txt files don't exist, when the sysprop_library only contains internal |
| 275 | // properties. But we have to feed current api file and latest api file to the rule builder. |
| 276 | // Currently we can't get android.Path representing the null device, so we add any existing API |
| 277 | // txt files to implicits, and then directly feed string paths, rather than calling Input(Path) |
| 278 | // method. |
| 279 | var apiFileList android.Paths |
| 280 | currentApiArgument := os.DevNull |
| 281 | if m.currentApiFile.Valid() { |
| 282 | apiFileList = append(apiFileList, m.currentApiFile.Path()) |
| 283 | currentApiArgument = m.currentApiFile.String() |
| 284 | } |
| 285 | |
| 286 | latestApiArgument := os.DevNull |
| 287 | if m.latestApiFile.Valid() { |
| 288 | apiFileList = append(apiFileList, m.latestApiFile.Path()) |
| 289 | latestApiArgument = m.latestApiFile.String() |
| 290 | } |
| 291 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 292 | // 1. compares current.txt to api-dump.txt |
| 293 | // current.txt should be identical to api-dump.txt. |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 294 | msg := fmt.Sprintf(`\n******************************\n`+ |
| 295 | `API of sysprop_library %s doesn't match with current.txt\n`+ |
| 296 | `Please update current.txt by:\n`+ |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 297 | `m %s-dump-api && mkdir -p %q && rm -rf %q && cp -f %q %q\n`+ |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 298 | `******************************\n`, baseModuleName, baseModuleName, |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 299 | apiDirectoryPath, currentApiFilePath, m.dumpedApiFile.String(), currentApiFilePath) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 300 | |
| 301 | rule.Command(). |
| 302 | Text("( cmp").Flag("-s"). |
| 303 | Input(m.dumpedApiFile). |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 304 | Text(currentApiArgument). |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 305 | Text("|| ( echo").Flag("-e"). |
| 306 | Flag(`"` + msg + `"`). |
| 307 | Text("; exit 38) )") |
| 308 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 309 | // 2. compares current.txt to latest.txt (frozen API) |
| 310 | // current.txt should be compatible with latest.txt |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 311 | msg = fmt.Sprintf(`\n******************************\n`+ |
| 312 | `API of sysprop_library %s doesn't match with latest version\n`+ |
| 313 | `Please fix the breakage and rebuild.\n`+ |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 314 | `******************************\n`, baseModuleName) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 315 | |
| 316 | rule.Command(). |
| 317 | Text("( "). |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 318 | BuiltTool("sysprop_api_checker"). |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 319 | Text(latestApiArgument). |
| 320 | Text(currentApiArgument). |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 321 | Text(" || ( echo").Flag("-e"). |
| 322 | Flag(`"` + msg + `"`). |
Inseob Kim | c9770d6 | 2021-01-15 18:04:20 +0900 | [diff] [blame] | 323 | Text("; exit 38) )"). |
| 324 | Implicits(apiFileList) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 325 | |
| 326 | m.checkApiFileTimeStamp = android.PathForModuleOut(ctx, "check_api.timestamp") |
| 327 | |
| 328 | rule.Command(). |
| 329 | Text("touch"). |
| 330 | Output(m.checkApiFileTimeStamp) |
| 331 | |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 332 | rule.Build(baseModuleName+"_check_api", baseModuleName+" check api") |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | func (m *syspropLibrary) AndroidMk() android.AndroidMkData { |
| 336 | return android.AndroidMkData{ |
| 337 | Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
| 338 | // sysprop_library module itself is defined as a FAKE module to perform API check. |
| 339 | // Actual implementation libraries are created on LoadHookMutator |
Sasha Smundak | 5c4729d | 2022-12-01 10:49:23 -0800 | [diff] [blame] | 340 | fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)", " # sysprop.syspropLibrary") |
| 341 | fmt.Fprintln(w, "LOCAL_MODULE :=", m.Name()) |
Bob Badour | b499922 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 342 | data.Entries.WriteLicenseVariables(w) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 343 | fmt.Fprintf(w, "LOCAL_MODULE_CLASS := FAKE\n") |
| 344 | fmt.Fprintf(w, "LOCAL_MODULE_TAGS := optional\n") |
| 345 | fmt.Fprintf(w, "include $(BUILD_SYSTEM)/base_rules.mk\n\n") |
| 346 | fmt.Fprintf(w, "$(LOCAL_BUILT_MODULE): %s\n", m.checkApiFileTimeStamp.String()) |
| 347 | fmt.Fprintf(w, "\ttouch $@\n\n") |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 348 | fmt.Fprintf(w, ".PHONY: %s-check-api %s-dump-api\n\n", name, name) |
| 349 | |
| 350 | // dump API rule |
| 351 | fmt.Fprintf(w, "%s-dump-api: %s\n\n", name, m.dumpedApiFile.String()) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 352 | |
| 353 | // check API rule |
| 354 | fmt.Fprintf(w, "%s-check-api: %s\n\n", name, m.checkApiFileTimeStamp.String()) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 355 | }} |
| 356 | } |
| 357 | |
Jiyong Park | 45bf82e | 2020-12-15 22:29:02 +0900 | [diff] [blame] | 358 | var _ android.ApexModule = (*syspropLibrary)(nil) |
| 359 | |
| 360 | // Implements android.ApexModule |
Dan Albert | c806053 | 2020-07-22 22:32:17 -0700 | [diff] [blame] | 361 | func (m *syspropLibrary) ShouldSupportSdkVersion(ctx android.BaseModuleContext, |
| 362 | sdkVersion android.ApiLevel) error { |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 363 | return fmt.Errorf("sysprop_library is not supposed to be part of apex modules") |
| 364 | } |
| 365 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 366 | // sysprop_library creates schematized APIs from sysprop description files (.sysprop). |
| 367 | // Both Java and C++ modules can link against sysprop_library, and API stability check |
| 368 | // against latest APIs (see build/soong/scripts/freeze-sysprop-api-files.sh) |
Trevor Radcliffe | d82e8f6 | 2022-06-08 16:16:31 +0000 | [diff] [blame] | 369 | // is performed. Note that the generated C++ module has its name prefixed with |
| 370 | // `lib`, and it is this module that should be depended on from other C++ |
| 371 | // modules; i.e., if the sysprop_library module is named `foo`, C++ modules |
| 372 | // should depend on `libfoo`. |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 373 | func syspropLibraryFactory() android.Module { |
| 374 | m := &syspropLibrary{} |
| 375 | |
| 376 | m.AddProperties( |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 377 | &m.properties, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 378 | ) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 379 | android.InitAndroidModule(m) |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 380 | android.InitApexModule(m) |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 381 | android.InitBazelModule(m) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 382 | android.AddLoadHook(m, func(ctx android.LoadHookContext) { syspropLibraryHook(ctx, m) }) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 383 | return m |
| 384 | } |
| 385 | |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 386 | type ccLibraryProperties struct { |
| 387 | Name *string |
| 388 | Srcs []string |
| 389 | Soc_specific *bool |
| 390 | Device_specific *bool |
| 391 | Product_specific *bool |
| 392 | Sysprop struct { |
| 393 | Platform *bool |
| 394 | } |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 395 | Target struct { |
| 396 | Android struct { |
| 397 | Header_libs []string |
| 398 | Shared_libs []string |
| 399 | } |
| 400 | Host struct { |
| 401 | Static_libs []string |
| 402 | } |
| 403 | } |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 404 | Required []string |
| 405 | Recovery *bool |
| 406 | Recovery_available *bool |
| 407 | Vendor_available *bool |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 408 | Product_available *bool |
Inseob Kim | 9da1f81 | 2021-06-14 12:03:59 +0900 | [diff] [blame] | 409 | Ramdisk_available *bool |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 410 | Host_supported *bool |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 411 | Apex_available []string |
Jooyung Han | 379660c | 2020-04-21 15:24:00 +0900 | [diff] [blame] | 412 | Min_sdk_version *string |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 413 | Bazel_module struct { |
Liz Kammer | 12dc96e | 2023-08-11 14:16:05 -0400 | [diff] [blame] | 414 | Label *string |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 415 | } |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | type javaLibraryProperties struct { |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 419 | Name *string |
| 420 | Srcs []string |
| 421 | Soc_specific *bool |
| 422 | Device_specific *bool |
| 423 | Product_specific *bool |
| 424 | Required []string |
| 425 | Sdk_version *string |
| 426 | Installable *bool |
| 427 | Libs []string |
| 428 | Stem *string |
| 429 | SyspropPublicStub string |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 430 | Apex_available []string |
| 431 | Min_sdk_version *string |
Liz Kammer | 12dc96e | 2023-08-11 14:16:05 -0400 | [diff] [blame] | 432 | Bazel_module struct { |
| 433 | Bp2build_available *bool |
| 434 | } |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 435 | } |
| 436 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 437 | func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 438 | if len(m.properties.Srcs) == 0 { |
Inseob Kim | 6e93ac9 | 2019-03-21 17:43:49 +0900 | [diff] [blame] | 439 | ctx.PropertyErrorf("srcs", "sysprop_library must specify srcs") |
| 440 | } |
| 441 | |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 442 | // ctx's Platform or Specific functions represent where this sysprop_library installed. |
| 443 | installedInSystem := ctx.Platform() || ctx.SystemExtSpecific() |
| 444 | installedInVendorOrOdm := ctx.SocSpecific() || ctx.DeviceSpecific() |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 445 | installedInProduct := ctx.ProductSpecific() |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 446 | isOwnerPlatform := false |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 447 | var javaSyspropStub string |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 448 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 449 | // javaSyspropStub contains stub libraries used by generated APIs, instead of framework stub. |
| 450 | // This is to make sysprop_library link against core_current. |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 451 | if installedInVendorOrOdm { |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 452 | javaSyspropStub = "sysprop-library-stub-vendor" |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 453 | } else if installedInProduct { |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 454 | javaSyspropStub = "sysprop-library-stub-product" |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 455 | } else { |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 456 | javaSyspropStub = "sysprop-library-stub-platform" |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 457 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 458 | |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 459 | switch m.Owner() { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 460 | case "Platform": |
| 461 | // Every partition can access platform-defined properties |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 462 | isOwnerPlatform = true |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 463 | case "Vendor": |
| 464 | // System can't access vendor's properties |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 465 | if installedInSystem { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 466 | ctx.ModuleErrorf("None of soc_specific, device_specific, product_specific is true. " + |
| 467 | "System can't access sysprop_library owned by Vendor") |
| 468 | } |
| 469 | case "Odm": |
| 470 | // Only vendor can access Odm-defined properties |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 471 | if !installedInVendorOrOdm { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 472 | ctx.ModuleErrorf("Neither soc_speicifc nor device_specific is true. " + |
| 473 | "Odm-defined properties should be accessed only in Vendor or Odm") |
| 474 | } |
| 475 | default: |
| 476 | ctx.PropertyErrorf("property_owner", |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 477 | "Unknown value %s: must be one of Platform, Vendor or Odm", m.Owner()) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 478 | } |
| 479 | |
Liz Kammer | 12dc96e | 2023-08-11 14:16:05 -0400 | [diff] [blame] | 480 | var label *string |
| 481 | if b, ok := ctx.Module().(android.Bazelable); ok && b.ShouldConvertWithBp2build(ctx) { |
| 482 | // TODO: b/295566168 - this will need to change once build files are checked in to account for |
| 483 | // checked in modules in mixed builds |
| 484 | label = proptools.StringPtr( |
| 485 | fmt.Sprintf("//%s:%s", ctx.ModuleDir(), m.CcImplementationModuleName())) |
| 486 | } |
| 487 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 488 | // Generate a C++ implementation library. |
| 489 | // cc_library can receive *.sysprop files as their srcs, generating sources itself. |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 490 | ccProps := ccLibraryProperties{} |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 491 | ccProps.Name = proptools.StringPtr(m.CcImplementationModuleName()) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 492 | ccProps.Srcs = m.properties.Srcs |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 493 | ccProps.Soc_specific = proptools.BoolPtr(ctx.SocSpecific()) |
| 494 | ccProps.Device_specific = proptools.BoolPtr(ctx.DeviceSpecific()) |
| 495 | ccProps.Product_specific = proptools.BoolPtr(ctx.ProductSpecific()) |
| 496 | ccProps.Sysprop.Platform = proptools.BoolPtr(isOwnerPlatform) |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 497 | ccProps.Target.Android.Header_libs = []string{"libbase_headers"} |
| 498 | ccProps.Target.Android.Shared_libs = []string{"liblog"} |
| 499 | ccProps.Target.Host.Static_libs = []string{"libbase", "liblog"} |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 500 | ccProps.Recovery_available = m.properties.Recovery_available |
| 501 | ccProps.Vendor_available = m.properties.Vendor_available |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 502 | ccProps.Product_available = m.properties.Product_available |
Inseob Kim | 9da1f81 | 2021-06-14 12:03:59 +0900 | [diff] [blame] | 503 | ccProps.Ramdisk_available = m.properties.Ramdisk_available |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 504 | ccProps.Host_supported = m.properties.Host_supported |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 505 | ccProps.Apex_available = m.ApexProperties.Apex_available |
Jooyung Han | 379660c | 2020-04-21 15:24:00 +0900 | [diff] [blame] | 506 | ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version |
Liz Kammer | 12dc96e | 2023-08-11 14:16:05 -0400 | [diff] [blame] | 507 | ccProps.Bazel_module.Label = label |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 508 | ctx.CreateModule(cc.LibraryFactory, &ccProps) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 509 | |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 510 | scope := "internal" |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 511 | |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 512 | // We need to only use public version, if the partition where sysprop_library will be installed |
| 513 | // is different from owner. |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 514 | if ctx.ProductSpecific() { |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 515 | // Currently product partition can't own any sysprop_library. So product always uses public. |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 516 | scope = "public" |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 517 | } else if isOwnerPlatform && installedInVendorOrOdm { |
| 518 | // Vendor or Odm should use public version of Platform's sysprop_library. |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 519 | scope = "public" |
| 520 | } |
| 521 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 522 | // Generate a Java implementation library. |
| 523 | // Contrast to C++, syspropJavaGenRule module will generate srcjar and the srcjar will be fed |
| 524 | // to Java implementation library. |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 525 | ctx.CreateModule(syspropJavaGenFactory, &syspropGenProperties{ |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 526 | Srcs: m.properties.Srcs, |
| 527 | Scope: scope, |
| 528 | Name: proptools.StringPtr(m.javaGenModuleName()), |
| 529 | Check_api: proptools.StringPtr(ctx.ModuleName()), |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 530 | }) |
| 531 | |
| 532 | // if platform sysprop_library is installed in /system or /system-ext, we regard it as an API |
| 533 | // and allow any modules (even from different partition) to link against the sysprop_library. |
| 534 | // To do that, we create a public stub and expose it to modules with sdk_version: system_*. |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 535 | var publicStub string |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 536 | if isOwnerPlatform && installedInSystem { |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 537 | publicStub = m.javaPublicStubName() |
| 538 | } |
| 539 | |
| 540 | ctx.CreateModule(java.LibraryFactory, &javaLibraryProperties{ |
| 541 | Name: proptools.StringPtr(m.BaseModuleName()), |
| 542 | Srcs: []string{":" + m.javaGenModuleName()}, |
| 543 | Soc_specific: proptools.BoolPtr(ctx.SocSpecific()), |
| 544 | Device_specific: proptools.BoolPtr(ctx.DeviceSpecific()), |
| 545 | Product_specific: proptools.BoolPtr(ctx.ProductSpecific()), |
| 546 | Installable: m.properties.Installable, |
| 547 | Sdk_version: proptools.StringPtr("core_current"), |
| 548 | Libs: []string{javaSyspropStub}, |
| 549 | SyspropPublicStub: publicStub, |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 550 | Apex_available: m.ApexProperties.Apex_available, |
| 551 | Min_sdk_version: m.properties.Java.Min_sdk_version, |
Liz Kammer | 12dc96e | 2023-08-11 14:16:05 -0400 | [diff] [blame] | 552 | Bazel_module: struct { |
| 553 | Bp2build_available *bool |
| 554 | }{ |
| 555 | Bp2build_available: proptools.BoolPtr(false), |
| 556 | }, |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 557 | }) |
| 558 | |
| 559 | if publicStub != "" { |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 560 | ctx.CreateModule(syspropJavaGenFactory, &syspropGenProperties{ |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 561 | Srcs: m.properties.Srcs, |
| 562 | Scope: "public", |
| 563 | Name: proptools.StringPtr(m.javaGenPublicStubName()), |
| 564 | Check_api: proptools.StringPtr(ctx.ModuleName()), |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 565 | }) |
| 566 | |
| 567 | ctx.CreateModule(java.LibraryFactory, &javaLibraryProperties{ |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 568 | Name: proptools.StringPtr(publicStub), |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 569 | Srcs: []string{":" + m.javaGenPublicStubName()}, |
| 570 | Installable: proptools.BoolPtr(false), |
| 571 | Sdk_version: proptools.StringPtr("core_current"), |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 572 | Libs: []string{javaSyspropStub}, |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 573 | Stem: proptools.StringPtr(m.BaseModuleName()), |
Liz Kammer | 12dc96e | 2023-08-11 14:16:05 -0400 | [diff] [blame] | 574 | Bazel_module: struct { |
| 575 | Bp2build_available *bool |
| 576 | }{ |
| 577 | Bp2build_available: proptools.BoolPtr(false), |
| 578 | }, |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 579 | }) |
Inseob Kim | 988f53c | 2019-09-16 15:59:01 +0900 | [diff] [blame] | 580 | } |
Inseob Kim | 628d7ef | 2020-03-21 03:38:32 +0900 | [diff] [blame] | 581 | |
Inseob Kim | 07def12 | 2020-11-23 14:43:02 +0900 | [diff] [blame] | 582 | // syspropLibraries will be used by property_contexts to check types. |
| 583 | // Record absolute paths of sysprop_library to prevent soong_namespace problem. |
Inseob Kim | 69cf09e | 2020-05-04 19:28:25 +0900 | [diff] [blame] | 584 | if m.ExportedToMake() { |
| 585 | syspropLibrariesLock.Lock() |
| 586 | defer syspropLibrariesLock.Unlock() |
Inseob Kim | 628d7ef | 2020-03-21 03:38:32 +0900 | [diff] [blame] | 587 | |
Inseob Kim | 69cf09e | 2020-05-04 19:28:25 +0900 | [diff] [blame] | 588 | libraries := syspropLibraries(ctx.Config()) |
| 589 | *libraries = append(*libraries, "//"+ctx.ModuleDir()+":"+ctx.ModuleName()) |
| 590 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 591 | } |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 592 | |
| 593 | // TODO(b/240463568): Additional properties will be added for API validation |
Chris Parsons | 637458d | 2023-09-19 20:09:00 +0000 | [diff] [blame] | 594 | func (m *syspropLibrary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { |
Trevor Radcliffe | cee4e05 | 2022-09-06 19:31:25 +0000 | [diff] [blame] | 595 | labels := cc.SyspropLibraryLabels{ |
| 596 | SyspropLibraryLabel: m.BaseModuleName(), |
| 597 | SharedLibraryLabel: m.CcImplementationModuleName(), |
| 598 | StaticLibraryLabel: cc.BazelLabelNameForStaticModule(m.CcImplementationModuleName()), |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 599 | } |
Trevor Radcliffe | cee4e05 | 2022-09-06 19:31:25 +0000 | [diff] [blame] | 600 | cc.Bp2buildSysprop(ctx, |
| 601 | labels, |
| 602 | bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Srcs)), |
| 603 | m.properties.Cpp.Min_sdk_version) |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 604 | } |