mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
CB-7714 Teach check_reqs about brew's install location for android SDK
This commit is contained in:
parent
30681eb772
commit
2dcd50c11b
@ -31,7 +31,7 @@ var isWindows = process.platform == 'win32';
|
|||||||
|
|
||||||
function forgivingWhichSync(cmd) {
|
function forgivingWhichSync(cmd) {
|
||||||
try {
|
try {
|
||||||
return which.sync(cmd);
|
return fs.realpathSync(which.sync(cmd));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ module.exports.check_java = function() {
|
|||||||
} else {
|
} else {
|
||||||
// See if we can derive it from javac's location.
|
// See if we can derive it from javac's location.
|
||||||
// fs.realpathSync is require on Ubuntu, which symplinks from /usr/bin -> JDK
|
// fs.realpathSync is require on Ubuntu, which symplinks from /usr/bin -> JDK
|
||||||
var maybeJavaHome = path.dirname(path.dirname(fs.realpathSync(javacPath)));
|
var maybeJavaHome = path.dirname(path.dirname(javacPath));
|
||||||
if (fs.existsSync(path.join(maybeJavaHome, 'lib', 'tools.jar'))) {
|
if (fs.existsSync(path.join(maybeJavaHome, 'lib', 'tools.jar'))) {
|
||||||
process.env['JAVA_HOME'] = maybeJavaHome;
|
process.env['JAVA_HOME'] = maybeJavaHome;
|
||||||
} else {
|
} else {
|
||||||
@ -179,9 +179,15 @@ module.exports.check_android = function() {
|
|||||||
}
|
}
|
||||||
if (androidCmdPath && !hasAndroidHome) {
|
if (androidCmdPath && !hasAndroidHome) {
|
||||||
var parentDir = path.dirname(androidCmdPath);
|
var parentDir = path.dirname(androidCmdPath);
|
||||||
|
var grandParentDir = path.dirname(parentDir);
|
||||||
if (path.basename(parentDir) == 'tools') {
|
if (path.basename(parentDir) == 'tools') {
|
||||||
process.env['ANDROID_HOME'] = path.dirname(parentDir);
|
process.env['ANDROID_HOME'] = path.dirname(parentDir);
|
||||||
hasAndroidHome = true;
|
hasAndroidHome = true;
|
||||||
|
} else if (fs.existsSync(path.join(grandParentDir, 'tools', 'android'))) {
|
||||||
|
process.env['ANDROID_HOME'] = grandParentDir;
|
||||||
|
hasAndroidHome = true;
|
||||||
|
} else {
|
||||||
|
throw new Error('ANDROID_HOME is not set and no "tools" directory found at ' + parentDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasAndroidHome && !adbInPath) {
|
if (hasAndroidHome && !adbInPath) {
|
||||||
|
Loading…
Reference in New Issue
Block a user