Deprecate depfile in gensrcs
All existing gensrsc modulePartners who use the property can use BUILD_BROKEN_DEP_FILE to bypass the error
Test: CI
Bug: 179452413
Fix: 179452413
Change-Id: I7cd39484b43eba693d79188b9a374f192198f90f
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index 1b5cef2..b9be1f7 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -15,6 +15,7 @@
package genrule
import (
+ "fmt"
"os"
"regexp"
"testing"
@@ -626,6 +627,73 @@
}
}
+func TestGensrcsBuildBrokenDepfile(t *testing.T) {
+ tests := []struct {
+ name string
+ prop string
+ BuildBrokenDepfile *bool
+ err string
+ }{
+ {
+ name: `error when BuildBrokenDepfile is set to false`,
+ prop: `
+ depfile: true,
+ cmd: "cat $(in) > $(out) && cat $(depfile)",
+ `,
+ BuildBrokenDepfile: proptools.BoolPtr(false),
+ err: "depfile: Deprecated to ensure the module type is convertible to Bazel",
+ },
+ {
+ name: `error when BuildBrokenDepfile is not set`,
+ prop: `
+ depfile: true,
+ cmd: "cat $(in) > $(out) && cat $(depfile)",
+ `,
+ err: "depfile: Deprecated to ensure the module type is convertible to Bazel.",
+ },
+ {
+ name: `no error when BuildBrokenDepfile is explicitly set to true`,
+ prop: `
+ depfile: true,
+ cmd: "cat $(in) > $(out) && cat $(depfile)",
+ `,
+ BuildBrokenDepfile: proptools.BoolPtr(true),
+ },
+ {
+ name: `no error if depfile is not set`,
+ prop: `
+ cmd: "cat $(in) > $(out)",
+ `,
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ bp := fmt.Sprintf(`
+ gensrcs {
+ name: "foo",
+ srcs: ["data.txt"],
+ %s
+ }`, test.prop)
+
+ var expectedErrors []string
+ if test.err != "" {
+ expectedErrors = append(expectedErrors, test.err)
+ }
+ android.GroupFixturePreparers(
+ prepareForGenRuleTest,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ if test.BuildBrokenDepfile != nil {
+ variables.BuildBrokenDepfile = test.BuildBrokenDepfile
+ }
+ }),
+ ).
+ ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(expectedErrors)).
+ RunTestWithBp(t, bp)
+ })
+
+ }
+}
+
func TestGenruleDefaults(t *testing.T) {
bp := `
genrule_defaults {