LoginSignup
1
1

More than 5 years have passed since last update.

io.jsのgit版でネイティブモジュールのビルドを通す

Last updated at Posted at 2015-05-01

まずnode-gypのコードを書き換えます。

git clone https://github.com/TooTallNate/node-gyp

lib/install.js

@@ -279,7 +279,9 @@ function install (gyp, argv, callback) {

         // download SHASUMS.txt
         async++
-        downloadShasums(deref)
+        //downloadShasums(deref)
+        cb();
+        return;

         if (async === 0) {
           // no async tasks required

チェックサムでnodejs.orgのホストへ見に行ってしまうので無視するようにします。

@@ -219,11 +219,11 @@ function install (gyp, argv, callback) {

       // download the tarball, gunzip and extract!

-      if (tarPath) {
-        var input = fs.createReadStream(tarballUrl)
-        input.pipe(gunzip).pipe(extracter)
-        return
-      }
+      //if (tarPath) {
+      //  var input = fs.createReadStream(tarballUrl)
+      //  input.pipe(gunzip).pipe(extracter)
+      //  return
+      //}

       var req = download(tarballUrl)
       if (!req) return

コンパイルにV8のヘッダを使ったりするのでio.jsのソースコードをダウンロードする処理があります。
引数で--tarballを渡すと強制でローカルパスから読み込んでしまうのでリモートからダウンロードしてもらうようにします。

./bin/node-gyp.js install --tarball="https://github.com/iojs/io.js/archive/master.tar.gz"

gyp info it worked if it ends with ok
gyp info using node-gyp@1.0.3
gyp info using node@2.0.0 | darwin | x64
gyp http GET https://github.com/iojs/io.js/archive/master.tar.gz
gyp http 200 https://github.com/iojs/io.js/archive/master.tar.gz
2.0.0
gyp info ok

node-gyp list2.0.0が見えるようになります

./bin/node-gyp.js list
# ...
1.6.2
1.8.1
2.0.0

実体は ~/.node-gyp ディレクトリ以下です

注意 (1)

npm install -g node-gypしてしまうとio.jsに対応していないnode-gypコマンドがパスに追加されてしまいます。
which node-gypしても出てきませんが実はnpm install時に~/.nvm/versions/io.js/v2.0.0/lib/node_modules/npm/bin/node-gyp-bin/node-gypが透過的に使用されています。

注意 (2)

リリース版とV8のバージョンがことなるので(deps/v8/include/v8-version で確認できる)いくつかのモジュールでネイティブコードを修正しないとコンパイルできなくなります。

cp -a ~/.node-gyp/1.8.1 ~/.node-gyp/2.0.0 でリリースバージョンを流用してしまうとか、
node-gyp rebuild --target="v1.8.1"でファイルセットを指定してしまうとかで回避できました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1