Add potentially orphaned libraries as android binary enhanced deps

Summary:
D1335355 dropped android libraries dependencies or android resource
rules, which potentially orphaned parts of the dependency tree.  For
pre-dexed builds, the android packeable changes made sure these
orphaned libraries were dependencies of the top-level android binary.
However, this was still an issues for non-pre-dexed buids.  This diff
explicitly adds all library JARs as deps for non-pre-dexed builds to
fix this.

Test Plan: built automation_pepper_release
Introduce android_prebuilt_aar() rule.

Summary:
An `.aar` file is a zip file that serves as the binary distribution of an Android Library Project,
as specified by http://tools.android.com/tech-docs/new-build-system/aar-format.

This diff makes it possible to depend on an `.aar` file as if it were an `android_library()` rule:

```
android_prebuilt_aar(
  name = 'play-services',
  aar = 'play-services-4.0.30.aar',
)

android_library(
  name = 'lib',
  # This Java code can compile against Play services and reference its resources.
  srcs = glob(['*.java']),
  deps = [ ':play-services' ],
)
```

Note that the `aar` argument to `android_prebuilt_aar()` could also be the output of a `genrule()`,
so now it is effectively possible to generate an `android_resource()` rule. Specifically, if you
generate the contents of a `res` folder and properly package it into an `.aar` zip file (which is the
output of a `genrule()`), then you could specify that `genrule()` as the `aar` argument to an
`android_prebuilt_aar()` so others can depend on your generated Android resources. You can
see an example of this in `AndroidPrebuiltAarIntegrationTest`.

This diff addresses the first half of https://github.com/facebook/buck/issues/117.

Test Plan:
`AndroidPrebuiltAarIntegrationTest` verifies that `android_prebuilt_aar()` can take a genfile
that conforms to the `.aar` package specification and serves as an Android library project
that another `android_library()` rule can build against.

In `test/com/facebook/buck/android/testdata/android_prebuilt_aar`, I ran:

```
touch .buckconfig
buck install //:app --run
```

and verified that the app started successfully.
Write BlueprintName and BuildableName to Buck-generated Xcode schemes

Summary:
Two pieces of data (BlueprintName and BuildableName) were missing
from Buck-generated Xcode schemes. Xcode doesn't seem to actually need these
(they're derivable from the projects to which the scheme refers), but xctool
barfs if they're not present.

This adds the fields as well as updates the tests.

Test Plan:
Unit tests updated. Ensured BlueprintName and BuildableName were
present in generated schemes.
New utility method MorePaths.relativize()

Summary:
Path.relativize() has a nasty bug JDK-6925169:

https://bugs.openjdk.java.net/browse/JDK-6925169

This caused #4669894.

This diff adds a fixed version, MorePaths.relativize(), to work around
the issue. I changed existing calls of Path.relativize() in MorePaths
to use the utility method.

When testing the workaround, I ran into another nasty bug,
JDK-8037945:

https://bugs.openjdk.java.net/browse/JDK-8037945

And now my workaround method has a workaround for another bug.

Test Plan: Unit tests updated.
When checking if buckd is running, actually send SIG_DFL to the pid.

Test Plan:
buck test --all
unset NO_BUCKD
buck build buck
buck targets #verify buckd is used.
buck clean #verify buckd gets killed and a new buckd is launched.
buckd --kill #verify buckd is killed.

buckd
kill -9 `cat .buckd/buckd.pid`
buck targets #verify no more connection refused error.
Re-enable writing Buck log errors to console

Summary:
I previously disabled writing Buck log errors to console,
because they interfered with SuperConsole (it was unaware
java.util.logging.ConsoleHandler was writing to System.err).

Unfortunately, that means we are not currently printing fatal
exceptions (except for HumanReadableException) to console when Buck
crashes.

Because it's instantiated by java.util.logging.LogManager at startup
long before SuperConsole exists, we need to support redirecting
log messages to SuperConsole once that's set up.

To make that happen, I first found a tempting method in
java.util.logging.ConsoleHandler called setOutputStream(), but
unfortunately that method has the side effect of closing the original
OutputStream.

Closing System.err is not something we want our logger to do (it means
we can no longer log after SuperConsole is torn down, like when we
throw an exception), so in this diff, I:

1) Introduce a new class com.facebook.buck.log.ConsoleHandler which
is just like java.util.logging.ConsoleHandler, except it supports
safely changing the OutputStream without closing the original one.
(It also enforces UTF-8 output as well as uses our LogFormatter by default.)

2) Refactor a utility function to get the global ConsoleHandler into
a new utility class JavaUtilLogHandlers

3) Introduce a new class ConsoleHandlerRedirector which uses
AutoCloseable to redirect ConsoleHandler from System.err to the
special OutputStream used by SuperConsole to watch for updates

4) Re-enable logging errors to the console in config/logging.properties

5) Add a test utility class FakeOutputStream which lets us check if
the stream has been closed

6) Add unit tests for ConsoleHandler

Test Plan:
Unit tests included. Introduced a fatal exception in Buck,
confirmed it printed to console.
Use MorePaths.relativize() to work around JDK bug in ProjectGenerator

Summary:
This uses the new utility method MorePaths.relativize() added
in D1440821 to work around JDK-6925169 in ProjectGenerator. I also
added some logging to help me figure out what was going on.

Depends On D1440821

Test Plan:
In fbobjc:

  % buck project //Apps/FBFeedCellConfigutationPerformanceTest:workspace --workspace-and-projects
  % Apps/FBFeedCellConfigutationPerformanceTest/build.sh -a i386 -s iphonesimulator -m local build-tests

