Port buck launcher scripts to python.

Summary:
Hopefully no major bugs this time.

- This handles the Ctrl-C issue where buckd was getting killed when buck build
  was interrupted. The fix is to change the process group of the child buckd
  process by calling `os.setpgrp()` in `preexec_fn`.
- Correctly pass java.util.logging.config.class and buck.logging_config_file.
- Include @jacko's fix to return proper exit code from buck.py.
- Bump up nailgun client timeout to 60s.

Test Plan:
```
$ buck build fb4a
^C while it's building.
$ buck build fb4a
```
Break GenRDotJavaStep into two steps: generate manifest; run aapt.

Summary:
Instead of generating the `AndroidManifest.xml` under a random tmp directory,
we now write it in a predictable location under `buck-out`.

Previously, some I/O was done in the constructor of `GenRDotJavaStep`,
which was not appropriate. This change also makes it possible to eliminate a
hack in the superclass, `ShellStep`, that was added to support this bad
behavior.

Test Plan: Sandcastle builds.
If package is not specified for an android_resource(), try to extract it from the manifest.

Summary:
Historically, we provided the option to specify the package for `R.java` via the `package`
argument to `android_resource()`:

```
android_resource(
  name = 'example',
  package = 'com.example',
  res = 'res',
)
```

This eliminates the burden of creating dummy `AndroidManifest.xml` files of the form:

```
<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='com.example' />
```

However, when importing resources from an `.aar`, it would be equally burdensome to require
users to do something like:

```
android_prebuilt_aar(
  name = 'example',
  aar = 'example.aar',
  package = 'com.example',
)
```

as the `package` argument duplicates information that is already present in the `AndroidManifest.xml`
that is in `example.aar`.

As such, we introduce the following new behavior:

* If there is no `res` argument, then no attempt is made to determine the package.
* If there is a `res` argument and `package` is specified, its value is used.
* Failing that, if there is a `manifest` argument, the `package` is parsed from it.
* If there is a `res` but no `package` or `manifest`, an exception is thrown.

An important side effect of this change is that `AndroidResource` now passes `rDotJavaPackage` as a
`Supplier` to `AndroidPackageableCollector`, which is needed for upcoming work with `.aar` files.

Test Plan:
Added test cases to `AndroidResourceTest.java`.
Added `AndroidResourceParsePackageFromManifestIntegrationTest`.
Sandcastle builds.
[python test] fix typo

Summary:
I'm not adding this to automation.sh because this small script is only
meant for manual benchmarks.

Test Plan: python src/com/facebook/buck/parser/buck_glob.py -i '**'
[glob] Fix mistake in calling 'normpath_join'

Summary:
[glob] Fix mistake in calling 'normpath_join'

I forgot to extract the last element of the path return by iglob(). This caused large 'stuttering' paths to be marked as seen, as reported by 'mread' on github: https://github.com/facebook/buck/issues/155

My take is that this bug had not consequence in production because in practice we link only files (not directories).

I tried to take a second look at performances but could not find any easy win. (If we want to maintain the same semantics w.r.t. symlinks, we need to call `islink` or something equivalent at least once per path.)

Test Plan:
smokebuild

cd fbandroid; time python ../buck/src/com/facebook/buck/parser/buck_glob.py -i '**'  # about 3.3 sec instead of 3.2 before this diff (roughly).
[trivial] buck.py : add punctuation in comments.

Summary: [trivial] buck.py : add punctuation in comments.

Test Plan: smokebuild
Drop aapt_package build time deps on android library rules

Summary:
The buck target graph allows for android resource rules to depend
on android library rules, as resources can contain runtime references
to library code and the dependency is needed to make sure the library
gets pulled into the top-level package. However, this dependency also
creates an artifical build time dependency, which causes resources to
re-run their aapt_package steps if the library JAR changes, which is
unnecessary.

This diff uses graph enhancement to work around this issue by moving
most of the logic in android resource rules into an internal android
resource symbols rule.  When this rule is created in the android
resource rule constructor, it's dependencies are trimmed to only
include other android resource symbol rules from corresponding android
resource rule dependencies.

This impacts the build in two ways:
1) The android resource symbols rules that actually run the aapt_package
no longer have dependencies, direct or transitive, on android library
rules, and so won't be re-run if libraries change.  The now-hollow android
resource rules still have these deps, but since they no longer have any
steps, this only serves to pull the andoird resource symbols rules into
the top-level graph.
2) Previously, an android resource rule would pick up additional android
resource rules transitively across an andoird library boundary, even if
they didn't have and android-resource-only path to it.  This diff
changes this behavior, which I *think* is correct, as we should probably
be requiring explicit deps from one android rule to another if it
references any symbols from it.

Test Plan:
- Test suite.
- Built fb4a with and w/o this change.  In both sitations, modified
//java/com/facebook/analytics/logger:logger and re-ran buck.  Without
this change, this caused aapt_package steps to be re-run.  With this
changed they weren't.
- In the process of adding some test cases for the new expected behavior
(e.g. modifying a library doesn't trigger a re-run of the aapt_package
steps), but wanted to get this out in parallel to get some initial
feedback).
Ensure generated Xcode schemes contain all actions with configuration names

Summary:
Previously, the Xcode schemes generated by Buck were missing two
actions (Analyze and Archive) which Xcode generates by default.

This wouldn't be a huge deal, but xctool hard-codes these entries, so we
might as well include them.

In addition, Xcode specifies a configuration name for each action, defaulting
to "Debug" and/or "Release". However, we will need to override these for Wilde
and other projects which have "Profile" and other custom config names, so this
diff makes that possible.

Test Plan: Unit tests included.
Use /data/local/tmp for storing exopackage jars

Summary:
Previously, we stored exopackage jars in the app's private data
directory.  This had 2 main benefits: (1) it closely mirrored how we
handle secondary dex files in production, and (2) the files were
automatically cleaned up when the app was uninstalled.

Unfortunately, it required a working "run-as" command on the device,
which turns out to be less reliable than I expected.  So we're switching
to an alternate mechanism: storing jars in /data/local/tmp.  It's
possible that this directory might not be shell-writable on some
devices, but our recent experiments suggest that it will be more
reliable than run-as.

These files will not be automatically cleaned up on uninstallation.  To
mitigate this, I try to delete them in "buck uninstall" which I will be
encouraging people to use.

We could use "adb push" to install these files, rather than relying on
the agent, but it looks like that will require 2 additional adb round
trips to avoid creating a world-readable file (see
https://github.com/android/platform_system_core/blob/android-4.4.4_r1/adb/file_sync_service.c#L309),
and that could hurt performance, so I'm not making that change now.

Test Plan:
Did an install and uninstall.  Saw dex files installed and deleted.  Was
able to load them.

Note that this will need to be synchronized with a change in fbandroid.
Add @Nullable annotations to some nullable fields

Summary: These are initialized after the constructor.

Test Plan: Buildbot.
Eliminate an unnecessary initializer

Test Plan: Buildbot
When killing buckd, send SIGTERM instead of SIGKILL signal.

Summary: Thanks @royw for spotting the regression.

Test Plan:
unset NO_BUCKD
buck build buck
buck clean # verify buckd gets killed.
buckd --kill # verify buckd gets killed again.
Don't delete the watch if there's other triggers waiting.

Test Plan:
./buck_speculate to create a trigger
buck clean to kill buckd
change a file and verify it's built on save
[easy] Fix perftest scuba logging

Test Plan: portalspace