Skip to content

Commit 33072be

Browse files
robertchirasMyles Borins
authored and
Myles Borins
committed
build: update android-configure script for npm
Now, that we can cross-compile node for Android, we also need to take care of native node modules installed with npm. Since there is no way to install and run npm on an Android device, we could instal node on host and setup an environment for installing node modules and cross-compile the native sources using Android NDK. The changes to this script will allow npm, when installing a module, to compile it using NDK. In order to do this, the developer should do the following steps: 1. Compile and install node on host, using: configure, make and make install 2. Build node for Android, using: source android-configure <path_to_ndk> arch and make 3. Push node binary to Android device 4. Using the same session, configure npm arch using: npm config set arch=<arch> 5. Install desired node modules using: npm install 6. Push installed node modules to Android device Signed-off-by: Robert Chiras <[email protected]> PR-URL: #6349 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 250887f commit 33072be

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

android-configure

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
#!/bin/bash
22

3+
# In order to cross-compile node for Android using NDK, run:
4+
# source android-configure <path_to_ndk> [arch]
5+
#
6+
# By running android-configure with source, will allow environment variables to
7+
# be persistent in current session. This is useful for installing native node
8+
# modules with npm. Also, don't forget to set the arch in npm config using
9+
# 'npm config set arch=<arch>'
10+
11+
312
if [ -z "$2" ]; then
413
ARCH=arm
514
else
@@ -42,8 +51,16 @@ export CC=$TOOLCHAIN/bin/$SUFFIX-gcc
4251
export CXX=$TOOLCHAIN/bin/$SUFFIX-g++
4352
export LINK=$TOOLCHAIN/bin/$SUFFIX-g++
4453

45-
./configure \
46-
--dest-cpu=$DEST_CPU \
47-
--dest-os=android \
48-
--without-snapshot \
49-
--openssl-no-asm
54+
GYP_DEFINES="target_arch=$ARCH"
55+
GYP_DEFINES+=" v8_target_arch=$ARCH"
56+
GYP_DEFINES+=" android_target_arch=$ARCH"
57+
GYP_DEFINES+=" host_os=linux OS=android"
58+
export GYP_DEFINES
59+
60+
if [ -f "configure" ]; then
61+
./configure \
62+
--dest-cpu=$DEST_CPU \
63+
--dest-os=android \
64+
--without-snapshot \
65+
--openssl-no-asm
66+
fi

0 commit comments

Comments
 (0)