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 | "github.com/google/blueprint" |
| 19 | |
| 20 | "android/soong/android" |
| 21 | ) |
| 22 | |
| 23 | type dependencyTag struct { |
| 24 | blueprint.BaseDependencyTag |
| 25 | name string |
| 26 | } |
| 27 | |
| 28 | var ( |
| 29 | pctx = android.NewPackageContext("android/soong/selinux") |
| 30 | ) |
Inseob Kim | 6c6f53b | 2023-04-26 11:03:35 +0900 | [diff] [blame] | 31 | |
| 32 | // pathForModuleOut is same as android.PathForModuleOut, except that it uses DeviceName() as its |
| 33 | // intermediate directory name for system_ext/product/vendor/odm modules, to avoid rebuilding upon |
| 34 | // target change. Contents of system modules (core sepolicy) should be identical across devices, so |
| 35 | // they falls back to android.PathForModuleOut. |
| 36 | func pathForModuleOut(ctx android.ModuleContext, paths ...string) android.OutputPath { |
| 37 | if ctx.Platform() && !ctx.InstallInRecovery() { |
| 38 | return android.PathForModuleOut(ctx, paths...).OutputPath |
| 39 | } |
| 40 | |
| 41 | return android.PathForModuleOut(ctx, ctx.Config().DeviceName()).Join(ctx, paths...) |
| 42 | } |
Inseob Kim | 6cd0ddd | 2023-10-25 23:48:16 +0900 | [diff] [blame^] | 43 | |
| 44 | // flagsToM4Macros converts given map to a list of M4's -D parameters to guard te files and contexts |
| 45 | // files. |
| 46 | func flagsToM4Macros(flags map[string]string) []string { |
| 47 | flagMacros := []string{} |
| 48 | for _, flag := range android.SortedKeys(flags) { |
| 49 | flagMacros = append(flagMacros, "-D target_flag_"+flag+"="+flags[flag]) |
| 50 | } |
| 51 | return flagMacros |
| 52 | } |