// executes a command in the shell, returns stdout or stderr if error
functionexec_out(command){
varoExec=shell.Exec(command);
varoutput=newString();
while(oExec.Status==0){
if(!oExec.StdOut.AtEndOfStream){
varline=oExec.StdOut.ReadAll();
// XXX: Change to verbose mode
// WScript.StdOut.WriteLine(line);
output+=line;
}
WScript.sleep(100);
}
//Check to make sure our scripts did not encounter an error
if(!oExec.StdErr.AtEndOfStream){
varline=oExec.StdErr.ReadAll();
return{'error':true,'output':line};
}elseif(!oExec.StdOut.AtEndOfStream){
varline=oExec.StdOut.ReadAll();
// XXX: Change to verbose mode
// WScript.StdOut.WriteLine(line);
output+=line;
}
return{'error':false,'output':output};
}
// log to stdout or stderr
functionLog(msg,error){
if(error){
WScript.StdErr.WriteLine(msg);
}
else{
WScript.StdOut.WriteLine(msg);
}
}
// checks that android requirements are met
functioncheck_requirements(){
varresult=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);
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);