4

我需要一些帮助来为我的 Arduino Yun 交叉编译 mips BIG ENDIAN 架构上的节点模块。我已经按照 Fiore Basile 编写的指南进行了操作,并在此之前发布了:

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

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

因此,我从 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 导出到......”等等,但结果总是相同的....

......你能帮忙弄清楚吗?

在此先感谢,阿图罗

4

2 回答 2

1

在我找到解决问题的方法后,这就是我的指南!从我的系统中卸载包 node-gyp 后,我能够成功构建任何包......

不管怎么说,还是要谢谢你 ;)

于 2014-08-07T14:32:24.950 回答
0

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

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

据我所知,这一切都告诉 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"
于 2014-07-07T11:48:41.390 回答