please icon indicating copy to clipboard operation
please copied to clipboard

how to include subrepo in root BUILD file?

Open georgegiovanni opened this issue 7 years ago • 4 comments

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."

georgegiovanni avatar Jan 30 '19 20:01 georgegiovanni

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.

peterebden avatar Jan 31 '19 10:01 peterebden

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?

georgegiovanni avatar Jan 31 '19 13:01 georgegiovanni

Yep, unfortunately there is no way around having two BUILD files for this case at present.

peterebden avatar Jan 31 '19 14:01 peterebden

Thanks for the clarification.

georgegiovanni avatar Jan 31 '19 14:01 georgegiovanni