platform_system_sepolicy/build/soong/selinux.go
Inseob Kim 6cd0dddf1f Support passing flag parameters to M4
This will be used to guard sepolicy changes. Also this adds default
modules for se_policy_conf and contexts modules.

Bug: 306563735
Test: build
Change-Id: I9b3460aaca07d325e0f83a1e2bf0e57caa498101
2023-11-09 16:00:11 +09:00

52 lines
1.8 KiB
Go

// Copyright (C) 2019 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package selinux
import (
"github.com/google/blueprint"
"android/soong/android"
)
type dependencyTag struct {
blueprint.BaseDependencyTag
name string
}
var (
pctx = android.NewPackageContext("android/soong/selinux")
)
// pathForModuleOut is same as android.PathForModuleOut, except that it uses DeviceName() as its
// intermediate directory name for system_ext/product/vendor/odm modules, to avoid rebuilding upon
// target change. Contents of system modules (core sepolicy) should be identical across devices, so
// they falls back to android.PathForModuleOut.
func pathForModuleOut(ctx android.ModuleContext, paths ...string) android.OutputPath {
if ctx.Platform() && !ctx.InstallInRecovery() {
return android.PathForModuleOut(ctx, paths...).OutputPath
}
return android.PathForModuleOut(ctx, ctx.Config().DeviceName()).Join(ctx, paths...)
}
// flagsToM4Macros converts given map to a list of M4's -D parameters to guard te files and contexts
// files.
func flagsToM4Macros(flags map[string]string) []string {
flagMacros := []string{}
for _, flag := range android.SortedKeys(flags) {
flagMacros = append(flagMacros, "-D target_flag_"+flag+"="+flags[flag])
}
return flagMacros
}