Skip to content

Commit c093d1e

Browse files
committed
Finally, Windows support!
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.
1 parent c7c961f commit c093d1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2598
-2744
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/build/*
22
!/build/codegen/
3+
/node_modules/
4+
/vendor/libgit2/
35
/doc/*
46
!/doc/Theme.css
5-
/node_modules
67
/test/.reposCache

binding.gyp

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -54,60 +54,26 @@
5454
],
5555

5656
"conditions": [
57-
['OS=="win"', {
58-
"link_settings": {
57+
[
58+
"OS=='win'", {
5959
"libraries": [
60-
"-lgit2.lib",
60+
"-l../vendor/libgit2/build/Debug/git2.lib"
61+
],
62+
}, { # 'OS!="win"'
63+
"libraries": [
64+
"-L<!(pwd)/vendor/libgit2/build",
65+
"-lgit2"
6166
]
62-
},
63-
"configurations": {
64-
"Release": {
65-
"msvs_settings": {
66-
"VCCLCompilerTool": {
67-
"RuntimeLibrary": 0,
68-
"Optimization": 3,
69-
"FavorSizeOrSpeed": 1,
70-
"InlineFunctionExpansion": 2,
71-
"WholeProgramOptimization": "true",
72-
"OmitFramePointers": "true",
73-
"EnableFunctionLevelLinking": "true",
74-
"EnableIntrinsicFunctions": "true",
75-
"RuntimeTypeInfo": "false",
76-
"ExceptionHandling": "0",
77-
"GenerateDebugInformation": "true",
78-
"AdditionalOptions": [
79-
"/MP /EHsc"
80-
]
81-
},
82-
"VCLibrarianTool": {
83-
"AdditionalOptions": [
84-
"/LTCG"
85-
]
86-
},
87-
"VCLinkerTool": {
88-
"LinkTimeCodeGeneration": 1,
89-
"OptimizeReferences": 2,
90-
"EnableCOMDATFolding": 2,
91-
"LinkIncremental": 1,
92-
"AdditionalLibraryDirectories": [
93-
"../vendor/libgit2/build/debug"
94-
]
95-
}
96-
}
97-
}
9867
}
99-
}, { # Not Windows.
100-
"libraries": [
101-
"-L<!(pwd)/vendor/libgit2/build",
102-
"-lgit2"
103-
]
104-
}],
68+
],
10569

106-
['OS=="mac"', {
107-
"xcode_settings": {
108-
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
70+
[
71+
"OS=='mac'", {
72+
"xcode_settings": {
73+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
74+
}
10975
}
110-
}]
76+
]
11177
]
11278
}
11379
]

build/codegen/templates/convertFromV8.cc.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<% } else if (arg.cppClassName == 'Buffer') { -%>
2121
from_<%- arg.name %> = Buffer::Data(args[<%- jsArg %>]->ToObject());
2222
<% } else if (isV8Value(arg.cppClassName)) { -%>
23-
from_<%- arg.name %> = (<%- arg.cType %>) args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value();
23+
from_<%- arg.name %> = (<%- arg.cType %>) <%- arg.additionalCast %> <%- arg.cast %> args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value();
2424
<% } else { -%>
2525
from_<%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->GetValue();
2626
<% } -%>
@@ -29,4 +29,4 @@
2929
from_<%- arg.name %> = 0;
3030
}
3131
<% } -%>
32-
<% } -%>
32+
<% } -%>

build/codegen/v0.18.0.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10380,7 +10380,8 @@
1038010380
"cType": "git_direction",
1038110381
"cppClassName": "Number",
1038210382
"jsClassName": "Number",
10383-
"comment": "GIT_DIRECTION_FETCH if you want to fetch or GIT_DIRECTION_PUSH if you want to push"
10383+
"comment": "GIT_DIRECTION_FETCH if you want to fetch or GIT_DIRECTION_PUSH if you want to push",
10384+
"additionalCast": "(int)"
1038410385
}
1038510386
],
1038610387
"isAsync": true,
@@ -17283,7 +17284,8 @@
1728317284
"cType": "git_filemode_t",
1728417285
"cppClassName": "Number",
1728517286
"jsClassName": "Number",
17286-
"comment": "Folder attributes of the entry. This parameter must be valued with one of the following entries: 0040000, 0100644, 0100755, 0120000 or 0160000."
17287+
"comment": "Folder attributes of the entry. This parameter must be valued with one of the following entries: 0040000, 0100644, 0100755, 0120000 or 0160000.",
17288+
"additionalCast": "(int)"
1728717289
}
1728817290
],
1728917291
"isAsync": false,

include/blob.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <v8.h>
99
#include <node.h>
1010
#include <string>
11-
#include "nan.h"
1211

1312
#include "git2.h"
1413

@@ -18,7 +17,7 @@ using namespace v8;
1817
class GitBlob : public ObjectWrap {
1918
public:
2019

21-
static Persistent<FunctionTemplate> constructor_template;
20+
static Persistent<Function> constructor_template;
2221
static void Initialize (Handle<v8::Object> target);
2322

2423
git_blob *GetValue();
@@ -29,12 +28,13 @@ class GitBlob : public ObjectWrap {
2928
GitBlob(git_blob *raw);
3029
~GitBlob();
3130

32-
static NAN_METHOD(New);
31+
static Handle<Value> New(const Arguments& args);
3332

34-
static NAN_METHOD(Oid);
35-
static NAN_METHOD(Content);
36-
static NAN_METHOD(Size);
37-
static NAN_METHOD(IsBinary);
33+
34+
static Handle<Value> Oid(const Arguments& args);
35+
static Handle<Value> Content(const Arguments& args);
36+
static Handle<Value> Size(const Arguments& args);
37+
static Handle<Value> IsBinary(const Arguments& args);
3838
git_blob *raw;
3939
};
4040

include/branch.h

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <node.h>
1010
#include <string>
1111

12-
#include "nan.h"
13-
1412
#include "git2.h"
1513

1614
using namespace node;
@@ -19,7 +17,7 @@ using namespace v8;
1917
class Branch : public ObjectWrap {
2018
public:
2119

22-
static Persistent<FunctionTemplate> constructor_template;
20+
static Persistent<Function> constructor_template;
2321
static void Initialize (Handle<v8::Object> target);
2422

2523
git_branch *GetValue();
@@ -30,19 +28,20 @@ class Branch : public ObjectWrap {
3028
Branch(git_branch *raw);
3129
~Branch();
3230

33-
static NAN_METHOD(New);
34-
35-
static NAN_METHOD(Create);
36-
static NAN_METHOD(Delete);
37-
static NAN_METHOD(Foreach);
38-
static NAN_METHOD(Move);
39-
static NAN_METHOD(Lookup);
40-
static NAN_METHOD(Name);
41-
static NAN_METHOD(Upstream);
42-
static NAN_METHOD(SetUpstream);
43-
static NAN_METHOD(UpstreamName);
44-
static NAN_METHOD(IsHead);
45-
static NAN_METHOD(RemoteName);
31+
static Handle<Value> New(const Arguments& args);
32+
33+
34+
static Handle<Value> Create(const Arguments& args);
35+
static Handle<Value> Delete(const Arguments& args);
36+
static Handle<Value> Foreach(const Arguments& args);
37+
static Handle<Value> Move(const Arguments& args);
38+
static Handle<Value> Lookup(const Arguments& args);
39+
static Handle<Value> Name(const Arguments& args);
40+
static Handle<Value> Upstream(const Arguments& args);
41+
static Handle<Value> SetUpstream(const Arguments& args);
42+
static Handle<Value> UpstreamName(const Arguments& args);
43+
static Handle<Value> IsHead(const Arguments& args);
44+
static Handle<Value> RemoteName(const Arguments& args);
4645
git_branch *raw;
4746
};
4847

include/clone_options.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <node.h>
1010
#include <string>
1111

12-
#include "nan.h"
13-
1412
#include "git2.h"
1513

1614
using namespace node;
@@ -19,7 +17,7 @@ using namespace v8;
1917
class GitCloneOptions : public ObjectWrap {
2018
public:
2119

22-
static Persistent<FunctionTemplate> constructor_template;
20+
static Persistent<Function> constructor_template;
2321
static void Initialize (Handle<v8::Object> target);
2422

2523
git_clone_options *GetValue();
@@ -30,7 +28,8 @@ class GitCloneOptions : public ObjectWrap {
3028
GitCloneOptions(git_clone_options *raw);
3129
~GitCloneOptions();
3230

33-
static NAN_METHOD(New);
31+
static Handle<Value> New(const Arguments& args);
32+
3433

3534
git_clone_options *raw;
3635
};

include/commit.h

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <node.h>
1010
#include <string>
1111

12-
#include "nan.h"
13-
1412
#include "git2.h"
1513

1614
using namespace node;
@@ -19,7 +17,7 @@ using namespace v8;
1917
class GitCommit : public ObjectWrap {
2018
public:
2119

22-
static Persistent<FunctionTemplate> constructor_template;
20+
static Persistent<Function> constructor_template;
2321
static void Initialize (Handle<v8::Object> target);
2422

2523
git_commit *GetValue();
@@ -30,19 +28,20 @@ class GitCommit : public ObjectWrap {
3028
GitCommit(git_commit *raw);
3129
~GitCommit();
3230

33-
static NAN_METHOD(New);
34-
35-
static NAN_METHOD(Oid);
36-
static NAN_METHOD(MessageEncoding);
37-
static NAN_METHOD(Message);
38-
static NAN_METHOD(Time);
39-
static NAN_METHOD(Offset);
40-
static NAN_METHOD(Committer);
41-
static NAN_METHOD(Author);
42-
static NAN_METHOD(TreeId);
43-
static NAN_METHOD(ParentCount);
44-
static NAN_METHOD(ParentId);
45-
static NAN_METHOD(NthGenAncestor);
31+
static Handle<Value> New(const Arguments& args);
32+
33+
34+
static Handle<Value> Oid(const Arguments& args);
35+
static Handle<Value> MessageEncoding(const Arguments& args);
36+
static Handle<Value> Message(const Arguments& args);
37+
static Handle<Value> Time(const Arguments& args);
38+
static Handle<Value> Offset(const Arguments& args);
39+
static Handle<Value> Committer(const Arguments& args);
40+
static Handle<Value> Author(const Arguments& args);
41+
static Handle<Value> TreeId(const Arguments& args);
42+
static Handle<Value> ParentCount(const Arguments& args);
43+
static Handle<Value> ParentId(const Arguments& args);
44+
static Handle<Value> NthGenAncestor(const Arguments& args);
4645
git_commit *raw;
4746
};
4847

include/delta.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <node.h>
1010
#include <string>
1111

12-
#include "nan.h"
13-
1412
#include "git2.h"
1513

1614
using namespace node;
@@ -19,7 +17,7 @@ using namespace v8;
1917
class GitDelta : public ObjectWrap {
2018
public:
2119

22-
static Persistent<FunctionTemplate> constructor_template;
20+
static Persistent<Function> constructor_template;
2321
static void Initialize (Handle<v8::Object> target);
2422

2523
git_diff_delta *GetValue();
@@ -30,13 +28,13 @@ class GitDelta : public ObjectWrap {
3028
GitDelta(git_diff_delta *raw);
3129
~GitDelta();
3230

33-
static NAN_METHOD(New);
31+
static Handle<Value> New(const Arguments& args);
3432

35-
static NAN_METHOD(OldFile);
36-
static NAN_METHOD(NewFile);
37-
static NAN_METHOD(Status);
38-
static NAN_METHOD(Similarity);
39-
static NAN_METHOD(Flags);
33+
static Handle<Value> OldFile(const Arguments& args);
34+
static Handle<Value> NewFile(const Arguments& args);
35+
static Handle<Value> Status(const Arguments& args);
36+
static Handle<Value> Similarity(const Arguments& args);
37+
static Handle<Value> Flags(const Arguments& args);
4038

4139
git_diff_delta *raw;
4240
};

include/diff_file.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <node.h>
1010
#include <string>
1111

12-
#include "nan.h"
13-
1412
#include "git2.h"
1513

1614
using namespace node;
@@ -19,7 +17,7 @@ using namespace v8;
1917
class GitDiffFile : public ObjectWrap {
2018
public:
2119

22-
static Persistent<FunctionTemplate> constructor_template;
20+
static Persistent<Function> constructor_template;
2321
static void Initialize (Handle<v8::Object> target);
2422

2523
git_diff_file *GetValue();
@@ -30,13 +28,13 @@ class GitDiffFile : public ObjectWrap {
3028
GitDiffFile(git_diff_file *raw);
3129
~GitDiffFile();
3230

33-
static NAN_METHOD(New);
31+
static Handle<Value> New(const Arguments& args);
3432

35-
static NAN_METHOD(Oid);
36-
static NAN_METHOD(Path);
37-
static NAN_METHOD(Size);
38-
static NAN_METHOD(Flags);
39-
static NAN_METHOD(Mode);
33+
static Handle<Value> Oid(const Arguments& args);
34+
static Handle<Value> Path(const Arguments& args);
35+
static Handle<Value> Size(const Arguments& args);
36+
static Handle<Value> Flags(const Arguments& args);
37+
static Handle<Value> Mode(const Arguments& args);
4038

4139
git_diff_file *raw;
4240
};

0 commit comments

Comments
 (0)