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>
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 73c8800..8679821 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -56,6 +56,7 @@
)
func registerBpfBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("bpf_defaults", defaultsFactory)
ctx.RegisterModuleType("bpf", BpfFactory)
}
@@ -77,10 +78,16 @@
// 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 bpf struct {
android.ModuleBase
-
+ android.DefaultableModuleBase
properties BpfProperties
objs android.Paths
@@ -163,6 +170,10 @@
"-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 @@
}
}
+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 @@
module.AddProperties(&module.properties)
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ android.InitDefaultableModule(module)
+
return module
}