-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Kitt-AI/devel
v1.0.3
- Loading branch information
Showing
12 changed files
with
176 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Example Makefile that wrappers snowboy c++ library (snowboy-detect.a) through | ||
# JNI interface, using swig. | ||
|
||
# When you extract Android toolchain from Android NDK, make sure you supply | ||
# --stl=libc++ option. This Makefile is optimized for armv7-a architecture. | ||
|
||
# Some versions of swig does not work well. We prefer compiling swig from source | ||
# code. We have tested swig-3.0.7.tar.gz. | ||
SWIG := swig | ||
|
||
# Please specify your NDK root directory here. | ||
NDKROOT := | ||
APILEVEL := 17 | ||
|
||
SNOWBOYDETECTSWIGITF = snowboy-detect-swig.i | ||
SNOWBOYDETECTSWIGOBJ = snowboy-detect-swig.o | ||
SNOWBOYDETECTSWIGCC = snowboy-detect-swig.cc | ||
SNOWBOYDETECTJAVAPKG = ai.kitt.snowboy | ||
SNOWBOYDETECTJAVAPKGDIR = java/ai/kitt/snowboy/ | ||
SNOWBOYDETECTSWIGLIBFILE = libsnowboy-detect-android.so | ||
OPENBLASLIBFILE = OpenBLAS-Android/install/lib/libopenblas.a | ||
|
||
ARCH := arm | ||
TOPDIR := ../../ | ||
LDFLAGS := | ||
|
||
CXXFLAGS := -O3 --sysroot=$(NDKROOT)/platforms/android-$(APILEVEL)/arch-$(ARCH) | ||
LDLIBS := -L$(NDKROOT)/platforms/android-$(APILEVEL)/arch-$(ARCH)/usr/lib | ||
|
||
ifeq ($(ARCH), arm) | ||
CXX := arm-linux-androideabi-g++ | ||
STRIP := arm-linux-androideabi-strip | ||
OPENBLASTARGET := ARMV7 | ||
SNOWBOYDETECTLIBFILE = $(TOPDIR)/lib/android/armv7a/libsnowboy-detect.a | ||
CXXFLAGS += -shared -std=c++0x -rdynamic -I$(TOPDIR) -Wl,--fix-cortex-a8 \ | ||
-Wl,--no-warn-mismatch -Wl,--no-undefined -Wl,-z,noexecstack \ | ||
-Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings \ | ||
-Wno-sign-compare -Wa,--noexecstack -Wformat -Werror=format-security \ | ||
-fno-rtti -ffunction-sections -funwind-tables -fstack-protector-strong \ | ||
-fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \ | ||
-fno-strict-aliasing -mthumb -no-canonical-prefixes -march=armv7-a \ | ||
-mfpu=vfpv3-d16 -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -DANDROID | ||
LDLIBS += \ | ||
-L$(NDKROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a-hard/thumb/ \ | ||
-lc++_static -lgcc -lm_hard -ldl -lc -lm | ||
SNOWBOYDETECTSWIGLIBFILE := jniLibs/armeabi-v7a/$(SNOWBOYDETECTSWIGLIBFILE) | ||
SNOWBOYDETECTSWIGLIBNAME := $(shell basename $(SNOWBOYDETECTSWIGLIBFILE)) | ||
endif | ||
|
||
all: $(SNOWBOYSWIGLIBFILE) $(SNOWBOYDETECTSWIGLIBFILE) | ||
|
||
%.a: | ||
$(MAKE) -C ${@D} ${@F} | ||
|
||
$(OPENBLASLIBFILE): | ||
@-./install_openblas_android.sh $(ARCH) $(OPENBLASTARGET) | ||
|
||
$(SNOWBOYDETECTSWIGCC): $(SNOWBOYDETECTSWIGITF) | ||
@-mkdir -p $(SNOWBOYDETECTJAVAPKGDIR) | ||
$(SWIG) -I$(TOPDIR) -c++ -java -package $(SNOWBOYDETECTJAVAPKG) -outdir \ | ||
$(SNOWBOYDETECTJAVAPKGDIR) -o $(SNOWBOYDETECTSWIGCC) $(SNOWBOYDETECTSWIGITF) | ||
|
||
$(SNOWBOYDETECTSWIGOBJ): $(SNOWBOYDETECTSWIGCC) | ||
$(CXX) $(CXXFLAGS) -c $(SNOWBOYDETECTSWIGCC) -o $(SNOWBOYDETECTSWIGOBJ) | ||
|
||
$(SNOWBOYDETECTSWIGLIBFILE): $(OPENBLASLIBFILE) $(SNOWBOYDETECTSWIGOBJ) $(SNOWBOYDETECTLIBFILE) | ||
@-mkdir -p `dirname $(SNOWBOYDETECTSWIGLIBFILE)` | ||
$(CXX) -Wl,-soname,$(SNOWBOYDETECTSWIGLIBNAME) $(CXXFLAGS) $(LDFLAGS) \ | ||
$(SNOWBOYDETECTSWIGOBJ) $(SNOWBOYDETECTLIBFILE) $(OPENBLASLIBFILE) \ | ||
$(LDLIBS) -o $(SNOWBOYDETECTSWIGLIBFILE) | ||
$(STRIP) --strip-unneeded $(SNOWBOYDETECTSWIGLIBFILE) | ||
|
||
clean: | ||
-rm -rf *.o *.a *.so java jniLibs $(SNOWBOYDETECTSWIGCC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
# This script compiles OpenBLAS for Android with the given architecture. The | ||
# prebuild Android NDK toolchains do not include Fortran, hence parts like | ||
# LAPACK will not be built. | ||
|
||
ARCH=$1 | ||
TARGET=$2 | ||
|
||
if [ ! -f OpenBLAS-0.2.18.tar.gz ]; then | ||
wget -T 10 -t 3 https://codeload.github.com/xianyi/OpenBLAS/tar.gz/v0.2.18 \ | ||
-O OpenBLAS-0.2.18.tar.gz || exit 1; | ||
fi | ||
|
||
tar -xvzf OpenBLAS-0.2.18.tar.gz || exit 1; | ||
mv OpenBLAS-0.2.18 OpenBLAS-Android | ||
|
||
cd OpenBLAS-Android | ||
make TARGET=${TARGET} HOSTCC=gcc \ | ||
CC=${ARCH}-linux-androideabi-gcc NOFORTRAN=1 || exit 1; | ||
make PREFIX=`pwd`/install install || exit 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// snowboy-detect-swig.i | ||
|
||
// Copyright 2016 KITT.AI (author: Guoguo Chen) | ||
|
||
%module snowboy | ||
|
||
// Suppress SWIG warnings. | ||
#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS | ||
%include "arrays_java.i" | ||
%include "std_string.i" | ||
|
||
%apply float[] {float*}; | ||
%apply short[] {int16_t*}; | ||
%apply int[] {int32_t*}; | ||
|
||
%{ | ||
#include "include/snowboy-detect.h" | ||
%} | ||
|
||
%include "include/snowboy-detect.h" |