versions() gcc fix macOS

This commit is contained in:
Sebastian Hildebrandt
2019-07-01 17:55:27 +02:00
parent 7a306cc4f9
commit 176c4e9afd
5 changed files with 39 additions and 24 deletions
+23 -22
View File
@@ -410,11 +410,8 @@ function versions(callback) {
functionProcessed();
});
if (_darwin) {
const cmdLineToolsExists = fs.existsSync('/Library/Developer/CommandLineTools/usr/bin/');
const xcodeAppExists = fs.existsSync('/Applications/Xcode.app/Contents/Developer/Tools');
const xcodeExists = fs.existsSync('/Library/Developer/Xcode/');
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/git');
if (cmdLineToolsExists || xcodeExists || gitHomebrewExists || xcodeAppExists) {
if (util.darwinXcodeExists() || gitHomebrewExists) {
exec('git --version', function (error, stdout) {
if (!error) {
let git = stdout.toString().split('\n')[0] || '';
@@ -616,25 +613,29 @@ function versions(callback) {
functionProcessed();
});
}
exec('gcc -dumpversion', function (error, stdout) {
if (!error) {
result.gcc = stdout.toString().split('\n')[0].trim() || '';
}
if (result.gcc.indexOf('.') > -1) {
functionProcessed();
} else {
exec('gcc --version', function (error, stdout) {
if (!error) {
const gcc = stdout.toString().split('\n')[0].trim();
if (gcc.indexOf('gcc') > -1 && gcc.indexOf(')') > -1) {
const parts = gcc.split(')');
result.gcc = parts[1].trim() || result.gcc;
}
}
if ((_darwin && util.darwinXcodeExists()) || !_darwin) {
exec('gcc -dumpversion', function (error, stdout) {
if (!error) {
result.gcc = stdout.toString().split('\n')[0].trim() || '';
}
if (result.gcc.indexOf('.') > -1) {
functionProcessed();
});
}
});
} else {
exec('gcc --version', function (error, stdout) {
if (!error) {
const gcc = stdout.toString().split('\n')[0].trim();
if (gcc.indexOf('gcc') > -1 && gcc.indexOf(')') > -1) {
const parts = gcc.split(')');
result.gcc = parts[1].trim() || result.gcc;
}
}
functionProcessed();
});
}
});
} else {
functionProcessed();
}
exec(util.getVboxmanage() + ' -v 2>&1', function (error, stdout) {
if (!error) {
const vbox = stdout.toString().split('\n')[0] || '';
+8
View File
@@ -386,6 +386,13 @@ function execWin(cmd, opts, callback) {
});
}
function darwinXcodeExists() {
const cmdLineToolsExists = fs.existsSync('/Library/Developer/CommandLineTools/usr/bin/');
const xcodeAppExists = fs.existsSync('/Applications/Xcode.app/Contents/Developer/Tools');
const xcodeExists = fs.existsSync('/Library/Developer/Xcode/');
return (cmdLineToolsExists || xcodeExists || xcodeAppExists);
}
function nanoSeconds() {
const time = process.hrtime();
if (!Array.isArray(time) || time.length !== 2) {
@@ -423,6 +430,7 @@ exports.parseHead = parseHead;
exports.findObjectByKey = findObjectByKey;
exports.getWmic = getWmic;
exports.wmic = wmic;
exports.darwinXcodeExists = darwinXcodeExists;
exports.getVboxmanage = getVboxmanage;
exports.powerShell = powerShell;
exports.nanoSeconds = nanoSeconds;