Browse Source

Merge pull request #185 from LearnBoost/gyp

Better node-gyp support
v1.x
TJ Holowaychuk 13 years ago
parent
commit
5249f3ef85
  1. 8
      Makefile
  2. 84
      binding.gyp
  3. 4
      package.json
  4. 2
      src/Canvas.cc
  5. 2
      src/Canvas.h
  6. 2
      src/init.cc

8
Makefile

@ -1,9 +1,9 @@
ADDON = build/default/canvas.node ADDON = build/Release/canvas.node
REPORTER = dot REPORTER = dot
$(ADDON): src/*.cc $(ADDON): src/*.cc
node-waf configure build node-gyp rebuild
test: $(ADDON) test: $(ADDON)
@./node_modules/.bin/mocha \ @./node_modules/.bin/mocha \
@ -19,6 +19,6 @@ benchmark:
@node benchmarks/run.js @node benchmarks/run.js
clean: clean:
node-waf distclean node-gyp clean
.PHONY: test test-server benchmark clean .PHONY: test test-server benchmark clean

84
binding.gyp

@ -1,30 +1,74 @@
{ {
'variables': { 'variables': {
# Set the location of GTK all-in-one bundle 'GTK_Root%': 'C:/GTK', # Set the location of GTK all-in-one bundle
'GTK_Root': 'C:/GTK', 'with_jpeg%': 'false',
'with_gif%': 'false'
}, },
'targets': [ 'targets': [
{ {
'target_name': 'canvas', 'target_name': 'canvas',
'sources': [ 'sources': [
'src/Canvas.cc', 'src/Canvas.cc',
'src/CanvasGradient.cc', 'src/CanvasGradient.cc',
'src/CanvasPattern.cc', 'src/CanvasPattern.cc',
'src/CanvasRenderingContext2d.cc', 'src/CanvasRenderingContext2d.cc',
'src/color.cc', 'src/color.cc',
'src/Image.cc', 'src/Image.cc',
'src/ImageData.cc', 'src/ImageData.cc',
'src/init.cc', 'src/init.cc',
'src/PixelArray.cc', 'src/PixelArray.cc',
], ],
'libraries': ['-l<(GTK_Root)/lib/cairo.lib' ], 'conditions': [
'include_dirs': [ ['OS=="win"', {
'<(GTK_Root)/include/cairo', 'libraries': [
], '-l<(GTK_Root)/lib/cairo.lib'
'defines': [ ],
'snprintf=_snprintf', 'include_dirs': [
'_USE_MATH_DEFINES' # for M_PI '<(GTK_Root)/include',
], ],
'defines': [
'snprintf=_snprintf',
'_USE_MATH_DEFINES' # for M_PI
]
}, { # 'OS!="win"'
'libraries': [
'-lpixman-1',
'-lcairo'
],
}],
['with_jpeg=="true"', {
'defines': [
'HAVE_JPEG'
],
'conditions': [
['OS=="win"', {
'libraries': [
'-l<(GTK_Root)/lib/jpeg.lib'
]
}, {
'libraries': [
'-ljpeg'
]
}]
]
}],
['with_gif=="true"', {
'defines': [
'HAVE_GIF'
],
'conditions': [
['OS=="win"', {
'libraries': [
'-l<(GTK_Root)/lib/gif.lib'
]
}, {
'libraries': [
'-lgif'
]
}]
]
}]
]
} }
] ]
} }

4
package.json

@ -6,7 +6,7 @@
, "homepage": "https://github.com/learnboost/node-canvas" , "homepage": "https://github.com/learnboost/node-canvas"
, "repository": "git://github.com/learnboost/node-canvas" , "repository": "git://github.com/learnboost/node-canvas"
, "scripts": { , "scripts": {
"preinstall": "node-waf configure build" "test": "make test"
} }
, "devDependencies": { , "devDependencies": {
"express": ">= 2.3.7 && < 3.0.0" "express": ">= 2.3.7 && < 3.0.0"
@ -16,4 +16,4 @@
} }
, "engines": { "node": ">= 0.4.0" } , "engines": { "node": ">= 0.4.0" }
, "main": "./lib/canvas.js" , "main": "./lib/canvas.js"
} }

2
src/Canvas.cc

@ -12,7 +12,7 @@
#include <string.h> #include <string.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_version.h> #include <node_version.h>
#include <cairo-pdf.h> #include <cairo/cairo-pdf.h>
#include "closure.h" #include "closure.h"
#ifdef HAVE_JPEG #ifdef HAVE_JPEG

2
src/Canvas.h

@ -12,7 +12,7 @@
#include <node.h> #include <node.h>
#include <node_object_wrap.h> #include <node_object_wrap.h>
#include <node_version.h> #include <node_version.h>
#include <cairo.h> #include <cairo/cairo.h>
using namespace v8; using namespace v8;
using namespace node; using namespace node;

2
src/init.cc

@ -26,4 +26,4 @@ init (Handle<Object> target) {
target->Set(String::New("cairoVersion"), String::New(cairo_version_string())); target->Set(String::New("cairoVersion"), String::New(cairo_version_string()));
} }
NODE_MODULE(canvas,init); NODE_MODULE(canvas,init);

Loading…
Cancel
Save