Created by: davido
Owning rule must not necessary belong to the same cell as the macros it contains:
genrule( name = 'foo', cmd = 'echo "$(location @bar//:baz)" > $OUT', out = 'qux', )
Cell can be located in the same project, but can be hijacked by the command line parameter. Consider the following configuration in .buckconfig for the example above:
[repositories] bar = lib/bar
It can optionally be relocated with --config CLI parameter:
$ buck build //:foo $ buck build --config repositories.bar=/path/to/hijacked/bar //:foo
IOW it is always wrong to assume that the owning rule and all macros it contains belong to the same cell. Remove filesystem parameter from the macro expansion machinery and rely on the rule that has access to its own filesystem to perform correct path resolution.
TEST PLAN:
-
Clone JGit with this patch: [1].
-
Clone Gerrit Code Review with this patch: [2].
-
Replace JGit cell during Gerrit build, with:
$ buck build --config repositories.jgit=/path/to/jgit gerrit
Observe that without this diff, '$(location @jgit//:jgit_src)' is expanded to /buck-out/gen/jgit_src.jar. With this diff, file system mismatch is fixed and the expansion is correct: /path/to/jgit/buck-out/gen/jgit_src.jar
[1] https://git.eclipse.org/r/61938 [2] https://gerrit-review.googlesource.com/73000