Don't use m32 cflag for x86_64.

When checking the skia_arch_type for "x86", instead of doing an
== compare, check if "x86" in skia_arch_type, so it will cover
both x86 and x86_64.

Except when we specifically want x86.

Set skia_arch_width based on "64" in skia_arch_type. No need to specify
in scripts.

In gyp_to_android.py, create a separate var_dict for x86_64.

BUG=skia:3419

Review URL: https://codereview.chromium.org/916113002
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi
index 9e8ce3f..53bfd2d 100644
--- a/gyp/common_conditions.gypi
+++ b/gyp/common_conditions.gypi
@@ -227,7 +227,7 @@
         'conditions': [
           [ 'skia_os != "chromeos"', {
             'conditions': [
-              [ 'skia_arch_width == 64 and skia_arch_type == "x86"', {
+              [ 'skia_arch_type == "x86_64"', {
                 'cflags': [
                   '-m64',
                 ],
@@ -235,7 +235,7 @@
                   '-m64',
                 ],
               }],
-              [ 'skia_arch_width == 32 and skia_arch_type == "x86"', {
+              [ 'skia_arch_type == "x86"', {
                 'cflags': [
                   '-m32',
                 ],
@@ -628,7 +628,7 @@
           '-fuse-ld=gold',
         ],
         'conditions': [
-          [ 'skia_arch_type == "x86"', {
+          [ '"x86" in skia_arch_type', {
             'cflags': [
               '-mssse3',
             ],
diff --git a/gyp/common_variables.gypi b/gyp/common_variables.gypi
index f89c08b..a20550b 100644
--- a/gyp/common_variables.gypi
+++ b/gyp/common_variables.gypi
@@ -40,14 +40,23 @@
 
       # Variables needed by conditions list within the level-2 variables dict.
       'variables': {  # level 3
-        # We use 'skia_os' instead of 'OS' throughout our gyp files, to allow
-        # for cross-compilation (e.g. building for either MacOS or iOS on Mac).
-        # We set it automatically based on 'OS' (the host OS), but allow the
-        # user to override it via GYP_DEFINES if they like.
-        'skia_os%': '<(OS)',
+        'variables': { # level 4
+          # We use 'skia_os' instead of 'OS' throughout our gyp files, to allow
+          # for cross-compilation (e.g. building for either MacOS or iOS on Mac).
+          # We set it automatically based on 'OS' (the host OS), but allow the
+          # user to override it via GYP_DEFINES if they like.
+          'skia_os%': '<(OS)',
+        },
+        'skia_os%': '<(skia_os)',
 
         'skia_android_framework%': 0,
-        'skia_arch_type%': 'x86',
+        'conditions' : [
+          [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "mac"]', {
+            'skia_arch_type%': 'x86_64',
+          }, {
+            'skia_arch_type%': 'x86',
+          }],
+        ],
         'arm_version%': 0,
         'arm_neon%': 0,
         'skia_egl%': 0,
@@ -82,7 +91,7 @@
         }, {
           'skia_poppler_enabled%': 0,
         }],
-        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "mac"] or skia_arch_type == "arm64"', {
+        ['"64" in skia_arch_type', {
           'skia_arch_width%': 64,
         }, {
           'skia_arch_width%': 32,
diff --git a/gyp/opts.gyp b/gyp/opts.gyp
index 2fb1468..6ff9008 100644
--- a/gyp/opts.gyp
+++ b/gyp/opts.gyp
@@ -1,3 +1,4 @@
+# Gyp file for building opts target.
 {
   # Source lists live in opts.gypi.  This makes it easier to maintain our Chrome GYP/GN setup.
   # (To be honest, I'm not sure why we need to include common.gypi.  I thought it was automatic.)
@@ -26,7 +27,7 @@
         '../include/utils',
       ],
       'conditions': [
-        [ 'skia_arch_type == "x86" and skia_os != "ios"', {
+        [ '"x86" in skia_arch_type and skia_os != "ios"', {
           'cflags': [ '-msse2' ],
           'dependencies': [ 'opts_ssse3', 'opts_sse41' ],
           'sources': [ '<@(sse2_sources)' ],
@@ -44,7 +45,9 @@
 
         [ '(skia_arch_type == "arm" and arm_version < 7) \
             or (skia_os == "ios") \
-            or (skia_os == "android" and skia_arch_type not in ["x86", "arm", "mips", "arm64"])', {
+            or (skia_os == "android" \
+                and skia_arch_type not in ["x86", "x86_64", "arm", "mips", \
+                                           "arm64"])', {
           'sources': [ '<@(none_sources)' ],
         }],
 
diff --git a/gyp/skia_lib.gyp b/gyp/skia_lib.gyp
index 9f61871..cc4984a 100644
--- a/gyp/skia_lib.gyp
+++ b/gyp/skia_lib.gyp
@@ -12,7 +12,7 @@
       'utils.gyp:utils',
     ],
     'conditions': [
-      [ 'skia_arch_type == "x86" and skia_os != "android"', {
+      [ '"x86" in skia_arch_type and skia_os != "android"', {
         'component_libs': [
           'opts.gyp:opts_ssse3',
           'opts.gyp:opts_sse41',
diff --git a/platform_tools/android/bin/android_setup.sh b/platform_tools/android/bin/android_setup.sh
index eaa6ac5..3c6d44d 100755
--- a/platform_tools/android/bin/android_setup.sh
+++ b/platform_tools/android/bin/android_setup.sh
@@ -116,16 +116,16 @@
       ANDROID_ARCH="arm"
       ;;
     intel_rhb | razr_i)
-      DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=32"
+      DEFINES="${DEFINES} skia_arch_type=x86"
       DEFINES="${DEFINES} skia_resource_cache_mb_limit=32"
       ANDROID_ARCH="x86"
       ;;
     x86)
-      DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=32"
+      DEFINES="${DEFINES} skia_arch_type=x86"
       ANDROID_ARCH="x86"
       ;;
     x86_64 | x64)
-      DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=64"
+      DEFINES="${DEFINES} skia_arch_type=x86_64"
       ANDROID_ARCH="x86_64"
       ;;
     arm_v7)
diff --git a/platform_tools/android/bin/gyp_to_android.py b/platform_tools/android/bin/gyp_to_android.py
index e700f2f..9ce330c 100755
--- a/platform_tools/android/bin/gyp_to_android.py
+++ b/platform_tools/android/bin/gyp_to_android.py
@@ -107,6 +107,8 @@
                                           True, gyp_source_dir)
     x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False,
                                      gyp_source_dir)
+    x86_64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86_64',
+                                        False, gyp_source_dir)
 
     mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False,
                                       gyp_source_dir)
@@ -121,8 +123,8 @@
     # should be part of the makefile always. Each dict will now contain trimmed
     # lists containing only variable definitions specific to that configuration.
     var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict,
-                     x86_var_dict, mips_var_dict, mips64_var_dict,
-                     arm64_var_dict]
+                     x86_var_dict, x86_64_var_dict, mips_var_dict,
+                     mips64_var_dict, arm64_var_dict]
     common = vars_dict_lib.intersect(var_dict_list)
 
     common.LOCAL_MODULE.add('libskia')
@@ -178,8 +180,7 @@
         arm_neon_var_dict, 'arm', 'ARCH_ARM_HAVE_NEON'))
     deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict,
                                                                'x86'))
-    # Currently, x86_64 is identical to x86
-    deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict,
+    deviations_from_common.append(makefile_writer.VarsDictData(x86_64_var_dict,
                                                                'x86_64'))
 
     deviations_from_common.append(makefile_writer.VarsDictData(mips_var_dict,
diff --git a/platform_tools/android/gyp/skia_android.gypi b/platform_tools/android/gyp/skia_android.gypi
index 210a61a..ace21cc 100644
--- a/platform_tools/android/gyp/skia_android.gypi
+++ b/platform_tools/android/gyp/skia_android.gypi
@@ -1,3 +1,4 @@
+#
 {
   'targets': [
     {
@@ -18,10 +19,10 @@
           [ 'skia_arch_type == "arm64"', {
             'android_arch%': "arm64-v8a",
           }],
-          [ 'skia_arch_type == "x86" and skia_arch_width == 32', {
+          [ 'skia_arch_type == "x86"', {
             'android_arch%': "x86",
           }],
-          [ 'skia_arch_type == "x86" and skia_arch_width == 64', {
+          [ 'skia_arch_type == "x86_64"', {
             'android_arch%': "x86_64",
           }],
           [ 'skia_arch_type == "mips" and skia_arch_width == 32', {