Merge "Soong: BPF: add defaults support and local include" into main

This commit is contained in:
Treehugger Robot
2024-09-17 18:25:12 +00:00
committed by Gerrit Code Review

View File

@@ -56,6 +56,7 @@ var (
)
func registerBpfBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("bpf_defaults", defaultsFactory)
ctx.RegisterModuleType("bpf", BpfFactory)
}
@@ -77,10 +78,16 @@ type BpfProperties struct {
// the C/C++ module.
Cflags []string
// directories (relative to the root of the source tree) that will
// be added to the include paths using -I.
// list of directories relative to the root of the source tree that
// will be added to the include paths using -I.
// If possible, don't use this. If adding paths from the current
// directory, use local_include_dirs. If adding paths from other
// modules, use export_include_dirs in that module.
Include_dirs []string
// list of directories relative to the Blueprint file that will be
// added to the include path using -I.
Local_include_dirs []string
// optional subdirectory under which this module is installed into.
Sub_dir string
@@ -94,7 +101,7 @@ type BpfProperties struct {
type bpf struct {
android.ModuleBase
android.DefaultableModuleBase
properties BpfProperties
objs android.Paths
@@ -163,6 +170,10 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) {
"-I " + ctx.ModuleDir(),
}
for _, dir := range android.PathsForModuleSrc(ctx, bpf.properties.Local_include_dirs) {
cflags = append(cflags, "-I "+dir.String())
}
for _, dir := range android.PathsForSource(ctx, bpf.properties.Include_dirs) {
cflags = append(cflags, "-I "+dir.String())
}
@@ -264,6 +275,26 @@ func (bpf *bpf) 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(&BpfProperties{})
android.InitDefaultsModule(module)
return module
}
func (bpf *bpf) SubDir() string {
return bpf.properties.Sub_dir
}
@@ -274,5 +305,7 @@ func BpfFactory() android.Module {
module.AddProperties(&module.properties)
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
return module
}