Stop using DIST_DIR in Soong
We're only using it to distribute files in case of failure, which isn't well supported currently, but can be handled for now by using the DIST_DIR environment variable during the command execution. This was at least one cause that we'd be re-running Soong during every build server build, as the DIST_DIR values are unique. Test: m dist Change-Id: Ibd5e6b6c46695350de80b745bfb6a6aa685033a0
This commit is contained in:
@@ -725,46 +725,6 @@ func PathForIntermediates(ctx PathContext, paths ...string) OutputPath {
|
|||||||
return PathForOutput(ctx, ".intermediates", path)
|
return PathForOutput(ctx, ".intermediates", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DistPath is a Path representing a file path rooted from the dist directory
|
|
||||||
type DistPath struct {
|
|
||||||
basePath
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p DistPath) withRel(rel string) DistPath {
|
|
||||||
p.basePath = p.basePath.withRel(rel)
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ Path = DistPath{}
|
|
||||||
|
|
||||||
// PathForDist joins the provided paths and returns a DistPath that is
|
|
||||||
// validated to not escape the dist dir.
|
|
||||||
// On error, it will return a usable, but invalid DistPath, and report a ModuleError.
|
|
||||||
func PathForDist(ctx PathContext, pathComponents ...string) DistPath {
|
|
||||||
path, err := validatePath(pathComponents...)
|
|
||||||
if err != nil {
|
|
||||||
reportPathError(ctx, err)
|
|
||||||
}
|
|
||||||
return DistPath{basePath{path, ctx.Config(), ""}}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p DistPath) writablePath() {}
|
|
||||||
|
|
||||||
func (p DistPath) Valid() bool {
|
|
||||||
return p.config.productVariables.DistDir != nil && *p.config.productVariables.DistDir != ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p DistPath) String() string {
|
|
||||||
if !p.Valid() {
|
|
||||||
panic("Requesting an invalid path")
|
|
||||||
}
|
|
||||||
return filepath.Join(*p.config.productVariables.DistDir, p.path)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p DistPath) RelPathString() string {
|
|
||||||
return p.path
|
|
||||||
}
|
|
||||||
|
|
||||||
// ModuleSrcPath is a Path representing a file rooted from a module's local source dir
|
// ModuleSrcPath is a Path representing a file rooted from a module's local source dir
|
||||||
type ModuleSrcPath struct {
|
type ModuleSrcPath struct {
|
||||||
SourcePath
|
SourcePath
|
||||||
|
@@ -228,7 +228,6 @@ type productVariables struct {
|
|||||||
Product_is_iot *bool `json:",omitempty"`
|
Product_is_iot *bool `json:",omitempty"`
|
||||||
|
|
||||||
DeviceKernelHeaders []string `json:",omitempty"`
|
DeviceKernelHeaders []string `json:",omitempty"`
|
||||||
DistDir *string `json:",omitempty"`
|
|
||||||
|
|
||||||
ExtraVndkVersions []string `json:",omitempty"`
|
ExtraVndkVersions []string `json:",omitempty"`
|
||||||
|
|
||||||
|
@@ -191,11 +191,8 @@ var (
|
|||||||
func(ctx android.PackageRuleContext) blueprint.RuleParams {
|
func(ctx android.PackageRuleContext) blueprint.RuleParams {
|
||||||
// TODO(b/78139997): Add -check-all-apis back
|
// TODO(b/78139997): Add -check-all-apis back
|
||||||
commandStr := "($sAbiDiffer $allowFlags -lib $libName -arch $arch -o ${out} -new $in -old $referenceDump)"
|
commandStr := "($sAbiDiffer $allowFlags -lib $libName -arch $arch -o ${out} -new $in -old $referenceDump)"
|
||||||
distAbiDiffDir := android.PathForDist(ctx, "abidiffs")
|
|
||||||
commandStr += "|| (echo ' ---- Please update abi references by running $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l ${libName} ----'"
|
commandStr += "|| (echo ' ---- Please update abi references by running $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l ${libName} ----'"
|
||||||
if distAbiDiffDir.Valid() {
|
commandStr += " && (mkdir -p $$DIST_DIR/abidiffs && cp ${out} $$DIST_DIR/abidiff/)"
|
||||||
commandStr += " && (mkdir -p " + distAbiDiffDir.String() + " && cp ${out} " + distAbiDiffDir.String() + ")"
|
|
||||||
}
|
|
||||||
commandStr += " && exit 1)"
|
commandStr += " && exit 1)"
|
||||||
return blueprint.RuleParams{
|
return blueprint.RuleParams{
|
||||||
Command: commandStr,
|
Command: commandStr,
|
||||||
|
@@ -34,6 +34,7 @@ type configImpl struct {
|
|||||||
arguments []string
|
arguments []string
|
||||||
goma bool
|
goma bool
|
||||||
environ *Environment
|
environ *Environment
|
||||||
|
distDir string
|
||||||
|
|
||||||
// From the arguments
|
// From the arguments
|
||||||
parallel int
|
parallel int
|
||||||
@@ -86,8 +87,11 @@ func NewConfig(ctx Context, args ...string) Config {
|
|||||||
ret.environ.Set("OUT_DIR", outDir)
|
ret.environ.Set("OUT_DIR", outDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure DIST_DIR is set appropriately
|
if distDir, ok := ret.environ.Get("DIST_DIR"); ok {
|
||||||
ret.environ.Set("DIST_DIR", ret.DistDir())
|
ret.distDir = filepath.Clean(distDir)
|
||||||
|
} else {
|
||||||
|
ret.distDir = filepath.Join(ret.OutDir(), "dist")
|
||||||
|
}
|
||||||
|
|
||||||
ret.environ.Unset(
|
ret.environ.Unset(
|
||||||
// We're already using it
|
// We're already using it
|
||||||
@@ -110,6 +114,9 @@ func NewConfig(ctx Context, args ...string) Config {
|
|||||||
// We handle this above
|
// We handle this above
|
||||||
"OUT_DIR_COMMON_BASE",
|
"OUT_DIR_COMMON_BASE",
|
||||||
|
|
||||||
|
// This is handled above too, and set for individual commands later
|
||||||
|
"DIST_DIR",
|
||||||
|
|
||||||
// Variables that have caused problems in the past
|
// Variables that have caused problems in the past
|
||||||
"CDPATH",
|
"CDPATH",
|
||||||
"DISPLAY",
|
"DISPLAY",
|
||||||
@@ -251,10 +258,10 @@ func (c *configImpl) parseArgs(ctx Context, args []string) {
|
|||||||
}
|
}
|
||||||
} else if k, v, ok := decodeKeyValue(arg); ok && len(k) > 0 {
|
} else if k, v, ok := decodeKeyValue(arg); ok && len(k) > 0 {
|
||||||
c.environ.Set(k, v)
|
c.environ.Set(k, v)
|
||||||
|
} else if arg == "dist" {
|
||||||
|
c.dist = true
|
||||||
} else {
|
} else {
|
||||||
if arg == "dist" {
|
if arg == "checkbuild" {
|
||||||
c.dist = true
|
|
||||||
} else if arg == "checkbuild" {
|
|
||||||
c.checkbuild = true
|
c.checkbuild = true
|
||||||
}
|
}
|
||||||
c.arguments = append(c.arguments, arg)
|
c.arguments = append(c.arguments, arg)
|
||||||
@@ -378,10 +385,7 @@ func (c *configImpl) OutDir() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *configImpl) DistDir() string {
|
func (c *configImpl) DistDir() string {
|
||||||
if distDir, ok := c.environ.Get("DIST_DIR"); ok {
|
return c.distDir
|
||||||
return filepath.Clean(distDir)
|
|
||||||
}
|
|
||||||
return filepath.Join(c.OutDir(), "dist")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *configImpl) NinjaArgs() []string {
|
func (c *configImpl) NinjaArgs() []string {
|
||||||
|
@@ -129,9 +129,7 @@ func runKatiBuild(ctx Context, config Config) {
|
|||||||
"TARGET_DEVICE_DIR="+config.TargetDeviceDir(),
|
"TARGET_DEVICE_DIR="+config.TargetDeviceDir(),
|
||||||
"KATI_PACKAGE_MK_DIR="+config.KatiPackageMkDir())
|
"KATI_PACKAGE_MK_DIR="+config.KatiPackageMkDir())
|
||||||
|
|
||||||
runKati(ctx, config, katiBuildSuffix, args, func(env *Environment) {
|
runKati(ctx, config, katiBuildSuffix, args, func(env *Environment) {})
|
||||||
env.Unset("DIST_DIR")
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runKatiPackage(ctx Context, config Config) {
|
func runKatiPackage(ctx Context, config Config) {
|
||||||
@@ -170,6 +168,7 @@ func runKatiPackage(ctx Context, config Config) {
|
|||||||
|
|
||||||
if config.Dist() {
|
if config.Dist() {
|
||||||
env.Set("DIST", "true")
|
env.Set("DIST", "true")
|
||||||
|
env.Set("DIST_DIR", config.DistDir())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -184,7 +183,5 @@ func runKatiCleanSpec(ctx Context, config Config) {
|
|||||||
"-f", "build/make/core/cleanbuild.mk",
|
"-f", "build/make/core/cleanbuild.mk",
|
||||||
"SOONG_MAKEVARS_MK=" + config.SoongMakeVarsMk(),
|
"SOONG_MAKEVARS_MK=" + config.SoongMakeVarsMk(),
|
||||||
"TARGET_DEVICE_DIR=" + config.TargetDeviceDir(),
|
"TARGET_DEVICE_DIR=" + config.TargetDeviceDir(),
|
||||||
}, func(env *Environment) {
|
}, func(env *Environment) {})
|
||||||
env.Unset("DIST_DIR")
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
@@ -60,6 +60,8 @@ func runNinja(ctx Context, config Config) {
|
|||||||
cmd.Environment.AppendFromKati(config.KatiEnvFile())
|
cmd.Environment.AppendFromKati(config.KatiEnvFile())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.Environment.Set("DIST_DIR", config.DistDir())
|
||||||
|
|
||||||
// Allow both NINJA_ARGS and NINJA_EXTRA_ARGS, since both have been
|
// Allow both NINJA_ARGS and NINJA_EXTRA_ARGS, since both have been
|
||||||
// used in the past to specify extra ninja arguments.
|
// used in the past to specify extra ninja arguments.
|
||||||
if extra, ok := cmd.Environment.Get("NINJA_ARGS"); ok {
|
if extra, ok := cmd.Environment.Get("NINJA_ARGS"); ok {
|
||||||
|
Reference in New Issue
Block a user