Skip to content

Commit e472e7e

Browse files
authored
configure.js: Simplify lldb version handling (#134)
Remove the hardcoded map of lldb versions to release branches. The —lldb_exe= parameter with unknown releases should find the correct branch. Make the installer aware of lldb-5.0 binaries. (Linux.) Fixes: #133 PR-URL: #134 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gibson Fahnestock <gib@uk.ibm.com>
1 parent 2d9db90 commit e472e7e

1 file changed

Lines changed: 12 additions & 26 deletions

File tree

scripts/configure.js

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@ const fs = require('fs');
55
const path = require('path');
66
const child_process = require('child_process');
77

8-
const lldbReleases = {
9-
'4.0': 'release_40',
10-
'3.9': 'release_39',
11-
'3.8': 'release_38',
12-
'3.7': 'release_37',
13-
'3.6': 'release_36',
14-
'3.5': 'release_35',
15-
'3.4': 'release_34',
16-
};
17-
188
const buildDir = process.cwd();
199

2010
console.log('Build dir is: ' + buildDir);
@@ -39,7 +29,7 @@ if (osName === 'Darwin') {
3929
process.exit(1);
4030
}
4131

42-
lldbHeadersBranch = lldbReleases[lldbVersion];
32+
lldbHeadersBranch = lldbVersionToBranch(lldbVersion);
4333
lldbIncludeDir = 'lldb-' + lldbVersion;
4434

4535
} else if (osName === 'Linux') {
@@ -57,7 +47,7 @@ if (osName === 'Darwin') {
5747
// console.log('installed_headers_dir is ' + installed_headers_dir);
5848
if (installedHeadersDir === undefined) {
5949
// Initialising lldb_headers_branch will cause us to clone them.
60-
lldbHeadersBranch = lldbReleases[lldbVersion];
50+
lldbHeadersBranch = lldbVersionToBranch(lldbVersion);
6151
lldbIncludeDir = 'lldb-' + lldbVersion;
6252
} else {
6353
lldbIncludeDir = installedHeadersDir;
@@ -140,6 +130,10 @@ fs.writeFileSync(`${buildDir}/scripts/llnode.sh`, scriptText(lldbExe));
140130
// Exit with success.
141131
process.exit(0);
142132

133+
function lldbVersionToBranch(version) {
134+
return 'release_' + version.replace('.', '');
135+
}
136+
143137
// On Mac the lldb version string doesn't match the original lldb versions.
144138
function getDarwinRelease() {
145139
var xcodeStr;
@@ -173,11 +167,12 @@ function getDarwinRelease() {
173167
// - the one specified by the user using npm --lldb_exe=... install llnode
174168
// - the default lldb executable
175169
// - the higest known lldb version
170+
// - the names of future releases are predictable for linux
176171
function getLldbExecutable() {
177172
var lldbExe = process.env.npm_config_lldb_exe;
178173
if (lldbExe === undefined) {
179-
var lldbExeNames = ['lldb', 'lldb-4.0', 'lldb-3.9',
180-
'lldb-3.8', 'lldb-3.7', 'lldb-3.6'];
174+
var lldbExeNames = ['lldb', 'lldb-5.0', 'lldb-4.0',
175+
'lldb-3.9', 'lldb-3.8', 'lldb-3.7', 'lldb-3.6'];
181176
for (var lldbExeVersion of lldbExeNames) {
182177
try {
183178
lldbExe = child_process.execSync('which ' +
@@ -205,18 +200,9 @@ function getLinuxVersion(lldbExe) {
205200
return undefined;
206201
}
207202
// Ignore minor revisions like 3.8.1
208-
if (lldbStr.indexOf('version 4.0') > 0) {
209-
return '4.0';
210-
} else if (lldbStr.indexOf('version 3.9') > 0) {
211-
return '3.9';
212-
} else if (lldbStr.indexOf('version 3.8') > 0) {
213-
return '3.8';
214-
} else if (lldbStr.indexOf('version 3.7') > 0) {
215-
return '3.7';
216-
} if (lldbStr.indexOf('version 3.6') > 0) {
217-
return '3.6';
218-
} if (lldbStr.indexOf('version 3.5') > 0) {
219-
return '3.5';
203+
let versionMatch = lldbStr.match(/version (\d.\d)/);
204+
if (versionMatch) {
205+
return versionMatch[1];
220206
}
221207
return undefined;
222208
}

0 commit comments

Comments
 (0)