how to include subrepo in root BUILD file?
Trying to include rules from a remote server and use them in the same BUILD file:
http_archive(
name = "foo",
urls = ["http://example.com/foo-build-defs.tar"],
)
subinclude("@foo//:main")
rule_from_foo_subrepo(
...
)
but i get the following error:
error: Subincludes cannot be from the local package
Directory structure looks like this:
- project/
BUILD
src/
file1
Trying to avoid having to create another BUILD file in a sub-directory just so i can use subinclude. Is this possible? Docs say "Currently, subrepo rules only work when placed at the repo root. In future we intend to lift this restriction."
This won't work as it stands; the subinclude requires the subrepo to be defined & downloaded so it can read from it, which can't happen until it finishes parsing the file, and of course it needs the subinclude to get there.
Fortunately the docs are out of date (I'm partway through updating them), so it is possible to put the subrepo somewhere else & subinclude from it that way.
I see, does that mean the simplest way to get this working is:
project/
BUILD <- http_archive (subrepo) in this file
sub/
BUILD <- subinclude in this file along with rule usage
src/
Any way to get around using two BUILD files?
Yep, unfortunately there is no way around having two BUILD files for this case at present.
Thanks for the clarification.