Limit a genrule's runtime environment variables to those that appear in the command string.

Summary:
We are seeing problems in the wild where we are exceeding exec's ARG_MAX limit with
genrules that have extremely long lists of environment variables. ($DEPS is the biggest
offender, and will ultimately be deleted.)

This is intended as a quick fix. The long-term fix is to interpolate the env variables
in place in the command string as we do for `$(location)` and `$(exe)`. This will also
simplify Windows support where env variables appear as `$OUT` in the `bash` argument,
but `%OUT%` in the `cmd_exe` argument. Care must be taken to escape the interpolated
variables correctly.

Admittedly, this will introduce a regression for genrules that are using environment
variables in the scripts that they run, but do not reference them in the command string.
A notice will be sent out.

Test Plan:
Sandcastle builds.

Ran `buck build fb4a messenger instagram` with this diff.
Everything built successfully, which is good, as this exercises most of the genrules in the codebase.
This is evidence that there are few, if any, genrules in fbandroid that use environment variables
that are not referenced explicitly in the command string.
4 files changed
tree: b991c26159959f5fa50fd930c8bb0905c2ea6375
  1. .idea/
  2. bin/
  3. config/
  4. docs/
  5. lib/
  6. plugin/
  7. pmd/
  8. scripts/
  9. src/
  10. test/
  11. testdata/
  12. third-party/
  13. .buckconfig
  14. .classpath
  15. .gitignore
  16. .project
  17. buck.iml
  18. build.xml
  19. DEFS
  20. LICENSE
  21. 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