| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c3a89ad commit 03d3c33
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,14 @@ | |||
| 1 | + /.travis/ | ||
| 1 | 2 | /build/ | |
| 2 | 3 | /examples/ | |
| 4 | + /generate/ | ||
| 5 | + /guides/ | ||
| 6 | + /lib/ | ||
| 3 | 7 | /test/ | |
| 4 | 8 | /vendor/Release/ | |
| 5 | 9 | ||
| 6 | - /generate/output | ||
| 7 | - /generate/**/*.json | ||
| 8 | - !/generate/input/*.json | ||
| 10 | + !/include | ||
| 11 | + !/src | ||
| 9 | 12 | ||
| 10 | 13 | .astylerc | |
| 11 | 14 | .editorconfig | |
@@ -15,8 +18,10 @@ | |||
| 15 | 18 | .travis.yml | |
| 16 | 19 | appveyor.yml | |
| 17 | 20 | ||
| 18 | - *.vcxproj | ||
| 21 | + !binding.gyp | ||
| 22 | + | ||
| 19 | 23 | *.filters | |
| 20 | - *.sln | ||
| 21 | 24 | *.log | |
| 22 | 25 | *.md | |
| 26 | + *.sln | ||
| 27 | + *.vcxproj | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -222,7 +222,7 @@ module.exports = function generateJson() { | |||
| 222 | 222 | _.merge(enumerable, _.omit(override, ["values"])); | |
| 223 | 223 | ||
| 224 | 224 | output.push(enumerable); | |
| 225 | - }).value(); | ||
| 225 | + }); | ||
| 226 | 226 | ||
| 227 | 227 | output = _.sortBy(output, "typeName"); | |
| 228 | 228 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -345,7 +345,7 @@ var Helpers = { | |||
| 345 | 345 | if (fnDef.jsFunctionName == utils.camelCase(collidingName)) { | |
| 346 | 346 | fnDef.jsFunctionName = utils.camelCase(newName); | |
| 347 | 347 | } | |
| 348 | - }).value(); | ||
| 348 | + }); | ||
| 349 | 349 | ||
| 350 | 350 | if ("git_" + typeDef.typeName == fnDef.cFunctionName) { | |
| 351 | 351 | fnDef.useAsOnRootProto = true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,187 +1,51 @@ | |||
| 1 | - var path = require("path"); | ||
| 2 | - var fs = require("fs"); | ||
| 3 | - var cp = require("child_process"); | ||
| 4 | - var prepareForBuild = require("./prepareForBuild"); | ||
| 5 | - var exec = require("../utils/execPromise"); | ||
| 1 | + var nodePreGypConstructor = require("node-pre-gyp"); | ||
| 2 | + var nodePreGyp = new nodePreGypConstructor.Run(); | ||
| 3 | + var buildFlags = require("../utils/buildFlags"); | ||
| 6 | 4 | ||
| 7 | 5 | module.exports = function install() { | |
| 8 | - var fromRegistry; | ||
| 6 | + // we need to add 2 blank entires to help the parser later. | ||
| 7 | + var argv = ["", "", "install"]; | ||
| 9 | 8 | ||
| 10 | - try { | ||
| 11 | - fs.statSync(path.join(__dirname, "..", "include")); | ||
| 12 | - fs.statSync(path.join(__dirname, "..", "src")); | ||
| 13 | - fs.statSync(path.join(__dirname, "..", "dist")); | ||
| 14 | - fromRegistry = true; | ||
| 15 | - } | ||
| 16 | - catch(e) { | ||
| 17 | - fromRegistry = false; | ||
| 18 | - } | ||
| 19 | - | ||
| 20 | - if (!fromRegistry) { | ||
| 21 | - console.info("[nodegit] Local install, no fetching allowed."); | ||
| 22 | - return prepareAndBuild(); | ||
| 23 | - } | ||
| 24 | - if (process.env.BUILD_DEBUG) { | ||
| 25 | - console.info("[nodegit] Doing a debug build, no fetching allowed."); | ||
| 26 | - return prepareAndBuild(); | ||
| 27 | - } | ||
| 28 | - if (process.env.BUILD_ONLY) { | ||
| 29 | - console.info("[nodegit] BUILD_ONLY is set to true, no fetching allowed."); | ||
| 30 | - return prepareAndBuild(); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - return installPrebuilt(); | ||
| 9 | + if (buildFlags.mustBuild) { | ||
| 10 | + argv.push("--build-from-source"); | ||
| 34 | 11 | ||
| 35 | - function installPrebuilt() { | ||
| 36 | - console.info("[nodegit] Fetching binary from S3."); | ||
| 37 | - var npg = pathForTool("node-pre-gyp"); | ||
| 38 | - return exec("\""+ npg + "\" install --fallback-to-build=false") | ||
| 39 | - .then( | ||
| 40 | - function() { | ||
| 41 | - console.info("[nodegit] Completed installation successfully."); | ||
| 42 | - }, | ||
| 43 | - function(err) { | ||
| 44 | - console.info("[nodegit] Failed to install prebuilt binary:"); | ||
| 45 | - console.error(err); | ||
| 46 | - console.info("[nodegit] Building manually. (You'll be here a while.)"); | ||
| 47 | - return prepareAndBuild(); | ||
| 48 | - } | ||
| 49 | - ); | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - function pathForTool(name) { | ||
| 53 | - var toolPath = path.resolve(".", "node_modules", ".bin", name); | ||
| 54 | - if (process.platform == "win32") { | ||
| 55 | - toolPath += ".cmd"; | ||
| 12 | + if (buildFlags.debugBuild) { | ||
| 13 | + argv.push("--debug"); | ||
| 56 | 14 | } | |
| 57 | - return toolPath; | ||
| 58 | 15 | } | |
| 59 | - | ||
| 60 | - function prepareAndBuild() { | ||
| 61 | - console.info("[nodegit] Regenerating and configuring code"); | ||
| 62 | - return prepareForBuild() | ||
| 63 | - .then(function() { | ||
| 64 | - return build(); | ||
| 65 | - }) | ||
| 66 | - .then(function() { | ||
| 67 | - return transpileJavascript(); | ||
| 68 | - }); | ||
| 16 | + else { | ||
| 17 | + argv.push("--fallback-to-build"); | ||
| 69 | 18 | } | |
| 70 | 19 | ||
| 71 | - function transpileJavascript() { | ||
| 72 | - var cmd = pathForTool("babel"); | ||
| 73 | - var args = [ | ||
| 74 | - "--presets", | ||
| 75 | - "es2015", | ||
| 76 | - "-d", | ||
| 77 | - "./dist", | ||
| 78 | - "./lib" | ||
| 79 | - ]; | ||
| 80 | - var opts = { | ||
| 81 | - cwd: ".", | ||
| 82 | - maxBuffer: Number.MAX_VALUE, | ||
| 83 | - env: process.env, | ||
| 84 | - stdio: "inherit" | ||
| 85 | - }; | ||
| 86 | - var home = process.platform == "win32" ? | ||
| 87 | - process.env.USERPROFILE : process.env.HOME; | ||
| 88 | - | ||
| 89 | - opts.env.HOME = path.join(home, ".nodegit-gyp"); | ||
| 20 | + nodePreGyp.parseArgv(argv); | ||
| 90 | 21 | ||
| 91 | - return new Promise(function(resolve, reject) { | ||
| 92 | - var child = cp.spawn(cmd, args, opts); | ||
| 93 | - child.on("close", function(code) { | ||
| 94 | - if (code) { | ||
| 95 | - reject(code); | ||
| 96 | - process.exitCode = 13; | ||
| 97 | - } | ||
| 98 | - else { | ||
| 99 | - resolve(); | ||
| 100 | - } | ||
| 101 | - }); | ||
| 102 | - }); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - function build() { | ||
| 106 | - console.info("[nodegit] Everything is ready to go, attempting compilation"); | ||
| 107 | - | ||
| 108 | - var electronVersion = process.env.ELECTRON_VERSION; | ||
| 109 | - var nwjsVersion = process.env.NWJS_VERSION; | ||
| 110 | - var opts = { | ||
| 111 | - cwd: ".", | ||
| 112 | - maxBuffer: Number.MAX_VALUE, | ||
| 113 | - env: process.env, | ||
| 114 | - stdio: "inherit" | ||
| 115 | - }; | ||
| 116 | - | ||
| 117 | - var builder = "node-gyp"; | ||
| 118 | - var debug = (process.env.BUILD_DEBUG ? "--debug" : ""); | ||
| 119 | - var target = ""; | ||
| 120 | - var arch = (process.env.TARGET_ARCH ? | ||
| 121 | - "--arch=" + process.env.TARGET_ARCH : ""); | ||
| 122 | - var distUrl = ""; | ||
| 123 | - var runtime = ""; | ||
| 124 | - | ||
| 125 | - process.argv.forEach(function(arg) { | ||
| 126 | - if (~arg.indexOf("electronVersion")) { | ||
| 127 | - electronVersion = arg.split("=")[1].trim(); | ||
| 128 | - } | ||
| 129 | - else if (~arg.indexOf("nsjwVersion")) { | ||
| 130 | - nwjsVersion = arg.split("=")[1].trim(); | ||
| 131 | - } | ||
| 132 | - }); | ||
| 22 | + function run() { | ||
| 23 | + var command = nodePreGyp.todo.shift(); | ||
| 24 | + if (!command) { | ||
| 25 | + return; | ||
| 26 | + } | ||
| 133 | 27 | ||
| 134 | - if (electronVersion) { | ||
| 135 | - target = "--target=" + electronVersion; | ||
| 136 | - distUrl = "--dist-url=https://atom.io/download/atom-shell"; | ||
| 137 | - runtime = "--runtime=electron"; | ||
| 28 | + nodePreGyp.commands[command.name](command.args, function (err) { | ||
| 29 | + if (err) { | ||
| 30 | + console.error(command.name + " error"); | ||
| 31 | + console.error("stack", err.stack); | ||
| 32 | + console.error("not ok"); | ||
| 33 | + console.log(err.message); | ||
| 34 | + return process.exit(1); | ||
| 138 | 35 | } | |
| 139 | - else if (nwjsVersion) { | ||
| 140 | - builder = "nw-gyp"; | ||
| 141 | - target = "--target=" + nwjsVersion; | ||
| 142 | - runtime = "--runtime=node-webkit"; | ||
| 36 | + var args_array = [].slice.call(arguments, 1); | ||
| 37 | + if (args_array.length) { | ||
| 38 | + console.log.apply(console, args_array); | ||
| 143 | 39 | } | |
| 40 | + // now run the next command in the queue | ||
| 41 | + process.nextTick(run); | ||
| 42 | + }); | ||
| 43 | + } | ||
| 144 | 44 | ||
| 145 | - var home = process.platform == "win32" ? | ||
| 146 | - process.env.USERPROFILE : process.env.HOME; | ||
| 147 | - | ||
| 148 | - opts.env.HOME = path.join(home, ".nodegit-gyp"); | ||
| 149 | - | ||
| 150 | - var cmd = pathForTool(builder); | ||
| 151 | - var args = [ | ||
| 152 | - "rebuild", | ||
| 153 | - debug, | ||
| 154 | - target, | ||
| 155 | - arch, | ||
| 156 | - distUrl, | ||
| 157 | - runtime | ||
| 158 | - ] | ||
| 159 | - .filter(function(arg) { | ||
| 160 | - return arg; | ||
| 161 | - }); | ||
| 162 | - | ||
| 163 | - return new Promise(function(resolve, reject) { | ||
| 164 | - var child = cp.spawn(cmd, args, opts); | ||
| 165 | - child.on("close", function(code) { | ||
| 166 | - console.log(code); | ||
| 167 | - if (code) { | ||
| 168 | - reject(code); | ||
| 169 | - process.exitCode = 13; | ||
| 170 | - } | ||
| 171 | - else { | ||
| 172 | - resolve(); | ||
| 173 | - } | ||
| 174 | - }); | ||
| 175 | - }); | ||
| 176 | - } | ||
| 45 | + run(); | ||
| 177 | 46 | }; | |
| 178 | 47 | ||
| 179 | 48 | // Called on the command line | |
| 180 | 49 | if (require.main === module) { | |
| 181 | - module | ||
| 182 | - .exports() | ||
| 183 | - .catch(function(err) { | ||
| 184 | - console.error(err); | ||
| 185 | - return -1; | ||
| 186 | - }); | ||
| 50 | + module.exports(); | ||
| 187 | 51 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,40 @@ | |||
| 1 | + #!/usr/bin/env node | ||
| 2 | + | ||
| 3 | + var fse = require("fs-extra"); | ||
| 4 | + var path = require("path"); | ||
| 5 | + var child_process = require("child_process"); | ||
| 6 | + var buildFlags = require("../utils/buildFlags"); | ||
| 7 | + | ||
| 8 | + var rootPath = path.join(__dirname, ".."); | ||
| 9 | + | ||
| 10 | + function printStandardLibError() { | ||
| 11 | + console.log( | ||
| 12 | + "[ERROR] Seems like the latest libstdc++ is missing on your system!" | ||
| 13 | + ); | ||
| 14 | + console.log(""); | ||
| 15 | + console.log("On Ubuntu you can install it using:"); | ||
| 16 | + console.log(""); | ||
| 17 | + console.log("$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test"); | ||
| 18 | + console.log("$ sudo apt-get update"); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + console.log("$ sudo apt-get install libstdc++-4.9-dev"); | ||
| 22 | + child_process.exec("node dist/nodegit.js", function(error, stdout, stderr) { | ||
| 23 | + if (stderr) { | ||
| 24 | + if (process.pladtform !== "linux" && ~stderr.indexOf("libstdc++")) { | ||
| 25 | + printStandardLibError(); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + return; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + // Is we're using NodeGit from a package manager then let's clean up after | ||
| 32 | + // ourselves when we install successfully. | ||
| 33 | + if (!buildFlags.mustBuild) { | ||
| 34 | + fse.removeSync(path.join(rootPath, "vendor")); | ||
| 35 | + fse.removeSync(path.join(rootPath, "src")); | ||
| 36 | + fse.removeSync(path.join(rootPath, "include")); | ||
| 37 | + fse.removeSync(path.join(rootPath, "build/Release/*.a")); | ||
| 38 | + fse.removeSync(path.join(rootPath, "build/Release/obj.target")); | ||
| 39 | + } | ||
| 40 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + var path = require("path"); | ||
| 2 | + var local = path.join.bind(path, __dirname); | ||
| 3 | + | ||
| 4 | + var configure = require(local("configureLibssh2")); | ||
| 5 | + var buildFlags = require(local("../utils/buildFlags")); | ||
| 6 | + | ||
| 7 | + module.exports = function prepareForBuild() { | ||
| 8 | + return configure() | ||
| 9 | + .then(function() { | ||
| 10 | + if (buildFlags.isGitRepo) { | ||
| 11 | + var submodules = require(local("submodules")); | ||
| 12 | + var generate = require(local("../generate")); | ||
| 13 | + return submodules() | ||
| 14 | + .then(function() { | ||
| 15 | + return generate(); | ||
| 16 | + }); | ||
| 17 | + } | ||
| 18 | + }); | ||
| 19 | + }; | ||
| 20 | + | ||
| 21 | + // Called on the command line | ||
| 22 | + if (require.main === module) { | ||
| 23 | + module.exports(); | ||
| 24 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments