From: jkummerow@chromium.org Date: Mon, 16 Jan 2012 13:29:12 +0000 (+0000) Subject: Add Android cross-compilation support to top-level Makefile X-Git-Tag: upstream/4.7.83~17606 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2dc816bb2d07ed8f04e0acd138db8487f626e42c;p=platform%2Fupstream%2Fv8.git Add Android cross-compilation support to top-level Makefile TEST=make android Review URL: http://codereview.chromium.org/9179009 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10409 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/Makefile b/Makefile index 09d1e8b..833c875 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Copyright 2011 the V8 project authors. All rights reserved. +# Copyright 2012 the V8 project authors. All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: @@ -33,6 +33,8 @@ OUTDIR ?= out TESTJOBS ?= -j16 GYPFLAGS ?= TESTFLAGS ?= +ANDROID_NDK_ROOT ?= +ANDROID_TOOL_PREFIX = $(ANDROID_NDK_ROOT)/toolchain/bin/arm-linux-androideabi # Special build flags. Use them like this: "make library=shared" @@ -93,6 +95,7 @@ endif # - every combination ., e.g. "ia32.release" # - "native": current host's architecture, release mode # - any of the above with .check appended, e.g. "ia32.release.check" +# - "android": cross-compile for Android/ARM (release mode) # - default (no target specified): build all DEFAULT_ARCHES and MODES # - "check": build all targets and run all tests # - ".clean" for any in ARCHES @@ -120,7 +123,8 @@ ENVFILE = $(OUTDIR)/environment .PHONY: all check clean dependencies $(ENVFILE).new native \ $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \ - $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) + $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \ + must-set-ANDROID_NDK_ROOT # Target definitions. "all" is the default. all: $(MODES) @@ -144,6 +148,18 @@ native: $(OUTDIR)/Makefile-native CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \ builddir="$(shell pwd)/$(OUTDIR)/$@" +# TODO(jkummerow): add "android.debug" when we need it. +android android.release: $(OUTDIR)/Makefile-android + @$(MAKE) -C "$(OUTDIR)" -f Makefile-android \ + CXX="$(ANDROID_TOOL_PREFIX)-g++" \ + AR="$(ANDROID_TOOL_PREFIX)-ar" \ + RANLIB="$(ANDROID_TOOL_PREFIX)-ranlib" \ + CC="$(ANDROID_TOOL_PREFIX)-gcc" \ + LD="$(ANDROID_TOOL_PREFIX)-ld" \ + LINK="$(ANDROID_TOOL_PREFIX)-g++" \ + BUILDTYPE=Release \ + builddir="$(shell pwd)/$(OUTDIR)/android.release" + # Test targets. check: all @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \ @@ -178,6 +194,11 @@ native.clean: rm -rf $(OUTDIR)/native find $(OUTDIR) -regex '.*\(host\|target\)-native\.mk' -delete +android.clean: + rm -f $(OUTDIR)/Makefile-android + rm -rf $(OUTDIR)/android.release + find $(OUTDIR) -regex '.*\(host\|target\)-android\.mk' -delete + clean: $(addsuffix .clean,$(ARCHES)) native.clean # GYP file generation targets. @@ -205,6 +226,18 @@ $(OUTDIR)/Makefile-native: $(GYPFILES) $(ENVFILE) build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ -Ibuild/standalone.gypi --depth=. -S-native $(GYPFLAGS) +$(OUTDIR)/Makefile-android: $(GYPFILES) $(ENVFILE) build/android.gypi \ + must-set-ANDROID_NDK_ROOT + CC="${ANDROID_TOOL_PREFIX}-gcc" \ + build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ + -Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \ + -S-android $(GYPFLAGS) + +must-set-ANDROID_NDK_ROOT: +ifndef ANDROID_NDK_ROOT + $(error ANDROID_NDK_ROOT is not set) +endif + # Replaces the old with the new environment file if they're different, which # will trigger GYP to regenerate Makefiles. $(ENVFILE): $(ENVFILE).new diff --git a/build/android.gypi b/build/android.gypi new file mode 100644 index 0000000..ffd0648 --- /dev/null +++ b/build/android.gypi @@ -0,0 +1,225 @@ +# Copyright 2012 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Definitions for building standalone V8 binaries to run on Android. +# This is mostly excerpted from: +# http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi + +{ + 'variables': { + # Location of Android NDK. + 'variables': { + 'variables': { + 'android_ndk_root%': '