skia/trunk changes for generic sanitizer gyp flag.
authormtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 8 Oct 2013 15:16:36 +0000 (15:16 +0000)
committermtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 8 Oct 2013 15:16:36 +0000 (15:16 +0000)
BUG=
R=borenet@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@11648 2bbb7eff-a529-9590-31e7-b0007b416f81

gyp/common_conditions.gypi
gyp/common_variables.gypi
tools/asan_build [deleted file]
tools/xsan_build [new file with mode: 0755]

index f8012b9..1cbdd7b 100644 (file)
               }],
             ],
           }],
-          [ 'skia_asan_build', {
+          # Enable asan, tsan, etc.
+          [ 'skia_sanitizer', {
             'cflags': [
-              '-fsanitize=address',
+              '-fsanitize=<(skia_sanitizer)',
               '-fno-omit-frame-pointer',
             ],
             'ldflags': [
-              '-fsanitize=address',
-            ],
-          }],
-          [ 'skia_tsan_build', {
-            'cflags': [
-              '-fsanitize=thread',
-              '-fno-omit-frame-pointer',
-            ],
-            'ldflags': [
-              '-fsanitize=thread',
+              '-fsanitize=<(skia_sanitizer)',
             ],
           }],
           [ 'skia_clang_build', {
             'cflags': [
+              # Extra warnings we like but that only Clang knows about.
               '-Wstring-conversion',
             ],
           }],
index 3f7b154..9aeee62 100644 (file)
@@ -78,8 +78,7 @@
         }],
       ],
 
-      'skia_asan_build%': 0,
-      'skia_tsan_build%': 0,
+      'skia_sanitizer%': '',
       'skia_scalar%': 'float',
       'skia_mesa%': 0,
       'skia_nv_path_rendering%': 0,
       }, {
         'skia_release_optimization_level%': '<(skia_default_gcc_optimization_level)',
       }],
-      [ 'skia_asan_build or skia_tsan_build', {
+      [ 'skia_sanitizer', {
         'skia_clang_build': 1,
       }, {
         'skia_clang_build%': 0,
     'arm_neon_optional%': 0,
     'skia_os%': '<(skia_os)',
     'os_posix%': '<(os_posix)',
-    'skia_asan_build%': '<(skia_asan_build)',
-    'skia_tsan_build%': '<(skia_tsan_build)',
+    'skia_sanitizer%': '<(skia_sanitizer)',
     'skia_scalar%': '<(skia_scalar)',
     'skia_mesa%': '<(skia_mesa)',
     'skia_nv_path_rendering%': '<(skia_nv_path_rendering)',
diff --git a/tools/asan_build b/tools/asan_build
deleted file mode 100755 (executable)
index 49817f6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-
-# Build Skia with Address Sanitizer.
-#
-# Address Sanitizer is available in LLVM (and Clang) 3.1 and above, as well as
-# GCC 4.8.  For now, this script assumes the use of Clang 3.2 or newer, which
-# uses different flag syntax from 3.1.
-#
-# For more information, see:
-# https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer
-
-makeVars="$@"
-
-export CC="$(which clang)"
-export CXX="$(which clang++)"
-export LINK="$(which clang)"
-
-noClang="Couldn't find Clang on this machine!"
-if [[ -z "${CC}" ]]; then
-  echo "${noClang}"
-  exit 1
-fi
-if [[ -z "${CXX}" ]]; then
-  echo "${noClang}"
-  exit 1
-fi
-if [[ -z "${LINK}" ]]; then
-  echo "${noClang}"
-  exit 1
-fi
-
-export GYP_DEFINES="skia_asan_build=1 ${GYP_DEFINES}"
-
-python gyp_skia
-if [[ "$?" != "0" ]]; then
-  exit 1
-fi
-
-make ${makeVars}
-if [[ "$?" != "0" ]]; then
-  exit 1
-fi
\ No newline at end of file
diff --git a/tools/xsan_build b/tools/xsan_build
new file mode 100755 (executable)
index 0000000..f4d82e9
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# Build Skia with one of Clang's many sanitizers.
+#
+# $ tools/xsan_build {address,thread,undefined,etc.} [any other flags to pass to make/ninja...]
+#
+# This script assumes the use of Clang >=3.2.
+#
+# For more information, see:
+#   http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
+
+set -e
+
+sanitizer=$1
+shift
+args="$@"
+
+export CC="$(which clang)"
+export CXX="$(which clang++)"
+export LINK="$(which clang)"
+
+if [[ -z "${CC}" ]] || [[ -z "${CXX}" ]] || [[ -z "${LINK}" ]]; then
+  echo "Couldn't find Clang on this machine!"
+  exit 1
+fi
+
+export GYP_DEFINES="skia_sanitizer=$sanitizer ${GYP_DEFINES}"
+
+./gyp_skia
+if [[ $GYP_GENERATORS == "ninja" ]]; then
+    ninja ${args}
+else
+    make ${args}
+fi