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

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

Merge "Add (obj|tidy)-*_os, and (obj|tidy)-*_subset targets"

parents 4efcb9d8 80783774
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -887,6 +887,10 @@ func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, mod blue
	return nil
}

func ShouldSkipAndroidMkProcessing(module Module) bool {
	return shouldSkipAndroidMkProcessing(module.base())
}

func shouldSkipAndroidMkProcessing(module *ModuleBase) bool {
	if !module.commonProperties.NamespaceExportedToMake {
		// TODO(jeffrygaston) do we want to validate that there are no modules being
+8 −50
Original line number Diff line number Diff line
@@ -419,7 +419,6 @@ type ModuleContext interface {
	PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec

	CheckbuildFile(srcPath Path)
	TidyFile(srcPath WritablePath)

	InstallInData() bool
	InstallInTestcases() bool
@@ -1200,7 +1199,6 @@ type ModuleBase struct {
	installFiles         InstallPaths
	installFilesDepSet   *installPathsDepSet
	checkbuildFiles      Paths
	tidyFiles            WritablePaths
	packagingSpecs       []PackagingSpec
	packagingSpecsDepSet *packagingSpecsDepSet
	noticeFiles          Paths
@@ -1216,7 +1214,6 @@ type ModuleBase struct {
	// Only set on the final variant of each module
	installTarget    WritablePath
	checkbuildTarget WritablePath
	tidyTarget       WritablePath
	blueprintDir     string

	hooks hooks
@@ -1779,17 +1776,15 @@ func (m *ModuleBase) VintfFragments() Paths {
func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
	var allInstalledFiles InstallPaths
	var allCheckbuildFiles Paths
	var allTidyFiles WritablePaths
	ctx.VisitAllModuleVariants(func(module Module) {
		a := module.base()
		allInstalledFiles = append(allInstalledFiles, a.installFiles...)
		// A module's -{checkbuild,tidy} phony targets should
		// A module's -checkbuild phony targets should
		// not be created if the module is not exported to make.
		// Those could depend on the build target and fail to compile
		// for the current build target.
		if !ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(a) {
			allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
			allTidyFiles = append(allTidyFiles, a.tidyFiles...)
		}
	})

@@ -1814,13 +1809,6 @@ func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
		deps = append(deps, m.checkbuildTarget)
	}

	if len(allTidyFiles) > 0 {
		name := namespacePrefix + ctx.ModuleName() + "-tidy"
		ctx.Phony(name, allTidyFiles.Paths()...)
		m.tidyTarget = PathForPhony(ctx, name)
		deps = append(deps, m.tidyTarget)
	}

	if len(deps) > 0 {
		suffix := ""
		if ctx.Config().KatiEnabled() {
@@ -2029,7 +2017,6 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)

		m.installFiles = append(m.installFiles, ctx.installFiles...)
		m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...)
		m.tidyFiles = append(m.tidyFiles, ctx.tidyFiles...)
		m.packagingSpecs = append(m.packagingSpecs, ctx.packagingSpecs...)
		m.katiInstalls = append(m.katiInstalls, ctx.katiInstalls...)
		m.katiSymlinks = append(m.katiSymlinks, ctx.katiSymlinks...)
@@ -2227,7 +2214,6 @@ type moduleContext struct {
	packagingSpecs  []PackagingSpec
	installFiles    InstallPaths
	checkbuildFiles Paths
	tidyFiles       WritablePaths
	module          Module
	phonies         map[string]Paths

@@ -3065,10 +3051,6 @@ func (m *moduleContext) CheckbuildFile(srcPath Path) {
	m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
}

func (m *moduleContext) TidyFile(srcPath WritablePath) {
	m.tidyFiles = append(m.tidyFiles, srcPath)
}

func (m *moduleContext) blueprintModuleContext() blueprint.ModuleContext {
	return m.bp
}
@@ -3327,9 +3309,10 @@ func parentDir(dir string) string {

type buildTargetSingleton struct{}

func addAncestors(ctx SingletonContext, dirMap map[string]Paths, mmName func(string) string) []string {
func AddAncestors(ctx SingletonContext, dirMap map[string]Paths, mmName func(string) string) ([]string, []string) {
	// Ensure ancestor directories are in dirMap
	// Make directories build their direct subdirectories
	// Returns a slice of all directories and a slice of top-level directories.
	dirs := SortedStringKeys(dirMap)
	for _, dir := range dirs {
		dir := parentDir(dir)
@@ -3342,34 +3325,31 @@ func addAncestors(ctx SingletonContext, dirMap map[string]Paths, mmName func(str
		}
	}
	dirs = SortedStringKeys(dirMap)
	var topDirs []string
	for _, dir := range dirs {
		p := parentDir(dir)
		if p != "." && p != "/" {
			dirMap[p] = append(dirMap[p], PathForPhony(ctx, mmName(dir)))
		} else if dir != "." && dir != "/" && dir != "" {
			topDirs = append(topDirs, dir)
		}
	}
	return SortedStringKeys(dirMap)
	return SortedStringKeys(dirMap), topDirs
}

func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
	var checkbuildDeps Paths
	var tidyDeps Paths

	mmTarget := func(dir string) string {
		return "MODULES-IN-" + strings.Replace(filepath.Clean(dir), "/", "-", -1)
	}
	mmTidyTarget := func(dir string) string {
		return "tidy-" + strings.Replace(filepath.Clean(dir), "/", "-", -1)
	}

	modulesInDir := make(map[string]Paths)
	tidyModulesInDir := make(map[string]Paths)

	ctx.VisitAllModules(func(module Module) {
		blueprintDir := module.base().blueprintDir
		installTarget := module.base().installTarget
		checkbuildTarget := module.base().checkbuildTarget
		tidyTarget := module.base().tidyTarget

		if checkbuildTarget != nil {
			checkbuildDeps = append(checkbuildDeps, checkbuildTarget)
@@ -3379,16 +3359,6 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
		if installTarget != nil {
			modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], installTarget)
		}

		if tidyTarget != nil {
			tidyDeps = append(tidyDeps, tidyTarget)
			// tidyTarget is in modulesInDir so it will be built with "mm".
			modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], tidyTarget)
			// tidyModulesInDir contains tidyTarget but not checkbuildTarget
			// or installTarget, so tidy targets in a directory can be built
			// without other checkbuild or install targets.
			tidyModulesInDir[blueprintDir] = append(tidyModulesInDir[blueprintDir], tidyTarget)
		}
	})

	suffix := ""
@@ -3399,24 +3369,12 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
	// Create a top-level checkbuild target that depends on all modules
	ctx.Phony("checkbuild"+suffix, checkbuildDeps...)

	// Create a top-level tidy target that depends on all modules
	ctx.Phony("tidy"+suffix, tidyDeps...)

	dirs := addAncestors(ctx, tidyModulesInDir, mmTidyTarget)

	// Kati does not generate tidy-* phony targets yet.
	// Create a tidy-<directory> target that depends on all subdirectories
	// and modules in the directory.
	for _, dir := range dirs {
		ctx.Phony(mmTidyTarget(dir), tidyModulesInDir[dir]...)
	}

	// Make will generate the MODULES-IN-* targets
	if ctx.Config().KatiEnabled() {
		return
	}

	dirs = addAncestors(ctx, modulesInDir, mmTarget)
	dirs, _ := AddAncestors(ctx, modulesInDir, mmTarget)

	// Create a MODULES-IN-<directory> target that depends on all modules in a directory, and
	// depends on the MODULES-IN-* targets of all of its subdirectories that contain Android.bp
+1 −1
Original line number Diff line number Diff line
@@ -389,7 +389,7 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
		}
	}

	var validations android.WritablePaths
	var validations android.Paths

	// Handle host bionic linker symbols.
	if ctx.Os() == android.LinuxBionic && !binary.static() {
+8 −9
Original line number Diff line number Diff line
@@ -413,7 +413,7 @@ type StripFlags struct {
// Objects is a collection of file paths corresponding to outputs for C++ related build statements.
type Objects struct {
	objFiles      android.Paths
	tidyFiles     android.WritablePaths
	tidyFiles     android.Paths
	coverageFiles android.Paths
	sAbiDumpFiles android.Paths
	kytheFiles    android.Paths
@@ -422,7 +422,7 @@ type Objects struct {
func (a Objects) Copy() Objects {
	return Objects{
		objFiles:      append(android.Paths{}, a.objFiles...),
		tidyFiles:     append(android.WritablePaths{}, a.tidyFiles...),
		tidyFiles:     append(android.Paths{}, a.tidyFiles...),
		coverageFiles: append(android.Paths{}, a.coverageFiles...),
		sAbiDumpFiles: append(android.Paths{}, a.sAbiDumpFiles...),
		kytheFiles:    append(android.Paths{}, a.kytheFiles...),
@@ -451,11 +451,11 @@ func transformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles, no

	// Source files are one-to-one with tidy, coverage, or kythe files, if enabled.
	objFiles := make(android.Paths, len(srcFiles))
	var tidyFiles android.WritablePaths
	var tidyFiles android.Paths
	noTidySrcsMap := make(map[android.Path]bool)
	var tidyVars string
	if flags.tidy {
		tidyFiles = make(android.WritablePaths, 0, len(srcFiles))
		tidyFiles = make(android.Paths, 0, len(srcFiles))
		for _, path := range noTidySrcs {
			noTidySrcsMap[path] = true
		}
@@ -665,7 +665,6 @@ func transformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles, no
				rule = clangTidyRE
			}

			ctx.TidyFile(tidyFile)
			ctx.Build(pctx, android.BuildParams{
				Rule:        rule,
				Description: "clang-tidy " + srcFile.Rel(),
@@ -719,7 +718,7 @@ func transformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles, no
// Generate a rule for compiling multiple .o files to a static library (.a)
func transformObjToStaticLib(ctx android.ModuleContext,
	objFiles android.Paths, wholeStaticLibs android.Paths,
	flags builderFlags, outputFile android.ModuleOutPath, deps android.Paths, validations android.WritablePaths) {
	flags builderFlags, outputFile android.ModuleOutPath, deps android.Paths, validations android.Paths) {

	arCmd := "${config.ClangBin}/llvm-ar"
	arFlags := ""
@@ -734,7 +733,7 @@ func transformObjToStaticLib(ctx android.ModuleContext,
			Output:      outputFile,
			Inputs:      objFiles,
			Implicits:   deps,
			Validations: validations.Paths(),
			Validations: validations,
			Args: map[string]string{
				"arFlags": "crsPD" + arFlags,
				"arCmd":   arCmd,
@@ -764,7 +763,7 @@ func transformObjToStaticLib(ctx android.ModuleContext,
func transformObjToDynamicBinary(ctx android.ModuleContext,
	objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps, crtBegin, crtEnd android.Paths,
	groupLate bool, flags builderFlags, outputFile android.WritablePath,
	implicitOutputs android.WritablePaths, validations android.WritablePaths) {
	implicitOutputs android.WritablePaths, validations android.Paths) {

	ldCmd := "${config.ClangBin}/clang++"

@@ -831,7 +830,7 @@ func transformObjToDynamicBinary(ctx android.ModuleContext,
		Inputs:          objFiles,
		Implicits:       deps,
		OrderOnly:       sharedLibs,
		Validations:     validations.Paths(),
		Validations:     validations,
		Args:            args,
	})
}
+6 −0
Original line number Diff line number Diff line
@@ -815,6 +815,10 @@ type Module struct {
	makeLinkType string
	// Kythe (source file indexer) paths for this compilation module
	kytheFiles android.Paths
	// Object .o file output paths for this compilation module
	objFiles android.Paths
	// Tidy .tidy file output paths for this compilation module
	tidyFiles android.Paths

	// For apex variants, this is set as apex.min_sdk_version
	apexSdkVersion android.ApiLevel
@@ -1835,6 +1839,8 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
			return
		}
		c.kytheFiles = objs.kytheFiles
		c.objFiles = objs.objFiles
		c.tidyFiles = objs.tidyFiles
	}

	if c.linker != nil {
Loading