Merge changes from topic "libbpf_defaults" into main am: d47cfab05b
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3270098 Change-Id: I309603b5bc1e591ba1c9a2cfcf500f2dd4e259ea Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -61,6 +61,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func registerLibbpfProgBuildComponents(ctx android.RegistrationContext) {
|
func registerLibbpfProgBuildComponents(ctx android.RegistrationContext) {
|
||||||
|
ctx.RegisterModuleType("libbpf_defaults", defaultsFactory)
|
||||||
ctx.RegisterModuleType("libbpf_prog", LibbpfProgFactory)
|
ctx.RegisterModuleType("libbpf_prog", LibbpfProgFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,14 +89,17 @@ type LibbpfProgProperties struct {
|
|||||||
// be added to the include path using -I
|
// be added to the include path using -I
|
||||||
Local_include_dirs []string `android:"arch_variant"`
|
Local_include_dirs []string `android:"arch_variant"`
|
||||||
|
|
||||||
|
Header_libs []string `android:"arch_variant"`
|
||||||
|
|
||||||
// optional subdirectory under which this module is installed into.
|
// optional subdirectory under which this module is installed into.
|
||||||
Relative_install_path string
|
Relative_install_path string
|
||||||
}
|
}
|
||||||
|
|
||||||
type libbpfProg struct {
|
type libbpfProg struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
|
android.DefaultableModuleBase
|
||||||
properties LibbpfProgProperties
|
properties LibbpfProgProperties
|
||||||
objs android.Paths
|
objs android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ android.ImageInterface = (*libbpfProg)(nil)
|
var _ android.ImageInterface = (*libbpfProg)(nil)
|
||||||
@@ -139,6 +143,7 @@ func (libbpf *libbpfProg) SetImageVariation(ctx android.BaseModuleContext, varia
|
|||||||
|
|
||||||
func (libbpf *libbpfProg) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (libbpf *libbpfProg) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
ctx.AddDependency(ctx.Module(), libbpfProgDepTag, "libbpf_headers")
|
ctx.AddDependency(ctx.Module(), libbpfProgDepTag, "libbpf_headers")
|
||||||
|
ctx.AddVariationDependencies(nil, cc.HeaderDepTag(), libbpf.properties.Header_libs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (libbpf *libbpfProg) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (libbpf *libbpfProg) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
@@ -180,6 +185,11 @@ func (libbpf *libbpfProg) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
depName := ctx.OtherModuleName(dep)
|
depName := ctx.OtherModuleName(dep)
|
||||||
ctx.ModuleErrorf("module %q is not a genrule", depName)
|
ctx.ModuleErrorf("module %q is not a genrule", depName)
|
||||||
}
|
}
|
||||||
|
} else if depTag == cc.HeaderDepTag() {
|
||||||
|
depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, cc.FlagExporterInfoProvider)
|
||||||
|
for _, dir := range depExporterInfo.IncludeDirs {
|
||||||
|
cflags = append(cflags, "-I "+dir.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -269,10 +279,32 @@ func (libbpf *libbpfProg) AndroidMk() android.AndroidMkData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Defaults struct {
|
||||||
|
android.ModuleBase
|
||||||
|
android.DefaultsModuleBase
|
||||||
|
}
|
||||||
|
|
||||||
|
func defaultsFactory() android.Module {
|
||||||
|
return DefaultsFactory()
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultsFactory(props ...interface{}) android.Module {
|
||||||
|
module := &Defaults{}
|
||||||
|
|
||||||
|
module.AddProperties(props...)
|
||||||
|
module.AddProperties(&LibbpfProgProperties{})
|
||||||
|
|
||||||
|
android.InitDefaultsModule(module)
|
||||||
|
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
func LibbpfProgFactory() android.Module {
|
func LibbpfProgFactory() android.Module {
|
||||||
module := &libbpfProg{}
|
module := &libbpfProg{}
|
||||||
|
|
||||||
module.AddProperties(&module.properties)
|
module.AddProperties(&module.properties)
|
||||||
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
||||||
|
android.InitDefaultableModule(module)
|
||||||
|
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user