Skip to content

Commit

Permalink
refactor(bob_toolchain): make mte props generic
Browse files Browse the repository at this point in the history
Change-Id: I891bcb77bba4eeca7f41251a24cae0069aef3e45
  • Loading branch information
lukokr-aarch64 committed Oct 11, 2023
1 parent ac53905 commit 720fb60
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
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

0 comments on commit 720fb60

Please sign in to comment.