Zip up all of the outputs for a build rule and store them as a single artifact.

Summary:
Previously, we used a complex scheme for storing metadata for a build rule
in the artifact cache. This diff introduces a vast simplification (note how much
code is removed from `DefaultJavaLibraryRule` as a result of this diff) where all outputs
and metadata for a build rule are stored in a zip file, and the zip file is stored in
the artifact cache. (Therefore, all metadata must be written to a file before it can
be included in the zip.) The structure of the zip file is such that it matches the layout
of the files in the user's project directory. This means that after an artifact is
downloaded, it can be unzipped in the root of the user's project directory to match
the state of `buck-out` as if the rule had been built locally.

There are two major abstractions introduced in this diff: `OnDiskBuildInfo` and
`BuildInfoRecorder`. Both of these are designed to help manage build rule
outputs and metadata (where metadata would be something like the ABI for a `java_library()` rule).

When deciding whether a rule needs to be built locally or if the current output file
in `buck-out` is valid, the current `RuleKey` must be compared with the
`RuleKey` on disk. The `OnDiskBuildInfo` is the interface through which the
`RuleKey` on disk is queried. This is true for all metadata about the output from
the previous execution of the build rule.

In a complementary fashion, `BuildInfoRecorder` is used to keep a record of all
metadata and output files generated by the build rule. Assuming the rule builds successfully,
the `BuildInfoRecorder` will write all of this data to disk, and will then zip it up
as a file to be stored in the artifact cache.

This diff introduces a new object, `BuildableContext`, which is passed along with
`BuildContext` to `Buildable`'s `getBuildSteps()` method. `BuildableContext` contains
data that is specific to the build rule being built, as opposed to `BuildContext`,
which contains shared data universal to all build rules.

This new scheme eliminates the need for the `ArchivingRule` that was introduced
earlier. This diff effectively reverts that diff, and updates `PrebuiltNativeLibrary`
and `NdkLibrary` so they extend `AbstractBuildable` rather than
`DoNotUseAbstractBuildable`. This will help us on our crusade to eliminate
`DoNotUseAbstractBuildable`, after which we can convert
`AbstractCachingBuildRule` from an abstract class to a non-extendible class
whose purpose in life is to execute `Buildable`s.

I also eliminated the `com.facebook.buck.cpp` package for now, as the only rule
in there (`PrebuiltNativeLibrary`) had Android-specific behavior because the layout
of its "libs" directory was required to have a structure that reflected that which
is required by Android. This code is now in the `com.facebook.buck.android`
package where it belongs.

Previously, `GenAidlRule` was not cacheable because it did not know where it
would generate its output files. This is exactly the type of issue that
`BuildInfoRecorder` is designed to solve, so `GenAidlRule` has been updated to
use `BuildInfoRecorder` so that it can be cached. While I was at it, I also
renamed `GenAidlRule` to `GenAidl`, as it now also extends `AbstractBuildable`
instead of `DoNotUseAbstractBuildable`.
53 files changed
tree: 88b86dbd7263400a2a7dd9914b45df1707d8f3cb
  1. .idea/
  2. bin/
  3. config/
  4. docs/
  5. lib/
  6. pmd/
  7. scripts/
  8. src/
  9. test/
  10. testdata/
  11. third-party/
  12. .buckconfig
  13. .classpath
  14. .gitignore
  15. .project
  16. buck.iml
  17. build.xml
  18. DEFS
  19. LICENSE
  20. README.md
README.md

Buck

Buck is an Android build tool. To see what Buck can do for you, check out the documentation at http://facebook.github.io/buck/.

Installation

To build Buck, run the following:

git clone git@github.com:facebook/buck.git
cd buck
ant
./bin/buck --help

License

Apache License 2.0