Last active
December 24, 2017 20:44
-
-
Save artynet/e8ca8467cdbb245d5ddffe3e4e49dc9d to your computer and use it in GitHub Desktop.
Simple script to cross-compile mozilla-iot-gateway modules for ARMv7 architecture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# | |
# This script is expected to run inside a docker container which has the Raspberry Pi toolchain | |
# and required prerequisites: | |
# - pkg-config | |
# - libusb-1.0-0-dev | |
# - libudev-dev | |
# | |
# /build corresponds to the current directory when the docker container is run and it is expected | |
# that the following directory structure has been setup: | |
# | |
# - /build/Open-ZWave/open-zwave - git repository containing the desired version of OpenZWave | |
# - /build/gateway - git repository containing the gateway software | |
# initial settings | |
REV=$(git rev-parse --short HEAD) | |
NODE_MODULES_TARBALL=node_modules-armv7l-${REV}.tar.gz | |
# Remove the output, if it exists | |
[ -e ${NODE_MODULES_TARBALL} ] && echo "already built !" && exit 0 | |
[ -d $PWD/node_modules ] && rm -rf $PWD/node_modules | |
NODE_VERSION=v8.9.1 | |
ARCH=armv7l | |
SYSROOT=${HOME}/cross-raspbian | |
# Setup Cross compiler vars which are used by node-gyp when building native node modules. | |
OPTS="--sysroot=${SYSROOT}" | |
export CC="arm-linux-gnueabihf-gcc ${OPTS}" | |
export CXX="arm-linux-gnueabihf-g++ ${OPTS}" | |
# building npm modules | |
# npm --arch=${ARCH} install --build-from-source | |
npm --arch=${ARCH} install | |
# Create a tarball with all of the node modules | |
tar czf ${NODE_MODULES_TARBALL} node_modules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment