Skip to content

Commit

Permalink
Add Builder.prototype.appendIncludeDir. Use fs.existsSync if found (a…
Browse files Browse the repository at this point in the history
…pi change in node 0.7).
  • Loading branch information
Brandon Benvie committed Feb 20, 2012
1 parent c35e03b commit 4ac7a11
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ var fs = require('fs');
var childProcess = require('child_process');
var ansi = require("./ansi.js");

var exists = fs.existsSync || path.existsSync;

function Builder() {
this.flagGroups = {};
this.target = "native_bindings";
Expand Down Expand Up @@ -121,6 +123,10 @@ Builder.prototype.appendLinkerSearchDir = function(dir) {
this.appendUnique('LINKFLAGS', flag);
}

Builder.prototype.appendIncludeDir = function(dir) {
this.appendUnique('CXXFLAGS', '-I' + dir);
}

Builder.prototype.getFlags = function(flagGroupName) {
var flags = this.flagGroups[flagGroupName];
if(!flags) {
Expand Down Expand Up @@ -187,10 +193,10 @@ Builder.prototype.getLinkerArgs = function(outFileName) {

Builder.prototype.createDir = function(dirName) {
var parent = path.dirname(dirName);
if(!path.existsSync(parent)) {
if(!exists(parent)) {
this.createDir(parent);
}
if(!path.existsSync(dirName)) {
if(!exists(dirName)) {
fs.mkdirSync(dirName);
}
}
Expand Down Expand Up @@ -312,13 +318,11 @@ Builder.prototype.compile = function(callback) {
}

// need to append these last to reduce conflicts
this.appendUnique('CXXFLAGS', '-I' + this.nodeIncludeDir);
this.appendIncludeDir(this.nodeIncludeDir);

if(process.platform == 'win32') {
this.appendUnique('CXXFLAGS', [
'-I' + this.v8IncludeDir,
'-I' + this.uvIncludeDir
]);
this.appendIncludeDir(this.v8IncludeDir);
this.appendIncludeDir(this.uvIncludeDir);
}

// no source then fail
Expand Down Expand Up @@ -473,7 +477,7 @@ Builder.prototype.printHelp = function() {

Builder.prototype.failIfNotExists = function(dirName, message) {
dirName = path.resolve(dirName);
if(!path.existsSync(dirName)) {
if(!exists(dirName)) {
message = message || "Could not find '%s'.";
this.fail(message, dirName);
}
Expand Down

0 comments on commit 4ac7a11

Please sign in to comment.