User Tools

Site Tools


Sidebar

Launch of Linino.org

wiki:nodepackage

Foreword

Before using this script you MUST have cross-compiled the node.js platform on your host machine as described here.

Build your own Node.js package with the linino toolchain

Since you don't have gcc/g++ on the Yun any npm module requiring it must be cross-compiled on your host machine. Make sure you have the same version of node and npm installed on your host machine.

We can again use a build script. Create build_npm_mipsbe.sh in your working directory (i.e ~/CROSS_MIPS).

#!/bin/bash
 
export BASEDIR=$(pwd)
 
export STAGING_DIR=${BASEDIR}/linino_distro/staging_dir
 
export V8SOURCE=${BASEDIR}/v8m-rb
 
export PREFIX=${STAGING_DIR}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-
 
export LIBPATH=${STAGING_DIR}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/lib/
 
# MIPS cross-compile exports
export CC=${PREFIX}gcc
export CXX=${PREFIX}g++
export AR=${PREFIX}ar
export RANLIB=${PREFIX}ranlib
export LINK=${PREFIX}g++
export CPP="${PREFIX}gcc -E"
export STRIP=${PREFIX}strip
export OBJCOPY=${PREFIX}objcopy
export LD=${PREFIX}g++
export OBJDUMP=${PREFIX}objdump
export NM=${PREFIX}nm
export AS=${PREFIX}as
export PS1="[${PREFIX}] \w$ "
 
export LDFLAGS='-Wl,-rpath-link '${LIBPATH}
 
export GYPFLAGS="-Dv8_use_mips_abi_hardfloat=false -Dv8_can_use_fpu_instructions=false"
 
export npm_config_arch=mips
# path to the node source that was used to create the cross-compiled version
export npm_config_nodedir=${BASEDIR}/node-v0.10."$2"-mips
 
if [ ! -d $(pwd)/mips_modules_"$2" ]
then
        mkdir $(pwd)/mips_modules_"$2"
fi
 
cd mips_modules_"$2"/
 
version=`npm view "$1" version`
 
npm install --target_arch=mips "$1"
 
if [ $? -eq 1 ]
then
    echo " "
    echo "Build of package for MIPS failed ! ! !"
    echo " "
    exit 0
else
    echo ""
    echo "Making archive of "$1" for MIPS........"
    echo ""
 
    cd node_modules/
    tar -cvf "$1"-"$version"_mips-"$2"-ubuntu.tar.gz "$1"/ > /dev/null
    mv "$1"-"$version"_mips-"$2"-ubuntu.tar.gz ../
    rm -rf *
    echo " "
    echo ""Build of package for MIPS finished ! ! !""
    echo " "
fi

Now make it executable with

chmod +x build_npm_mipsbe.sh 

and invoke it with the name of the module you need to build i.e. :

./build.sh serialport 24

Inside the mips_modules_24/node_modules' folder, you will find the cross-compiled module and all its dependencies. Just move over everything via scp and you should be set. In addition to this, you can define your own path(s) for the Node.js modules. Just edit the .profile file in your root home folder and set the NODE_PATH'' enviroment variable :

export NODE_PATH=path_1:path_2:.........:path_n:$NODE_PATH

then update your setup with :

root@Arduino:~# . .profile

or simply reboot the system.

PS : The whole process has successfully been tested on Node.js until v0.10.28 so far.

/var/www/wiki.linino.org/data/pages/wiki/nodepackage.txt · Last modified: 2014/06/26 05:44 by arturo

2014 © dog hunter llc and the Linino Community. Linino.org is a dog hunter sponsored community project. Credits