diff --git a/build.sh b/build.sh deleted file mode 100755 index a96bafe..0000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# Author: Ivan Egorov (egorich.3.04@gmail.com). -# - -node-waf configure $* -node-waf build -cp ./build/default/compress-bindings.node ./lib/compress diff --git a/package.json b/package.json index 972e3fd..64e4e04 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,5 @@ "engine": [ "node >=0.1.90" ], "directories": { "lib": "./lib/compress" - }, - "scripts": { - "install": "./build.sh" } } diff --git a/src/zlib.h b/src/zlib.h index bfa6622..327ab3c 100644 --- a/src/zlib.h +++ b/src/zlib.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "utils.h" @@ -85,8 +86,13 @@ class ZipLib : ObjectWrap { Request(ZipLib *self, Local inputBuffer, Local callback) : kind_(RWrite), self_(self), buffer_(Persistent::New(inputBuffer)), +#if NODE_VERSION_AT_LEAST(0,3,0) + data_(Buffer::Data(inputBuffer->ToObject())), + length_(Buffer::Length(inputBuffer->ToObject())), +#else data_(GetBuffer(inputBuffer)->data()), length_(GetBuffer(inputBuffer)->length()), +#endif callback_(Persistent::New(callback)) {} @@ -109,9 +115,12 @@ class ZipLib : ObjectWrap { } } +#if NODE_VERSION_AT_LEAST(0,3,0) +#else static Buffer *GetBuffer(Local buffer) { - return ObjectWrap::Unwrap(buffer->ToObject()); + return ObjectWrap::Unwrap(buffer->ToObject()); } +#endif public: static Request* Write(Self *self, Local inputBuffer, diff --git a/wscript b/wscript index bc16511..8ef6274 100644 --- a/wscript +++ b/wscript @@ -1,11 +1,18 @@ import Options from os import unlink, symlink, popen from os.path import exists +from shutil import copy2 as copy srcdir = "." blddir = "build" VERSION = "0.1.10" +TARGET = 'compress-bindings' +TARGET_FILE = '%s.node' % TARGET +built = 'build/default/%s' % TARGET_FILE +dest = 'lib/compress/%s' % TARGET_FILE + + def set_options(opt): opt.tool_options("compiler_cxx") @@ -46,7 +53,16 @@ def configure(conf): def build(bld): obj = bld.new_task_gen("cxx", "shlib", "node_addon") obj.cxxflags = ["-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"] - obj.target = "compress-bindings" + obj.target = TARGET obj.source = "src/compress.cc" obj.defines = bld.env.DEFINES obj.uselib = bld.env.USELIB + + +def shutdown(): + if Options.commands['clean']: + if exists(dest): + unlink(dest) + else: + if exists(built): + copy(built, dest)