Use Rule-local implicit dependencies
Depends on https://github.com/google/blueprint/pull/78
This uses the new CommandDeps field to move implicit dependencies
embedded in the Command string next to the definition, instead of having
to specify them in every BuildParam struct. This should make it easier
to verify dependencies.
Change-Id: I2711b160920e22fa962a436e1f7041272166f50f
diff --git a/cc/builder.go b/cc/builder.go
index 3d5bb77..a1d7f2c 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -45,6 +45,7 @@
Depfile: "${out}.d",
Deps: blueprint.DepsGCC,
Command: "$relPwd $ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
+ CommandDeps: []string{"$ccCmd"},
Description: "cc $out",
},
"ccCmd", "cFlags")
@@ -53,6 +54,7 @@
blueprint.RuleParams{
Command: "$ldCmd ${ldDirFlags} ${crtBegin} @${out}.rsp " +
"${libFlags} ${crtEnd} -o ${out} ${ldFlags}",
+ CommandDeps: []string{"$ldCmd"},
Description: "ld $out",
Rspfile: "${out}.rsp",
RspfileContent: "${in}",
@@ -62,6 +64,7 @@
partialLd = pctx.StaticRule("partialLd",
blueprint.RuleParams{
Command: "$ldCmd -r ${in} -o ${out}",
+ CommandDeps: []string{"$ldCmd"},
Description: "partialLd $out",
},
"ldCmd")
@@ -69,6 +72,7 @@
ar = pctx.StaticRule("ar",
blueprint.RuleParams{
Command: "rm -f ${out} && $arCmd $arFlags $out @${out}.rsp",
+ CommandDeps: []string{"$arCmd"},
Description: "ar $out",
Rspfile: "${out}.rsp",
RspfileContent: "${in}",
@@ -78,6 +82,7 @@
darwinAr = pctx.StaticRule("darwinAr",
blueprint.RuleParams{
Command: "rm -f ${out} && $arCmd $arFlags $out $in",
+ CommandDeps: []string{"$arCmd"},
Description: "ar $out",
},
"arCmd", "arFlags")
@@ -85,6 +90,7 @@
darwinAppendAr = pctx.StaticRule("darwinAppendAr",
blueprint.RuleParams{
Command: "cp -f ${inAr} ${out}.tmp && $arCmd $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}",
+ CommandDeps: []string{"$arCmd"},
Description: "ar $out",
},
"arCmd", "arFlags", "inAr")
@@ -92,6 +98,7 @@
prefixSymbols = pctx.StaticRule("prefixSymbols",
blueprint.RuleParams{
Command: "$objcopyCmd --prefix-symbols=${prefix} ${in} ${out}",
+ CommandDeps: []string{"$objcopyCmd"},
Description: "prefixSymbols $out",
},
"objcopyCmd", "prefix")
@@ -103,6 +110,7 @@
Depfile: "${out}.d",
Deps: blueprint.DepsGCC,
Command: "$copyGccLibPath $out $ccCmd $cFlags -print-file-name=${libName}",
+ CommandDeps: []string{"$copyGccLibPath", "$ccCmd"},
Description: "copy gcc $out",
},
"ccCmd", "cFlags", "libName")
@@ -202,13 +210,11 @@
ccCmd = gccCmd(flags.toolchain, ccCmd)
}
- objDeps := append([]string{ccCmd}, deps...)
-
ctx.Build(pctx, blueprint.BuildParams{
Rule: cc,
Outputs: []string{objFile},
Inputs: []string{srcFile},
- Implicits: objDeps,
+ Implicits: deps,
Args: map[string]string{
"cFlags": moduleCflags,
"ccCmd": ccCmd,
@@ -227,10 +233,9 @@
arFlags := "crsPD"
ctx.Build(pctx, blueprint.BuildParams{
- Rule: ar,
- Outputs: []string{outputFile},
- Inputs: objFiles,
- Implicits: []string{arCmd},
+ Rule: ar,
+ Outputs: []string{outputFile},
+ Inputs: objFiles,
Args: map[string]string{
"arFlags": arFlags,
"arCmd": arCmd,
@@ -337,7 +342,6 @@
ldDirs = append(ldDirs, dir)
}
- deps = append(deps, ldCmd)
deps = append(deps, sharedLibs...)
deps = append(deps, staticLibs...)
deps = append(deps, lateStaticLibs...)
@@ -368,13 +372,10 @@
ldCmd := gccCmd(flags.toolchain, "ld")
- deps := []string{ldCmd}
-
ctx.Build(pctx, blueprint.BuildParams{
- Rule: partialLd,
- Outputs: []string{outputFile},
- Inputs: objFiles,
- Implicits: deps,
+ Rule: partialLd,
+ Outputs: []string{outputFile},
+ Inputs: objFiles,
Args: map[string]string{
"ldCmd": ldCmd,
},
@@ -388,10 +389,9 @@
objcopyCmd := gccCmd(flags.toolchain, "objcopy")
ctx.Build(pctx, blueprint.BuildParams{
- Rule: prefixSymbols,
- Outputs: []string{outputFile},
- Inputs: []string{inputFile},
- Implicits: []string{objcopyCmd},
+ Rule: prefixSymbols,
+ Outputs: []string{outputFile},
+ Inputs: []string{inputFile},
Args: map[string]string{
"objcopyCmd": objcopyCmd,
"prefix": prefix,
@@ -405,10 +405,6 @@
ctx.Build(pctx, blueprint.BuildParams{
Rule: copyGccLib,
Outputs: []string{outputFile},
- Implicits: []string{
- "$copyGccLibPath",
- gccCmd(flags.toolchain, "gcc"),
- },
Args: map[string]string{
"ccCmd": gccCmd(flags.toolchain, "gcc"),
"cFlags": flags.globalFlags,
diff --git a/cc/gen.go b/cc/gen.go
index 3bfe679..be50d75 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -38,6 +38,7 @@
blueprint.RuleParams{
Command: "BISON_PKGDATADIR=$yaccDataDir $yaccCmd -d $yaccFlags -o $cppFile $in && " +
"cp -f $hppFile $hFile",
+ CommandDeps: []string{"$yaccCmd"},
Description: "yacc $out",
},
"yaccFlags", "cppFile", "hppFile", "hFile")
@@ -45,6 +46,7 @@
lex = pctx.StaticRule("lex",
blueprint.RuleParams{
Command: "$lexCmd -o$out $in",
+ CommandDeps: []string{"$lexCmd"},
Description: "lex $out",
})
)
@@ -57,10 +59,9 @@
headerFile = pathtools.ReplaceExtension(cppFile, "h")
ctx.Build(pctx, blueprint.BuildParams{
- Rule: yacc,
- Outputs: []string{cppFile, headerFile},
- Inputs: []string{yaccFile},
- Implicits: []string{"$yaccCmd"},
+ Rule: yacc,
+ Outputs: []string{cppFile, headerFile},
+ Inputs: []string{yaccFile},
Args: map[string]string{
"yaccFlags": yaccFlags,
"cppFile": cppFile,
@@ -78,10 +79,9 @@
cppFile = pathtools.ReplaceExtension(cppFile, "cpp")
ctx.Build(pctx, blueprint.BuildParams{
- Rule: lex,
- Outputs: []string{cppFile},
- Inputs: []string{lexFile},
- Implicits: []string{"$lexCmd"},
+ Rule: lex,
+ Outputs: []string{cppFile},
+ Inputs: []string{lexFile},
})
return cppFile