Comparing version 0.3.2 to 0.3.4
@@ -8,3 +8,4 @@ | ||
var path = require('path') | ||
var fs = require('fs') | ||
, path = require('path') | ||
, glob = require('glob') | ||
@@ -22,2 +23,5 @@ , which = require('which') | ||
var command = win ? 'msbuild' : 'make' | ||
, buildDir = path.resolve('build') | ||
, configPath = path.resolve(buildDir, 'config.gypi') | ||
, config | ||
, emitter | ||
@@ -28,10 +32,22 @@ | ||
emitter = _e | ||
if (win) { | ||
findSolutionFile() | ||
} else { | ||
doWhich() | ||
} | ||
loadConfigGypi() | ||
}) | ||
/** | ||
* Load the "config.gypi" file that was generated during "configure". | ||
*/ | ||
function loadConfigGypi () { | ||
fs.readFile(configPath, 'utf8', function (err, data) { | ||
if (err) return callback(err) | ||
config = JSON.parse(data.replace(/\#.+\n/, '')) | ||
if (win) { | ||
findSolutionFile() | ||
} else { | ||
doWhich() | ||
} | ||
}) | ||
} | ||
/** | ||
* On Windows, find first build/*.sln file. | ||
@@ -92,4 +108,9 @@ */ | ||
function build () { | ||
var config = gyp.opts.debug ? 'Debug' : 'Release' | ||
var buildType = config.target_defaults.default_configuration | ||
, platform = config.target_arch == 'x64' ? '64' : '32' | ||
if (gyp.opts.debug) { | ||
buildType = 'Debug' | ||
} | ||
// Enable Verbose build | ||
@@ -110,5 +131,5 @@ if (!win && gyp.opts.verbose) { | ||
if (win) { | ||
argv.push('/p:Configuration=' + config) | ||
argv.push('/p:Configuration=' + buildType + ';Platform=Win' + platform) | ||
} else { | ||
argv.push('BUILDTYPE=' + config) | ||
argv.push('BUILDTYPE=' + buildType) | ||
// Invoke the Makefile in the 'build' dir. | ||
@@ -115,0 +136,0 @@ argv.push('-C') |
@@ -12,2 +12,3 @@ | ||
, semver = require('semver') | ||
, mkdirp = require('./util/mkdirp') | ||
, createHook = require('./util/hook') | ||
@@ -22,2 +23,4 @@ , asyncEmit = require('./util/asyncEmit') | ||
var python = gyp.opts.python || 'python' | ||
, buildDir = path.resolve('build') | ||
, configPath | ||
, emitter | ||
@@ -51,8 +54,43 @@ , versionStr | ||
gyp.opts.ensure = true | ||
gyp.commands.install([ version ], go) | ||
gyp.commands.install([ version ], createBuildDir) | ||
} | ||
function go (err) { | ||
function createBuildDir (err) { | ||
if (err) return callback(err) | ||
gyp.verbose('attempting to create "build" dir', buildDir) | ||
mkdirp(buildDir, function (err, isNew) { | ||
if (err) return callback(err) | ||
gyp.verbose('"build" dir needed to be created?', isNew) | ||
createConfigFile() | ||
}) | ||
} | ||
function createConfigFile (err) { | ||
if (err) return callback(err) | ||
gyp.verbose('creating build/config.gypi file') | ||
var config = {} | ||
configPath = path.resolve(buildDir, 'config.gypi') | ||
config.target_defaults = { | ||
cflags: [] | ||
, default_configuration: gyp.opts.debug ? 'Debug' : 'Release' | ||
, defines: [] | ||
, include_dirs: [] | ||
, libraries: [] | ||
} | ||
config.variables = { | ||
target_arch: gyp.opts.arch || process.arch || 'ia32' | ||
} | ||
var prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step' | ||
, json = JSON.stringify(config, null, 2) | ||
gyp.verbose('writing out config file', configPath) | ||
fs.writeFile(configPath, [prefix, json, ''].join('\n'), runGypAddon) | ||
} | ||
function runGypAddon (err) { | ||
if (err) return callback(err) | ||
var devDir = path.resolve(process.env.HOME, '.node-gyp', version) | ||
@@ -67,22 +105,5 @@ , gyp_addon = path.resolve(devDir, 'tools', 'gyp_addon') | ||
var hasArch = argv.some(function (arg) { | ||
return arg.indexOf('-Dtarget_arch') === 0 | ||
}) | ||
// was --arch specified? | ||
if (!hasArch && gyp.opts.arch) { | ||
gyp.verbose('using the architecture specified by --arch', gyp.opts.arch) | ||
argv.push('-Dtarget_arch=' + gyp.opts.arch) | ||
hasArch = true | ||
} | ||
// include the "config.gypi" file that was generated | ||
argv.unshift('-I' + configPath) | ||
// this may need to be tweaked for windows and stuff, we'll see... | ||
if (!hasArch) { | ||
// on < 0.8 the target_arch variable is set to ia32 by default unless | ||
// overridden, so we have to explicitly specify the arch here | ||
gyp.verbose('target arch not specified, using the current host architecture', process.arch) | ||
argv.push('-Dtarget_arch=' + process.arch) | ||
gyp.opts.arch = process.arch | ||
hasArch = true | ||
} | ||
// enforce use of the "binding.gyp" file | ||
@@ -89,0 +110,0 @@ argv.unshift('binding.gyp') |
@@ -42,6 +42,4 @@ | ||
// Determine which node dev files version we are installing | ||
var versionStr = argv[0] || gyp.opts.target | ||
if (!versionStr) { | ||
return callback(new Error('You must specify a version number to install. Ex: "0.6.12"')) | ||
} | ||
var versionStr = argv[0] || gyp.opts.target || process.version | ||
gyp.verbose('input version string', versionStr) | ||
@@ -48,0 +46,0 @@ // parse the version to normalize and ensure it's valid |
{ "name": "node-gyp" | ||
, "description": "Node.js native addon build tool" | ||
, "keywords": [ "native", "addon", "module", "c", "c++", "bindings", "gyp" ] | ||
, "version": "0.3.2" | ||
, "version": "0.3.4" | ||
, "installVersion": 5 | ||
@@ -6,0 +6,0 @@ , "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)" |
@@ -58,8 +58,7 @@ node-gyp | ||
__Note__: The `configure` step looks for the first `.gyp` file in the current | ||
directory to processs. See below for instructions on creating the `.gyp` file. | ||
__Note__: The `configure` step looks for the `binding.gyp` file in the current | ||
directory to processs. See below for instructions on creating the `binding.gyp` file. | ||
Now you will have either a `Makefile` (on Unix platforms) or a | ||
`vcxproj` file (on Windows) in the current directory. Next invoke the `build` | ||
step: | ||
Now you will have either a `Makefile` (on Unix platforms) or a `vcxproj` file | ||
(on Windows) in the `build/` directory. Next invoke the `build` command: | ||
@@ -70,8 +69,8 @@ ``` bash | ||
Now you have your compiled `.node` bindings file! The compiled bindings end up in | ||
`build/Debug` or `buld/Release`, depending on the build mode. At this point you can | ||
require the `.node` file with Node and run your tests! | ||
Now you have your compiled `.node` bindings file! The compiled bindings end up | ||
in `build/Debug/` or `buld/Release/`, depending on the build mode. At this point | ||
you can require the `.node` file with Node and run your tests! | ||
__Note:__ To create a _Debug_ build of the bindings file, pass the `--debug` (or | ||
`-d`) switch when running the `build` command. | ||
`-d`) switch when running the either `configure` or `build` command. | ||
@@ -113,2 +112,3 @@ | ||
* `configure` - Generates project build files for the current platform | ||
* `rebuild` - Runs "clean", "configure" and "build" all at once | ||
* `install` - Installs node development files for the given version. Respects http_proxy/HTTP_PROXY and --proxy=<proxyurl> when downloading. | ||
@@ -115,0 +115,0 @@ * `list` - Lists the currently installed node development file versions |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
909618
75
977
20