Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Buck have anything like Gradle's build variants and product flavors?

I have been looking into using Buck for a large project, but I want to know if there is an equivalent to gradle's build variants and product flavors that have been so useful.

like image 491
Daniel Smith Avatar asked Dec 31 '25 17:12

Daniel Smith


1 Answers

For debug vs. release builds (i.e., constants in BuildConfig.java), there's android_build_config(): http://facebook.github.io/buck/rule/android_build_config.html. If you're curious, the commit that introduced it explains in detail how android_build_config() works and why it has a more efficient implementation than Gradle. Specifically, in Buck, you can build debug and release builds in parallel at the same time, but in Gradle, you cannot.

Although not currently documented, android_binary() has arguments resource_filter and cpu_filters to restrict the generated APK to the appropriate resources. resource_filter could be a list like ['mdpi', 'hdpi'] while cpu_filters could be a set like ['arm', 'armv7', 'x86']. Currently, for each permutation, you have to write a separate android_binary() rule, which is admittedly more tedious than how you define things in Gradle. I recommend defining a macro to generate all of your android_binary() rules to help eliminate boilerplate. We are working to make this easier to do using the built-in rule so developers don't have to create their own macros for this stuff.

like image 76
bolinfest Avatar answered Jan 02 '26 09:01

bolinfest



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!