GN: Android

Once you have downloaded an android NDK, you can set the ndk GN arg to use it.
E.g. my gn.args looks like:
  is_debug = false
  ndk = "/opt/android-ndk"

This should be enough to get you going for an arm64 build.  You ought to be able to tweak that to other architectures by changing target_cpu to "arm", "x86", "x86-64", etc.  That won't quite work until I follow this up a bit, but the skeleton is there.

This is enough to get me compiled, linked, and running to completion on my N5x.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2275983004

Review-Url: https://codereview.chromium.org/2275983004
diff --git a/BUILD.gn b/BUILD.gn
index 90f531f..8c053cf 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -161,16 +161,16 @@
 
 is_x86 = current_cpu == "x64" || current_cpu == "x86"
 
-opts("armv7") {
-  enabled = current_cpu == "arm"
-  sources = opts_gypi.armv7_sources
+opts("none") {
+  enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
+  sources = opts_gypi.none_sources
   cflags = []
 }
 
-opts("neon") {
+opts("armv7") {
   enabled = current_cpu == "arm"
-  sources = opts_gypi.neon_sources
-  cflags = [ "-mfpu=neon" ]
+  sources = opts_gypi.armv7_sources + opts_gypi.neon_sources
+  cflags = []
 }
 
 opts("arm64") {
@@ -185,12 +185,6 @@
   cflags = [ "-march=armv8-a+crc" ]
 }
 
-opts("none") {
-  enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
-  sources = opts_gypi.none_sources
-  cflags = []
-}
-
 opts("sse2") {
   enabled = is_x86
   sources = opts_gypi.sse2_sources
@@ -342,7 +336,6 @@
     ":crc32",
     ":gif",
     ":jpeg",
-    ":neon",
     ":none",
     ":pdf",
     ":png",
@@ -354,10 +347,6 @@
     ":xml",
   ]
 
-  if (!is_win) {
-    libs = [ "pthread" ]
-  }
-
   sources = []
   sources += core_gypi.sources
   sources += effects_gypi.sources
@@ -401,6 +390,8 @@
     "src/gpu/gl/GrGLDefaultInterface_none.cpp",
   ]
 
+  libs = []
+
   if (is_win) {
     sources += [
       "src/ports/SkDebug_win.cpp",
@@ -418,17 +409,38 @@
     sources -= [ "src/utils/SkThreadUtils_pthread.cpp" ]
   } else {
     sources += [
-      "src/ports/SkDebug_stdio.cpp",
       "src/ports/SkOSFile_posix.cpp",
       "src/ports/SkTLS_pthread.cpp",
       "src/xps/SkDocument_XPS_None.cpp",
     ]
   }
 
+  if (is_android) {
+    deps += [
+      "//third_party/cpu-features",
+      "//third_party/expat",
+      "//third_party/freetype2",
+    ]
+    sources += [
+      "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
+      "src/ports/SkDebug_android.cpp",
+      "src/ports/SkFontHost_FreeType.cpp",
+      "src/ports/SkFontHost_FreeType_common.cpp",
+      "src/ports/SkFontMgr_android.cpp",
+      "src/ports/SkFontMgr_android_factory.cpp",
+      "src/ports/SkFontMgr_android_parser.cpp",
+    ]
+    libs += [
+      "EGL",
+      "GLESv2",
+      "log",
+    ]
+  }
+
   if (is_linux) {
     deps += [
       "third_party:fontconfig",
-      "third_party:freetype2",
+      "//third_party/freetype2",
     ]
     libs += [
       "GL",
@@ -437,6 +449,7 @@
     ]
     sources += [
       "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
+      "src/ports/SkDebug_stdio.cpp",
       "src/ports/SkFontConfigInterface_direct.cpp",
       "src/ports/SkFontConfigInterface_direct_factory.cpp",
       "src/ports/SkFontHost_FreeType.cpp",
@@ -450,6 +463,7 @@
   if (is_mac) {
     sources += [
       "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
+      "src/ports/SkDebug_stdio.cpp",
       "src/ports/SkFontHost_mac.cpp",
       "src/ports/SkImageEncoder_CG.cpp",
       "src/ports/SkImageGeneratorCG.cpp",
@@ -463,6 +477,7 @@
   if (is_fuchsia) {
     sources += [
       "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
+      "src/ports/SkDebug_stdio.cpp",
       "src/ports/SkFontMgr_empty_factory.cpp",
     ]
   }
@@ -547,7 +562,9 @@
     ]
     libs = []
 
-    if (is_linux) {
+    if (is_android) {
+      sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
+    } else if (is_linux) {
       sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
     } else if (is_mac) {
       sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]