Skip to content

Commit

Permalink
Finally, Windows support!
Browse files Browse the repository at this point in the history
This has taken me hours to figure out, but in order to get Windows
working a few issues had to be resolved:

- Casting. I've added an additional argument parameter in the libgit2
  JSON API to allow for special cast provisioning in the case where
  direct casting isn't possible.

- Update libgit2 build flags to not use STDCALL when compiling in
  Windows.

- Updated the binding.gyp file to have the correct configuratoin
  necessary for cross platform compiling.
  • Loading branch information
tbranyen committed Apr 30, 2014
1 parent c7c961f commit c093d1e
Show file tree
Hide file tree
Showing 68 changed files with 2,598 additions and 2,744 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/build/*
!/build/codegen/
/node_modules/
/vendor/libgit2/
/doc/*
!/doc/Theme.css
/node_modules
/test/.reposCache
64 changes: 15 additions & 49 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -54,60 +54,26 @@
],

"conditions": [
['OS=="win"', {
"link_settings": {
[
"OS=='win'", {
"libraries": [
"-lgit2.lib",
"-l../vendor/libgit2/build/Debug/git2.lib"
],
}, { # 'OS!="win"'
"libraries": [
"-L<!(pwd)/vendor/libgit2/build",
"-lgit2"
]
},
"configurations": {
"Release": {
"msvs_settings": {
"VCCLCompilerTool": {
"RuntimeLibrary": 0,
"Optimization": 3,
"FavorSizeOrSpeed": 1,
"InlineFunctionExpansion": 2,
"WholeProgramOptimization": "true",
"OmitFramePointers": "true",
"EnableFunctionLevelLinking": "true",
"EnableIntrinsicFunctions": "true",
"RuntimeTypeInfo": "false",
"ExceptionHandling": "0",
"GenerateDebugInformation": "true",
"AdditionalOptions": [
"/MP /EHsc"
]
},
"VCLibrarianTool": {
"AdditionalOptions": [
"/LTCG"
]
},
"VCLinkerTool": {
"LinkTimeCodeGeneration": 1,
"OptimizeReferences": 2,
"EnableCOMDATFolding": 2,
"LinkIncremental": 1,
"AdditionalLibraryDirectories": [
"../vendor/libgit2/build/debug"
]
}
}
}
}
}, { # Not Windows.
"libraries": [
"-L<!(pwd)/vendor/libgit2/build",
"-lgit2"
]
}],
],

['OS=="mac"', {
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
[
"OS=='mac'", {
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
}
}
}]
]
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions build/codegen/templates/convertFromV8.cc.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<% } else if (arg.cppClassName == 'Buffer') { -%>
from_<%- arg.name %> = Buffer::Data(args[<%- jsArg %>]->ToObject());
<% } else if (isV8Value(arg.cppClassName)) { -%>
from_<%- arg.name %> = (<%- arg.cType %>) args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value();
from_<%- arg.name %> = (<%- arg.cType %>) <%- arg.additionalCast %> <%- arg.cast %> args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value();
<% } else { -%>
from_<%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->GetValue();
<% } -%>
Expand All @@ -29,4 +29,4 @@
from_<%- arg.name %> = 0;
}
<% } -%>
<% } -%>
<% } -%>
6 changes: 4 additions & 2 deletions build/codegen/v0.18.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -10380,7 +10380,8 @@
"cType": "git_direction",
"cppClassName": "Number",
"jsClassName": "Number",
"comment": "GIT_DIRECTION_FETCH if you want to fetch or GIT_DIRECTION_PUSH if you want to push"
"comment": "GIT_DIRECTION_FETCH if you want to fetch or GIT_DIRECTION_PUSH if you want to push",
"additionalCast": "(int)"
}
],
"isAsync": true,
Expand Down Expand Up @@ -17283,7 +17284,8 @@
"cType": "git_filemode_t",
"cppClassName": "Number",
"jsClassName": "Number",
"comment": "Folder attributes of the entry. This parameter must be valued with one of the following entries: 0040000, 0100644, 0100755, 0120000 or 0160000."
"comment": "Folder attributes of the entry. This parameter must be valued with one of the following entries: 0040000, 0100644, 0100755, 0120000 or 0160000.",
"additionalCast": "(int)"
}
],
"isAsync": false,
Expand Down
14 changes: 7 additions & 7 deletions include/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <v8.h>
#include <node.h>
#include <string>
#include "nan.h"

#include "git2.h"

Expand All @@ -18,7 +17,7 @@ using namespace v8;
class GitBlob : public ObjectWrap {
public:

static Persistent<FunctionTemplate> constructor_template;
static Persistent<Function> constructor_template;
static void Initialize (Handle<v8::Object> target);

git_blob *GetValue();
Expand All @@ -29,12 +28,13 @@ class GitBlob : public ObjectWrap {
GitBlob(git_blob *raw);
~GitBlob();

static NAN_METHOD(New);
static Handle<Value> New(const Arguments& args);

static NAN_METHOD(Oid);
static NAN_METHOD(Content);
static NAN_METHOD(Size);
static NAN_METHOD(IsBinary);

static Handle<Value> Oid(const Arguments& args);
static Handle<Value> Content(const Arguments& args);
static Handle<Value> Size(const Arguments& args);
static Handle<Value> IsBinary(const Arguments& args);
git_blob *raw;
};

Expand Down
31 changes: 15 additions & 16 deletions include/branch.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <node.h>
#include <string>

#include "nan.h"

#include "git2.h"

using namespace node;
Expand All @@ -19,7 +17,7 @@ using namespace v8;
class Branch : public ObjectWrap {
public:

static Persistent<FunctionTemplate> constructor_template;
static Persistent<Function> constructor_template;
static void Initialize (Handle<v8::Object> target);

git_branch *GetValue();
Expand All @@ -30,19 +28,20 @@ class Branch : public ObjectWrap {
Branch(git_branch *raw);
~Branch();

static NAN_METHOD(New);

static NAN_METHOD(Create);
static NAN_METHOD(Delete);
static NAN_METHOD(Foreach);
static NAN_METHOD(Move);
static NAN_METHOD(Lookup);
static NAN_METHOD(Name);
static NAN_METHOD(Upstream);
static NAN_METHOD(SetUpstream);
static NAN_METHOD(UpstreamName);
static NAN_METHOD(IsHead);
static NAN_METHOD(RemoteName);
static Handle<Value> New(const Arguments& args);


static Handle<Value> Create(const Arguments& args);
static Handle<Value> Delete(const Arguments& args);
static Handle<Value> Foreach(const Arguments& args);
static Handle<Value> Move(const Arguments& args);
static Handle<Value> Lookup(const Arguments& args);
static Handle<Value> Name(const Arguments& args);
static Handle<Value> Upstream(const Arguments& args);
static Handle<Value> SetUpstream(const Arguments& args);
static Handle<Value> UpstreamName(const Arguments& args);
static Handle<Value> IsHead(const Arguments& args);
static Handle<Value> RemoteName(const Arguments& args);
git_branch *raw;
};

Expand Down
7 changes: 3 additions & 4 deletions include/clone_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <node.h>
#include <string>

#include "nan.h"

#include "git2.h"

using namespace node;
Expand All @@ -19,7 +17,7 @@ using namespace v8;
class GitCloneOptions : public ObjectWrap {
public:

static Persistent<FunctionTemplate> constructor_template;
static Persistent<Function> constructor_template;
static void Initialize (Handle<v8::Object> target);

git_clone_options *GetValue();
Expand All @@ -30,7 +28,8 @@ class GitCloneOptions : public ObjectWrap {
GitCloneOptions(git_clone_options *raw);
~GitCloneOptions();

static NAN_METHOD(New);
static Handle<Value> New(const Arguments& args);


git_clone_options *raw;
};
Expand Down
31 changes: 15 additions & 16 deletions include/commit.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <node.h>
#include <string>

#include "nan.h"

#include "git2.h"

using namespace node;
Expand All @@ -19,7 +17,7 @@ using namespace v8;
class GitCommit : public ObjectWrap {
public:

static Persistent<FunctionTemplate> constructor_template;
static Persistent<Function> constructor_template;
static void Initialize (Handle<v8::Object> target);

git_commit *GetValue();
Expand All @@ -30,19 +28,20 @@ class GitCommit : public ObjectWrap {
GitCommit(git_commit *raw);
~GitCommit();

static NAN_METHOD(New);

static NAN_METHOD(Oid);
static NAN_METHOD(MessageEncoding);
static NAN_METHOD(Message);
static NAN_METHOD(Time);
static NAN_METHOD(Offset);
static NAN_METHOD(Committer);
static NAN_METHOD(Author);
static NAN_METHOD(TreeId);
static NAN_METHOD(ParentCount);
static NAN_METHOD(ParentId);
static NAN_METHOD(NthGenAncestor);
static Handle<Value> New(const Arguments& args);


static Handle<Value> Oid(const Arguments& args);
static Handle<Value> MessageEncoding(const Arguments& args);
static Handle<Value> Message(const Arguments& args);
static Handle<Value> Time(const Arguments& args);
static Handle<Value> Offset(const Arguments& args);
static Handle<Value> Committer(const Arguments& args);
static Handle<Value> Author(const Arguments& args);
static Handle<Value> TreeId(const Arguments& args);
static Handle<Value> ParentCount(const Arguments& args);
static Handle<Value> ParentId(const Arguments& args);
static Handle<Value> NthGenAncestor(const Arguments& args);
git_commit *raw;
};

Expand Down
16 changes: 7 additions & 9 deletions include/delta.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <node.h>
#include <string>

#include "nan.h"

#include "git2.h"

using namespace node;
Expand All @@ -19,7 +17,7 @@ using namespace v8;
class GitDelta : public ObjectWrap {
public:

static Persistent<FunctionTemplate> constructor_template;
static Persistent<Function> constructor_template;
static void Initialize (Handle<v8::Object> target);

git_diff_delta *GetValue();
Expand All @@ -30,13 +28,13 @@ class GitDelta : public ObjectWrap {
GitDelta(git_diff_delta *raw);
~GitDelta();

static NAN_METHOD(New);
static Handle<Value> New(const Arguments& args);

static NAN_METHOD(OldFile);
static NAN_METHOD(NewFile);
static NAN_METHOD(Status);
static NAN_METHOD(Similarity);
static NAN_METHOD(Flags);
static Handle<Value> OldFile(const Arguments& args);
static Handle<Value> NewFile(const Arguments& args);
static Handle<Value> Status(const Arguments& args);
static Handle<Value> Similarity(const Arguments& args);
static Handle<Value> Flags(const Arguments& args);

git_diff_delta *raw;
};
Expand Down
16 changes: 7 additions & 9 deletions include/diff_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <node.h>
#include <string>

#include "nan.h"

#include "git2.h"

using namespace node;
Expand All @@ -19,7 +17,7 @@ using namespace v8;
class GitDiffFile : public ObjectWrap {
public:

static Persistent<FunctionTemplate> constructor_template;
static Persistent<Function> constructor_template;
static void Initialize (Handle<v8::Object> target);

git_diff_file *GetValue();
Expand All @@ -30,13 +28,13 @@ class GitDiffFile : public ObjectWrap {
GitDiffFile(git_diff_file *raw);
~GitDiffFile();

static NAN_METHOD(New);
static Handle<Value> New(const Arguments& args);

static NAN_METHOD(Oid);
static NAN_METHOD(Path);
static NAN_METHOD(Size);
static NAN_METHOD(Flags);
static NAN_METHOD(Mode);
static Handle<Value> Oid(const Arguments& args);
static Handle<Value> Path(const Arguments& args);
static Handle<Value> Size(const Arguments& args);
static Handle<Value> Flags(const Arguments& args);
static Handle<Value> Mode(const Arguments& args);

git_diff_file *raw;
};
Expand Down
7 changes: 3 additions & 4 deletions include/diff_find_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <node.h>
#include <string>

#include "nan.h"

#include "git2.h"

using namespace node;
Expand All @@ -19,7 +17,7 @@ using namespace v8;
class GitDiffFindOptions : public ObjectWrap {
public:

static Persistent<FunctionTemplate> constructor_template;
static Persistent<Function> constructor_template;
static void Initialize (Handle<v8::Object> target);

git_diff_find_options *GetValue();
Expand All @@ -30,7 +28,8 @@ class GitDiffFindOptions : public ObjectWrap {
GitDiffFindOptions(git_diff_find_options *raw);
~GitDiffFindOptions();

static NAN_METHOD(New);
static Handle<Value> New(const Arguments& args);


git_diff_find_options *raw;
};
Expand Down
Loading

0 comments on commit c093d1e

Please sign in to comment.