Soong: BPF: add defaults support and local include
Add support for defaults clause in the bpf soong module, as well as local_include_dirs property. Test: TH Change-Id: Iaa03e7f1f6dcf0e929d1d5b23bb79ca2a8366bef Signed-off-by: Neill Kapron <nkapron@google.com>
This commit is contained in:
39
bpf/bpf.go
39
bpf/bpf.go
@@ -56,6 +56,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func registerBpfBuildComponents(ctx android.RegistrationContext) {
|
func registerBpfBuildComponents(ctx android.RegistrationContext) {
|
||||||
|
ctx.RegisterModuleType("bpf_defaults", defaultsFactory)
|
||||||
ctx.RegisterModuleType("bpf", BpfFactory)
|
ctx.RegisterModuleType("bpf", BpfFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,10 +78,16 @@ type BpfProperties struct {
|
|||||||
// the C/C++ module.
|
// the C/C++ module.
|
||||||
Cflags []string
|
Cflags []string
|
||||||
|
|
||||||
// directories (relative to the root of the source tree) that will
|
// list of directories relative to the root of the source tree that
|
||||||
// be added to the include paths using -I.
|
// 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
|
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.
|
// optional subdirectory under which this module is installed into.
|
||||||
Sub_dir string
|
Sub_dir string
|
||||||
|
|
||||||
@@ -94,7 +101,7 @@ type BpfProperties struct {
|
|||||||
|
|
||||||
type bpf struct {
|
type bpf struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
|
android.DefaultableModuleBase
|
||||||
properties BpfProperties
|
properties BpfProperties
|
||||||
|
|
||||||
objs android.Paths
|
objs android.Paths
|
||||||
@@ -163,6 +170,10 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
"-I " + ctx.ModuleDir(),
|
"-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) {
|
for _, dir := range android.PathsForSource(ctx, bpf.properties.Include_dirs) {
|
||||||
cflags = append(cflags, "-I "+dir.String())
|
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 {
|
func (bpf *bpf) SubDir() string {
|
||||||
return bpf.properties.Sub_dir
|
return bpf.properties.Sub_dir
|
||||||
}
|
}
|
||||||
@@ -274,5 +305,7 @@ func BpfFactory() android.Module {
|
|||||||
module.AddProperties(&module.properties)
|
module.AddProperties(&module.properties)
|
||||||
|
|
||||||
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
||||||
|
android.InitDefaultableModule(module)
|
||||||
|
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user