Previously, build.sh failed with the error on #4669894. Now, it succeeds.
[glob] do not treat symlinked files as special

Summary:
[glob] do not treat symlinked files as special

This diff changes the semantics of `glob_walk()` to ignore symlinked files (but not symlinked directories).

This is meant to speed up things (a little) while still maintaining termination.

The new semantics is also potentially less surprising.

Test Plan: unit test included
Revert to the old bash scripts for launching buck.

Summary:
Really sorry about this back and forth. All tests passed and builds were green
on my diff that added the python scripts, but turns out robolectric tests can
sometimes time out. The script also doesn't respect the BUCK_REPOSITORY_DIRTY
environment variable and so tries to perform git operations, which fails.

Instead of reverting a whole bunch of diffs, I am keeping both the versions in
the tree. I don't want to revert buckversion because it also includes the new
exopackage and android resource deps improvements.

Test Plan: buck test --all
Do not cache ignored file hashes.

Summary:
DefaultFileHashCache caches hashes for input files and
invalidates them based on file changes. If it caches hashes for
ignored files this causes problems as those cached hashes will never
be invalidated. This change stops DefaultFileHashCache caching the
hashes for ignored files to fix the problem.

Test Plan: buck test --all
Stop threads and cancel futures on client disconnection.

Summary:
When running as a daemon buck interrupts the main thread to
interrupt commands on client disconnection. This change cancels the
futures and threads started by the main thread in order to stop
processing build and test commands.

Test Plan:
1) buck test --all
2) kill the buck client process during test execution
3) check that CPU load and java process count drops to normal levels
Create buck_speculate script

Summary: SPECULATIVE BUILDS!!!11!!1!eleven

Test Plan:
Use `buck speculate` in fb4a, verify I get notifications about build finishing
```
./buck_speculate.sh watch $PWD ~/src/devtools/buckSyncTest buck
```
Verify building after that hits dir cache
Allow read only commands to be executed concurrently.

Summary:
Previously buckd enforced serialization of command execution
and the buck wrapper script spawned a new Java VM to run concurrent
buck commands when the daemon was busy executing, primarily to support
some recursive uses of buck. This change allows read only buck
commands (audit and targets) to safely execute concurrently with any
other buck command inside the buck daemon and removes the wrapper
script support for spawning new Java processes to run commands
concurrently. This is both faster (as new JVMs do not need to be
started to run the concurrent commands) and safer (as concurrent
read/write commands are prohibited).

Test Plan: buck test --all
Copy local.properties if it exists

Summary:
This change propagates the project's local.properties file to any temporary
test projects it creates. This solves the issue where if the SDK or NDK paths
were specified in a project's local.properties file instead of env variables,
the temp test projects generated failed to build correctly.

Test Plan:
1. Check out buck
2. Create a local.properties file in the root directory of the buck project. Use it to specify an SDK and NDK. For example:

    sdk.dir=/path/to/android-sdk-macosx
    ndk.dir=/path/to/android-ndk-r9b

3. Make sure the ANDROID_NDK env variable isn't set (e.g. run `unset ANDROID_NDK`)
4. Run the android tests: `buck test //test/com/facebook/buck/android`

Expected results:
The tests pass. (Prior to this change, they failed with an error that the NDK couldn't be found.)
Fix malformed Javadoc.

Test Plan: Yellow warning icon goes away in Eclipse.
Bash escape some arguments in ShellStep descriptions.

Summary:
This ensures that the commands are copy/pasteable when printed
out by `--verbose 2`.

Test Plan:
Verified that building `R.java` with `--verbose 2` included:

  echo '<manifest xmlns:android='\''http://schemas.android.com/apk/res/android'\'' package='\''com.google.android.apps.iosched'\'' />' > buck-out/gen/__res_dummy_manifest/AndroidManifest.xml

And that I could copy/paste that to achieve the same result as what Buck was doing.
Make sure android_resource() can depend on resources from android_prebuilt_aar().

Summary:
Previously, an `android_resource()` that declared an `android_prebuilt_aar()` in
its `deps` would not build against the AAR's resources. The problem was that
`android_resource()` considered only immediate `android_resource()` rules
from its `deps` as its *real* dependencies, filtering out all non-`android_resource()`
rules, including `android_prebuilt_aar()` rules.

This diff adds a special case for `android_prebuilt_aar()` rules when the
`android_resource()` does its filterting so that the `android_resource()` created
via graph enhancement for an AAR is also included by the filter.

Because the `BuildRule` created by `AndroidPrebuiltJarDescription` is an
ordinary `AndroidLibrary`, additional information had to be added to `AndroidLibrary`
to distinguish when it was created from an AAR. This is exposed via
`AndroidLibrary#isPrebuiltAar()`.

Test Plan: Created UberRDotJavaUtilTest. TDD ftw!
Fix a typo in the launcher script.

Test Plan: yolo1
Use lastKnownFileType for file.xib

Summary:
Xcode 5.0.2 refuses to honor "explicitFileType" for file.xib.
It only allows opening XIBs in Interface Builder if you use
"lastKnownFileType".

Why?

becausexcode

Test Plan:
Tools/buck-project.py Libraries/FBConsoleKit, open
Messenger in Xcode 5, double-click on a xib. Before, it opened
in an XML editor. Now, it opens in Interface Builder.
Fix Scuba to use proper environment variables

Test Plan: Unit tests