jumper, drop Android NDK dependency
authorMike Klein <mtklein@chromium.org>
Fri, 31 Mar 2017 18:15:56 +0000 (14:15 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 3 Apr 2017 13:54:42 +0000 (13:54 +0000)
We don't _really_ need the Android NDK.  We just need <arm_neon.h>
(which comes from Clang, not the NDK) and a smattering of <stdint.h>
([u]intN_t), <string.h> (memcpy) and <stddef.h> (size_t).

The idea here is solely to make it easier to run build_stages.py.
If this becomes a pain to maintain, I'm happy to go back to the NDK.

Change-Id: Ic6bb287646b6160ac42ac6e4d5290a66a7e92425
Reviewed-on: https://skia-review.googlesource.com/10980
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>

src/jumper/SkJumper.h
src/jumper/SkJumper_stages.cpp
src/jumper/build_stages.py

index 712417a..5758d4e 100644 (file)
 // and SkJumper_stages.cpp (compiled into Skia _and_ offline into SkJumper_generated.h).
 // Keep it simple!
 
-#include <stdint.h>
+#if defined(JUMPER) && defined(__ANDROID__)
+    // To reduce SkJumper's dependency on the Android NDK,
+    // we provide what we need from <string.h>, <stdint.h>, and <stddef.h> ourselves.
+    #define memcpy __builtin_memcpy
+
+    using  int8_t  =   signed char;
+    using uint8_t  = unsigned char;
+    using  int16_t =   signed short;
+    using uint16_t = unsigned short;
+    using  int32_t =   signed int;
+    using uint32_t = unsigned int;
+    #if defined(__aarch64__)
+        using  int64_t =   signed long;
+        using uint64_t = unsigned long;
+        using size_t = uint64_t;
+    #else
+        using  int64_t =   signed long long;
+        using uint64_t = unsigned long long;
+        using size_t = uint32_t;
+    #endif
+
+    // Now pretend we've included <stdint.h> (or it'll be included again by <arm_neon.h>).
+    #define __CLANG_STDINT_H
+    #define _STDINT_H_
+#else
+    #include <string.h>
+    #include <stdint.h>
+#endif
 
 // SkJumper_stages.cpp has some unusual constraints on what constants it can use.
 //
index 6dddf9c..455184f 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include "SkJumper.h"
-#include <string.h>
 
 #define SI static inline
 
index 65234d9..60d9c1d 100755 (executable)
@@ -5,14 +5,12 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import os
 import re
 import subprocess
 import sys
 
 clang   = sys.argv[1] if len(sys.argv) > 1 else 'clang-4.0'
-ndk     = sys.argv[2] if len(sys.argv) > 2 else os.path.expanduser('~/ndk')
-objdump = sys.argv[3] if len(sys.argv) > 3 else 'gobjdump'
+objdump = sys.argv[2] if len(sys.argv) > 2 else 'gobjdump'
 
 clang = ['ccache', clang, '-x', 'c++']
 
@@ -53,17 +51,13 @@ subprocess.check_call(clang + cflags + hsw + win +
                       ['-c', 'src/jumper/SkJumper_stages.cpp'] +
                       ['-o', 'win_hsw.o'])
 
-aarch64 = [
-    '--target=aarch64-linux-android',
-    '--sysroot=' + ndk + '/platforms/android-21/arch-arm64',
-]
+aarch64 = [ '--target=aarch64-linux-android' ]
 subprocess.check_call(clang + cflags + aarch64 +
                       ['-c', 'src/jumper/SkJumper_stages.cpp'] +
                       ['-o', 'aarch64.o'])
 
 vfp4 = [
     '--target=armv7a-linux-android',
-    '--sysroot=' + ndk + '/platforms/android-18/arch-arm',
     '-mfpu=neon-vfpv4',
     '-mfloat-abi=hard',
 ]