Skip to content

Instantly share code, notes, and snippets.

@UweTrottmann
Last active November 24, 2022 21:31
Show Gist options
  • Save UweTrottmann/4753899 to your computer and use it in GitHub Desktop.
Save UweTrottmann/4753899 to your computer and use it in GitHub Desktop.
Building and running node-webkit for ARM This is based on the script available at http://code.google.com/p/chromium/wiki/LinuxChromiumArm#Recipe3:_Packaged/Automated_Cross_compiling
=== Relevant links
https://help.ubuntu.com/community/MultiArch
http://unix.stackexchange.com/questions/60282/can-one-install-an-armel-ubuntu-package-on-armhf-ubuntu-system
=== Setup multiarch for armel
Create
'/etc/dpkg/dpkg.cfg.d/multiarch'
containing
'foreign-architecture armel'.
dpkg --print-foreign-architectures
to get a list of the foreign architectures you have added
dpkg-architecture -qDEB_HOST_MULTIARCH
to see the multiarch pathname for your system's native architecture
Entries in /etc/apt/sources.list also get an extra arch field, for instance:
deb [arch=armhf,armel] http://archive.ubuntu.com/ubuntu precise main
After an "apt-get update" to refresh the package list, you can just install an available multiarch-ready library by specifying the architecture after a colon, for instance
apt-get install libattr1-dev:armel
This has been working in Ubuntu since 11.04.
=== Installing node-webkit dependencies
Install the following packages:
libc6:armel libx11-6:armel libxrandr2:armel libnss3:armel libgtk2.0-0:armel
libudev0:armel libstdc++6:armel libgconf2-4:armel libasound2:armel
You can check any missing shared libraries by running
#!/bin/bash
set -o nounset
set -o errexit
#@
#@ THIS HAS BEEN MODIFIED TO BUILD NODE-WEBKIT ON UBUNTU 12.04 ARMEL or ARMHF
#@
#@ The typical usage for this tool is:
#@
#@ Install cross toolchain (do this only once per system)
#@
#@ build/install-build-deps.sh --arm
#@
#@ you may also want to:
#@ build/install-build-deps.sh
#@ build/linux/install-arm-sysroot.py (should already be done by hooks)
#@ sudo apt-get install g++-multilib gcc-multilib
#@
#@
#@ build chrome with the cross toolchain
#@ chrome-setup.sh configure-chrome
#@ chrome-setup.sh make-chrome
#@ chrome-setup.sh package-chrome
#@ now copy the chrome tarball (chrome-arm.tgz) to your are device
readonly SYSROOT=$(pwd)/arm-sysroot
readonly PARALLELISM=20
readonly GYP_DEFINES="\
target_arch=arm \
"
#@
#@
configure-chrome() {
[ ! -d ${SYSROOT} ] && exit "arm root not found (run install-build-deps.sh --arm)"
export CXX=arm-linux-gnueabi-g++
export CC=arm-linux-gnueabi-gcc
export AR=arm-linux-gnueabi-ar
export AS=arm-linux-gnueabi-as
export RANLIB=arm-linux-gnueabi-ranlib
export CXX_host=g++
export CC_host=gcc
export GYP_DEFINES
# note this reads GYP_DEFINES
gclient runhooks
}
#@
#@
configure-chrome-hf() {
[ ! -d ${SYSROOT} ] && exit "arm root not found (run install-build-deps.sh --arm)"
export CXX=arm-linux-gnueabihf-g++
export CC=arm-linux-gnueabihf-gcc
export AR=arm-linux-gnueabihf-ar
export AS=arm-linux-gnueabihf-as
export RANLIB=arm-linux-gnueabihf-ranlib
export CXX_host=g++
export CC_host=gcc
export GYP_DEFINES
# note this reads GYP_DEFINES
gclient runhooks
}
build-targets() {
[ ! -d ${SYSROOT} ] && exit "arm root not found"
# $CXX should have been baked into both the ninja
# files and the Makefiles by this time, but due
# to several issues/bugs we need to set CXX during
# the build too.
# Ninja needs it since ld_bfd.py reads this env var
# and ninja doesn't export it.
# Make seems to need it otherwise it defines the
# linker command incorrectly.
# TODO(sbc): remove this
export CXX=arm-linux-gnueabi-g++
if [ "${GYP_GENERATORS:=}" == "ninja" ]; then
set -x
ninja -C ${GYP_GENERATOR_OUTPUT:=.}/out/Release $*
else
set -x
make BUILDTYPE=Release -j ${PARALLELISM} $*
fi
}
build-targets-hf() {
[ ! -d ${SYSROOT} ] && exit "arm root not found"
# $CXX should have been baked into both the ninja
# files and the Makefiles by this time, but due
# to several issues/bugs we need to set CXX during
# the build too.
# Ninja needs it since ld_bfd.py reads this env var
# and ninja doesn't export it.
# Make seems to need it otherwise it defines the
# linker command incorrectly.
# TODO(sbc): remove this
export CXX=arm-linux-gnueabihf-g++
if [ "${GYP_GENERATORS:=}" == "ninja" ]; then
set -x
ninja -C ${GYP_GENERATOR_OUTPUT:=.}/out/Release $*
else
set -x
make BUILDTYPE=Release -j ${PARALLELISM} $*
fi
}
#@
#@ Make node-webkit binaries (pass -v, or V=99 in you
#@ want verbosity in make/ninja respectively.
make-chrome() {
build-targets nw $*
}
#@
#@ Make node-webkit binaries (pass -v, or V=99 in you
#@ want verbosity in make/ninja respectively.
make-chrome-hf() {
build-targets-hf nw $*
}
package-chrome() {
local OUT=${GYP_GENERATOR_OUTPUT:=.}/out/Release
rm -rf ${OUT}/nw-arm
mkdir ${OUT}/nw-arm
cp -r ${OUT}/nw \
${OUT}/lib*.so \
${OUT}/nw.pak \
${OUT}/nw-arm
tar cfvz ${OUT}/nw-arm.tgz -C ${OUT} nw-arm
echo "chrome packaged in chrome-arm.tgz"
}
######################################################################
# DISPATCH
######################################################################
Usage() {
egrep "^#@" $0 | cut --bytes=3-
}
if [[ $# -eq 0 ]] ; then
echo "you must specify a mode on the commandline:"
echo
Usage
exit -1
elif [[ "$(type -t $1)" != "function" ]]; then
echo "ERROR: unknown function '$1'." >&2
echo "For help, try:"
echo " $0 help"
exit 1
else
"$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment