@@ -7,6 +7,31 @@ load("//diff/private:diff.bzl", "diff_rule")
77def cmp (name , srcs , args = [], out = None , ** kwargs ):
88 """Runs cmp (binary diff) between two files and returns the output.
99
10+ Examples:
11+
12+ Compare two binaries.
13+
14+ ```starlark
15+ cmp(
16+ name = "compare_bins",
17+ args = ["--bytes", "4", "--verbose"],
18+ srcs = ["bin_a", "bin_b"],
19+ out = "cmp_output"
20+ )
21+ ```
22+
23+ Run cmp in a genrule.
24+
25+ ```starlark
26+ genrule(
27+ name = "run_cmp",
28+ srcs = ["bin_a", "bin_b"],
29+ outs = ["cmp_output"],
30+ cmd = "$(CMP_BIN) --verbose $(execpath bin_a) $(execpath bin_b) > $@",
31+ toolchains = ["@diff.bzl//diff/toolchain:execution_type"],
32+ )
33+ ```
34+
1035 Args:
1136 name: The name of the rule
1237 srcs: The files to compare.
@@ -54,6 +79,18 @@ def diff(name, srcs, args = ["--unified"], patch = None, **kwargs):
5479 )
5580 ```
5681
82+ Run diff in a genrule.
83+
84+ ```starlark
85+ genrule(
86+ name = "run_diff",
87+ srcs = ["a.txt", "b.txt"],
88+ outs = ["a.patch"],
89+ cmd = "$(DIFF_BIN) --unified $(execpath a.txt) $(execpath b.txt) > $@",
90+ toolchains = ["@diff.bzl//diff/toolchain:execution_type"],
91+ )
92+ ```
93+
5794 _By default, diff creates a unified format patch by passing `["--unified"]`
5895 to `args`. If overriding arguments, --unified must be added explicitly._
5996
0 commit comments