Skip to content

Commit b7ad1c4

Browse files
committed
Fix http_parser woes
1 parent 9c77a10 commit b7ad1c4

3 files changed

Lines changed: 54 additions & 7 deletions

File tree

install.js

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var paths = envOverride({
4646
pkg: local("package"),
4747
libgit2: local("vendor/libgit2/"),
4848
libssh2: local("vendor/libssh2/"),
49+
http_parser: local("vendor/http_parser/"),
4950
sys: {
5051
include: local("include/sys/"),
5152
src: local("src/sys/"),
@@ -121,7 +122,7 @@ var dependencies = Q.allSettled([
121122
});
122123
})
123124

124-
// Grab libssh2 if needed
125+
// Grab libssh2 if needed.
125126
.then(function() {
126127
console.info("[nodegit] Detecting vendor/libssh2.");
127128

@@ -156,11 +157,55 @@ var dependencies = Q.allSettled([
156157
}).then(function() {
157158
// Only run the configuration script in a BSD-like environment.
158159
if (process.platform !== "win32") {
159-
return Q.nfcall(exec, "cd " + paths.libssh2 + " ; " + paths.libssh2 + "configure");
160+
return Q.nfcall(exec, "cd " + paths.libssh2 + " ; " + paths.libssh2 +
161+
"configure");
160162
}
161163
});
162164
})
163165

166+
// Grab http-parser if needed.
167+
.then(function() {
168+
console.info("[nodegit] Detecting vendor/http_parser.");
169+
170+
return Q.ninvoke(fs, "stat", paths.http_parser).then(function() {
171+
return Q.ninvoke(fs, "stat", paths.http_parser + pkg.http_parser.version);
172+
}).fail(function() {
173+
console.info("[nodegit] Removing outdated vendor/http_parser.");
174+
175+
// This directory is outdated, remove.
176+
throw Q.ninvoke(rimraf, null, paths.http_parser);
177+
});
178+
})
179+
180+
// If the directory already exists, no need to refetch.
181+
.fail(function() {
182+
// Otherwise fetch the http_parser source.
183+
console.info("[nodegit] Fetching vendor/http_parser.");
184+
185+
var url = pkg.http_parser.url;
186+
187+
var extract = tar.Extract({
188+
path: paths.http_parser,
189+
strip: true
190+
});
191+
192+
// First extract from Zlib and then extract from Tar.
193+
var expand = request.get(url).pipe(zlib.createUnzip()).pipe(extract);
194+
195+
return Q.ninvoke(expand, "on", "end").then(function() {
196+
// Write out a sha file for testing in the future.
197+
return Q.ninvoke(fs, "writeFile", paths.http_parser +
198+
pkg.http_parser.version, "");
199+
}).then(function() {
200+
// Only run the configuration script in a BSD-like environment.
201+
if (process.platform !== "win32") {
202+
return Q.nfcall(exec, "cd " + paths.http_parser + " ; " +
203+
paths.http_parser + "configure");
204+
}
205+
});
206+
})
207+
208+
164209
// Build the native module using node-gyp.
165210
.then(function() {
166211
console.info("[nodegit] Building native node module.");

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"url": "http://www.libssh2.org/download/libssh2-1.4.3.tar.gz",
1111
"version": "1.4.3"
1212
},
13+
"http_parser": {
14+
"url": "https://github.com/joyent/http-parser/archive/v2.3.tar.gz",
15+
"version": "2.3.0"
16+
},
1317
"homepage": "https://github.com/tbranyen/nodegit",
1418
"keywords": [
1519
"libgit2",

vendor/libgit2.gyp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"gcc_version%": 0,
1010
"is_clang%": 0,
1111
},
12-
"targets": [
13-
],
1412
"targets": [
1513
{
1614
"target_name": "libgit2",
@@ -406,12 +404,12 @@
406404
"target_name": "http_parser",
407405
"type": "static_library",
408406
"sources": [
409-
"libgit2/deps/http-parser/http_parser.c",
410-
"libgit2/deps/http-parser/http_parser.h",
407+
"http-parser/http_parser.c",
408+
"http-parser/http_parser.h",
411409
],
412410
"direct_dependent_settings": {
413411
"include_dirs": [
414-
"libgit2/deps/http-parser",
412+
"http-parser",
415413
],
416414
},
417415
"conditions": [

0 commit comments

Comments
 (0)