Permalink
Browse files

add shell of project

  • Loading branch information...
1 parent 659d9eb commit 9033e9055592083cb5d183fe2f7f0264398ef3a9 @springmeyer springmeyer committed Jan 19, 2011
Showing with 182 additions and 0 deletions.
  1. +32 −0 LICENSE.txt
  2. +16 −0 Makefile
  3. +3 −0 configure
  4. BIN lib/_zipfile.node
  5. +8 −0 lib/index.js
  6. +24 −0 package.json
  7. +30 −0 src/_zipfile.cc
  8. +8 −0 test.js
  9. +61 −0 wscript
View
32 LICENSE.txt
@@ -0,0 +1,32 @@
+Copyright (c) 2011, Dane Springmeyer
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of the author nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+This project also includes code and files from GDAL, see GDAL_LICENSE
+for more details.
View
16 Makefile
@@ -0,0 +1,16 @@
+all: zipfile.node
+
+install: all
+ node-waf -v build install
+
+zipfile.node:
+ node-waf -v build
+
+clean:
+ node-waf -v clean distclean
+
+uninstall:
+ node-waf -v uninstall
+
+test:
+ node test.js
View
3 configure
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+node-waf configure $@
View
BIN lib/_zipfile.node
Binary file not shown.
View
8 lib/index.js
@@ -0,0 +1,8 @@
+var assert = require('assert');
+var zipfile = require('./_zipfile');
+
+/* assert ABI compatibility */
+assert.ok(zipfile.versions.node === process.versions.node, 'The running node version "' + process.versions.node + '" does not match the node version that node-zipfile was compiled against: "' + zipfile.versions.node + '"');
+
+// push all C++ symbols into js module
+for (var k in zipfile) { exports[k] = zipfile[k]; }
View
24 package.json
@@ -0,0 +1,24 @@
+{
+ "name" : "zipfile",
+ "version" : "0.1.0",
+ "main" : "./lib/index.js",
+ "description" : "C++ library for handling zipfiles in node",
+ "keywords" : ["zipfile", "uncompress", "unzip", "zlib"],
+ "url" : "http://github.com/springmeyer/node-zipfile",
+ "repositories" : [
+ {
+ "type" : "git",
+ "url" : "git://github.com/springmeyer/node-zipfile.git"
+ }
+ ],
+ "author" : "Dane Springmeyer <dane@dbsgeo.com>",
+ "contributors" : [],
+ "licenses" : ["BSD"],
+ "dependencies" : [],
+ "directories" : {
+ "examples" : "examples",
+ "src": "src"
+ },
+ "engines" : { "node": ">= 0.2.4" },
+ "scripts" : {"install": "node-waf -v configure build"}
+}
View
30 src/_zipfile.cc
@@ -0,0 +1,30 @@
+// v8
+#include <v8.h>
+
+// node
+#include <node.h>
+#include <node_version.h>
+
+using namespace node;
+using namespace v8;
+
+#define TOSTR(obj) (*String::Utf8Value((obj)->ToString()))
+
+extern "C" {
+
+ static void init (Handle<Object> target)
+ {
+
+ // node-zipfile version
+ target->Set(String::NewSymbol("version"), String::New("0.1.0"));
+
+ // versions of deps
+ Local<Object> versions = Object::New();
+ versions->Set(String::NewSymbol("node"), String::New(NODE_VERSION+1));
+ versions->Set(String::NewSymbol("v8"), String::New(V8::GetVersion()));
+ target->Set(String::NewSymbol("versions"), versions);
+
+ }
+
+ NODE_MODULE(_zipfile, init);
+}
View
8 test.js
@@ -0,0 +1,8 @@
+#!/usr/bin/env node
+
+var zipfile = require('zipfile');
+var assert = require('assert');
+//var path = require('path');
+var fs = require('fs');
+
+console.log('All tests pass...');
View
61 wscript
@@ -0,0 +1,61 @@
+import os
+from glob import glob
+from os import unlink, symlink, popen, uname, environ
+from os.path import exists
+from shutil import copy2 as copy
+from subprocess import call
+
+# http://www.freehackers.org/~tnagy/wafbook/index.html
+
+# node-wafadmin
+import Options
+import Utils
+
+TARGET = '_zipfile'
+TARGET_FILE = '%s.node' % TARGET
+built = 'build/default/%s' % TARGET_FILE
+dest = 'lib/%s' % TARGET_FILE
+settings = 'lib/settings.js'
+
+def set_options(opt):
+ opt.tool_options("compiler_cxx")
+
+def configure(conf):
+ conf.check_tool("compiler_cxx")
+ conf.check_tool("node_addon")
+
+ linkflags = []
+ linkflags.append('-L/usr/local/lib')
+ linkflags.append('-lzip')
+
+ conf.env.append_value("LINKFLAGS", linkflags)
+
+ cxxflags = []
+ cxxflags.append('-I/usr/local/include')
+ cxxflags.append('-I/usr/local/lib/libzip/include/')
+
+ conf.env.append_value("CXXFLAGS", cxxflags)
+
+ #ldflags = []
+ #conf.env.append_value("LDFLAGS", ldflags)
+
+def build(bld):
+ obj = bld.new_task_gen("cxx", "shlib", "node_addon", install_path=None)
+ obj.cxxflags = ["-DNDEBUG", "-O3", "-g", "-Wall", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE"]
+ obj.target = TARGET
+ obj.source = "src/_zipfile.cc"
+ obj.uselib = "ZIPFILE"
+ start_dir = bld.path.find_dir('lib')
+ # http://www.freehackers.org/~tnagy/wafbook/index.html#_installing_files
+ bld.install_files('${PREFIX}/lib/node/zipfile', start_dir.ant_glob('*'), cwd=start_dir, relative_trick=True)
+
+
+def shutdown():
+ if Options.commands['clean']:
+ if exists(TARGET): unlink(TARGET)
+ if Options.commands['clean']:
+ if exists(dest):
+ unlink(dest)
+ else:
+ if exists(built):
+ copy(built,dest)

0 comments on commit 9033e90

Please sign in to comment.