@@ -39,39 +39,36 @@ public class AndroidBuilder : MonoBehaviour {
39
39
40
40
static bool Exec ( string filename , string args )
41
41
{
42
+ Debug . Log ( "========================================================" ) ;
43
+ Debug . LogFormat ( "exec:{0}, args:{1}" , filename , args ) ;
42
44
System . Diagnostics . Process process = new System . Diagnostics . Process ( ) ;
43
45
process . StartInfo . FileName = filename ;
44
46
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 ) ;
45
53
46
54
int exit_code = - 1 ;
47
55
48
56
try
49
57
{
50
58
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 ( ) ;
66
60
}
67
61
catch ( Exception e )
68
62
{
69
63
Debug . LogException ( e ) ;
64
+ Debug . Log ( "--------------------------------------------------------" ) ;
70
65
return false ;
71
66
}
72
67
process . WaitForExit ( ) ;
73
68
exit_code = process . ExitCode ;
74
69
process . Close ( ) ;
70
+ Debug . LogFormat ( "exec:{0}, args:{1}, ret:{2}" , filename , args , exit_code ) ;
71
+ Debug . Log ( "--------------------------------------------------------" ) ;
75
72
return exit_code == 0 ;
76
73
}
77
74
0 commit comments