Skip to content

Commit 1ddf8c3

Browse files
Rewrite Makefile rules for Android to allow parallel execution
BUG=v8:2257 Review URL: https://chromiumcodereview.appspot.com/10824039 Patch from Haitao Feng <[email protected]>. git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@12211 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
1 parent 764c414 commit 1ddf8c3

File tree

3 files changed

+100
-102
lines changed

3 files changed

+100
-102
lines changed

Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,12 @@ native: $(OUTDIR)/Makefile.native
178178
$(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
179179

180180
$(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \
181-
must-set-ANDROID_NDK_ROOT
182-
@tools/android-build.sh $(basename $@) $(subst .,,$(suffix $@)) \
183-
$(OUTDIR) $(GYPFLAGS)
181+
must-set-ANDROID_NDK_ROOT Makefile.android
182+
@$(MAKE) -f Makefile.android $@ \
183+
ARCH="$(basename $@)" \
184+
MODE="$(subst .,,$(suffix $@))" \
185+
OUTDIR="$(OUTDIR)" \
186+
GYPFLAGS="$(GYPFLAGS)"
184187

185188
# Test targets.
186189
check: all
@@ -231,8 +234,8 @@ native.clean:
231234
clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES)) native.clean
232235

233236
# GYP file generation targets.
234-
MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ARCHES))
235-
$(MAKEFILES): $(GYPFILES) $(ENVFILE)
237+
OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ARCHES))
238+
$(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
236239
GYP_GENERATORS=make \
237240
build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
238241
-Ibuild/standalone.gypi --depth=. \

Makefile.android

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright 2012 the V8 project authors. All rights reserved.
2+
# Redistribution and use in source and binary forms, with or without
3+
# modification, are permitted provided that the following conditions are
4+
# met:
5+
#
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above
9+
# copyright notice, this list of conditions and the following
10+
# disclaimer in the documentation and/or other materials provided
11+
# with the distribution.
12+
# * Neither the name of Google Inc. nor the names of its
13+
# contributors may be used to endorse or promote products derived
14+
# from this software without specific prior written permission.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
# Those definitions should be consistent with the main Makefile
29+
ANDROID_ARCHES = android_ia32 android_arm
30+
MODES = release debug
31+
32+
# Generates all combinations of ANDROID ARCHES and MODES,
33+
# e.g. "android_ia32.release" or "android_arm.release"
34+
ANDROID_BUILDS = $(foreach mode,$(MODES), \
35+
$(addsuffix .$(mode),$(ANDROID_ARCHES)))
36+
37+
HOST_OS = $(shell uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
38+
ifeq ($(HOST_OS), linux)
39+
TOOLCHAIN_DIR = linux-x86
40+
else
41+
ifeq ($(HOST_OS), mac)
42+
TOOLCHAIN_DIR = darwin-x86
43+
else
44+
$(error Host platform "${HOST_OS}" is not supported)
45+
endif
46+
endif
47+
48+
ifeq ($(ARCH), android_arm)
49+
DEFINES = target_arch=arm v8_target_arch=arm android_target_arch=arm
50+
DEFINES += arm_neon=0 armv7=1
51+
TOOLCHAIN_ARCH = arm-linux-androideabi-4.4.3
52+
else
53+
ifeq ($(ARCH), android_ia32)
54+
DEFINES = target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86
55+
TOOLCHAIN_ARCH = x86-4.4.3
56+
else
57+
$(error Target architecture "${ARCH}" is not supported)
58+
endif
59+
endif
60+
61+
TOOLCHAIN_PATH = ${ANDROID_NDK_ROOT}/toolchains/${TOOLCHAIN_ARCH}/prebuilt
62+
ANDROID_TOOLCHAIN = ${TOOLCHAIN_PATH}/${TOOLCHAIN_DIR}/bin
63+
ifeq ($(wildcard $(ANDROID_TOOLCHAIN)),)
64+
$(error Cannot find Android toolchain in "${ANDROID_TOOLCHAIN}")
65+
endif
66+
67+
# For mksnapshot host generation.
68+
DEFINES += host_os=${HOST_OS}
69+
70+
.SECONDEXPANSION:
71+
$(ANDROID_BUILDS): $(OUTDIR)/Makefile.$$(basename $$@)
72+
@$(MAKE) -C "$(OUTDIR)" -f Makefile.$(basename $@) \
73+
CXX="$(ANDROID_TOOLCHAIN)/*-g++" \
74+
AR="$(ANDROID_TOOLCHAIN)/*-ar" \
75+
RANLIB="$(ANDROID_TOOLCHAIN)/*-ranlib" \
76+
CC="$(ANDROID_TOOLCHAIN)/*-gcc" \
77+
LD="$(ANDROID_TOOLCHAIN)/*-ld" \
78+
LINK="$(ANDROID_TOOLCHAIN)/*-g++" \
79+
BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
80+
python -c "print raw_input().capitalize()") \
81+
builddir="$(shell pwd)/$(OUTDIR)/$@"
82+
83+
# Android GYP file generation targets.
84+
ANDROID_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ANDROID_ARCHES))
85+
$(ANDROID_MAKEFILES):
86+
@GYP_GENERATORS=make-android \
87+
GYP_DEFINES="${DEFINES}" \
88+
CC="${ANDROID_TOOLCHAIN}/*-gcc" \
89+
CXX="${ANDROID_TOOLCHAIN}/*-g++" \
90+
build/gyp/gyp --generator-output="${OUTDIR}" build/all.gyp \
91+
-Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \
92+
-S.${ARCH} ${GYPFLAGS}

tools/android-build.sh

-97
Original file line numberDiff line numberDiff line change
@@ -1,97 +0,0 @@
1-
#!/bin/bash
2-
# Copyright 2012 the V8 project authors. All rights reserved.
3-
# Redistribution and use in source and binary forms, with or without
4-
# modification, are permitted provided that the following conditions are
5-
# met:
6-
#
7-
# * Redistributions of source code must retain the above copyright
8-
# notice, this list of conditions and the following disclaimer.
9-
# * Redistributions in binary form must reproduce the above
10-
# copyright notice, this list of conditions and the following
11-
# disclaimer in the documentation and/or other materials provided
12-
# with the distribution.
13-
# * Neither the name of Google Inc. nor the names of its
14-
# contributors may be used to endorse or promote products derived
15-
# from this software without specific prior written permission.
16-
#
17-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20-
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21-
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
29-
if [ ${#@} -lt 4 ] ; then
30-
echo "$0: Error: needs 4 arguments."
31-
exit 1
32-
fi
33-
34-
ARCH=$1
35-
MODE=$2
36-
OUTDIR=$3
37-
GYPFLAGS=$4
38-
39-
host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
40-
41-
case "${host_os}" in
42-
"linux")
43-
toolchain_dir="linux-x86"
44-
;;
45-
"mac")
46-
toolchain_dir="darwin-x86"
47-
;;
48-
*)
49-
echo "$0: Host platform ${host_os} is not supported" >& 2
50-
exit 1
51-
esac
52-
53-
case "${ARCH}" in
54-
"android_arm")
55-
DEFINES=" target_arch=arm v8_target_arch=arm android_target_arch=arm"
56-
DEFINES+=" arm_neon=0 armv7=1"
57-
toolchain_arch="arm-linux-androideabi-4.4.3"
58-
;;
59-
"android_ia32")
60-
DEFINES=" target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86"
61-
toolchain_arch="x86-4.4.3"
62-
;;
63-
*)
64-
echo "$0: Target architecture ${ARCH} is not supported." >& 2
65-
echo "$0: Current supported architectures: android_arm|android_ia32." >& 2
66-
exit 1
67-
esac
68-
69-
toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}/prebuilt/"
70-
ANDROID_TOOLCHAIN="${toolchain_path}/${toolchain_dir}/bin"
71-
if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then
72-
echo "$0: Cannot find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2
73-
echo "$0: The NDK version might be wrong." >& 2
74-
exit 1
75-
fi
76-
77-
# For mksnapshot host generation.
78-
DEFINES+=" host_os=${host_os}"
79-
80-
# The set of GYP_DEFINES to pass to gyp.
81-
export GYP_DEFINES="${DEFINES}"
82-
83-
# Use the "android" flavor of the Makefile generator for both Linux and OS X.
84-
export GYP_GENERATORS=make-android
85-
export CC=${ANDROID_TOOLCHAIN}/*-gcc
86-
export CXX=${ANDROID_TOOLCHAIN}/*-g++
87-
build/gyp/gyp --generator-output="${OUTDIR}" build/all.gyp \
88-
-Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \
89-
-S.${ARCH} ${GYPFLAGS}
90-
91-
export AR=${ANDROID_TOOLCHAIN}/*-ar
92-
export RANLIB=${ANDROID_TOOLCHAIN}/*-ranlib
93-
export LD=${ANDROID_TOOLCHAIN}/*-ld
94-
export LINK=${ANDROID_TOOLCHAIN}/*-g++
95-
export BUILDTYPE=$(echo ${MODE} | python -c "print raw_input().capitalize()")
96-
export builddir=${PWD}/${OUTDIR}/${ARCH}.${MODE}
97-
make -C "${OUTDIR}" -f Makefile.${ARCH}

0 commit comments

Comments
 (0)