1#!/bin/bash
2
3# Build Skia with Address Sanitizer.
4#
5# Address Sanitizer is available in LLVM (and Clang) 3.1 and above, as well as
6# GCC 4.8.  For now, this script assumes the use of Clang 3.2 or newer, which
7# uses different flag syntax from 3.1.
8#
9# For more information, see:
10# https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer
11
12makeVars="$@"
13
14export CC="$(which clang)"
15export CXX="$(which clang++)"
16export LINK="$(which clang)"
17
18noClang="Couldn't find Clang on this machine!"
19if [[ -z "${CC}" ]]; then
20  echo "${noClang}"
21  exit 1
22fi
23if [[ -z "${CXX}" ]]; then
24  echo "${noClang}"
25  exit 1
26fi
27if [[ -z "${LINK}" ]]; then
28  echo "${noClang}"
29  exit 1
30fi
31
32export GYP_DEFINES="skia_asan_build=1 ${GYP_DEFINES}"
33
34python gyp_skia
35if [[ "$?" != "0" ]]; then
36  exit 1
37fi
38
39make ${makeVars}
40if [[ "$?" != "0" ]]; then
41  exit 1
42fi