Cross compiling node.js modules on mips Big Endian

I need help cross-compiling node modules on the MIP BIG ENDIAN architecture for my Arduino Yun .. I followed a tutorial written by Fiore Bazil and published here some time ago:

http://fibasile.imtqy.com/compiling-nodejs-for-arduino-yun.html

after compiling the fixed V8 libraries and the version of the source file node 0.10.25 .... time to build the node modules!

So, I took inspiration from the Fiore script and wrote my own, adding some corrections then and there ....

#!/bin/bash

export BASEDIR=$(pwd)

# cd ${BASEDIR}/node-v0.10."$2"-mips/

export STAGING_DIR=${BASEDIR}/linino_distro/staging_dir

export V8SOURCE=${BASEDIR}/v8m-rb-dm-dev-mipsbe

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/

#export AR=${PREFIX}uclibc-ar

export CC=${PREFIX}gcc
export CXX=${PREFIX}g++
export AR=${PREFIX}ar
export RANLIB=${PREFIX}ranlib
export LINK=${PREFIX}g++

# export LDFLAGS='-fno-use-linker-plugin'

#------------------------------------------

# export CFLAGS='-fno-use-linker-plugin'

# export CXXFLAGS='-fno-use-linker-plugin'

#------------------------------------------

export LDFLAGS='-Wl,-rpath-link '${LIBPATH}

# export TARGET_PATH=${BASEDIR}/nodeyun/opt

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

#node-gyp clean configure build --verbose --arch=mips

if [ ! -d $(pwd)/mips_modules ]
then
    mkdir $(pwd)/mips_modules
fi

cd mips_modules/

npm install "$1"

However, something doesnโ€™t add up ..... when you run the script with

$ ./build_npm_package.sh serialport 25

but I end up getting these errors .....

> serialport@1.3.1 install /home/artynet/Downloads/CROSS_MIPS/mips_modules/node_modules/serialport
> node-gyp rebuild


npm http GET https://registry.npmjs.org/serialport
npm http 304 https://registry.npmjs.org/serialport
npm http GET https://registry.npmjs.org/sf/0.1.6
npm http GET https://registry.npmjs.org/bindings/1.1.1
npm http GET https://registry.npmjs.org/async/0.1.18
npm http GET https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/bindings/1.1.1
npm http 304 https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/async/0.1.18
npm http 304 https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/sf/0.1.6
npm http GET https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/wordwrap
Traceback (most recent call last):
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
    sys.exit(gyp.script_main())
AttributeError: 'module' object has no attribute 'script_main'
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.11.0-19-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/artynet/Downloads/CROSS_MIPS/mips_modules/node_modules/serialport
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm ERR! serialport@1.3.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the serialport@1.3.1 install script.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls serialport
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.0-19-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "serialport"
npm ERR! cwd /home/artynet/Downloads/CROSS_MIPS/mips_modules
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/artynet/Downloads/CROSS_MIPS/mips_modules/npm-debug.log
npm ERR! not ok code 0

..... " ..." " npm_config_arch mips" " npm_config_nodedir ..." , ....

..... ?

,

+4
2

, , , . linino: http://wiki.linino.org/doku.php?id=wiki:nodepackage

script , nodejs - mips.

, , , npm, :

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"
0

, , ! node -gyp ...

;)

0

Source: https://habr.com/ru/post/1535379/


All Articles