#61 fixed
authoradam <anton@adamansky.com>
Wed, 1 May 2013 18:23:15 +0000 (01:23 +0700)
committeradam <anton@adamansky.com>
Wed, 1 May 2013 18:23:15 +0000 (01:23 +0700)
.gitignore
.npmignore
binding.gyp
node/platform.js
package.json

index 594e0ec..eb27e18 100644 (file)
@@ -23,6 +23,7 @@
 .dep.inc
 /ejdbdll
 /node_modules
+/configure.gypi
 
 addressbook*
 autom4te.cache/
index 9bca257..f62acf0 100644 (file)
@@ -28,6 +28,7 @@
 */nbproject/private/*
 /ejdbdll
 /node_modules
+/configure.gypi
 
 addressbook*
 /.idea/workspace.xml
index b76cca3..db76243 100644 (file)
@@ -24,9 +24,7 @@
         },
         'conditions': [
             ['OS == "win"', {
-               'variables': {
-                  'EJDB_HOME%': 'C:/EJDB'
-               },
+                          'includes': ['configure.gypi'],              
                'defines': [
                  '_UNICODE',
                ],
index 4f0b5a1..456189a 100644 (file)
@@ -5,7 +5,6 @@ var fs = require("fs");
 var path = require("path");
 var http = require("http");
 var util = require("util");
-var AdmZip = require("adm-zip");
 
 if (process.platform === "win32") {
     win();
@@ -15,7 +14,7 @@ if (process.platform === "win32") {
 
 function exithandler(cmd, cb) {
     return function(code) {
-        if (code !== 0) {
+        if (code != null && code !== 0) {
             console.log("" + cmd + " process exited with code " + code);
             process.exit(code);
         }
@@ -106,8 +105,8 @@ function win() {
                         process.stdout.write(".");
                     });
                     res.on("end", function() {
-                        console.log("\n%d bytes downloaded", len);
-                        processArchive();
+                        console.log("\n%d bytes received", len);
+                                               setTimeout(processArchive, 2000);
                     });
                     res.pipe(wf);
                 });
@@ -117,17 +116,54 @@ function win() {
             }
 
             function processArchive() {
+                               var AdmZip = require("adm-zip");
                 console.log("Unzip archive '%s'", zfile);
                 var azip = new AdmZip(zfile);
                 azip.extractAllTo(sdir, true);
                 sdir = path.resolve(sdir);
-                var args = ["rebuild", util.format("-DEJDB_HOME=%s", sdir)];
+                               
+                               var config = {};
+                               config["variables"] = {
+                                       "EJDB_HOME" : sdir
+                               };
+                               fs.writeFileSync("configure.gypi", JSON.stringify(config));
+                       
+                var args = ["configure", "rebuild"];
                 console.log("node-gyp %j", args);
-                var ng = spawn("node-gyp", args, {stdio : "inherit"});
-                ng.on("close", exithandler("node-gyp"));
+                var ng = spawn("node-gyp.cmd", args, {stdio : "inherit"});
+                               ng.on("error", function(ev) {
+                                       console.log("Spawn error: " + ev);
+                                       process.exit(1);
+                               });
+                ng.on("close", exithandler("node-gyp", function() {
+                                       copyFile(path.join(sdir, "lib/tcejdbdll.dll"), 
+                                                        "build/Release/tcejdbdll.dll", 
+                                                        exithandler("copy tcejdbdll.dll"));
+                               }));
             }
         }
     }
+}
 
 
+function copyFile(source, target, cb) {
+  var cbCalled = false;
+  var rd = fs.createReadStream(source);
+  rd.on("error", function(err) {
+    done(err);
+  });
+  var wr = fs.createWriteStream(target);
+  wr.on("error", function(err) {
+    done(err);
+  });
+  wr.on("close", function(ex) {
+    done();
+  });
+  rd.pipe(wr);
+  function done(err) {
+    if (!cbCalled) {
+      cb(err);
+      cbCalled = true;
+    }
+  }
 }
\ No newline at end of file
index 00c4fd8..96744dd 100644 (file)
@@ -1,6 +1,6 @@
 {
     "name" : "ejdb",
-    "version" : "1.1.3-1",
+    "version" : "1.1.3-2",
     "config" : {
         "windownloadurl" : "http://dl.dropboxusercontent.com/u/4709222/ejdb/tcejdb-1.1.3-mingw32-i686.zip"
     },
@@ -33,8 +33,7 @@
         "node" : "0.8.x || 0.10.x"
     },
     "dependencies" : {
-        "nodeunit" : ">=0.7.0",
-        "adm-zip" : "*"
+        "nodeunit" : ">=0.7.0"
     },
     "scripts" : {
         "preinstall" : "node node/platform.js preinstall",