Update android_make to support both --gcc and --clang options.
authordjsollen <djsollen@google.com>
Mon, 7 Mar 2016 20:30:47 +0000 (12:30 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 7 Mar 2016 20:30:47 +0000 (12:30 -0800)
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

gyp/codec.gyp
gyp/common_conditions.gypi
gyp/freetype.gyp
gyp/lua.gyp
platform_tools/android/bin/android_setup.sh
platform_tools/android/bin/utils/setup_toolchain.sh
platform_tools/android/gyp/dependencies.gypi
src/views/SkView.cpp
tools/android/SkAndroidSDKCanvas.h

index e96aaed..81b28fe 100644 (file)
@@ -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',
index 2c04ea3..bfdbb9e 100644 (file)
           [ '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',
+            ],
+          }],
         ],
       },
     ],
index 94ab94c..f282f77 100644 (file)
             '-O2',
           ],
         }],
+        [ 'skia_clang_build == 1', {
+          'cflags':[
+            '-Wno-error',
+          ],
+        }],
       ],
     },
   ],
index e030ffe..5b160eb 100644 (file)
             ],
           }
         ],
+        [ 'skia_clang_build == 1', {
+          'cflags':[
+            '-Wno-error',
+          ],
+        }],
       ],
     },
   ],
index d9799c2..3af118e 100755 (executable)
@@ -12,6 +12,7 @@
 set -e
 
 BUILDTYPE=${BUILDTYPE-Debug}
+USE_CLANG="false"
 
 while (( "$#" )); do
   if [[ "$1" == "-d" ]]; then
@@ -29,9 +30,10 @@ while (( "$#" )); do
     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 @@ while (( "$#" )); do
   shift
 done
 
+if [ "$USE_CLANG" == "true" ]; then
+  export GYP_DEFINES="skia_clang_build=1 $GYP_DEFINES"
+fi
+
 function verbose {
   if [[ -n $VERBOSE ]]; then
     echo $@
index a61b507..b423446 100755 (executable)
@@ -99,7 +99,7 @@ CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)}
 # 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 @@ if [ $(uname) == "Linux" ]; then
     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 @@ if [ $(uname) == "Linux" ]; then
   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 @@ if [ $(uname) == "Darwin" ]; then
   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
index 49937b0..e1fe783 100644 (file)
             'type': 'shared_library',
           }],
         ],
+        'cflags': [
+          '-Wno-unused-private-field',
+        ],
         'sources': [
           '../apps/sample_app/src/main/jni/com_skia_SkiaSampleRenderer.cpp',
         ],
index 9e8182b..492b2cd 100644 (file)
@@ -608,8 +608,6 @@ void SkView::localToGlobal(SkMatrix* matrix) const {
 }
 
 bool SkView::globalToLocal(SkScalar x, SkScalar y, SkPoint* local) const {
-    SkASSERT(this);
-
     if (local) {
         SkMatrix m;
         this->localToGlobal(&m);
index d8ee0ed..68a5381 100644 (file)
@@ -72,7 +72,7 @@ protected:
     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;