Merge "Revert "Split property and file contexts modules""

This commit is contained in:
Vova Sharaienko 2021-11-18 17:56:09 +00:00 committed by Gerrit Code Review
commit 919fa4f9fc
2 changed files with 17 additions and 75 deletions

View file

@ -494,26 +494,8 @@ file_contexts {
flatten_apex: {
srcs: ["apex/*-file_contexts"],
},
}
file_contexts {
name: "plat_file_contexts.recovery",
srcs: [":file_contexts_files"],
stem: "plat_file_contexts",
product_variables: {
address_sanitize: {
srcs: [":file_contexts_asan_files"],
},
debuggable: {
srcs: [":file_contexts_overlayfs_files"],
},
},
flatten_apex: {
srcs: ["apex/*-file_contexts"],
},
recovery: true,
recovery_available: true,
}
file_contexts {
@ -577,13 +559,7 @@ hwservice_contexts {
property_contexts {
name: "plat_property_contexts",
srcs: [":property_contexts_files"],
}
property_contexts {
name: "plat_property_contexts.recovery",
srcs: [":property_contexts_files"],
stem: "plat_property_contexts",
recovery: true,
recovery_available: true,
}
property_contexts {
@ -1219,17 +1195,3 @@ se_bug_map {
se_freeze_test {
name: "sepolicy_freeze_test",
}
//////////////////////////////////
// Makefile rules temporary imported to Soong
// TODO(b/33691272): remove these after migrating seapp to Soong
//////////////////////////////////
makefile_goal {
name: "plat_seapp_contexts_rule",
product_out_path: "obj/ETC/plat_seapp_contexts_intermediates/plat_seapp_contexts",
}
makefile_goal {
name: "plat_seapp_neverallows_rule",
product_out_path: "obj/ETC/plat_seapp_neverallows_intermediates/plat_seapp_neverallows",
}

View file

@ -30,9 +30,6 @@ type selinuxContextsProperties struct {
// Filenames under sepolicy directories, which will be used to generate contexts file.
Srcs []string `android:"path"`
// Output file name. Defaults to module name
Stem *string
Product_variables struct {
Debuggable struct {
Srcs []string
@ -123,10 +120,6 @@ func (m *selinuxContextsModule) propertyContextsDeps(ctx android.BottomUpMutator
}
}
func (m *selinuxContextsModule) stem() string {
return proptools.StringDefault(m.properties.Stem, m.Name())
}
func (m *selinuxContextsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if m.InRecovery() {
// Installing context files at the root of the recovery partition
@ -140,7 +133,7 @@ func (m *selinuxContextsModule) GenerateAndroidBuildActions(ctx android.ModuleCo
if reuseDeps, ok := dep.(*selinuxContextsModule); ok {
m.outputPath = reuseDeps.outputPath
ctx.InstallFile(m.installPath, m.stem(), m.outputPath)
ctx.InstallFile(m.installPath, m.Name(), m.outputPath)
return
}
}
@ -192,7 +185,7 @@ func (m *selinuxContextsModule) GenerateAndroidBuildActions(ctx android.ModuleCo
}
m.outputPath = m.build(ctx, inputs)
ctx.InstallFile(m.installPath, m.stem(), m.outputPath)
ctx.InstallFile(m.installPath, ctx.ModuleName(), m.outputPath)
}
func newModule() *selinuxContextsModule {
@ -237,21 +230,21 @@ func (m *selinuxContextsModule) AndroidMk() android.AndroidMkData {
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", m.installPath.ToMakePath().String())
fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", m.stem())
fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", m.Name())
},
},
}
}
func (m *selinuxContextsModule) ImageMutatorBegin(ctx android.BaseModuleContext) {
if proptools.Bool(m.properties.Recovery_available) && m.ModuleBase.InstallInRecovery() {
if proptools.Bool(m.properties.Recovery_available) && m.InstallInRecovery() {
ctx.PropertyErrorf("recovery_available",
"doesn't make sense at the same time as `recovery: true`")
}
}
func (m *selinuxContextsModule) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
return !m.ModuleBase.InstallInRecovery()
return !m.InstallInRecovery()
}
func (m *selinuxContextsModule) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
@ -267,7 +260,7 @@ func (m *selinuxContextsModule) DebugRamdiskVariantNeeded(ctx android.BaseModule
}
func (m *selinuxContextsModule) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return m.ModuleBase.InstallInRecovery() || proptools.Bool(m.properties.Recovery_available)
return m.InstallInRecovery() || proptools.Bool(m.properties.Recovery_available)
}
func (m *selinuxContextsModule) ExtraImageVariations(ctx android.BaseModuleContext) []string {
@ -280,7 +273,7 @@ func (m *selinuxContextsModule) SetImageVariation(ctx android.BaseModuleContext,
var _ android.ImageInterface = (*selinuxContextsModule)(nil)
func (m *selinuxContextsModule) buildGeneralContexts(ctx android.ModuleContext, inputs android.Paths) android.Path {
builtContext := android.PathForModuleGen(ctx, ctx.ModuleName()+"_m4out")
ret := android.PathForModuleGen(ctx, ctx.ModuleName()+"_m4out")
rule := android.NewRuleBuilder(pctx, ctx)
@ -289,40 +282,37 @@ func (m *selinuxContextsModule) buildGeneralContexts(ctx android.ModuleContext,
Text("--fatal-warnings -s").
FlagForEachArg("-D", ctx.DeviceConfig().SepolicyM4Defs()).
Inputs(inputs).
FlagWithOutput("> ", builtContext)
FlagWithOutput("> ", ret)
if proptools.Bool(m.properties.Remove_comment) {
rule.Temporary(builtContext)
rule.Temporary(ret)
remove_comment_output := android.PathForModuleGen(ctx, ctx.ModuleName()+"_remove_comment")
rule.Command().
Text("sed -e 's/#.*$//' -e '/^$/d'").
Input(builtContext).
Input(ret).
FlagWithOutput("> ", remove_comment_output)
builtContext = remove_comment_output
ret = remove_comment_output
}
if proptools.Bool(m.properties.Fc_sort) {
rule.Temporary(builtContext)
rule.Temporary(ret)
sorted_output := android.PathForModuleGen(ctx, ctx.ModuleName()+"_sorted")
rule.Command().
Tool(ctx.Config().HostToolPath(ctx, "fc_sort")).
FlagWithInput("-i ", builtContext).
FlagWithInput("-i ", ret).
FlagWithOutput("-o ", sorted_output)
builtContext = sorted_output
ret = sorted_output
}
ret := android.PathForModuleGen(ctx, m.stem())
rule.Temporary(builtContext)
rule.Command().Text("cp").Input(builtContext).Output(ret)
rule.Build("selinux_contexts", "building contexts: "+m.Name())
rule.DeleteTemporaryFiles()
rule.Build("selinux_contexts", "building contexts: "+m.Name())
return ret
}
@ -510,13 +500,3 @@ func keystoreKeyFactory() android.Module {
m.build = m.buildGeneralContexts
return m
}
var _ android.OutputFileProducer = (*selinuxContextsModule)(nil)
// Implements android.OutputFileProducer
func (m *selinuxContextsModule) OutputFiles(tag string) (android.Paths, error) {
if tag == "" {
return []android.Path{m.outputPath}, nil
}
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}