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

Commit 1845f420 authored by Sasha Smundak's avatar Sasha Smundak
Browse files

Simplify soong_build top-level code

* `android.Context` holds `android.Config`, so provide an accessor to it
  and avoid passing them separately to a lot of functions.
* factor common code in `readBazelPaths`/`getExistingBazelRelatedFiles`
  into `readFileLines`
* refactor check-error-and-quit into `maybeQuit`
* use switch instead of if-elseif-... where appropriate
* rearrange the code in `runApiBp2build`, `runSymlinkForestCreation`

Test: treehugger
Change-Id: I639929c21ec4999cdfd737c07136f32df2d488bc
parent af5ca926
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ type sortableComponent interface {
	// tests.
	componentName() string

	// register registers this component in the supplied context.
	// registers this component in the supplied context.
	register(ctx *Context)
}

@@ -124,7 +124,7 @@ func SingletonFactoryAdaptor(ctx *Context, factory SingletonFactory) blueprint.S
	return func() blueprint.Singleton {
		singleton := factory()
		if makevars, ok := singleton.(SingletonMakeVarsProvider); ok {
			registerSingletonMakeVarsProvider(ctx.config, makevars)
			ctx.registerSingletonMakeVarsProvider(makevars)
		}
		return &singletonAdaptor{Singleton: singleton}
	}
@@ -208,6 +208,14 @@ func (ctx *Context) Register() {
	singletons.registerAll(ctx)
}

func (ctx *Context) Config() Config {
	return ctx.config
}

func (ctx *Context) registerSingletonMakeVarsProvider(makevars SingletonMakeVarsProvider) {
	registerSingletonMakeVarsProvider(ctx.config, makevars)
}

func collateGloballyRegisteredSingletons() sortableComponents {
	allSingletons := append(sortableComponents(nil), singletons...)
	allSingletons = append(allSingletons,
@@ -335,7 +343,7 @@ func (ctx *initRegistrationContext) PreArchMutators(f RegisterMutatorFunc) {
	PreArchMutators(f)
}

func (ctx *initRegistrationContext) HardCodedPreArchMutators(f RegisterMutatorFunc) {
func (ctx *initRegistrationContext) HardCodedPreArchMutators(_ RegisterMutatorFunc) {
	// Nothing to do as the mutators are hard code in preArch in mutator.go
}

+177 −250

File changed.

Preview size limit exceeded, changes collapsed.