update gyp for ARM builds to be more well defined.

R=mtklein@google.com

Review URL: https://codereview.chromium.org/21096005

git-svn-id: http://skia.googlecode.com/svn/trunk@10454 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi
index 6828660..c9d24ae 100644
--- a/gyp/common_conditions.gypi
+++ b/gyp/common_conditions.gypi
@@ -150,17 +150,28 @@
             'cflags': [
               '-mthumb',
             ],
-          }],
-          [ 'skia_arch_type == "arm" and armv7 == 1', {
-            'variables': {
-              'arm_neon_optional%': 0,
-            },
-            'defines': [
-              '__ARM_ARCH__=7',
+            # The --fix-cortex-a8 switch enables a link-time workaround for
+            # an erratum in certain Cortex-A8 processors.  The workaround is
+            # enabled by default if you target the ARM v7-A arch profile.
+            # It can be enabled otherwise by specifying --fix-cortex-a8, or
+            # disabled unconditionally by specifying --no-fix-cortex-a8.
+            #
+            # The erratum only affects Thumb-2 code.
+            'conditions': [
+              [ 'arm_version < 7', {
+                'ldflags': [
+                  '-Wl,--fix-cortex-a8',
+                ],
+              }],
             ],
+          }],
+          [ 'skia_arch_type == "arm" and arm_version >= 7', {
             'cflags': [
               '-march=armv7-a',
             ],
+            'ldflags': [
+              '-march=armv7-a',
+            ],
             'conditions': [
               [ 'arm_neon == 1', {
                 'defines': [
@@ -169,10 +180,6 @@
                 'cflags': [
                   '-mfpu=neon',
                 ],
-                'ldflags': [
-                  '-march=armv7-a',
-                  '-Wl,--fix-cortex-a8',
-                ],
               }],
               [ 'arm_neon_optional == 1', {
                 'defines': [
diff --git a/gyp/common_variables.gypi b/gyp/common_variables.gypi
index d7d41f2..8965c82 100644
--- a/gyp/common_variables.gypi
+++ b/gyp/common_variables.gypi
@@ -69,11 +69,11 @@
         }],
         [ 'skia_os == "ios"', {
           'skia_arch_type%': 'arm',
-          'armv7%': 1,
+          'arm_version%': 7,
           'arm_neon%': 0, # neon asm files known not to work with the ios build
         },{ # skia_os is not ios
           'skia_arch_type%': 'x86',
-          'armv7%': 0,
+          'arm_version%': 0,
           'arm_neon%': 0,
         }],
       ],
@@ -121,8 +121,9 @@
 
     # Re-define all variables defined within the level-2 'variables' dict,
     # so that siblings of the level-1 'variables' dict can see them.
-    'armv7%': '<(armv7)',
+    'arm_version%': '<(arm_version)',
     'arm_neon%': '<(arm_neon)',
+    'arm_neon_optional%': 0,
     'skia_os%': '<(skia_os)',
     'os_posix%': '<(os_posix)',
     'skia_scalar%': '<(skia_scalar)',
diff --git a/gyp/core.gyp b/gyp/core.gyp
index 28f5111..14eda4b 100644
--- a/gyp/core.gyp
+++ b/gyp/core.gyp
@@ -80,7 +80,7 @@
             '../src/core/SkPaintOptionsAndroid.cpp',
           ],
         }],
-        [ 'skia_os == "android" and skia_arch_type == "arm" and armv7 == 1', {
+        [ 'skia_os == "android" and skia_arch_type == "arm"', {
           # The code in SkUtilsArm.cpp can be used on an ARM-based Linux system, not only Android.
           'sources': [
             '../src/core/SkPaintOptionsAndroid.cpp',
diff --git a/gyp/libwebp.gyp b/gyp/libwebp.gyp
index 4b36fbb..17e0026 100644
--- a/gyp/libwebp.gyp
+++ b/gyp/libwebp.gyp
@@ -67,7 +67,7 @@
         {
           'target_name': 'libwebp_dsp_neon',
           'conditions': [
-            ['armv7 == 1', {
+            ['arm_version >= 7', {
               'type': 'static_library',
               'include_dirs': [
                   '../third_party/externals/libwebp',
@@ -82,7 +82,7 @@
                 '-mfpu=vfpv3-d16',
               ],
               'cflags': [ '-mfpu=neon' ],
-            },{  # "armv7 != 1"
+            },{  # !(arm_version >= 7)
               'type': 'none',
             }],
           ],
diff --git a/gyp/opts.gyp b/gyp/opts.gyp
index 8aa5e0f..010ddfb 100644
--- a/gyp/opts.gyp
+++ b/gyp/opts.gyp
@@ -56,7 +56,7 @@
             '../src/opts/SkUtils_opts_SSE2.cpp',
           ],
         }],
-        [ 'skia_arch_type == "arm" and armv7 == 1', {
+        [ 'skia_arch_type == "arm" and arm_version >= 7', {
           # The assembly uses the frame pointer register (r7 in Thumb/r11 in
           # ARM), the compiler doesn't like that.
           'cflags!': [
@@ -94,7 +94,7 @@
             }],
           ],
         }],
-        [ '(skia_arch_type == "arm" and armv7 == 0) or (skia_os == "ios")', {
+        [ '(skia_arch_type == "arm" and arm_version < 7) or (skia_os == "ios")', {
           'sources': [
             '../src/opts/SkBitmapProcState_opts_none.cpp',
             '../src/opts/SkBlitRow_opts_none.cpp',
diff --git a/platform_tools/android/bin/android_setup.sh b/platform_tools/android/bin/android_setup.sh
index 807b3c4..0b4d87d 100755
--- a/platform_tools/android/bin/android_setup.sh
+++ b/platform_tools/android/bin/android_setup.sh
@@ -141,17 +141,17 @@
 
   case $TARGET_DEVICE in
     nexus_s)
-        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 armv7=1 arm_thumb=1"
+        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 arm_version=7 arm_thumb=1"
         DEFINES="${DEFINES} skia_texture_cache_mb_limit=24"
         ;;
     nexus_4 | nexus_7 | nexus_10)
-        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 armv7=1 arm_thumb=1"
+        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 arm_version=7 arm_thumb=1"
         ;;
     xoom)
-        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 armv7=1 arm_thumb=1"
+        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 arm_version=7 arm_thumb=1"
         ;;
     galaxy_nexus)
-        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 armv7=1 arm_thumb=1"
+        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 arm_version=7 arm_thumb=1"
         DEFINES="${DEFINES} skia_texture_cache_mb_limit=32"
         ;;
     razr_i)
@@ -159,16 +159,16 @@
         DEFINES="${DEFINES} skia_texture_cache_mb_limit=32"
         ;;
     arm_v7)
-        DEFINES="${DEFINES} skia_arch_type=arm arm_neon_optional=1 armv7=1 arm_thumb=0"
+        DEFINES="${DEFINES} skia_arch_type=arm arm_neon_optional=1 arm_version=7 arm_thumb=0"
         ;;
     arm_v7_thumb)
-        DEFINES="${DEFINES} skia_arch_type=arm arm_neon_optional=1 armv7=1 arm_thumb=1"
+        DEFINES="${DEFINES} skia_arch_type=arm arm_neon_optional=1 arm_version=7 arm_thumb=1"
         ;;
     arm)
-        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 armv7=0 arm_thumb=0"
+        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 arm_thumb=0"
         ;;
     arm_thumb)
-        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 armv7=0 arm_thumb=1"
+        DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 arm_thumb=1"
         ;;
     x86)
         DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=32"
diff --git a/platform_tools/android/gyp/skia_android.gypi b/platform_tools/android/gyp/skia_android.gypi
index 72dc942..fb0a50a 100644
--- a/platform_tools/android/gyp/skia_android.gypi
+++ b/platform_tools/android/gyp/skia_android.gypi
@@ -21,7 +21,7 @@
             'android_arch%': "x86",
           }, {
             'conditions': [
-              [ 'armv7', {
+              [ 'arm_version == 7', {
                 'android_arch%': "armeabi-v7a",
               }, {
                'android_arch%': "armeabi",