Skip to content

Commit 3497732

Browse files
committed
Touch up README for utils, code formatting, links
1 parent a637c19 commit 3497732

File tree

3 files changed

+72
-70
lines changed

3 files changed

+72
-70
lines changed

utils/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
Determines how NodeGit should build. Use `BUILD_ONLY` environment variable to build from source.
77

88
## discoverOpenSSLDistros
9-
Crawls a series of static links on the [Conan package manager](https://conan.io/) for the [latest release of OpenSSL](https://bintray.com/conan-community/conan/OpenSSL%3Aconan#files/conan%2FOpenSSL%2F1.1.0i) (1.1.0i at the time of writing). It acquires statically linked binaries and header files of OpenSSL for Mac and Windows. The provided binaries are compiled on:
9+
Crawls a series of static URLS on the [Conan package manager](https://conan.io/) for the [latest release of OpenSSL](https://bintray.com/conan-community/conan/OpenSSL%3Aconan#files/conan%2FOpenSSL%2F1.1.0i) (1.1.0i at the time of writing). It acquires URLS for releases of statically linked binaries and header files of OpenSSL for Mac and Windows. The provided binaries are compiled on:
1010

1111
* Mac: clang-8.1 or clang-9.
1212
* Windows: vs12, vs14, vs15
1313

1414
The discovered distributions are written into `vendor/openssl_distributions.json`. This script does not need to be run unless you are updating the version of OpenSSL to build against.
1515

1616
### acquireOpenSSL
17-
Download the OpenSSL binaries and headers applicable to the current OS for the latest compiler version (clang-9/vs15).
17+
Download the OpenSSL binaries and headers applicable to the current OS for the latest compiler version (clang-9/vs15). Uses links from `vendor/openssl_distributions.json`.
1818

1919
TODO:
20-
* Make the script pull the debug versions if node-gyp is building in debug mode
21-
* Make the script pull down a version of the binaries that matches the sytem compiler
20+
* Make the script pull the debug versions if node-gyp is building in debug mode
21+
* Make the script pull down a version of the binaries that matches the system compiler

utils/acquireOpenSSL.js

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,65 @@
1-
const fse = require('fs-extra');
2-
const path = require('path');
3-
const R = require('ramda');
4-
const request = require('request-promise-native');
5-
const stream = require('stream');
6-
const tar = require('tar-fs');
7-
const zlib = require('zlib');
1+
const fse = require("fs-extra");
2+
const path = require("path");
3+
const R = require("ramda");
4+
const request = require("request-promise-native");
5+
const stream = require("stream");
6+
const tar = require("tar-fs");
7+
const zlib = require("zlib");
88

9-
const vendorPath = path.resolve(__dirname, '..', 'vendor');
10-
const distrosFilePath = path.join(vendorPath, 'openssl_distributions.json');
11-
const extractPath = path.join(vendorPath, 'openssl');
9+
const vendorPath = path.resolve(__dirname, "..", "vendor");
10+
const distrosFilePath = path.join(vendorPath, "openssl_distributions.json");
11+
const extractPath = path.join(vendorPath, "openssl");
1212

1313
const getOSName = () => {
14-
if (process.platform === 'win32') {
14+
if (process.platform === "win32") {
1515
if (process.arch === "x64" || process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")) {
16-
return 'win64';
16+
return "win64";
1717
} else {
18-
return 'win32';
18+
return "win32";
1919
}
20-
} else if (process.platform === 'darwin') {
21-
return 'macOS';
20+
} else if (process.platform === "darwin") {
21+
return "macOS";
2222
} else {
23-
// We only discover distros for Mac and Windows. We don't care about any other OS.
24-
return 'unknown';
23+
// We only discover distros for Mac and Windows. We don"t care about any other OS.
24+
return "unknown";
2525
}
26-
}
26+
};
2727

2828
const getCompilerVersion = () => {
2929
// TODO: Get actual compiler version. For now, just assume latest compiler for distros in openssl_distributions.js
3030
const osName = getOSName();
31-
if (osName === 'win32' || osName === 'win64') {
32-
return 'vs15';
33-
} else if (osName === 'macOS') {
34-
return 'clang-9';
31+
if (osName === "win32" || osName === "win64") {
32+
return "vs15";
33+
} else if (osName === "macOS") {
34+
return "clang-9";
3535
} else {
36-
// We only discover distros for Mac and Windows. We don't care about any other OS.
37-
return 'unknown';
36+
// We only discover distros for Mac and Windows. We don"t care about any other OS.
37+
return "unknown";
3838
}
39-
}
39+
};
4040

41-
const getIsDebug = () => false // TODO: Determine if we are GYPing in Debug
41+
// TODO: Determine if we are GYPing in Debug
42+
const getIsDebug = () => false;
4243

4344
const getMatchingDistributionName = () =>
44-
`${getOSName()}-${getCompilerVersion()}-static${getIsDebug() ? '-debug' : '-release'}`;
45+
`${getOSName()}-${getCompilerVersion()}-static${getIsDebug() ? "-debug" : "-release"}`;
4546

4647
const getDistributionsConfig = () =>
47-
fse.readFile(distrosFilePath, 'utf8')
48-
.then(JSON.parse)
48+
fse.readFile(distrosFilePath, "utf8")
49+
.then(JSON.parse);
4950

5051
const getDistrbutionURLFromConfig = (config) => {
5152
const distName = getMatchingDistributionName();
5253
const distURL = R.propOr(null, distName, config);
5354

5455
if (!distURL) {
55-
return Promise.reject(new Error('No matching distribution for this operating system'));
56+
return Promise.reject(new Error("No matching distribution for this operating system"));
5657
}
5758
return Promise.resolve(distURL);
58-
}
59+
};
5960

6061
const fetchFileFromURL = (distUrl) => request({
61-
method: 'GET',
62+
method: "GET",
6263
uri: distUrl,
6364
encoding: null,
6465
gzip: true
@@ -70,10 +71,10 @@ const extractFile = (body) => new Promise((resolve, reject) => {
7071
streamableBody.push(null);
7172
streamableBody
7273
.pipe(zlib.createGunzip())
73-
.on('error', reject)
74+
.on("error", reject)
7475
.pipe(tar.extract(extractPath))
75-
.on('error', reject)
76-
.on('close', resolve);
76+
.on("error", reject)
77+
.on("close", resolve);
7778
});
7879

7980
const acquireOpenSSL = () =>

utils/discoverOpenSSLDistros.js

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const cheerio = require('cheerio');
2-
const fse = require('fs-extra');
3-
const path = require('path');
4-
const R = require('ramda');
5-
const request = require('request-promise-native');
1+
const cheerio = require("cheerio");
2+
const fse = require("fs-extra");
3+
const path = require("path");
4+
const R = require("ramda");
5+
const request = require("request-promise-native");
66

77
const windowsCommonConditions = [
88
R.test(/^\s*os=Windows$/gm),
99
R.test(/^\s*shared=False$/gm)
10-
]
10+
];
1111

1212
const macCommonConditions = [
1313
R.test(/^\s*arch=x86_64$/gm),
@@ -17,113 +17,113 @@ const macCommonConditions = [
1717
];
1818

1919
const debugPairs = R.toPairs({
20-
'win32-vs12-static-debug': R.allPass([
20+
"win32-vs12-static-debug": R.allPass([
2121
...windowsCommonConditions,
2222
R.test(/^\s*arch=x86$/gm),
2323
R.test(/^\s*build_type=Debug$/gm),
2424
R.test(/^\s*compiler\.runtime=MTd$/gm),
2525
R.test(/^\s*compiler\.version=12$/gm)
2626
]),
27-
'win32-vs14-static-debug': R.allPass([
27+
"win32-vs14-static-debug": R.allPass([
2828
...windowsCommonConditions,
2929
R.test(/^\s*arch=x86$/gm),
3030
R.test(/^\s*build_type=Debug$/gm),
3131
R.test(/^\s*compiler\.runtime=MTd$/gm),
3232
R.test(/^\s*compiler\.version=14$/gm)
3333
]),
34-
'win32-vs15-static-debug': R.allPass([
34+
"win32-vs15-static-debug": R.allPass([
3535
...windowsCommonConditions,
3636
R.test(/^\s*arch=x86$/gm),
3737
R.test(/^\s*build_type=Debug$/gm),
3838
R.test(/^\s*compiler\.runtime=MTd$/gm),
3939
R.test(/^\s*compiler\.version=15$/gm)
4040
]),
4141

42-
'win64-vs12-static-debug': R.allPass([
42+
"win64-vs12-static-debug": R.allPass([
4343
...windowsCommonConditions,
4444
R.test(/^\s*arch=x86_64$/gm),
4545
R.test(/^\s*build_type=Debug$/gm),
4646
R.test(/^\s*compiler\.runtime=MTd$/gm),
4747
R.test(/^\s*compiler\.version=12$/gm)
4848
]),
49-
'win64-vs14-static-debug': R.allPass([
49+
"win64-vs14-static-debug": R.allPass([
5050
...windowsCommonConditions,
5151
R.test(/^\s*arch=x86_64$/gm),
5252
R.test(/^\s*build_type=Debug$/gm),
5353
R.test(/^\s*compiler\.runtime=MTd$/gm),
5454
R.test(/^\s*compiler\.version=14$/gm)
5555
]),
56-
'win64-vs15-static-debug': R.allPass([
56+
"win64-vs15-static-debug": R.allPass([
5757
...windowsCommonConditions,
5858
R.test(/^\s*arch=x86_64$/gm),
5959
R.test(/^\s*build_type=Debug$/gm),
6060
R.test(/^\s*compiler\.runtime=MTd$/gm),
6161
R.test(/^\s*compiler\.version=15$/gm)
6262
]),
6363

64-
'macOS-clang-9-static-debug': R.allPass([
64+
"macOS-clang-9-static-debug": R.allPass([
6565
...macCommonConditions,
6666
R.test(/^\s*build_type=Debug$/gm),
6767
R.test(/^\s*compiler\.version=9.0$/gm)
6868
]),
69-
'macOS-clang-8.1-static-debug': R.allPass([
69+
"macOS-clang-8.1-static-debug": R.allPass([
7070
...macCommonConditions,
7171
R.test(/^\s*build_type=Debug$/gm),
7272
R.test(/^\s*compiler\.version=8\.1$/gm)
7373
])
74-
})
74+
});
7575

7676
const releasePairs = R.toPairs({
77-
'win32-vs12-static-release': R.allPass([
77+
"win32-vs12-static-release": R.allPass([
7878
...windowsCommonConditions,
7979
R.test(/^\s*arch=x86$/gm),
8080
R.test(/^\s*build_type=Release$/gm),
8181
R.test(/^\s*compiler\.runtime=MT$/gm),
8282
R.test(/^\s*compiler\.version=12$/gm)
8383
]),
84-
'win32-vs14-static-release': R.allPass([
84+
"win32-vs14-static-release": R.allPass([
8585
...windowsCommonConditions,
8686
R.test(/^\s*arch=x86$/gm),
8787
R.test(/^\s*build_type=Release$/gm),
8888
R.test(/^\s*compiler\.runtime=MT$/gm),
8989
R.test(/^\s*compiler\.version=14$/gm)
9090
]),
91-
'win32-vs15-static-release': R.allPass([
91+
"win32-vs15-static-release": R.allPass([
9292
...windowsCommonConditions,
9393
R.test(/^\s*arch=x86$/gm),
9494
R.test(/^\s*build_type=Release$/gm),
9595
R.test(/^\s*compiler\.runtime=MT$/gm),
9696
R.test(/^\s*compiler\.version=15$/gm)
9797
]),
9898

99-
'win64-vs12-static-release': R.allPass([
99+
"win64-vs12-static-release": R.allPass([
100100
...windowsCommonConditions,
101101
R.test(/^\s*arch=x86_64$/gm),
102102
R.test(/^\s*build_type=Release$/gm),
103103
R.test(/^\s*compiler\.runtime=MT$/gm),
104104
R.test(/^\s*compiler\.version=12$/gm)
105105
]),
106-
'win64-vs14-static-release': R.allPass([
106+
"win64-vs14-static-release": R.allPass([
107107
...windowsCommonConditions,
108108
R.test(/^\s*arch=x86_64$/gm),
109109
R.test(/^\s*build_type=Release$/gm),
110110
R.test(/^\s*compiler\.runtime=MT$/gm),
111111
R.test(/^\s*compiler\.version=14$/gm)
112112
]),
113-
'win64-vs15-static-release': R.allPass([
113+
"win64-vs15-static-release": R.allPass([
114114
...windowsCommonConditions,
115115
R.test(/^\s*arch=x86_64$/gm),
116116
R.test(/^\s*build_type=Release$/gm),
117117
R.test(/^\s*compiler\.runtime=MT$/gm),
118118
R.test(/^\s*compiler\.version=15$/gm)
119119
]),
120120

121-
'macOS-clang-9-static-release': R.allPass([
121+
"macOS-clang-9-static-release": R.allPass([
122122
...macCommonConditions,
123123
R.test(/^\s*build_type=Release$/gm),
124124
R.test(/^\s*compiler\.version=9.0$/gm)
125125
]),
126-
'macOS-clang-8.1-static-release': R.allPass([
126+
"macOS-clang-8.1-static-release": R.allPass([
127127
...macCommonConditions,
128128
R.test(/^\s*build_type=Release$/gm),
129129
R.test(/^\s*compiler\.version=8\.1$/gm)
@@ -133,13 +133,13 @@ const releasePairs = R.toPairs({
133133
const distributionPairs = [...debugPairs, ...releasePairs];
134134

135135
const getDistributionConfigURLFromHash = itemHash =>
136-
`https://bintray.com/conan-community/conan/download_file?file_path=conan%2FOpenSSL%2F1.1.0i%2Fstable%2Fpackage%2F${itemHash}%2Fconaninfo.txt`
136+
`https://dl.bintray.com/conan-community/conan/conan/OpenSSL/1.1.0i/stable/package/${itemHash}/conaninfo.txt`;
137137

138138
const getDistributionDownloadURLFromHash = itemHash =>
139-
`https://dl.bintray.com/conan-community/conan/conan/OpenSSL/1.1.0i/stable/package/${itemHash}/conan_package.tgz`
139+
`https://dl.bintray.com/conan-community/conan/conan/OpenSSL/1.1.0i/stable/package/${itemHash}/conan_package.tgz`;
140140

141141
const getDistributionsRootURL = () =>
142-
'https://bintray.com/package/files/conan-community/conan/OpenSSL%3Aconan?order=asc&sort=name&basePath=conan%2FOpenSSL%2F1.1.0i%2Fstable%2Fpackage&tab=files'
142+
"https://dl.bintray.com/conan-community/conan/conan/OpenSSL/1.1.0i/stable/package/";
143143

144144
const detectDistributionPairFromConfig = (itemHash, body) => R.reduce(
145145
(acc, [releaseName, predicate]) => R.cond([
@@ -158,12 +158,13 @@ const discoverDistributions = (treeHtml) => {
158158
const releaseHashes = [];
159159

160160
const $ = cheerio.load(treeHtml);
161-
const links = $('#treeBrowseTable > tbody > tr > td.nameCol > a');
162-
links.each((_, link) => {
163-
const releaseHash = link.children[0].data;
164-
if (!releaseHash) {
161+
$("a").each((_, link) => {
162+
const linkText = link.children[0].data;
163+
if (!linkText) {
165164
return;
166165
}
166+
// Trim off the trailing '/'
167+
const releaseHash = linkText.substring(0, linkText.length - 1);
167168
releaseHashes.push(releaseHash);
168169
});
169170

@@ -172,7 +173,7 @@ const discoverDistributions = (treeHtml) => {
172173
);
173174
}
174175

175-
const outputPath = path.resolve(__dirname, '..', 'vendor', 'openssl_distributions.json');
176+
const outputPath = path.resolve(__dirname, "..", "vendor", "openssl_distributions.json");
176177
request(getDistributionsRootURL())
177178
.then(discoverDistributions)
178179
.then(R.filter(R.identity))

0 commit comments

Comments
 (0)