Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(bob_toolchain): make mte props generic #676

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions core/androidbp_cclibs.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,10 @@ func addBinaryProps(mod bpwriter.Module, m ModuleBinary, ctx blueprint.ModuleCon
}
}

addMTEProps(mod, m.Properties.Build.AndroidMTEProps)
bc := GetModuleBackendConfiguration(ctx, m)
if bc != nil {
addMTEProps(mod, bc.GetMteProps(ctx))
}
addHWASANProps(mod, m.Properties.Build)
}

Expand Down Expand Up @@ -487,17 +490,10 @@ func addCompilableProps(mod bpwriter.Module, m Compilable, ctx blueprint.ModuleC
}
})

ctx.VisitDirectDepsIf(
func(dep blueprint.Module) bool {
return ctx.OtherModuleDependencyTag(dep) == tag.ToolchainTag
},
func(dep blueprint.Module) {
if t, ok := dep.(*ModuleToolchain); ok {
addMTEProps(mod, t.Properties.AndroidMTEProps)
} else {
panic(fmt.Errorf("dependency '%s' of '%s' is not a toolchain module", dep.Name(), ctx.ModuleName()))
}
})
bc := GetModuleBackendConfiguration(ctx, m)
if bc != nil {
addMTEProps(mod, bc.GetMteProps(ctx))
}

if std := ccflags.GetCompilerStandard(cflags, conlyFlags); std != "" {
mod.AddString("c_std", std)
Expand Down
5 changes: 3 additions & 2 deletions core/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ type binaryInterface interface {
file.Provider // A binary can provide itself as a source
}

var _ binaryInterface = (*ModuleBinary)(nil) // impl check
var _ libraryInterface = (*ModuleBinary)(nil) // impl check
var _ binaryInterface = (*ModuleBinary)(nil) // impl check
var _ libraryInterface = (*ModuleBinary)(nil) // impl check
var _ BackendConfiguration = (*ModuleBinary)(nil) // impl check

func (m *ModuleBinary) OutFiles() (srcs file.Paths) {
return file.Paths{file.NewPath(m.outputName(), string(m.getTarget()), file.TypeBinary|file.TypeExecutable|file.TypeInstallable)}
Expand Down
4 changes: 4 additions & 0 deletions core/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ func (m *ModuleLibrary) GetBuildWrapperAndDeps(ctx blueprint.ModuleContext) (str
return m.Properties.Build.GetBuildWrapperAndDeps(ctx)
}

func (m *ModuleLibrary) GetMteProps(blueprint.ModuleContext) AndroidMTEProps {
return m.Properties.AndroidMTEProps
}

func (m *ModuleLibrary) IsForwardingSharedLibrary() bool {
return m.Properties.isForwardingSharedLibrary()
}
Expand Down
10 changes: 7 additions & 3 deletions core/module_toolchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type ModuleToolchainProps struct {

// Wrapper for all build commands (object file compilation *and* linking)
Build_wrapper *string

AndroidMTEProps
}

type ToolchainFlagsProps struct {
Expand All @@ -54,16 +56,14 @@ type ModuleToolchain struct {
Host TargetSpecific
TargetType toolchain.TgtType `blueprint:"mutated"`

// Arm Memory Tagging Extension
AndroidMTEProps

Features
}
}

type BackendConfiguration interface {
stripable
GetBuildWrapperAndDeps(blueprint.ModuleContext) (string, []string)
GetMteProps(blueprint.ModuleContext) AndroidMTEProps
}

// This interface provides configuration features
Expand Down Expand Up @@ -148,6 +148,10 @@ func (m *ModuleToolchain) targetableProperties() []interface{} {
}
}

func (m *ModuleToolchain) GetMteProps(blueprint.ModuleContext) AndroidMTEProps {
return m.Properties.AndroidMTEProps
}

func (m *ModuleToolchain) GetBuildWrapperAndDeps(ctx blueprint.ModuleContext) (string, []string) {
// Copies the behaviour from core/build.go
if m.Properties.Build_wrapper != nil {
Expand Down