summaryrefslogtreecommitdiff
path: root/android/defs.go
diff options
context:
space:
mode:
author Jihoon Kang <jihoonkang@google.com> 2024-12-19 02:06:22 +0000
committer Jihoon Kang <jihoonkang@google.com> 2024-12-20 00:11:38 +0000
commitbd7afdc2a15e776e9aff208577ab16fd693499f2 (patch)
tree9602250981e8265a404fde6d4fe07cb10743c9d3 /android/defs.go
parentee97ae8c667dba51897e4a9cdfe5e6df9255dee1 (diff)
Define a tool and a static rule to calculate the hash of a directory
The rule will be used in a follow up change that adds a directory in a provider. Test: m nothing Bug: 381104942 Change-Id: I7147dcbc43e19840b2d73380785a01bda6643d85
Diffstat (limited to 'android/defs.go')
-rw-r--r--android/defs.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/android/defs.go b/android/defs.go
index 9f3fb1ee6..c4e3b995f 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -102,6 +102,18 @@ var (
Description: "concatenate files to $out",
})
+ // Calculates the hash of a directory and writes to a file.
+ // Note that the directory to calculate the hash is intentionally not listed as an input,
+ // to prevent adding directory as a ninja dependency. Thus, an implicit dependency to a file
+ // is required.
+ WriteDirectoryHash = pctx.AndroidStaticRule("WriteDirectoryHash",
+ blueprint.RuleParams{
+ Command: "rm -f $out && ${calculateDirectoryHash} $dir $out",
+ CommandDeps: []string{"${calculateDirectoryHash}"},
+ Description: "Calculates the hash of a directory and writes to $out",
+ }, "dir",
+ )
+
// Used only when USE_GOMA=true is set, to restrict non-goma jobs to the local parallelism value
localPool = blueprint.NewBuiltinPool("local_pool")
@@ -118,4 +130,6 @@ func init() {
pctx.VariableFunc("RBEWrapper", func(ctx PackageVarContext) string {
return ctx.Config().RBEWrapper()
})
+
+ pctx.HostBinToolVariable("calculateDirectoryHash", "calculate_directory_hash")
}