Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ad497a3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

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

parents 1c8c5698 a898bb85
Loading
Loading
Loading
Loading
+36 −3
Original line number Original line Diff line number Diff line
@@ -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
}
}