Skip to content

Commit

Permalink
Add binding.gyp sypport for node v0.6.x, refs #111
Browse files Browse the repository at this point in the history
  • Loading branch information
Sannis committed Mar 31, 2012
1 parent 1847bd2 commit 9545ea7
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -4,10 +4,12 @@ build
mysql_bindings.node
.idea
node_modules

conf-stamp
build-stamp
waf-stamp
gyp-stamp
devdependencies-stamp
node-mysql-libmysqlclient

*.gcda
*.gcno
Expand Down
31 changes: 16 additions & 15 deletions Makefile
Expand Up @@ -6,29 +6,31 @@ NI_DEBUG_PORT=5858
NI_WEB_PORT=8888
WEB_BROWSER=google-chrome

all: conf build

conf: clean conf-stamp

conf-stamp:
touch conf-stamp
node-waf configure
all: waf

clean:
rm -rf ./build
rm -f ./mysql_bindings.node
rm -f conf-stamp
rm -f build-stamp
rm -f waf-stamp
rm -f gyp-stamp

cleanall: clean
clean-all: clean
rm -f devdependencies-stamp

build: build-stamp
waf: waf-stamp

build-stamp: ./src/*
touch build-stamp
waf-stamp: ./wscript ./src/*
touch waf-stamp
node-waf configure
node-waf build

gyp: gyp-stamp

gyp-stamp: ./binding.gyp ./src/*
touch gyp-stamp
node-gyp configure
node-gyp build

test: devdependencies
./node_modules/.bin/nodeunit tests/simple tests/complex tests/issues

Expand All @@ -53,5 +55,4 @@ devdependencies-stamp:
touch devdependencies-stamp
npm install --dev .

.PHONY: all build clean conf test test-all test-profile inspector mlf

.PHONY: all waf gyp clean clean-all test test-all test-profile inspector mlf
35 changes: 35 additions & 0 deletions binding.gyp
@@ -0,0 +1,35 @@
{
'targets': [
{
# have to specify 'liblib' here since gyp will remove the first one :\
'target_name': 'mysql_bindings',
'sources': [
'src/mysql_bindings.cc',
'src/mysql_bindings_connection.cc',
'src/mysql_bindings_result.cc',
'src/mysql_bindings_statement.cc',
],
'conditions': [
['OS=="win"', {
# no Windows support yet...
}, {
'libraries': [
'<!@(mysql_config --libs)'
],
}],
['OS=="mac"', {
# cflags on OS X are stupid and have to be defined like this
'xcode_settings': {
'OTHER_CFLAGS': [
'<!@(mysql_config --cflags)'
]
}
}, {
'cflags': [
'<!@(mysql_config --cflags)'
],
}]
]
}
]
}
13 changes: 13 additions & 0 deletions mysql-libmysqlclient-bindings.js
@@ -0,0 +1,13 @@
/*!
* Copyright by Oleg Efimov and node-mysql-libmysqlclient contributors
* See contributors list in README
*
* See license text in LICENSE file
*/

try {
module.exports = require('./build/default/mysql_bindings');
} catch(e) {
// For node v0.5.5+
module.exports = require('./build/Release/mysql_bindings');
}
6 changes: 3 additions & 3 deletions mysql-libmysqlclient.js
Expand Up @@ -10,7 +10,7 @@
*
* @ignore
*/
var binding = require("./mysql_bindings");
var bindings = require("./mysql-libmysqlclient-bindings");

/**
* Create connection to database
Expand All @@ -23,8 +23,8 @@ var binding = require("./mysql_bindings");
* @param {String|null} socket
* @return {MysqlConnection}
*/
exports.createConnectionSync = function () {
var db = new binding.MysqlConnection();
exports.createConnectionSync = function createConnectionSync() {
var db = new bindings.MysqlConnection();
if (arguments.length > 0) {
db.connectSync.apply(db, Array.prototype.slice.call(arguments, 0, 6));
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -47,8 +47,7 @@
}
, "main" : "./mysql-libmysqlclient"
, "scripts" :
{ "install" : "make conf all"
, "test" : "make test"
{ "test" : "make test"
, "doc" : "make doc"
}
, "engines" : { "node" : "0.4.x || 0.5.x || 0.6.x" }
Expand Down
2 changes: 1 addition & 1 deletion tests/config.js
Expand Up @@ -14,7 +14,7 @@ GRANT ALL ON test.* TO test@localhost IDENTIFIED BY "";
module.exports = {
// Required modules
mysql_libmysqlclient: require("../mysql-libmysqlclient"),
mysql_bindings: require("../mysql_bindings"),
mysql_bindings: require("../mysql-libmysqlclient-bindings"),
util: require("util"),

// Database connection settings
Expand Down
10 changes: 0 additions & 10 deletions wscript
Expand Up @@ -114,13 +114,3 @@ def doc(doc):

def gh_pages(context):
Utils.exec_command('./gh_pages.sh')

def shutdown(bld):
if Options.commands['clean'] and not Options.commands['build']:
if lexists('mysql_bindings.node'):
unlink('mysql_bindings.node')
elif Options.commands['build']:
if exists('build/default/mysql_bindings.node') and not lexists('mysql_bindings.node'):
symlink('build/default/mysql_bindings.node', 'mysql_bindings.node')
if exists('build/Release/mysql_bindings.node') and not lexists('mysql_bindings.node'):
symlink('build/Release/mysql_bindings.node', 'mysql_bindings.node')

0 comments on commit 9545ea7

Please sign in to comment.