[OCaml] Initial commit

Summary:
Adds support for ocaml_binary, ocaml_library, and
prebuilt_ocaml_library rules.

Test Plan:
A// Run integration tests
B// Check Hack is building (Works on Mac at the moment)
    1/ Check out hack from github
    2/ Apply patch https://phabricator.fb.com/P16376931 or https://gist.github.com/alfa07/bfba8f8b2d5e388f9eb9#file-gistfile1-txt
    3/ cd to hack/hhi and run make to build ../bin/hhi.tar.gz
    4/ cd to hack/src
    5/ run buck build :hh_server and hh_single
    6/ go to hack/test and run tests:
        python3 verify.py --hh_single_type_check ../src/buck-out/bin/hh_single/hh_single suggest
        python3 verify.py --hh_single_type_check ../src/buck-out/bin/hh_single/hh_single typecheck
Rename UberRDotJavaUtil --> RDotJavaUtil.

Summary: No logical change.

Test Plan: buck test --all
Refactor C/C++ specific settings into `CxxPlatform`

Summary:
This creates an interface to wrap all the C/C++ specific environment
settings used to describe a particular build platform into an interface
and moves the existing `CxxBuckConfig` code into an `DefaultCxxPlatform`
implementation.

This also takes the chance to move all the default path definitions
from their various locations and consolidates them into `DefaultCxxPlatform`.

Subsequent changes will add an `AndroidNdkCxxPlatform` for use with
making `ndk_library` use our C/C++ support.

Test Plan: buck test --all
Fixing some @Nullable inconsistencies in graph/

Summary: Fixing some @Nullable inconsistencies and documenting some implicit assumptions using Preconditions.checkNotNull

Test Plan: buck test --all
Removing unnecessary Precondition check

Summary:
Apparently the PATH isn't visible on Windows. That's okay, because
we can set the Python executable in the tools section of .buckconfig
and if it's missing `getEnv` returns the empty string.

Test Plan:
* Attempt to build selenium on Windows.
* Weep at the fact that the PATH is necessary
* Apply patch
* Weep at the fact you're working on Windows. At least your build kind of works.
Remove incorrect @Nullable from anonymous Function and Predicate.

Summary:
IntelliJ's expansion of anonymous Function and Predicate starts
off with @Nullable, and these annotations weren't deleted in some
cases where they didn't make sense.

Test Plan: CI
Add @Nullable annotations to buck/apple/.

Summary: Add @Nullable annotations to buck/apple/.

Test Plan: buck test --all
Add test for BuildTargetTypeCoercer when dealing with Windows paths.

Summary:
This has broken twice. Time to add a test. Of course, it's not a simple thing
since EasyMock won't mock out `toString`. As such, we use a dynamic proxy from
normal Java. The other problem was that the test wouldn't ever pass on a
UNIX-like OS since the path separator is a "/", so the path was being returned
unmodified. We now brute force the separator to always be "/", though it's not
terribly elegant.

Test Plan: buck test --all
Restore "Pass build ID from 'buck' Python launcher to Java"

Summary:
I added logic to ensure the BUCK_BUILD_ID environment variable is not
included in the check for changed environment variables.

Test Plan:
ant clean default; buck build buck; buck build buck
Confirmed no error in logs:

  [com.facebook.buck.parser.Parser] Parser invalidating entire cache on environment change.
[OCaml] Makes OCaml tests runnable on sandcastle

Summary: Change paths to the OCaml's rpms install locations

Test Plan: Check that sandcastle runs as expected
[OCaml] Fixing error when compiling with cxx libraries using gcc

Summary: Clang allows to link cxx with gcc while gcc itself doens't

Test Plan: Check that buck test all runs on sandcastle
[buck] fixing OCaml unit tests

Summary:
target references in the OCaml test data are messing with `buck target`.
Removing those.

Test Plan:
`buck targets`
`buck test --all`
pathlib: Fix match() API and add more tests

Summary:
When replacing our glob() implementation with pathlib, I ran
into a nasty bug. The match() API (which applies a glob to a path and
returns True or False) didn't work correctly when we passed in globs
like:

  a/**/*.java

