Skip to content
This repository was archived by the owner on Nov 29, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions build.sh

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@
"engine": [ "node >=0.1.90" ],
"directories": {
"lib": "./lib/compress"
},
"scripts": {
"install": "./build.sh"
}
}
11 changes: 10 additions & 1 deletion src/zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <node.h>
#include <node_events.h>
#include <node_buffer.h>
#include <node_version.h>
#include <assert.h>

#include "utils.h"
Expand Down Expand Up @@ -85,8 +86,13 @@ class ZipLib : ObjectWrap {
Request(ZipLib *self, Local<Value> inputBuffer, Local<Function> callback)
: kind_(RWrite), self_(self),
buffer_(Persistent<Value>::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<Function>::New(callback))
{}

Expand All @@ -109,9 +115,12 @@ class ZipLib : ObjectWrap {
}
}

#if NODE_VERSION_AT_LEAST(0,3,0)
#else
static Buffer *GetBuffer(Local<Value> buffer) {
return ObjectWrap::Unwrap<Buffer>(buffer->ToObject());
return ObjectWrap::Unwrap<Buffer>(buffer->ToObject());
}
#endif

public:
static Request* Write(Self *self, Local<Value> inputBuffer,
Expand Down
18 changes: 17 additions & 1 deletion wscript
Original file line number Diff line number Diff line change
@@ -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")

Expand Down Expand Up @@ -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)