Update android_make to support both --gcc and --clang options.
This CL also fixes all the errors that resulted from compiling
with clang and ccache.
BUG=skia:4948
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1774503004
Review URL: https://codereview.chromium.org/1774503004
diff --git a/gyp/codec.gyp b/gyp/codec.gyp
index e96aaed..81b28fe 100644
--- a/gyp/codec.gyp
+++ b/gyp/codec.gyp
@@ -24,7 +24,7 @@
],
'cflags':[
# FIXME: This gets around a warning: "Argument might be clobbered by longjmp".
- '-Wno-clobbered -Wno-error',
+ '-Wno-clobbered -Wno-error',
],
'include_dirs': [
'../include/codec',
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi
index 2c04ea3..bfdbb9e 100644
--- a/gyp/common_conditions.gypi
+++ b/gyp/common_conditions.gypi
@@ -656,6 +656,15 @@
[ 'skia_profile_enabled == 1', {
'cflags': ['-g', '-fno-omit-frame-pointer', '-marm', '-mapcs'],
}],
+ [ 'skia_clang_build', {
+ 'cflags': [
+ '-Wno-unknown-warning-option', # Allows unknown warnings
+ # These flags that are on by default for only the android
+ # toolchain and no other platforms.
+ '-Wno-tautological-compare',
+ '-Wno-unused-command-line-argument',
+ ],
+ }],
],
},
],
diff --git a/gyp/freetype.gyp b/gyp/freetype.gyp
index 94ab94c..f282f77 100644
--- a/gyp/freetype.gyp
+++ b/gyp/freetype.gyp
@@ -102,6 +102,11 @@
'-O2',
],
}],
+ [ 'skia_clang_build == 1', {
+ 'cflags':[
+ '-Wno-error',
+ ],
+ }],
],
},
],
diff --git a/gyp/lua.gyp b/gyp/lua.gyp
index e030ffe..5b160eb 100644
--- a/gyp/lua.gyp
+++ b/gyp/lua.gyp
@@ -67,6 +67,11 @@
],
}
],
+ [ 'skia_clang_build == 1', {
+ 'cflags':[
+ '-Wno-error',
+ ],
+ }],
],
},
],
diff --git a/platform_tools/android/bin/android_setup.sh b/platform_tools/android/bin/android_setup.sh
index d9799c2..3af118e 100755
--- a/platform_tools/android/bin/android_setup.sh
+++ b/platform_tools/android/bin/android_setup.sh
@@ -12,6 +12,7 @@
set -e
BUILDTYPE=${BUILDTYPE-Debug}
+USE_CLANG="false"
while (( "$#" )); do
if [[ "$1" == "-d" ]]; then
@@ -29,9 +30,10 @@
shift
elif [[ "$1" == "--release" ]]; then
BUILDTYPE=Release
+ elif [[ "$1" == "--gcc" ]]; then
+ USE_CLANG="false"
elif [[ "$1" == "--clang" ]]; then
- USE_CLANG="true"
- export GYP_DEFINES="skia_clang_build=1 $GYP_DEFINES"
+ USE_CLANG="true"
elif [[ "$1" == "--logcat" ]]; then
LOGCAT=1
elif [[ "$1" == "--verbose" ]]; then
@@ -42,6 +44,10 @@
shift
done
+if [ "$USE_CLANG" == "true" ]; then
+ export GYP_DEFINES="skia_clang_build=1 $GYP_DEFINES"
+fi
+
function verbose {
if [[ -n $VERBOSE ]]; then
echo $@
diff --git a/platform_tools/android/bin/utils/setup_toolchain.sh b/platform_tools/android/bin/utils/setup_toolchain.sh
index a61b507..b423446 100755
--- a/platform_tools/android/bin/utils/setup_toolchain.sh
+++ b/platform_tools/android/bin/utils/setup_toolchain.sh
@@ -99,7 +99,7 @@
# should be compiled on Linux for performance reasons.
# TODO (msarett): Collect more information about this.
if [ $(uname) == "Linux" ]; then
- if [ -z $USE_CLANG ]; then
+ if [ "$USE_CLANG" != "true" ]; then
exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++"
exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
@@ -107,8 +107,6 @@
exportVar CXX_host "$CCACHE c++"
exportVar LINK_host "$CCACHE cc"
else
- # temporarily disable ccache as it is generating errors
- CCACHE=""
exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang"
exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++"
exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang"
@@ -126,13 +124,11 @@
exportVar OBJCOPY_host "objcopy"
exportVar STRIP_host "strip"
else
- if [ -z $USE_CLANG ]; then
+ if [ "$USE_CLANG" != "true" ]; then
exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++"
exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
else
- # temporarily disable ccache as it is generating errors
- CCACHE=""
exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang"
exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++"
exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang"
@@ -153,4 +149,12 @@
ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as
fi
+# fix bug in the toolchain in order to enable ccache to work with clang
+if [ $(head -c 2 $ANDROID_TOOLCHAIN_PREFIX-clang) != "#!" ]; then
+ echo -e "#!/bin/bash\n$(cat $ANDROID_TOOLCHAIN_PREFIX-clang)" > $ANDROID_TOOLCHAIN_PREFIX-clang
+fi
+if [ $(head -c 2 $ANDROID_TOOLCHAIN_PREFIX-clang++) != "#!" ]; then
+ echo -e "#!/bin/bash\n$(cat $ANDROID_TOOLCHAIN_PREFIX-clang++)" > $ANDROID_TOOLCHAIN_PREFIX-clang++
+fi
+
exportVar PATH $ANDROID_TOOLCHAIN:$PATH
diff --git a/platform_tools/android/gyp/dependencies.gypi b/platform_tools/android/gyp/dependencies.gypi
index 49937b0..e1fe783 100644
--- a/platform_tools/android/gyp/dependencies.gypi
+++ b/platform_tools/android/gyp/dependencies.gypi
@@ -113,6 +113,9 @@
'type': 'shared_library',
}],
],
+ 'cflags': [
+ '-Wno-unused-private-field',
+ ],
'sources': [
'../apps/sample_app/src/main/jni/com_skia_SkiaSampleRenderer.cpp',
],
diff --git a/src/views/SkView.cpp b/src/views/SkView.cpp
index 9e8182b..492b2cd 100644
--- a/src/views/SkView.cpp
+++ b/src/views/SkView.cpp
@@ -608,8 +608,6 @@
}
bool SkView::globalToLocal(SkScalar x, SkScalar y, SkPoint* local) const {
- SkASSERT(this);
-
if (local) {
SkMatrix m;
this->localToGlobal(&m);
diff --git a/tools/android/SkAndroidSDKCanvas.h b/tools/android/SkAndroidSDKCanvas.h
index d8ee0ed..68a5381 100644
--- a/tools/android/SkAndroidSDKCanvas.h
+++ b/tools/android/SkAndroidSDKCanvas.h
@@ -72,7 +72,7 @@
void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
SrcRectConstraint) override;
- void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*);
+ void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[],
const SkColor[], int count, SkXfermode::Mode,
const SkRect* cull, const SkPaint*) override;