This feature is still experimental; some aspects may not work fully or at all just yet. Proceed with caution!
It is possible to pull in dependencies from separate repositories using Please. These are called subrepos and are defined in BUILD files.
They're heavily based on Bazel's similar concept and a certain amount of interoperability is possible.
Subrepos are defined using builtins like http_archive or
new_http_archive. These download a remote file and
extract it, and make the contents available to other rules. The main difference is that
new_http_archive needs to be given a BUILD file but
uses one existing within the file.
For example (as seen at the root of the Please repo):
http_archive( name = "pleasings", hashes = ["388baebf9381c619f13507915f16d0165a5dc13e"], strip_prefix = "pleasings-f0c549b375067802400699247106e4907de917c2", urls = ["https://github.com/thought-machine/pleasings/archive/f0c549b375067802400699247106e4907de917c2.zip"], )
Currently, subrepo rules only work when placed at the repo root. In future we intend to lift this restriction. In Bazel compatibility mode they can also be used within the WORKSPACE file.
Rules within subrepos can be referenced using an
@ prefix on rules, anywhere
where a build rule would normally be accepted. For example:
In this case
subinclude("@pleasings//go:go_bindata") cc_test( name = "my_test", ... deps = [ "@pleasings//eggs:spam", ], )
pleasingscorresponds to the name of the subrepo as declared in the
Subrepos also underpin cross-compiling and share the same syntax; you can use that to reference architectures as well. There is currently some ambiguity here and so it is best not to define subrepo names that match cross-compile architectures.
If the subrepo and the package names are the same, for example,
the build label reference to the target can be abbreviated, like so:
cc_test( name = "my_test", ... deps = [ "@unittest_cpp", ], )