Building with GN+ninja
======================

system/bt is buildable using the GN and and ninja buildtools from the Chromium
project. After setting up these tools, several third_party packages need to be
set up to build the stack. It's a simple matter of copying (or sym-linking) some
packages out of AOSP into "system/bt/third_party":

From AOSP:
1. "platform/external/libevent" => third_party/libevent. The relevant
  headers here are "event.h" and "event-config.h". event-config.h from
  external/libevent is only compatible on Android; this means that you will need
  to generate a new one based on the current platform. Please follow the
  instructions in external/libevent/README.android for instructions on how to
  generate this file.
2. "platform/external/libchrome" => third_party/libchrome. After that, remove
the BUILD.gn file that's in libchrome/base. This is a legacy file that only
works inside the Chromium project and we're using our own from secondary build
sources.
3. "platform/external/modp_b64" => third_party/modp_b64

From Chromium:
1. "src/testing/gtest" => third_party/gtest

You will also need a fresh checkout of platform/hardware/libhardware and
platform/system/core for some include dependencies.

BUILD.gn files for all of these packages have already been set up under
"system/bt/build/secondary/third_party" (note: we don't have a BUILD.gn file for
modp_b64 since it comes with its own; as the package was imported into AOSP from
Chromium). To build, run:

1. 'gn args out/Default': This will prompt you to fill the contents of your
"args.gn" file. Set the two following variables:
  a. libhw_include_path=<path to your "platform/hardware/libhardware/include">
  b. core_include_path=<path to your "platform/system/core/include">

Once done, this will create the *.ninja files for the entire project.

2. 'ninja -C out/Default all': This will build all targets (the shared library,
executables, tests, etc) and put them in out/Default (or whatever you named the
output directory. To build an individual target, replace "all" with the target
of your choice, e.g. 'ninja -C out/Default net_test_osi'.
