Size: 702
Comment:
|
Size: 2007
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 17: | Line 17: |
== node-gyp == node-gyp is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js. https://github.com/TooTallNate/node-gyp === Install with npm === su npm install -g node-gyp node-gyp === Hello world gyp === Based on https://github.com/joyent/node/tree/master/test/addons/hello-world * cd /tmp/ * nano test.js * nano binding.cc * nano binding.gyp * node-gyp configure #The configure step looks for the binding.gyp file in the current directory * node-gyp build # gave an error building ! Based on https://github.com/rvagg/node-addon-examples * nano binding.gyp {{{ { "targets": [ { "target_name": "hello", "sources": [ "hello.cc" ] } ] } }}} * nano hello.cc {{{#!highlight cpp #include <node.h> #include <v8.h> using namespace v8; Handle<Value> Method(const Arguments& args) { HandleScope scope; return scope.Close(String::New("world")); } void init(Handle<Object> exports) { exports->Set(String::NewSymbol("hello"), FunctionTemplate::New(Method)->GetFunction()); } NODE_MODULE(hello, init) }}} * nano hello.js {{{#!highlight javascript var addon = require('./build/Release/hello'); console.log(addon.hello()); // 'world' }}} * node hello.js |
NodeJS
Node.js is a platform built on Chrome's Javascript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
SlackBuild Slackware64 14.0
- su
- cd /tmp
wget http://slackbuilds.org/slackbuilds/14.0/network/node.tar.gz
- tar xvzf node.tar.gz
- cd node
./node.SlackBuild
- installpkg /tmp/node-0.10.12-x86_64-1_SBo.tgz
Package 64 bit: node-0.10.12-x86_64-1_SBo.tgz
node-gyp
node-gyp is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js.
https://github.com/TooTallNate/node-gyp
Install with npm
su npm install -g node-gyp node-gyp
Hello world gyp
Based on https://github.com/joyent/node/tree/master/test/addons/hello-world
- cd /tmp/
- nano test.js
- nano binding.cc
- nano binding.gyp
- node-gyp configure #The configure step looks for the binding.gyp file in the current directory
- node-gyp build # gave an error building !
Based on https://github.com/rvagg/node-addon-examples
- nano binding.gyp
{ "targets": [ { "target_name": "hello", "sources": [ "hello.cc" ] } ] }
- nano hello.cc
1 #include <node.h>
2 #include <v8.h>
3
4 using namespace v8;
5
6 Handle<Value> Method(const Arguments& args) {
7 HandleScope scope;
8 return scope.Close(String::New("world"));
9 }
10
11 void init(Handle<Object> exports) {
12 exports->Set(String::NewSymbol("hello"),
13 FunctionTemplate::New(Method)->GetFunction());
14 }
15
16 NODE_MODULE(hello, init)
- nano hello.js
- node hello.js