Inseob Kim | b554e59 | 2019-04-15 20:10:46 +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 selinux |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "io" |
| 20 | "strings" |
| 21 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 22 | "github.com/google/blueprint" |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 23 | "github.com/google/blueprint/proptools" |
| 24 | |
| 25 | "android/soong/android" |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 26 | "android/soong/sysprop" |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 27 | ) |
| 28 | |
| 29 | const ( |
| 30 | coreMode = "core" |
| 31 | recoveryMode = "recovery" |
| 32 | ) |
| 33 | |
| 34 | type selinuxContextsProperties struct { |
| 35 | // Filenames under sepolicy directories, which will be used to generate contexts file. |
| 36 | Srcs []string `android:"path"` |
| 37 | |
| 38 | Product_variables struct { |
| 39 | Debuggable struct { |
| 40 | Srcs []string |
| 41 | } |
| 42 | |
| 43 | Address_sanitize struct { |
| 44 | Srcs []string |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // Whether reqd_mask directory is included to sepolicy directories or not. |
| 49 | Reqd_mask *bool |
| 50 | |
| 51 | // Whether the comments in generated contexts file will be removed or not. |
| 52 | Remove_comment *bool |
| 53 | |
| 54 | // Whether the result context file is sorted with fc_sort or not. |
| 55 | Fc_sort *bool |
| 56 | |
| 57 | // Make this module available when building for recovery |
| 58 | Recovery_available *bool |
| 59 | |
| 60 | InRecovery bool `blueprint:"mutated"` |
| 61 | } |
| 62 | |
| 63 | type fileContextsProperties struct { |
| 64 | // flatten_apex can be used to specify additional sources of file_contexts. |
| 65 | // Apex paths, /system/apex/{apex_name}, will be amended to the paths of file_contexts |
| 66 | // entries. |
| 67 | Flatten_apex struct { |
| 68 | Srcs []string |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | type selinuxContextsModule struct { |
| 73 | android.ModuleBase |
| 74 | |
| 75 | properties selinuxContextsProperties |
| 76 | fileContextsProperties fileContextsProperties |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 77 | build func(ctx android.ModuleContext, inputs android.Paths) android.Path |
| 78 | deps func(ctx android.BottomUpMutatorContext) |
| 79 | outputPath android.Path |
Colin Cross | 040f151 | 2019-10-02 10:36:09 -0700 | [diff] [blame] | 80 | installPath android.InstallPath |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | var ( |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 84 | reuseContextsDepTag = dependencyTag{name: "reuseContexts"} |
| 85 | syspropLibraryDepTag = dependencyTag{name: "sysprop_library"} |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 86 | ) |
| 87 | |
| 88 | func init() { |
| 89 | pctx.HostBinToolVariable("fc_sort", "fc_sort") |
| 90 | |
| 91 | android.RegisterModuleType("file_contexts", fileFactory) |
| 92 | android.RegisterModuleType("hwservice_contexts", hwServiceFactory) |
| 93 | android.RegisterModuleType("property_contexts", propertyFactory) |
| 94 | android.RegisterModuleType("service_contexts", serviceFactory) |
Janis Danisevskis | c40681f | 2020-07-25 13:02:29 -0700 | [diff] [blame] | 95 | android.RegisterModuleType("keystore2_key_contexts", keystoreKeyFactory) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 96 | |
| 97 | android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
| 98 | ctx.BottomUp("selinux_contexts", selinuxContextsMutator).Parallel() |
| 99 | }) |
| 100 | } |
| 101 | |
| 102 | func (m *selinuxContextsModule) inRecovery() bool { |
| 103 | return m.properties.InRecovery || m.ModuleBase.InstallInRecovery() |
| 104 | } |
| 105 | |
| 106 | func (m *selinuxContextsModule) onlyInRecovery() bool { |
| 107 | return m.ModuleBase.InstallInRecovery() |
| 108 | } |
| 109 | |
| 110 | func (m *selinuxContextsModule) InstallInRecovery() bool { |
| 111 | return m.inRecovery() |
| 112 | } |
| 113 | |
Colin Cross | 040f151 | 2019-10-02 10:36:09 -0700 | [diff] [blame] | 114 | func (m *selinuxContextsModule) InstallInRoot() bool { |
| 115 | return m.inRecovery() |
| 116 | } |
| 117 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 118 | func (m *selinuxContextsModule) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 119 | if m.deps != nil { |
| 120 | m.deps(ctx) |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func (m *selinuxContextsModule) propertyContextsDeps(ctx android.BottomUpMutatorContext) { |
| 125 | for _, lib := range sysprop.SyspropLibraries(ctx.Config()) { |
| 126 | ctx.AddFarVariationDependencies([]blueprint.Variation{}, syspropLibraryDepTag, lib) |
| 127 | } |
| 128 | } |
| 129 | |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 130 | func (m *selinuxContextsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Colin Cross | 040f151 | 2019-10-02 10:36:09 -0700 | [diff] [blame] | 131 | if m.inRecovery() { |
| 132 | // Installing context files at the root of the recovery partition |
| 133 | m.installPath = android.PathForModuleInstall(ctx) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 134 | } else { |
| 135 | m.installPath = android.PathForModuleInstall(ctx, "etc", "selinux") |
| 136 | } |
| 137 | |
| 138 | if m.inRecovery() && !m.onlyInRecovery() { |
| 139 | dep := ctx.GetDirectDepWithTag(m.Name(), reuseContextsDepTag) |
| 140 | |
| 141 | if reuseDeps, ok := dep.(*selinuxContextsModule); ok { |
| 142 | m.outputPath = reuseDeps.outputPath |
| 143 | ctx.InstallFile(m.installPath, m.Name(), m.outputPath) |
| 144 | return |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | var inputs android.Paths |
| 149 | |
| 150 | ctx.VisitDirectDepsWithTag(android.SourceDepTag, func(dep android.Module) { |
| 151 | segroup, ok := dep.(*fileGroup) |
| 152 | if !ok { |
| 153 | ctx.ModuleErrorf("srcs dependency %q is not an selinux filegroup", |
| 154 | ctx.OtherModuleName(dep)) |
| 155 | return |
| 156 | } |
| 157 | |
| 158 | if ctx.ProductSpecific() { |
| 159 | inputs = append(inputs, segroup.ProductPrivateSrcs()...) |
| 160 | } else if ctx.SocSpecific() { |
| 161 | inputs = append(inputs, segroup.SystemVendorSrcs()...) |
| 162 | inputs = append(inputs, segroup.VendorSrcs()...) |
| 163 | } else if ctx.DeviceSpecific() { |
| 164 | inputs = append(inputs, segroup.OdmSrcs()...) |
Bowgo Tsai | 86a048d | 2019-09-09 22:04:06 +0800 | [diff] [blame] | 165 | } else if ctx.SystemExtSpecific() { |
| 166 | inputs = append(inputs, segroup.SystemExtPrivateSrcs()...) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 167 | } else { |
| 168 | inputs = append(inputs, segroup.SystemPrivateSrcs()...) |
Felix | 342b58a | 2020-03-02 16:13:12 +0100 | [diff] [blame] | 169 | inputs = append(inputs, segroup.SystemPublicSrcs()...) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | if proptools.Bool(m.properties.Reqd_mask) { |
| 173 | inputs = append(inputs, segroup.SystemReqdMaskSrcs()...) |
| 174 | } |
| 175 | }) |
| 176 | |
| 177 | for _, src := range m.properties.Srcs { |
| 178 | // Module sources are handled above with VisitDirectDepsWithTag |
| 179 | if android.SrcIsModule(src) == "" { |
| 180 | inputs = append(inputs, android.PathForModuleSrc(ctx, src)) |
| 181 | } |
| 182 | } |
| 183 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 184 | m.outputPath = m.build(ctx, inputs) |
| 185 | ctx.InstallFile(m.installPath, ctx.ModuleName(), m.outputPath) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | func newModule() *selinuxContextsModule { |
| 189 | m := &selinuxContextsModule{} |
| 190 | m.AddProperties( |
| 191 | &m.properties, |
| 192 | ) |
| 193 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 194 | android.AddLoadHook(m, func(ctx android.LoadHookContext) { |
| 195 | m.selinuxContextsHook(ctx) |
| 196 | }) |
| 197 | return m |
| 198 | } |
| 199 | |
| 200 | func (m *selinuxContextsModule) selinuxContextsHook(ctx android.LoadHookContext) { |
| 201 | // TODO: clean this up to use build/soong/android/variable.go after b/79249983 |
| 202 | var srcs []string |
| 203 | |
| 204 | if ctx.Config().Debuggable() { |
| 205 | srcs = append(srcs, m.properties.Product_variables.Debuggable.Srcs...) |
| 206 | } |
| 207 | |
| 208 | for _, sanitize := range ctx.Config().SanitizeDevice() { |
| 209 | if sanitize == "address" { |
| 210 | srcs = append(srcs, m.properties.Product_variables.Address_sanitize.Srcs...) |
| 211 | break |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | m.properties.Srcs = append(m.properties.Srcs, srcs...) |
| 216 | } |
| 217 | |
| 218 | func (m *selinuxContextsModule) AndroidMk() android.AndroidMkData { |
| 219 | return android.AndroidMkData{ |
| 220 | Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
| 221 | nameSuffix := "" |
| 222 | if m.inRecovery() && !m.onlyInRecovery() { |
| 223 | nameSuffix = ".recovery" |
| 224 | } |
| 225 | fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") |
| 226 | fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) |
| 227 | fmt.Fprintln(w, "LOCAL_MODULE :=", name+nameSuffix) |
| 228 | fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") |
| 229 | if m.Owner() != "" { |
| 230 | fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", m.Owner()) |
| 231 | } |
| 232 | fmt.Fprintln(w, "LOCAL_MODULE_TAGS := optional") |
| 233 | fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", m.outputPath.String()) |
Colin Cross | 040f151 | 2019-10-02 10:36:09 -0700 | [diff] [blame] | 234 | fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", m.installPath.ToMakePath().String()) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 235 | fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", name) |
| 236 | fmt.Fprintln(w, "include $(BUILD_PREBUILT)") |
| 237 | }, |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | func selinuxContextsMutator(ctx android.BottomUpMutatorContext) { |
| 242 | m, ok := ctx.Module().(*selinuxContextsModule) |
| 243 | if !ok { |
| 244 | return |
| 245 | } |
| 246 | |
| 247 | var coreVariantNeeded bool = true |
| 248 | var recoveryVariantNeeded bool = false |
| 249 | if proptools.Bool(m.properties.Recovery_available) { |
| 250 | recoveryVariantNeeded = true |
| 251 | } |
| 252 | |
| 253 | if m.ModuleBase.InstallInRecovery() { |
| 254 | recoveryVariantNeeded = true |
| 255 | coreVariantNeeded = false |
| 256 | } |
| 257 | |
| 258 | var variants []string |
| 259 | if coreVariantNeeded { |
| 260 | variants = append(variants, coreMode) |
| 261 | } |
| 262 | if recoveryVariantNeeded { |
| 263 | variants = append(variants, recoveryMode) |
| 264 | } |
| 265 | mod := ctx.CreateVariations(variants...) |
| 266 | |
| 267 | for i, v := range variants { |
| 268 | if v == recoveryMode { |
| 269 | m := mod[i].(*selinuxContextsModule) |
| 270 | m.properties.InRecovery = true |
| 271 | |
| 272 | if coreVariantNeeded { |
| 273 | ctx.AddInterVariantDependency(reuseContextsDepTag, m, mod[i-1]) |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 279 | func (m *selinuxContextsModule) buildGeneralContexts(ctx android.ModuleContext, inputs android.Paths) android.Path { |
| 280 | ret := android.PathForModuleGen(ctx, ctx.ModuleName()+"_m4out") |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 281 | |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 282 | rule := android.NewRuleBuilder(pctx, ctx) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 283 | |
| 284 | rule.Command(). |
Dan Willemsen | 3c3e59b | 2019-06-19 10:52:50 -0700 | [diff] [blame] | 285 | Tool(ctx.Config().PrebuiltBuildTool(ctx, "m4")). |
| 286 | Text("--fatal-warnings -s"). |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 287 | FlagForEachArg("-D", ctx.DeviceConfig().SepolicyM4Defs()). |
| 288 | Inputs(inputs). |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 289 | FlagWithOutput("> ", ret) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 290 | |
| 291 | if proptools.Bool(m.properties.Remove_comment) { |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 292 | rule.Temporary(ret) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 293 | |
| 294 | remove_comment_output := android.PathForModuleGen(ctx, ctx.ModuleName()+"_remove_comment") |
| 295 | |
| 296 | rule.Command(). |
| 297 | Text("sed -e 's/#.*$//' -e '/^$/d'"). |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 298 | Input(ret). |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 299 | FlagWithOutput("> ", remove_comment_output) |
| 300 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 301 | ret = remove_comment_output |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | if proptools.Bool(m.properties.Fc_sort) { |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 305 | rule.Temporary(ret) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 306 | |
| 307 | sorted_output := android.PathForModuleGen(ctx, ctx.ModuleName()+"_sorted") |
| 308 | |
| 309 | rule.Command(). |
| 310 | Tool(ctx.Config().HostToolPath(ctx, "fc_sort")). |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 311 | FlagWithInput("-i ", ret). |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 312 | FlagWithOutput("-o ", sorted_output) |
| 313 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 314 | ret = sorted_output |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 315 | } |
| 316 | |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 317 | rule.Build("selinux_contexts", "building contexts: "+m.Name()) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 318 | |
| 319 | rule.DeleteTemporaryFiles() |
| 320 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 321 | return ret |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 322 | } |
| 323 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 324 | func (m *selinuxContextsModule) buildFileContexts(ctx android.ModuleContext, inputs android.Paths) android.Path { |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 325 | if m.properties.Fc_sort == nil { |
| 326 | m.properties.Fc_sort = proptools.BoolPtr(true) |
| 327 | } |
| 328 | |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 329 | rule := android.NewRuleBuilder(pctx, ctx) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 330 | |
| 331 | if ctx.Config().FlattenApex() { |
| 332 | for _, src := range m.fileContextsProperties.Flatten_apex.Srcs { |
| 333 | if m := android.SrcIsModule(src); m != "" { |
| 334 | ctx.ModuleErrorf( |
| 335 | "Module srcs dependency %q is not supported for flatten_apex.srcs", m) |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 336 | return nil |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 337 | } |
| 338 | for _, path := range android.PathsForModuleSrcExcludes(ctx, []string{src}, nil) { |
| 339 | out := android.PathForModuleGen(ctx, "flattened_apex", path.Rel()) |
| 340 | apex_path := "/system/apex/" + strings.Replace( |
| 341 | strings.TrimSuffix(path.Base(), "-file_contexts"), |
| 342 | ".", "\\\\.", -1) |
| 343 | |
| 344 | rule.Command(). |
| 345 | Text("awk '/object_r/{printf(\""+apex_path+"%s\\n\",$0)}'"). |
| 346 | Input(path). |
| 347 | FlagWithOutput("> ", out) |
| 348 | |
| 349 | inputs = append(inputs, out) |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 354 | rule.Build(m.Name(), "flattened_apex_file_contexts") |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 355 | return m.buildGeneralContexts(ctx, inputs) |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | func fileFactory() android.Module { |
| 359 | m := newModule() |
| 360 | m.AddProperties(&m.fileContextsProperties) |
| 361 | m.build = m.buildFileContexts |
| 362 | return m |
| 363 | } |
| 364 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 365 | func (m *selinuxContextsModule) buildHwServiceContexts(ctx android.ModuleContext, inputs android.Paths) android.Path { |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 366 | if m.properties.Remove_comment == nil { |
| 367 | m.properties.Remove_comment = proptools.BoolPtr(true) |
| 368 | } |
| 369 | |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 370 | return m.buildGeneralContexts(ctx, inputs) |
| 371 | } |
| 372 | |
| 373 | func (m *selinuxContextsModule) buildPropertyContexts(ctx android.ModuleContext, inputs android.Paths) android.Path { |
| 374 | builtCtxFile := m.buildGeneralContexts(ctx, inputs) |
| 375 | |
| 376 | var apiFiles android.Paths |
| 377 | ctx.VisitDirectDepsWithTag(syspropLibraryDepTag, func(c android.Module) { |
| 378 | i, ok := c.(interface{ CurrentSyspropApiFile() android.Path }) |
| 379 | if !ok { |
| 380 | panic(fmt.Errorf("unknown dependency %q for %q", ctx.OtherModuleName(c), ctx.ModuleName())) |
| 381 | } |
| 382 | apiFiles = append(apiFiles, i.CurrentSyspropApiFile()) |
| 383 | }) |
| 384 | |
| 385 | // check compatibility with sysprop_library |
| 386 | if len(apiFiles) > 0 { |
| 387 | out := android.PathForModuleGen(ctx, ctx.ModuleName()+"_api_checked") |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 388 | rule := android.NewRuleBuilder(pctx, ctx) |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 389 | |
| 390 | msg := `\n******************************\n` + |
| 391 | `API of sysprop_library doesn't match with property_contexts\n` + |
| 392 | `Please fix the breakage and rebuild.\n` + |
| 393 | `******************************\n` |
| 394 | |
| 395 | rule.Command(). |
| 396 | Text("( "). |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 397 | BuiltTool("sysprop_type_checker"). |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 398 | FlagForEachInput("--api ", apiFiles). |
| 399 | FlagWithInput("--context ", builtCtxFile). |
| 400 | Text(" || ( echo").Flag("-e"). |
| 401 | Flag(`"` + msg + `"`). |
| 402 | Text("; exit 38) )") |
| 403 | |
| 404 | rule.Command().Text("cp -f").Input(builtCtxFile).Output(out) |
Colin Cross | 242c8bc | 2020-11-16 17:58:17 -0800 | [diff] [blame] | 405 | rule.Build("property_contexts_check_api", "checking API: "+m.Name()) |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 406 | builtCtxFile = out |
| 407 | } |
| 408 | |
| 409 | return builtCtxFile |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | func hwServiceFactory() android.Module { |
| 413 | m := newModule() |
| 414 | m.build = m.buildHwServiceContexts |
| 415 | return m |
| 416 | } |
| 417 | |
| 418 | func propertyFactory() android.Module { |
| 419 | m := newModule() |
Inseob Kim | cd61649 | 2020-03-24 23:06:40 +0900 | [diff] [blame] | 420 | m.build = m.buildPropertyContexts |
| 421 | m.deps = m.propertyContextsDeps |
Inseob Kim | b554e59 | 2019-04-15 20:10:46 +0900 | [diff] [blame] | 422 | return m |
| 423 | } |
| 424 | |
| 425 | func serviceFactory() android.Module { |
| 426 | m := newModule() |
| 427 | m.build = m.buildGeneralContexts |
| 428 | return m |
| 429 | } |
Janis Danisevskis | c40681f | 2020-07-25 13:02:29 -0700 | [diff] [blame] | 430 | |
| 431 | func keystoreKeyFactory() android.Module { |
| 432 | m := newModule() |
| 433 | m.build = m.buildGeneralContexts |
| 434 | return m |
| 435 | } |