Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: Makefile.android

Issue 10228016: Android build target for libadblockplus (Closed)
Patch Set: Created April 30, 2013, 7:40 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Makefile.android
===================================================================
new file mode 100644
--- /dev/null
+++ b/Makefile.android
@@ -0,0 +1,76 @@
+PATCH ?= patch
+# Those definitions should be consistent with the main Makefile
+ANDROID_ARCHES = android_ia32 android_arm android_mipsel
+MODES = release debug
+# Generates all combinations of ANDROID ARCHES and MODES,
+# e.g. "android_ia32.release" or "android_arm.release"
+ANDROID_BUILDS = $(foreach mode,$(MODES), \
+ $(addsuffix .$(mode),$(ANDROID_ARCHES)))
+
+HOST_OS = $(shell uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
+ifeq ($(HOST_OS), linux)
+ TOOLCHAIN_DIR = linux-x86
+else
+ ifeq ($(HOST_OS), mac)
+ TOOLCHAIN_DIR = darwin-x86
+ else
+ $(error Host platform "${HOST_OS}" is not supported)
+ endif
+endif
+
+ifeq ($(ARCH), android_arm)
+ DEFINES = target_arch=arm v8_target_arch=arm android_target_arch=arm
Wladimir Palant 2013/05/07 08:18:54 Setting v8_target_arch explicitly shouldn't be nec
+ DEFINES += arm_neon=0 armv7=1
+ TOOLCHAIN_ARCH = arm-linux-androideabi-4.6
+else
+ ifeq ($(ARCH), android_mipsel)
+ DEFINES = target_arch=mipsel v8_target_arch=mipsel android_target_arch=mips
+ DEFINES += mips_arch_variant=mips32r2
+ TOOLCHAIN_ARCH = mipsel-linux-android-4.6
+ else
+ ifeq ($(ARCH), android_ia32)
+ DEFINES = target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86
+ TOOLCHAIN_ARCH = x86-4.6
+ else
+ $(error Target architecture "${ARCH}" is not supported)
+ endif
+ endif
+endif
+
+TOOLCHAIN_PATH = ${ANDROID_NDK_ROOT}/toolchains/${TOOLCHAIN_ARCH}/prebuilt
+ANDROID_TOOLCHAIN ?= ${TOOLCHAIN_PATH}/${TOOLCHAIN_DIR}
+ifeq ($(wildcard $(ANDROID_TOOLCHAIN)),)
+ $(error Cannot find Android toolchain in "${ANDROID_TOOLCHAIN}")
+endif
+
+DEFINES += host_os=${HOST_OS} OS=android
+
+.PHONY: v8
+
+must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
+ifndef ANDROID_NDK_ROOT
+ifndef ANDROID_TOOLCHAIN
+ $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
+endif
+endif
+
+v8:
+ $(PATCH) -d third_party/v8 < patches/V8.patch
Andrey Novikov 2013/04/30 20:16:05 I do not like this approach because it is not erro
Wladimir Palant 2013/05/07 08:18:54 I don't like that approach either. You don't need
+ OUTDIR=../../build $(MAKE) -C third_party/v8 vfp3=off armv7=false $(ARCH).$(MODE)
+ $(PATCH) -d third_party/v8 -R < patches/V8.patch
+
+$(ANDROID_BUILDS): must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN v8
+ @GYP_GENERATORS=make-android \
+ GYP_DEFINES="${DEFINES}" \
+ CC="$(ANDROID_TOOLCHAIN)/bin/*-gcc" \
+ CXX="$(ANDROID_TOOLCHAIN)/bin/*-g++" \
+ third_party/gyp/gyp --depth=. -I common.gypi -I third_party/v8/build/standalone.gypi --generator-output=build -Dtarget_arch=$(ARCH) libadblockplus.gyp
Wladimir Palant 2013/05/07 08:18:54 Why do we need to include standalone.gypi? We don'
+ $(MAKE) V=1 -C build \
+ CXX="$(ANDROID_TOOLCHAIN)/bin/*-g++" \
+ AR="$(ANDROID_TOOLCHAIN)/bin/*-ar" \
+ RANLIB="$(ANDROID_TOOLCHAIN)/bin/*-ranlib" \
+ CC="$(ANDROID_TOOLCHAIN)/bin/*-gcc" \
+ LD="$(ANDROID_TOOLCHAIN)/bin/*-ld" \
+ LINK="$(ANDROID_TOOLCHAIN)/bin/*-g++" \
+ BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
+ python -c "print raw_input().capitalize()")

Powered by Google App Engine
This is Rietveld