From cdb2421812a678d5e0c343b884519f18758df027 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 23 Jul 2012 11:04:02 -0700 Subject: [PATCH 1/7] build: begin making gyp file work on unix --- binding.gyp | 43 +++++++++++++++++++++++-------------------- src/Canvas.cc | 2 +- src/Canvas.h | 2 +- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/binding.gyp b/binding.gyp index b78327e..73f56e4 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,30 +1,33 @@ { 'variables': { - # Set the location of GTK all-in-one bundle - 'GTK_Root': 'C:/GTK', + 'GTK_Root': 'C:/GTK' # Set the location of GTK all-in-one bundle }, 'targets': [ { 'target_name': 'canvas', 'sources': [ - 'src/Canvas.cc', - 'src/CanvasGradient.cc', - 'src/CanvasPattern.cc', - 'src/CanvasRenderingContext2d.cc', - 'src/color.cc', - 'src/Image.cc', - 'src/ImageData.cc', - 'src/init.cc', - 'src/PixelArray.cc', - ], - 'libraries': ['-l<(GTK_Root)/lib/cairo.lib' ], - 'include_dirs': [ - '<(GTK_Root)/include/cairo', - ], - 'defines': [ - 'snprintf=_snprintf', - '_USE_MATH_DEFINES' # for M_PI - ], + 'src/Canvas.cc', + 'src/CanvasGradient.cc', + 'src/CanvasPattern.cc', + 'src/CanvasRenderingContext2d.cc', + 'src/color.cc', + 'src/Image.cc', + 'src/ImageData.cc', + 'src/init.cc', + 'src/PixelArray.cc', + ], + 'conditions': [ + ['OS=="win"', { + 'libraries': ['-l<(GTK_Root)/lib/cairo.lib' ], + 'include_dirs': [ + '<(GTK_Root)/include', + ], + 'defines': [ + 'snprintf=_snprintf', + '_USE_MATH_DEFINES' # for M_PI + ] + }] + ] } ] } diff --git a/src/Canvas.cc b/src/Canvas.cc index da1939a..27ceb16 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include "closure.h" #ifdef HAVE_JPEG diff --git a/src/Canvas.h b/src/Canvas.h index 023591f..f5b3740 100644 --- a/src/Canvas.h +++ b/src/Canvas.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include using namespace v8; using namespace node; From 0e4fa461de5bd6ae7417ebfdcdc11d4970591e37 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 23 Jul 2012 11:06:44 -0700 Subject: [PATCH 2/7] src: add newline at end of file to fix compiler warning --- src/init.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cc b/src/init.cc index 32d15d4..6e28d23 100644 --- a/src/init.cc +++ b/src/init.cc @@ -26,4 +26,4 @@ init (Handle target) { target->Set(String::New("cairoVersion"), String::New(cairo_version_string())); } -NODE_MODULE(canvas,init); \ No newline at end of file +NODE_MODULE(canvas,init); From 38a157c310e074b038cc77b8abdd6263764a638f Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 23 Jul 2012 11:10:08 -0700 Subject: [PATCH 3/7] Makefile: update the makefile to use node-gyp --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index cf0d4a3..927ab58 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ -ADDON = build/default/canvas.node +ADDON = build/Release/canvas.node REPORTER = dot $(ADDON): src/*.cc - node-waf configure build + node-gyp configure build test: $(ADDON) @./node_modules/.bin/mocha \ @@ -19,6 +19,6 @@ benchmark: @node benchmarks/run.js clean: - node-waf distclean + node-gyp clean -.PHONY: test test-server benchmark clean \ No newline at end of file +.PHONY: test test-server benchmark clean From 566a9a9eede6cc6f9d8e843ea8a092ba8fc7e256 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 23 Jul 2012 11:28:08 -0700 Subject: [PATCH 4/7] Makefile: run "rebuild" --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 927ab58..9f9c567 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ ADDON = build/Release/canvas.node REPORTER = dot $(ADDON): src/*.cc - node-gyp configure build + node-gyp rebuild test: $(ADDON) @./node_modules/.bin/mocha \ From 95947e0c1c19ee9bbdd0b81699255fd9f7ff0c0f Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 23 Jul 2012 11:28:21 -0700 Subject: [PATCH 5/7] build: add linking with pixman & cairo on unix, and add the HAVE_JPEG and HAVE_GIF defines --- binding.gyp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/binding.gyp b/binding.gyp index 73f56e4..b5e7e10 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,6 +1,8 @@ { 'variables': { - 'GTK_Root': 'C:/GTK' # Set the location of GTK all-in-one bundle + 'GTK_Root%': 'C:/GTK', # Set the location of GTK all-in-one bundle + 'with_jpeg%': 'false', + 'with_gif%': 'false' }, 'targets': [ { @@ -18,7 +20,9 @@ ], 'conditions': [ ['OS=="win"', { - 'libraries': ['-l<(GTK_Root)/lib/cairo.lib' ], + 'libraries': [ + '-l<(GTK_Root)/lib/cairo.lib' + ], 'include_dirs': [ '<(GTK_Root)/include', ], @@ -26,6 +30,21 @@ 'snprintf=_snprintf', '_USE_MATH_DEFINES' # for M_PI ] + }, { # 'OS!="win"' + 'libraries': [ + '-lpixman-1', + '-lcairo' + ], + }], + ['with_jpeg=="true"', { + 'defines': [ + 'HAVE_JPEG=1' + ] + }], + ['with_gif=="true"', { + 'defines': [ + 'HAVE_GIF=1' + ] }] ] } From 4a8ef34912b8cdfd0bd2011c96595d4497d34c9e Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 23 Jul 2012 11:35:41 -0700 Subject: [PATCH 6/7] build: link to "jpeg" and "gif" when specified --- binding.gyp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/binding.gyp b/binding.gyp index b5e7e10..2ab2824 100644 --- a/binding.gyp +++ b/binding.gyp @@ -38,12 +38,34 @@ }], ['with_jpeg=="true"', { 'defines': [ - 'HAVE_JPEG=1' + 'HAVE_JPEG' + ], + 'conditions': [ + ['OS=="win"', { + 'libraries': [ + '-l<(GTK_Root)/lib/jpeg.lib' + ] + }, { + 'libraries': [ + '-ljpeg' + ] + }] ] }], ['with_gif=="true"', { 'defines': [ - 'HAVE_GIF=1' + 'HAVE_GIF' + ], + 'conditions': [ + ['OS=="win"', { + 'libraries': [ + '-l<(GTK_Root)/lib/gif.lib' + ] + }, { + 'libraries': [ + '-lgif' + ] + }] ] }] ] From c1645a7da71c4d37b209493be3146190a4536e54 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 23 Jul 2012 11:38:35 -0700 Subject: [PATCH 7/7] package: remove the "preinstall" phase, add the "test" phase --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 55e601e..8730053 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ , "homepage": "https://github.com/learnboost/node-canvas" , "repository": "git://github.com/learnboost/node-canvas" , "scripts": { - "preinstall": "node-waf configure build" + "test": "make test" } , "devDependencies": { "express": ">= 2.3.7 && < 3.0.0" @@ -16,4 +16,4 @@ } , "engines": { "node": ">= 0.4.0 && < 0.9.0" } , "main": "./lib/canvas.js" -} \ No newline at end of file +}