[CB-4466] fixed jscript check_reqs to get target from project.properties (cherry picked from commit 53b8da81985464b82d87e1655e6561f2076b4206)
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/e1de55cc Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/e1de55cc Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/e1de55cc Branch: refs/heads/2.9.x Commit: e1de55cc82c050911d36b1ccd12cf6e499df8edb Parents: 4b501a5 Author: Benn Mapes <[email protected]> Authored: Thu Aug 1 17:57:58 2013 -0700 Committer: Andrew Grieve <[email protected]> Committed: Tue Oct 22 15:14:09 2013 -0400 ---------------------------------------------------------------------- bin/check_reqs.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e1de55cc/bin/check_reqs.js ---------------------------------------------------------------------- diff --git a/bin/check_reqs.js b/bin/check_reqs.js index 7fc32b8..4a724a6 100644 --- a/bin/check_reqs.js +++ b/bin/check_reqs.js @@ -54,22 +54,28 @@ function Log(msg, error) { else { WScript.StdOut.WriteLine(msg); } -} +} // checks that android requirements are met 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'); 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); WScript.Quit(2); } - else if(!result.output.match(/android[-]18/)) { - 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('Output : ' + result.output); + else if(result.output.indexOf(target) == -1) { + Log(result.output.indexOf(target)); + 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); } 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); if(result.error) { 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(); +