I added tests to reproduce the bug and fixed it. I plan to contribute
these fixes upstream as well.

Depends On D1567730

Test Plan: ant py-test
pathlib: Add support to Path.match() to require entire path to match

Summary:
Currently, pathlib's Path.match() has two modes:

1) Relative path mode: If neither the path nor the pattern start with
`/` or a drive letter, then the pattern only needs to match a suffix
of the path. This lets `*.py` match `foo/bar/baz.py`.

2) Absolute path mode: If both the path and the pattern start with `/`,
then the pattern must match the entire path, so `/foo/bar/*.py` matches
`/foo/bar/baz.py`.

To properly support the `excludes` feature of Buck's `glob()`, we need
to allow requiring the entire relative path to match. This adds the
feature, defaulting to off, and adds more tests.

Depends On D1567741

Test Plan: ant py-test
Perf: Reimplement buck.py glob() with pathlib

Summary:
This reimplements our custom buck.py `glob()` function with
the third-party pathlib library.

I also replaced a few places where we manually manipulated paths in
`buck.py` with `pathlib.Path` operations.

I updated `ProjectBuildFileParser` to update `PYTHONPATH` to look
in `third-party/py/pathlib`.

I also rewrote the tests to use a fake version of pathlib.Path for most
tests, but I included one integration test as a sanity check.

Note: I had to add `bin` to the ignore paths, because pathlib's `glob()`
obeys the filesystem's case-insensitivity property, and `**/BUCK`
matches `bin/buck` on OS X's HFS+ when configured for
case-insensitivity.

Perf tests with fbobj @ 36388955106458bada434574208dd38101b42e93:

== Before ==

https://phabricator.fb.com/P16421989

**18.858 seconds**

== After ==

https://phabricator.fb.com/P16421967

**10.426 seconds**

Improvement: **44.7%**

Depends On D1567741

Test Plan: ant py-test
Allow `BuildRule` objects to opt out of caching

Summary:
There are some class of ##BuildRule## objects which it doesn't make
sense to cache.  The main example right now is the ##SymlinkTree##
rule, which is purely a collection of FS operations which would
happen even if we used caching, and so caching will only ever add
overhead.

This diff adds a ##BuildRule#getCacheMode## method which rules can
override to opt out of caching and changes ##SymlinkTree## to use
this.

Test Plan: added unittest
Remove weak framework support.

Summary:
Currently weak framework support is broken: if a library declares a
strong link on a framework, but the binary using it declares a weak
link, the strong link will override the weak link. Xcode will figure
out whether a framework should be linked to weakly or strongly by
looking at the availability macros. There is no need for a user to
be able to override Xcode's decision, short of frameworks being
annotated with the wrong availability macros. In those rare cases
specifying the linker flags is an acceptable solution.

Test Plan: CI
Remove some unused methods.

Summary:
This removes AndroidManifest#getSkeletonFile and
PrebuiltJar#getGwtJar as they're not used anywhere.

Test Plan: CI
Remove SourcePath#getName.

Summary:
To remove BuildRule creation as a prerequisite of TargetGraph
population, the SourcePath implementation referring to rules
must be changed from taking a BuildRule to taking a BuildTarget.
This moves the logic to determine the name of an output file
referred to by a SourcePath from the SourcePath to helper
methods to prepare for that.

Test Plan: CI
Add a `FlavorDomain` class to organize flavors

Summary:
It's common to use flavors, which are essentially boolean settings,
to model types with larger domains.  This diff adds ##FlavorDomain##
class to make this easier.  ##FlavorDomain## objects are constructed
around a mapping that defines their entire domain in terms of flavors
and maps them to some user-defined value.  An example of a domain
would be something like the various thrift languages that support,
mapped to the enhancers the thrift description uses to construct
language specific rules.  As part of this diff, thrift was also
converted to use this domains.

This diff also provides a helper function to propagate flavors,
represented by ##FlavorDomain## objects from a dependent target to
dependent targets.

Test Plan: included tests