我需要一些帮助来交叉编译我的Arduino Yun的mips BIG ENDIAN架构上的节点模块。我遵循了Fiore Basile撰写的指南,并在前段时间发布在这里:
http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html
在编译了修补的 V8 库和 0.10.25 版本的节点源代码压缩包之后......是时候构建节点模块了!
所以,我从Fiore的剧本中汲取灵感,写了我自己的剧本,当时就在那里添加了一些修复......
#!/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
通过谷歌搜索建议总是相同的....."将编译器设置为..."将npm_config_arch变量导出到 MIPS" "将npm_config_nodedir导出到...."等等,但结果总是相同的....
.....你能帮忙弄清楚吗?
提前感谢,阿图罗
找到如何解决问题后的指南!从我的系统中卸载软件包 node-gyp 后,我能够成功构建任何软件包......
无论如何,谢谢;)
这个回复已经很晚了,我认为你已经解决了你的问题。你有没有看过以下关于linino的指南:http://wiki.linino.org/doku.php?id=wiki:nodepackage
它提供了一个构建脚本,其中包含必要的环境变量,需要设置这些变量才能编译 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"