Ignore certain input files while computing android_resource's rule key.

Summary: Use the same pattern as `aapt` to ignore files.

Test Plan:
buck test --all
Added a unit test.
Pass client environment to DefaultExecutionEnvironment.

Summary:
Previously DefaultExecutionEnvironment would always use the process
environment whether or not buckd was used. This change ensures that
DefaultExecutionEnvironment always uses the client environment.

Test Plan: buck test --all
Delete watchman watch entry when killing buckd

Test Plan:
buckd
watchman watch-list
buckd --kill
verify watchman watch-list returns empty list.
Disable one of the `ExternalJavacIntegrationTest` test cases.

Summary:
Because we need green builds.
I will make sure to turn this one and DaemonIntegrationTest back on once we
resolve the inotify watches limit on buildbot.

Test Plan: sandcastle
Make Android agent run on latest AOSP

Summary: Compile agent as a PIE executable so that it runs on latest AOSP, which insists that all executables are PIE

Test Plan: buck install fb4a
Extract all graph enhancement into a single interface.

Summary:
Prior to this diff, there were three ways that dependencies could be altered:

1) Return "null" from "getEnhancedDeps()", which was effectively a no-op
2) Return non-null from "getEhancedDeps()", which added those deps to the inferred deps.
3) Implement HasDepsOverride and go nuts.

Hilariously, it was possible to combine 2 and 3, though nothing did. Rather than do this
nastiness, we now delegate all graph enhancement to the Buildable. The reason for doing
this here rather than at the Description level is that each Flavor could ultimatley
generate its own Buildable, and each of those might want to mutate the graph in different
ways.

Test Plan:
buck test --all
Build the prod apps repeatedly and run every automated test we have on them.
Simplify logic in BuildRuleFactoryParams to resolve a path.

Summary:
Currently, no one uses this method other than tests.

My diff which introduces the target graph collects all paths referenced by a
target, using `resolveFilePathRelativeToBuildFileDirectory()`. A lot of time
was spent checking if the file exists or not, which is anyway later than by
`PathTypeCoercer`. This diff minimizes the logic in that method to simply return
a path without doing any checks.

Remove test cases for deleted code.

Test Plan: sandcastle.
Normalize exported and provided deps to ##ImmutableSortedSet##

Summary:
These are created and eventually stored as ##ImmutableSortedSet##
types, but the interfaces in between their creation and their
member references are generalized around the ##Set## type which
forces a copy in the ##DefaultJavaLibrary## constructor.  I'm
entirely sure if we want to standardize on ##ImmutableSortedSet##
as the main ##BuildRule## container, but it seems nice to make
this consistent and avoid the copy.

Test Plan: ant test
Pass client environment to ProjectBuildFileParser.

Summary:
Previously ProjectBuildFileParser would always use the
process environment whether or not buckd was used. This change ensures
that ProjectBuildFileParser always uses the client environment. This
change also invalidates the Parser build rule cache on environment
changes in case build rules depend on the environment.

Test Plan: buck test --all
Fixes for several typos and typesetting problems in the docs.

Summary:
I read through all the docs over the weekend, and noticed several small typos and typesetting problems. Here are some fixes.

Closes #123

Test Plan: careful inspection
Clean up Buildable instances to rely on BuildRuleParams a little less.

Summary:
When we transitioned from BuildRules to Buildables we simply changed the inheritance hierarchy
and then fixed the compilation errors. This isn't ideal, since we left references to
BuildRuleParams in many constructors. This diff clears up most of those references and deletes
the newly unusued code.

Test Plan: buck test --all
Extract buildTarget field in AbstractBuildable implementations.

Summary: buildTarget is a common field in many AbstractBuildable subclasses. This Extracts the field to an AbstractBuildTargetBuildable common superclass. Fixes T3610259.

Test Plan: buck test buck --all
Ensure buck, and its tests, pass cleanly on Java 8.

Summary:
Looks like Java 8 rejigs the way that Sets are ordered by default. Get our tests green again,
but I suspect we need to audit where we add lists to rule keys and ensure that they're always
sorted.

