Buck as general purpose build system?

2,096 views
Skip to first unread message

Red Daly

unread,
Sep 21, 2013, 4:36:39 PM9/21/13
to buck-...@googlegroups.com

Can buck be used as a build system for software projects that have nothing to do with Android?  It seems like it can be used as such, but it's not clear if that's intended or supported.

Red

Shawn Pearce

unread,
Sep 21, 2013, 5:44:08 PM9/21/13
to Red Daly, buck-build
Yes. I use it to build Gerrit Code Review, which is a Java program
that is not an Android application.

Michael Bolin

unread,
Sep 25, 2013, 3:44:30 PM9/25/13
to buck-...@googlegroups.com, Red Daly
Hi Red, at a minimum, Buck is not accidentally a solid Java build system since building Java is a subset of building Android. Though at the moment, we don't have direct support for building J2EE artifacts such as .war files (or GWT support, for that matter). However, you can often use a combination of macros (http://facebook.github.io/buck/extending/macros.html) and genrules (http://facebook.github.io/buck/rule/genrule.html) to build such things without modifying Buck's source code. We are also working on a plugin system for Buck so that you can write more sophisticated Buck build rules in Java without modifying Buck, as well.

We would like to expand the range of languages/artefacts that Buck can build out of the box, though much of our current effort is still focused on speeding up Android builds. There are particular stages of building an Android application that are still slow, and we know what we want to do to fix them: we just have to write the code. And test it :)

But today, I suspect you will get a lot of benefit from using Buck to build a Java project, as we do some smart caching to minimize rebuilds. Also, it doesn't stand out in the documentation today, but you can set up a local build cache by adding the following to your .buckconfig file (http://facebook.github.io/buck/concept/buckconfig.html):

[cache]
  mode = dir

For bonus points, you can also set up a remote cache using Cassandra. If you populate it via your CI system, you can see some pretty incredible reductions in build times!

Sorry, I'm getting a bit ahead of myself, but the short answer to your question is most definitely: Yes.

Yesudeep Mangalapilly

unread,
Nov 27, 2014, 12:32:28 PM11/27/14
to buck-...@googlegroups.com, red...@gmail.com
Namaste,

Can buck be used for non-Java projects? I'd like to be able to build C, Go, C++, etc. too. 

Cheers,
Yesudeep.

Michael Bolin

unread,
Nov 27, 2014, 1:49:14 PM11/27/14
to Yesudeep Mangalapilly, buck-...@googlegroups.com, red...@gmail.com

Buck can be used for non-Java projects, though support for other languages varies.

As you can see from the "build rules" section of the docs:

http://facebook.github.io/buck/

There's first class support for Java and Python.

There is support for C, but it's currently undocumented. I'm not sure if that's because it's still in flux or because we just haven't had a chance to write it up yet.

There is no built-in support for Go right now. You could try building your own build steps out of genrules. My understanding is that Go builds very quickly, so even if a genrule isn't the most efficient, I guess it should still be pretty performant.

--
You received this message because you are subscribed to the Google Groups "Buck" group.
To unsubscribe from this group and stop receiving emails from it, send an email to buck-build+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tibo...@googlemail.com

unread,
Jan 25, 2015, 9:06:33 AM1/25/15
to buck-...@googlegroups.com, yesu...@bhojo.com, red...@gmail.com
Hi,

In case anyone is interested, I made a small project building the same java source using several buildsystems (ant, maven, gradle, buildr, buck, sbt, leiningen). As a benchmark it may not yet be very meaningful as I did not try a multi-module build: https://github.com/tkruse/build-bench

Several things bothered me when trying to use buck:

There is no strong notion of using the Maven conventions for organizing the file tree. The rest of the java world mostly accepted this structure:
- src
--main
--- java
--- groovy
--- scala
--- ...
--- resources
--- webapp
-- test
--- java
--- groovy
--- scala
--- ...
--- resources

Those conventions have proven themselves, they provide a "familiar face" when joining a project. I find that much better than every project inventing it's own creative solution to where to put which files, and how to name them.

Thus, when I wanted to run tests including (non-code) resources from src/main/resources and src/test/resources both, I got confused over java_library() offering to configure multiple resources, but only a single resources_root. java_test only mentions resources in the docs, not sure whether resources_root is also viable.

How to use bucklets also seems to not be well documented anywhere.

buck seems to write logs to <current-dir>/buck-out, instead of <.buckconfig-dir>/buck-out, or <BUCK-dir>/buck-out. That seems inappropriate.

regards,
  Thibault

david.o...@gmail.com

unread,
Jan 25, 2015, 2:39:48 PM1/25/15
to buck-...@googlegroups.com

Am Sonntag, 25. Januar 2015 15:06:33 UTC+1 schrieb tibo...@googlemail.com:
Hi,

In case anyone is interested, I made a small project building the same java source using several buildsystems (ant, maven, gradle, buildr, buck, sbt, leiningen). As a benchmark it may not yet be very meaningful as I did not try a multi-module build: https://github.com/tkruse/build-bench

Several things bothered me when trying to use buck:

There is no strong notion of using the Maven conventions for organizing the file tree. The rest of the java world mostly accepted this structure:
- src
--main
--- java
--- groovy
--- scala
--- ...
--- resources
--- webapp
-- test
--- java
--- groovy
--- scala
--- ...
--- resources

Those conventions have proven themselves, they provide a "familiar face" when joining a project. I find that much better than every project inventing it's own creative solution to where to put which files, and how to name them.

Thus, when I wanted to run tests including (non-code) resources from src/main/resources and src/test/resources both, I got confused over java_library() offering to configure multiple resources, but only a single resources_root. java_test only mentions resources in the docs, not sure whether resources_root is also viable.

How to use bucklets also seems to not be well documented anywhere.

All bucklets include documentation and example, e.g. [1].


tibo...@googlemail.com

unread,
Jan 25, 2015, 5:13:42 PM1/25/15
to buck-...@googlegroups.com


On Sunday, January 25, 2015 at 8:39:48 PM UTC+1, david.o...@gmail.com wrote:

All bucklets include documentation and example, e.g. [1].



Good tip. i am still more looking for how to get bucklets into my project from different sources, update them after several months, and what I need to do so that they get found. If that were all solved for me, then I guess I could find my way onhow to use specific bucklets.

david.o...@gmail.com

unread,
Jan 25, 2015, 5:43:18 PM1/25/15
to buck-...@googlegroups.com
The plan was to use `remote_file()` rule to fetch bucklets from
remote location(s) and include them in local build. Here is example
how to use `remote_file()` to fetch a JAR from Central: [1].

So something like this should probably work:

include_defs(':local_jar')
remote_file(
name = 'local_jar',
sha1 = 'a8762d07e76cfde2395257a5da47ba7c1dbd3dce',
out = 'local_jar.bucklet'
)


tibo...@googlemail.com

unread,
Jan 26, 2015, 4:39:27 AM1/26/15
to buck-...@googlegroups.com
Hi David,

thanks for elaborating. I do not see remote_file() documented in the docs at all. I am not complaining or requesting, just reporting as an outsider.

I assume this is related to this issue: https://github.com/facebook/buck/issues/64

regards,
  Thibault
Reply all
Reply to author
Forward
0 new messages