proposed gn_to_bp fixes

in response to 5784

Change-Id: I3ad34a30743e7ffbd04767668c288a4f884eb19c
Reviewed-on: https://skia-review.googlesource.com/5732
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index c687ded..c2258c0 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -12,6 +12,7 @@
 
 declare_args() {
   skia_use_angle = false
+  skia_use_cpufeatures = is_android
   skia_use_expat = true
   skia_use_fontconfig = is_linux
   skia_use_freetype = is_android || is_fuchsia || is_linux
@@ -92,7 +93,6 @@
     "include/private",
     "src/c",
     "src/codec",
-    "src/config",
     "src/core",
     "src/effects",
     "src/effects/gradients",
@@ -640,10 +640,10 @@
   }
 
   if (is_android) {
-    deps += [
-      "//third_party/cpu-features",
-      "//third_party/expat",
-    ]
+    if (skia_use_cpufeatures) {
+      deps += [ "//third_party/cpu-features" ]
+    }
+    deps += [ "//third_party/expat" ]
     sources += [ "src/ports/SkDebug_android.cpp" ]
     libs += [
       "EGL",
diff --git a/gn/gn_to_bp.py b/gn/gn_to_bp.py
index bb75b83..1791697 100644
--- a/gn/gn_to_bp.py
+++ b/gn/gn_to_bp.py
@@ -81,7 +81,7 @@
       "libz",
   ],
   static_libs: [
-      "cpufeatures",  // TODO: use this for CRC32 detection
+      //"cpufeatures",  // TODO: use this for CRC32 detection
       "libsfntly",
       "libwebp-decode",
       "libwebp-encode",
@@ -92,6 +92,8 @@
 # We'll run GN to get the main source lists and include directories for Skia.
 gn_args = {
   'skia_enable_vulkan_debug_layers': 'false',
+  'skia_use_cpufeatures':            'false',
+  'skia_use_system_expat':           'true',
   'skia_use_vulkan':                 'true',
   'target_cpu':                      '"none"',
   'target_os':                       '"android"',
@@ -114,6 +116,8 @@
 for dep in js['targets']['//:skia']['deps']:
   if 'third_party' in dep:
     continue   # We've handled all third-party DEPS as static or shared_libs.
+  if 'none' in dep:
+    continue   # We'll handle all cpu-specific sources manually later.
   srcs.extend(strip_slashes(js['targets'][dep].get('sources', [])))
 
 # No need to list headers.
@@ -123,7 +127,6 @@
 # Start with the defines :skia uses, minus a couple.  We'll add more in a bit.
 defines = [str(d) for d in js['targets']['//:skia']['defines']]
 defines.remove('SKIA_IMPLEMENTATION=1')  # Only libskia should have this define.
-defines.remove('XML_STATIC')       # On Android, libexpat is dynamically linked.
 
 # For architecture specific files, it's easier to just read the same source
 # that GN does (opts.gni) rather than re-run GN once for each architecture.
@@ -191,10 +194,10 @@
   })
 
 #... and all the #defines we want to put in SkUserConfig.h.
-with open('SkUserConfig.h', 'w') as f:
+with open('include/config/SkUserConfig.h', 'w') as f:
   print >>f, '// This file is autogenerated by gn_to_bp.py.'
   print >>f, '#ifndef SkUserConfig_DEFINED'
   print >>f, '#define SkUserConfig_DEFINED'
   for define in sorted(defines):
-    print >>f, '  #define', define
+    print >>f, '  #define', define.replace('=', ' ')
   print >>f, '#endif//SkUserConfig_DEFINED'