Move build -> gn/standalone

Make it explicit that those gn files are only for the standalone
build.

Bug: 68710794
Change-Id: I7e2a15219d63b62bf8f249becfdbf39fda2cc183
diff --git a/gn/standalone/BUILD.gn b/gn/standalone/BUILD.gn
new file mode 100644
index 0000000..59f60fd
--- /dev/null
+++ b/gn/standalone/BUILD.gn
@@ -0,0 +1,200 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//gn/standalone/android.gni")
+import("//gn/standalone/sanitizers/sanitizers.gni")
+
+config("extra_warnings") {
+  cflags = [
+    "-Wextra",
+    "-Wno-missing-field-initializers",
+    "-Wno-unused-parameter",
+  ]
+  if (is_clang) {
+    cflags += [
+      "-Weverything",
+      "-Wno-c++98-compat-pedantic",
+      "-Wno-c++98-compat",
+      "-Wno-gnu-include-next",
+      "-Wno-gnu-statement-expression",
+      "-Wno-gnu-zero-variadic-macro-arguments",
+      "-Wno-padded",
+      "-Wno-reserved-id-macro",
+      "-Wno-weak-vtables",
+    ]
+  }
+}
+
+config("no_exceptions") {
+  cflags = [ "-fno-exceptions" ]
+}
+
+config("no_rtti") {
+  cflags = [ "-fno-rtti" ]
+}
+
+config("default") {
+  asmflags = []
+  cflags = []
+  cflags_c = []
+  cflags_cc = []
+  defines = []
+  ldflags = []
+  libs = []
+
+  cflags_cc += [ "-std=c++11" ]
+
+  cflags += [
+    "-fstrict-aliasing",
+    "-fstack-protector",
+    "-fPIC",
+    "-Wa,--noexecstack",
+    "-Wformat",
+    "-Wall",
+    "-Werror",
+  ]
+
+  # Color compiler output, see https://github.com/ninja-build/ninja/wiki/FAQ
+  if (is_clang) {
+    cflags += [
+      "-fcolor-diagnostics",
+      "-Wno-unknown-warning-option",
+    ]
+  } else {
+    cflags += [ "-Wno-unknown-warning" ]
+  }
+
+  if (current_cpu == "arm") {
+    cflags += [
+      "-march=armv7-a",
+      "-mfpu=neon",
+      "-mthumb",
+    ]
+  } else if (current_cpu == "x86") {
+    asmflags += [ "-m32" ]
+    cflags += [
+      "-m32",
+      "-msse2",
+      "-mfpmath=sse",
+    ]
+    ldflags += [ "-m32" ]
+  }
+
+  if (is_linux) {
+    libs += [
+      "pthread",
+      "rt",
+    ]
+  }
+
+  if (is_android) {
+    libs += [ "log" ]
+  }
+
+  if (is_android) {
+    asmflags += [ "--target=$android_abi_target" ]
+    cflags += [
+      "--sysroot=$android_compile_sysroot",
+      "-isystem$android_compile_sysroot/$android_compile_sysroot_subdir",
+      "-isystem$android_compile_sysroot",
+      "-DANDROID",
+      "-D__ANDROID_API__=21",
+      "--target=$android_abi_target",
+    ]
+    cflags_cc += [
+      "-I$android_ndk_root/sources/cxx-stl/llvm-libc++/include",
+      "-I$android_ndk_root/sources/android/support/include",
+      "-I$android_ndk_root/sources/cxx-stl/llvm-libc++abi/include",
+    ]
+    ldflags += [
+      "-Wl,-z,nocopyreloc",
+      "-gcc-toolchain",
+      "$android_toolchain_root",
+      "--sysroot=$android_ndk_root/$android_link_sysroot_subdir",
+      "--target=$android_abi_target",
+      "-Wl,--exclude-libs,libunwind.a",
+      "-Wl,--exclude-libs,libgcc.a",
+      "-Wl,--exclude-libs,libc++_static.a",
+      "-Wl,--build-id",
+      "-Wl,--no-undefined",
+      "-Wl,-z,noexecstack",
+      "-Wl,-z,relro",
+      "-Wl,-z,now",
+      "-Wl,--warn-shared-textrel",
+      "-Wl,--fatal-warnings",
+    ]
+    lib_dirs = [ "$android_ndk_root/sources/cxx-stl/llvm-libc++/libs/$android_app_abi" ]
+    libs += [
+      "gcc",
+      "c++_static",
+      "c++abi",
+      "android_support",
+    ]
+  }
+}
+
+config("debug_symbols") {
+  if (is_android) {
+    cflags = [
+      "-gline-tables-only",
+      "-funwind-tables",
+    ]
+  } else {
+    cflags = [ "-g2" ]
+  }
+}
+
+config("release") {
+  cflags = [
+    "-O3",
+    "-fdata-sections",
+    "-ffunction-sections",
+  ]
+  if (is_mac) {
+    ldflags = [ "-dead_strip" ]
+  } else {
+    ldflags = [ "-Wl,--gc-sections" ]
+  }
+  defines = [ "NDEBUG" ]
+}
+
+config("shared_library") {
+  if (is_android || is_linux) {
+    ldflags = [ "-fPIC" ]
+  }
+}
+
+config("executable") {
+  ldflags = []
+
+  # Android will refuse to run executables if they aren't position independent.
+  # Instead on Linux there isn't any need and they break ASan (goo.gl/paFR6K).
+  if (is_android) {
+    asmflags = [ "-fPIE" ]
+    cflags = [ "-fPIE" ]
+    ldflags += [ "-pie" ]
+  }
+
+  # -rpath stores the path to the linked shared libraries into the binary, so
+  # that they can be launched without passing any LD_LIBRARY_PATH. It's
+  # supported only by Linux, not Android. But concretely we need this only when
+  # use_custom_libcxx=true && custom_libcxx_is_static=false, which happens only
+  # on Linux right now.
+  if (is_linux) {
+    ldflags += [
+      "-Wl,-rpath=\$ORIGIN/.",
+      "-Wl,-rpath-link=.",
+    ]
+  }
+}