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

Commit dd0c8a85 authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge changes I2c0e2f4b,I539f38ab,I7ffa177c into main

* changes:
  Don't mutate sources when reusing objects
  Add PostApex mutator stage
  Add test for sabi propagation to static libraries
parents 13e719c0 7297f05e
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -32,11 +32,11 @@ import (
// collateGloballyRegisteredMutators constructs the list of mutators that have been registered
// with the InitRegistrationContext and will be used at runtime.
func collateGloballyRegisteredMutators() sortableComponents {
	return collateRegisteredMutators(preArch, preDeps, postDeps, finalDeps)
	return collateRegisteredMutators(preArch, preDeps, postDeps, postApex, finalDeps)
}

// collateRegisteredMutators constructs a single list of mutators from the separate lists.
func collateRegisteredMutators(preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc) sortableComponents {
func collateRegisteredMutators(preArch, preDeps, postDeps, postApex, finalDeps []RegisterMutatorFunc) sortableComponents {
	mctx := &registerMutatorsContext{}

	register := func(funcs []RegisterMutatorFunc) {
@@ -53,6 +53,8 @@ func collateRegisteredMutators(preArch, preDeps, postDeps, finalDeps []RegisterM

	register(postDeps)

	register(postApex)

	mctx.finalPhase = true
	register(finalDeps)

@@ -166,6 +168,8 @@ var postDeps = []RegisterMutatorFunc{
	RegisterOverridePostDepsMutators,
}

var postApex = []RegisterMutatorFunc{}

var finalDeps = []RegisterMutatorFunc{}

func PreArchMutators(f RegisterMutatorFunc) {
@@ -180,6 +184,10 @@ func PostDepsMutators(f RegisterMutatorFunc) {
	postDeps = append(postDeps, f)
}

func PostApexMutators(f RegisterMutatorFunc) {
	postApex = append(postApex, f)
}

func FinalDepsMutators(f RegisterMutatorFunc) {
	finalDeps = append(finalDeps, f)
}
+5 −0
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ type RegistrationContext interface {

	PreDepsMutators(f RegisterMutatorFunc)
	PostDepsMutators(f RegisterMutatorFunc)
	PostApexMutators(f RegisterMutatorFunc)
	FinalDepsMutators(f RegisterMutatorFunc)
}

@@ -326,6 +327,10 @@ func (ctx *initRegistrationContext) PostDepsMutators(f RegisterMutatorFunc) {
	PostDepsMutators(f)
}

func (ctx *initRegistrationContext) PostApexMutators(f RegisterMutatorFunc) {
	PostApexMutators(f)
}

func (ctx *initRegistrationContext) FinalDepsMutators(f RegisterMutatorFunc) {
	FinalDepsMutators(f)
}
+7 −3
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ func NewTestArchContext(config Config) *TestContext {

type TestContext struct {
	*Context
	preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc
	preArch, preDeps, postDeps, postApex, finalDeps []RegisterMutatorFunc
	NameResolver                                    *NameResolver

	// The list of singletons registered for the test.
@@ -229,6 +229,10 @@ func (ctx *TestContext) PostDepsMutators(f RegisterMutatorFunc) {
	ctx.postDeps = append(ctx.postDeps, f)
}

func (ctx *TestContext) PostApexMutators(f RegisterMutatorFunc) {
	ctx.postApex = append(ctx.postApex, f)
}

func (ctx *TestContext) FinalDepsMutators(f RegisterMutatorFunc) {
	ctx.finalDeps = append(ctx.finalDeps, f)
}
@@ -449,7 +453,7 @@ func globallyRegisteredComponentsOrder() *registrationSorter {
func (ctx *TestContext) Register() {
	globalOrder := globallyRegisteredComponentsOrder()

	mutators := collateRegisteredMutators(ctx.preArch, ctx.preDeps, ctx.postDeps, ctx.finalDeps)
	mutators := collateRegisteredMutators(ctx.preArch, ctx.preDeps, ctx.postDeps, ctx.postApex, ctx.finalDeps)
	// Ensure that the mutators used in the test are in the same order as they are used at runtime.
	globalOrder.mutatorOrder.enforceOrdering(mutators)
	mutators.registerAll(ctx.Context)
+1 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ bootstrap_go_package {
        "orderfile_test.go",
        "prebuilt_test.go",
        "proto_test.go",
        "sabi_test.go",
        "sanitize_test.go",
        "sdk_test.go",
        "test_data_test.go",
+14 −12
Original line number Diff line number Diff line
@@ -228,9 +228,6 @@ type BaseCompilerProperties struct {
		Static *bool `android:"arch_variant"`
	} `android:"arch_variant"`

	// Stores the original list of source files before being cleared by library reuse
	OriginalSrcs proptools.Configurable[[]string] `blueprint:"mutated"`

	// Build and link with OpenMP
	Openmp *bool `android:"arch_variant"`
}
@@ -363,10 +360,20 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
	tc := ctx.toolchain()
	modulePath := ctx.ModuleDir()

	srcs := compiler.Properties.Srcs.GetOrDefault(ctx, nil)
	reuseObjs := false
	if len(ctx.GetDirectDepsWithTag(reuseObjTag)) > 0 {
		reuseObjs = true
	}

	// If a reuseObjTag dependency exists then this module is reusing the objects (generally the shared variant
	// reusing objects from the static variant), and doesn't need to compile any sources of its own.
	var srcs []string
	if !reuseObjs {
		srcs = compiler.Properties.Srcs.GetOrDefault(ctx, nil)
		exclude_srcs := compiler.Properties.Exclude_srcs.GetOrDefault(ctx, nil)
		compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, srcs, exclude_srcs)
		compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)
	}

	cflags := compiler.Properties.Cflags.GetOrDefault(ctx, nil)
	cppflags := compiler.Properties.Cppflags.GetOrDefault(ctx, nil)
@@ -721,11 +728,6 @@ func (compiler *baseCompiler) hasSrcExt(ctx BaseModuleContext, ext string) bool
			return true
		}
	}
	for _, src := range compiler.Properties.OriginalSrcs.GetOrDefault(ctx, nil) {
		if filepath.Ext(src) == ext {
			return true
		}
	}

	return false
}
Loading