When Buck is compiled using Ant, the source and target versions of Java are not specified, so
whatever is being used by the system is selected. Android, OTOH, popularly targets Java 6,
so we need to ensure that the correct versions are being tested in the `DalvikStatsToolTest`.

Test Plan: buck test --all on Java 7 and 8
Introduce the concept of a target graph.

Summary:
TargetNode is pretty much a copy pasta of DescribedRuleBuilder's constructor,
except it skips parsing the visibility patterns since it's not needed until you
actually build a rule. TargetNode encapsulates a parsed build rule's raw inputs,
its description, input paths and build targets referenced. Once we have the target
graph, we traverse over it bottom up, building up the action graph using the
TargetNodeToBuildRuleTransformer.

Test Plan:
buck build instagram
Used visualvm to record memory usage during the parsing step, did not notice any
significant impact. Ditto with time to finish parsing for fb4a.
Support targets of the form 'android-#' for android_binary

Summary:
Modified the regex in AndroidPlatformTarget.getTargetForId() to work for
strings of the form 'android-#'. Closes #118

Test Plan:
Run `buck build hello` and verify that the build succeeds. Then replace 'Google
Inc.:Google APIs:16' with 'android-16' in fbandroid/apps/samples/hello/BUCK,
run `buck build hello`, and verify that the build succeeds.
Revert incorrect support for 'android-#' targets

Summary: This reverts commit 509f94a65e2123447c337730d54775702285d8f0.

Test Plan: revert-hammer

Reviewed By: natthu

Subscribers:

Tasks: 4391518
Kill RecordArtifactsInDirectoryStep.

Summary: Replace it with a copystep and buildableContext.recordArtifactsInDirectory().

Test Plan:
buck test --all
sandcastle
Pass system environment `PATH` in the NGContext for DaemonIntegrationTest.

Summary:
I turned on the test locally (because I think we solved the watchman issue now)
but the test still failed - although this time for a different reason. This
particular test case calls 'buck targets' which was failing essentially due to
some failure in executing buck.py. I printed the command to execute buck.py and
noticed that the interpreter used was jython (and not python2). Turns out since
the "PATH" property is not set in the test NGContext, `BuckConfig` cannot find
the system python/python2 files and so uses the fallback jython interpreter.

We should probably figure out why the jython invocation fails.

FWIW, this is the python trace for the jython failure:
```
Traceback (most recent call last):
  File "/tmp/buck8197345396108643146.py", line 1049, in <module>
  main()
  File "/tmp/buck8197345396108643146.py", line 1049, in <module>
  main()
  File "/tmp/buck8197345396108643146.py", line 468, in main
  buildFileProcessor.process(build_file)
  File "/tmp/buck8197345396108643146.py", line 399, in process
  execfile(os.path.join(self.project_root, build_file),
  File "/home/natthu/devtools/buck/src/com/facebook/buck/httpserver/BUCK", line 1, in <module>
  java_library(
  File "/tmp/buck8197345396108643146.py", line 80, in invoke
  return self.func(*args, **updated_kwargs)
  File "/tmp/buck8197345396108643146.py", line 298, in glob
  paths = [p for p in paths if not exclusion(p)]
  File "/tmp/buck8197345396108643146.py", line 296, in exclusion
  return next(exclusions, None)
  NameError: global name 'next' is not defined
```

Test Plan: DaemonIntegrationTest passes (after removing the Ignore annotation).
Re-enable integration tests that were disabled because of the inotify limit issue.

Test Plan: sandcastle
Fixed printing tabbed stack lines with a color code

Summary:
For some reason, printing a leading tab with a prefixed color code
outputs 4 spaces instead of 8, so this diff just moves the color code to be
after the leading tabs, if any.  Also removed dupey Ansi class code.

Test Plan:
- In buck repo, run this failing test: buck test test/com/facebook/buck/util
- Verify all the stack lines are aligned, and the ones from the test are
  colored.