Fix and optimize relPwd in cc
We cannot use the PWD trick for any compile on Darwin, since /proc doesn't exist. So instead of checking for darwin host modules, just check runtime.GOOS. And since this isn't a per-module decision, don't pass it along as a variable to every build command, but make it a global variable. Change-Id: Iea8609f49a9d316c58aed527f62d1986c970eaac
This commit is contained in:
parent
5602b5888e
commit
322a0a6b59
1 changed files with 13 additions and 11 deletions
|
@ -47,7 +47,7 @@ var (
|
|||
Command: "$relPwd $ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
|
||||
Description: "cc $out",
|
||||
},
|
||||
"relPwd", "ccCmd", "cFlags")
|
||||
"ccCmd", "cFlags")
|
||||
|
||||
ld = pctx.StaticRule("ld",
|
||||
blueprint.RuleParams{
|
||||
|
@ -108,6 +108,18 @@ var (
|
|||
"ccCmd", "cFlags", "libName")
|
||||
)
|
||||
|
||||
func init() {
|
||||
// We run gcc/clang with PWD=/proc/self/cwd to remove $TOP from the
|
||||
// debug output. That way two builds in two different directories will
|
||||
// create the same output.
|
||||
if runtime.GOOS != "darwin" {
|
||||
pctx.StaticVariable("relPwd", "PWD=/proc/self/cwd")
|
||||
} else {
|
||||
// Darwin doesn't have /proc
|
||||
pctx.StaticVariable("relPwd", "")
|
||||
}
|
||||
}
|
||||
|
||||
type builderFlags struct {
|
||||
globalFlags string
|
||||
asFlags string
|
||||
|
@ -128,15 +140,6 @@ func TransformSourceToObj(ctx common.AndroidModuleContext, subdir string, srcFil
|
|||
srcRoot := ctx.AConfig().SrcDir()
|
||||
intermediatesRoot := ctx.AConfig().IntermediatesDir()
|
||||
|
||||
// We run gcc/clang with PWD=/proc/self/cwd to remove $TOP from the
|
||||
// debug output. That way two builds in two different directories will
|
||||
// create the same output.
|
||||
relPwd := "PWD=/proc/self/cwd"
|
||||
if ctx.Darwin() {
|
||||
// /proc doesn't exist on Darwin
|
||||
relPwd = ""
|
||||
}
|
||||
|
||||
objFiles = make([]string, len(srcFiles))
|
||||
objDir := common.ModuleObjDir(ctx)
|
||||
if subdir != "" {
|
||||
|
@ -209,7 +212,6 @@ func TransformSourceToObj(ctx common.AndroidModuleContext, subdir string, srcFil
|
|||
Args: map[string]string{
|
||||
"cFlags": moduleCflags,
|
||||
"ccCmd": ccCmd,
|
||||
"relPwd": relPwd,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue