Skip to content

Commit

Permalink
Use node-waf instead of makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Oct 4, 2009
1 parent 0cc50e0 commit b4df70d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 30 deletions.
15 changes: 0 additions & 15 deletions Makefile

This file was deleted.

12 changes: 3 additions & 9 deletions README
@@ -1,12 +1,6 @@
At the moment this is an experiemental project to build external libraries
into node.

1. make

2. make a table called "xxx" in a database called "test" on your local
postgres server

3. node test.js
At the moment this is an experiemental project. Grab the latest node (39e6d95
or better) and do

node-waf configure build


4 changes: 2 additions & 2 deletions binding.cc
@@ -1,7 +1,7 @@
#include <libpq-fe.h>
#include "type-oids.h"
#include <node/node.h>
#include <node/events.h>
#include <node.h>
#include <events.h>
#include <assert.h>

using namespace v8;
Expand Down
9 changes: 5 additions & 4 deletions test.js
@@ -1,6 +1,7 @@
include("/utils.js");
var postgres = require("postgres.js");

var c = postgres.createConnection("host=/var/run/postgresql dbname=test");
var c = postgres.createConnection("host=localhost dbname=ryan");

c.addListener("connect", function () {
puts("connected");
Expand All @@ -14,17 +15,17 @@ c.addListener("close", function (e) {
}
});

c.query("select * from xxx;").addCallback(function (rows) {
c.query("select * from test;").addCallback(function (rows) {
puts("result1:");
p(rows);
});

c.query("select * from xxx limit 1;").addCallback(function (rows) {
c.query("select * from test limit 1;").addCallback(function (rows) {
puts("result2:");
p(rows);
});

c.query("select ____ from xxx limit 1;").addCallback(function (rows) {
c.query("select ____ from test limit 1;").addCallback(function (rows) {
puts("result3:");
p(rows);
}).addErrback(function (e) {
Expand Down
38 changes: 38 additions & 0 deletions wscript
@@ -0,0 +1,38 @@
import os

srcdir = '.'
blddir = 'build'
VERSION = '0.0.1'

def set_options(opt):
opt.tool_options('compiler_cxx')

def configure(conf):
conf.check_tool('compiler_cxx')
conf.check_tool('node_addon')
conf.check_node_headers()

pg_config = conf.find_program('pg_config', var='PG_CONFIG', mandatory=True)
pg_libdir = os.popen("%s --libdir" % pg_config).readline().strip()
conf.env.append_value("LIBPATH_PG", pg_libdir)
conf.env.append_value("LIB_PG", "pq")
pg_includedir = os.popen("%s --includedir" % pg_config).readline().strip()
conf.env.append_value("CPPPATH_PG", pg_includedir)

def build(bld):
obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
obj.target = 'binding'
obj.source = "binding.cc"
obj.uselib = "PG"


def shutdown():
# HACK to get binding.node out of build directory.
# better way to do this?
import Options, shutil
if not Options.commands['clean']:
if os.path.exists('build/default/binding.node'):
shutil.copy('build/default/binding.node', 'binding.node')
else:
if os.path.exists('binding.node'):
os.unlink('binding.node')

0 comments on commit b4df70d

Please sign in to comment.