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

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

Merge "Delete arch hooks"

parents f4b13d41 87f790c5
Loading
Loading
Loading
Loading
+0 −34
Original line number Diff line number Diff line
@@ -33,24 +33,11 @@ type LoadHookContext interface {
	CreateModule(ModuleFactory, ...interface{}) Module
}

// Arch hooks are run after the module has been split into architecture variants, and can be used
// to add architecture-specific properties.
type ArchHookContext interface {
	BaseModuleContext
	AppendProperties(...interface{})
	PrependProperties(...interface{})
}

func AddLoadHook(m blueprint.Module, hook func(LoadHookContext)) {
	h := &m.(Module).base().hooks
	h.load = append(h.load, hook)
}

func AddArchHook(m blueprint.Module, hook func(ArchHookContext)) {
	h := &m.(Module).base().hooks
	h.arch = append(h.arch, hook)
}

func (x *hooks) runLoadHooks(ctx LoadHookContext, m *ModuleBase) {
	if len(x.load) > 0 {
		for _, x := range x.load {
@@ -62,17 +49,6 @@ func (x *hooks) runLoadHooks(ctx LoadHookContext, m *ModuleBase) {
	}
}

func (x *hooks) runArchHooks(ctx ArchHookContext, m *ModuleBase) {
	if len(x.arch) > 0 {
		for _, x := range x.arch {
			x(ctx)
			if ctx.Failed() {
				return
			}
		}
	}
}

type InstallHookContext interface {
	ModuleContext
	Path() InstallPath
@@ -119,7 +95,6 @@ func (x *hooks) runInstallHooks(ctx ModuleContext, path InstallPath, symlink boo

type hooks struct {
	load    []func(LoadHookContext)
	arch    []func(ArchHookContext)
	install []func(InstallHookContext)
}

@@ -137,12 +112,3 @@ func LoadHookMutator(ctx TopDownMutatorContext) {
		m.base().hooks.runLoadHooks(loadHookCtx, m.base())
	}
}

func archHookMutator(ctx TopDownMutatorContext) {
	if m, ok := ctx.Module().(Module); ok {
		// Cast through *topDownMutatorContext because AppendProperties is implemented
		// on *topDownMutatorContext but not exposed through TopDownMutatorContext
		var archHookCtx ArchHookContext = ctx.(*topDownMutatorContext)
		m.base().hooks.runArchHooks(archHookCtx, m.base())
	}
}
+0 −1
Original line number Diff line number Diff line
@@ -89,7 +89,6 @@ func registerArchMutator(ctx RegisterMutatorsContext) {
	ctx.BottomUp("os", osMutator).Parallel()
	ctx.BottomUp("image", imageMutator).Parallel()
	ctx.BottomUp("arch", archMutator).Parallel()
	ctx.TopDown("arch_hooks", archHookMutator).Parallel()
}

var preDeps = []RegisterMutatorFunc{