@@ -39,39 +39,36 @@ public class AndroidBuilder : MonoBehaviour {
3939
4040 static bool Exec ( string filename , string args )
4141 {
42+ Debug . Log ( "========================================================" ) ;
43+ Debug . LogFormat ( "exec:{0}, args:{1}" , filename , args ) ;
4244 System . Diagnostics . Process process = new System . Diagnostics . Process ( ) ;
4345 process . StartInfo . FileName = filename ;
4446 process . StartInfo . Arguments = args ;
47+ process . StartInfo . UseShellExecute = false ;
48+ process . StartInfo . CreateNoWindow = true ;
49+ process . StartInfo . RedirectStandardOutput = true ;
50+ process . StartInfo . RedirectStandardError = true ;
51+ process . OutputDataReceived += ( sender , args ) => Debug . Log ( args . Data ) ;
52+ process . ErrorDataReceived += ( sender , args ) => Debug . LogError ( args . Data ) ;
4553
4654 int exit_code = - 1 ;
4755
4856 try
4957 {
5058 process . Start ( ) ;
51- if ( process . StartInfo . RedirectStandardOutput && process . StartInfo . RedirectStandardError )
52- {
53- process . BeginOutputReadLine ( ) ;
54- Debug . LogError ( process . StandardError . ReadToEnd ( ) ) ;
55- }
56- else if ( process . StartInfo . RedirectStandardOutput )
57- {
58- string data = process . StandardOutput . ReadToEnd ( ) ;
59- Debug . Log ( data ) ;
60- }
61- else if ( process . StartInfo . RedirectStandardError )
62- {
63- string data = process . StandardError . ReadToEnd ( ) ;
64- Debug . LogError ( data ) ;
65- }
59+ process . BeginOutputReadLine ( ) ;
6660 }
6761 catch ( Exception e )
6862 {
6963 Debug . LogException ( e ) ;
64+ Debug . Log ( "--------------------------------------------------------" ) ;
7065 return false ;
7166 }
7267 process . WaitForExit ( ) ;
7368 exit_code = process . ExitCode ;
7469 process . Close ( ) ;
70+ Debug . LogFormat ( "exec:{0}, args:{1}, ret:{2}" , filename , args , exit_code ) ;
71+ Debug . Log ( "--------------------------------------------------------" ) ;
7572 return exit_code == 0 ;
7673 }
7774
0 commit comments