Buck: A fast build tool

1,585 阅读2分钟
原文链接: buckbuild.com
Buck is a build system for Android that encourages the creation of small, reusable modules consisting of code and resources. Because Android applications are predominantly written in Java, Buck also functions as a Java build system. Learn more about the strategies Buck uses to build Java code so quickly.

Features

Buck can help you do the following:
  • Speed up your Android builds. Buck builds independent artifacts in parallel to take advantage of multiple cores. Further, it reduces incremental build times by keeping track of unchanged modules so that the minimal set of modules is rebuilt.
  • Introduce ad-hoc build steps for building artifacts that are not supported out-of-the-box using the standard Ant build scripts for Android.
  • Keep the logic for generating build rules in the build system instead of requiring a separate system to generate build files.
  • Generate code-coverage metrics for your unit tests.
  • Generate an IntelliJ project based on your build rules. This makes Buck ideal for both local development builds in an IDE as well as headless builds on a continuous integration machine.
  • Make sense of your build dependencies.
  • Understand what is going on under the hood when building an APK.
Speed is the primary focus for Buck. At Facebook, we found Buck to be more than twice as fast as Ant, and we are continuing to make it even faster.

How Buck Works

Buck has three primary concepts:
  • A build rule is a procedure for producing an output file from a set of input files.
  • A build target is a string identifier for a build rule. It can be thought of as a "URI" within a project using Buck.
  • A build file that defines one or more build rules. In Make, this would be a Makefile, but in Buck, these files are named BUCK. A project using Buck is expected to have many BUCK files.
Every build rule can have zero or more dependencies associated with it, or deps. These dependencies form a directed graph, which Buck requires to be acyclic.

When building the output of a build rule, all of the rule's transitive dependencies are built first. This means that the graph is built in a "bottom-up" fashion. A build rule knows only who it depends on, not what depends on it, which makes the build graph easier to reason about. This helps Buck identify independent subgraphs that can be built in parallel, as well as determine the minimal set of build rules that need to be rebuilt.

Is Buck for Me?

Buck is designed for building multiple deliverables from a single repository rather than across multiple repositories. It has been our experience that maintaining dependencies in the same repository makes it easier to ensure that all developers have the correct version of all of the code, and simplifies the process of making atomic commits.

If you build multiple applications, or even if you ship one application but use several sample applications for development, then Buck is definitely for you. Give the Quick Start a try and see how Buck can help you organize your Android project and build it faster than ever before.

Getting Started

About

Concepts

Build Rules

Functions

Commands

Extending Buck

Contributing to Buck

© Copyright Facebook, 2013 -