Bazel: Feature Request: Contributed BUILD Files Repository

Created on 9 Feb 2017  路  6Comments  路  Source: bazelbuild/bazel

For C/C++ libraries that don't have Bazel support (i.e.: almost all of them), it's easy to pull down the source via new_http_archive (etc), but sometimes the Bazel BUILD file that must be constructed is decidedly nontrivial. (e.g., consider the details necessary for the libjpeg-turbo library) .

It would be a shame to force people to reinvent wheels for things like this; it would also be unfortunate to have people simply replicate these files via copy-n-paste between projects (both for licensing and maintenance reasons).

Has the Bazel team thought about encouraging a "Contributed BUILD Files" repository for this sort of thing? It seems like it would make using C/C++ with Bazel potentially a lot simpler if coders knew where to look for existing Bazel build rules and avoid reinventing wheels unnecessarily.

P4 team-Bazel feature request

Most helpful comment

Yeah, I've been playing around with writing a repository rule that is basically:

for url in ctx.attr.urls:
   ctx.download_and_extract(url)
for script in ctx.attr.scripts:
   ctx.execute(script)

So you could download a bunch of stuff and then configure/set it up. Not sure exactly what the API should look like, yet, though.

All 6 comments

Yes, definitely. @mzhaom actually started one a while ago: https://github.com/mzhaom/trunk. We haven't gotten a chance to make a standardized system for it, yet.

Didn't know about @mzhaom repo until now -- looks like a good starting point.

What would make this even cooler would be if new_http_archive() and friends could retrieve the BUILD files from a remote repo as well, e.g.

  native.new_http_archive(
     name = "jpeg",
     url = "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.5.1.tar.gz",
     sha256 = "c15a9607892113946379ccea3ca8b85018301b200754f209453ab21674268e77",
     build_file_url = "https://github.com/mzhaom/path/to/libjpeg-turbo.BUILD",
     build_file_sha256 = "<expected SHA for BUILD file>",
  )

(Writing a wrapper around new_http_archive() to do this should be simple, of course, but having it built-in would make this workflow easier for people to rely on)

Yeah, I've been playing around with writing a repository rule that is basically:

for url in ctx.attr.urls:
   ctx.download_and_extract(url)
for script in ctx.attr.scripts:
   ctx.execute(script)

So you could download a bunch of stuff and then configure/set it up. Not sure exactly what the API should look like, yet, though.

Contribute that rule to the repo as well.

Any updates on this?

There is currently nobody working on this. I am putting it in the ice-box for now and hope that the community will come with a solution.

Was this page helpful?
0 / 5 - 0 ratings