在mips Big Endian上交叉编译node.js模块

时间:2014-04-07 14:01:51

标签: node.js npm mips cross-compiling node-gyp

我需要一些帮助来为我的Arduino Yun交叉编译mips BIG ENDIAN架构上的节点模块..我已经按照Fiore Basile编写的指南进行了一段时间的发布:

http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html

编译修补后的V8库和0.10.25版本的节点源代码tarball ....是时候构建节点模块了!

所以,我从菲奥雷的剧本中汲取灵感并编写了我自己的剧本,并在那里添加了一些修复......

#!/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"

然而,当使用

启动脚本时,某些内容不会加起来.....
$ ./build_npm_package.sh serialport 25

但我最终得到了这些错误......

> 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

通过google搜索建议始终是相同的.....“将编译器设置为...”“将npm_config_arch变量导出到mips”“将npm_config_nodedir导出到....”等等但结果总是一样的....

.....你能帮忙解决一下吗?

提前致谢,Arturo

2 个答案:

答案 0 :(得分:0)

我知道这个回复已经很晚了,我估计你已经解决了问题。您是否看过以下关于linino的指南:http://wiki.linino.org/doku.php?id=wiki:nodepackage

它提供了一个构建脚本,其中包含需要设置的必要环境变量,以便在mips硬件上编译nodejs - modules。

从我可以收集的内容中,所有这些都归结为告诉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"

答案 1 :(得分:0)

在我找到如何解决问题之后,我的向导是谁!从我的系统卸载软件包node-gyp后,我能够成功构建任何软件包......

非常感谢;)