mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
[CB-4466] fixed jscript check_reqs to get target from project.properties
(cherry picked from commit 53b8da8198
)
This commit is contained in:
parent
4b501a5b63
commit
e1de55cc82
@ -58,18 +58,24 @@ function Log(msg, error) {
|
|||||||
|
|
||||||
// checks that android requirements are met
|
// checks that android requirements are met
|
||||||
function check_requirements() {
|
function check_requirements() {
|
||||||
|
var target = get_target();
|
||||||
|
if(target==null) {
|
||||||
|
Log('Unable to find android target in project.properties');
|
||||||
|
WScript.Quit(2);
|
||||||
|
}
|
||||||
var result = exec_out('%comspec% /c android list target');
|
var result = exec_out('%comspec% /c android list target');
|
||||||
if(result.error) {
|
if(result.error) {
|
||||||
Log('The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ' + result.output, true);
|
Log('The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ' + result.output, true);
|
||||||
WScript.Quit(2);
|
WScript.Quit(2);
|
||||||
}
|
}
|
||||||
else if(!result.output.match(/android[-]18/)) {
|
else if(result.output.indexOf(target) == -1) {
|
||||||
Log('Please install Android target 18 (the Android 4.3 SDK). Make sure you have the latest Android tools installed as well. Run `android` from your command-line to install/update any missing SDKs or tools.', true);
|
Log(result.output.indexOf(target));
|
||||||
Log('Output : ' + result.output);
|
Log('Please install the latest Android target (' + target + '). Make sure you have the latest Android tools installed as well. Run `android` from your command-line to install/update any missing SDKs or tools.', true);
|
||||||
|
Log(result.output);
|
||||||
WScript.Quit(2);
|
WScript.Quit(2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var cmd = '%comspec% /c android update project -p ' + ROOT + '\\framework -t android-18';
|
var cmd = '%comspec% /c android update project -p ' + ROOT + '\\framework -t ' + target;
|
||||||
result = exec_out(cmd);
|
result = exec_out(cmd);
|
||||||
if(result.error) {
|
if(result.error) {
|
||||||
Log('Error updating the Cordova library to work with your Android environment. Command run: "' + cmd + '", output: ' + result.output, true);
|
Log('Error updating the Cordova library to work with your Android environment. Command run: "' + cmd + '", output: ' + result.output, true);
|
||||||
@ -78,4 +84,19 @@ function check_requirements() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_target() {
|
||||||
|
var fso=WScript.CreateObject("Scripting.FileSystemObject");
|
||||||
|
var f=fso.OpenTextFile(ROOT + '\\framework\\project.properties', 1);
|
||||||
|
var s=f.ReadAll();
|
||||||
|
var lines = s.split('\n');
|
||||||
|
for (var line in lines) {
|
||||||
|
if(lines[line].match(/target=/))
|
||||||
|
{
|
||||||
|
return lines[line].split('=')[1].replace(' ', '').replace('\r', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
check_requirements();
|
check_requirements();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user