diff --git a/unity.inc.php b/unity.inc.php index f2c3487..ac1c88d 100644 --- a/unity.inc.php +++ b/unity.inc.php @@ -20,17 +20,7 @@ task('unity', function() task('unity_kill', function() { - $proc_id = unity_find_proc_id(); - if($proc_id) - { - echo "Found Unity process '$proc_id', killing it...\n"; - system("kill -9 $proc_id"); - sleep(5); - } - else - { - echo "No Unity process found to kill\n"; - } + unity_kill(); }); function unity_exec($func, $build_target = "", $quit = true, $batchmode = true) @@ -67,31 +57,42 @@ function unity_exec($func, $build_target = "", $quit = true, $batchmode = true) return array($log_file, $pid); } -function unity_batch_exec($func, $build_target = "", $notify = true) +function unity_batch_exec($func, $build_target = "") { global $GAME_ROOT; - try - { - list($log_file, $pid) = unity_exec($func, $build_target, /*$quit = */ true, /*$batchmode = */ true); + unity_kill(); - watch_running_process($pid, $log_file, - array( - 'Exiting batchmode successfully' - ), - array( - 'Build Finished, Result: Failure', - 'Aborting batchmode due to failure', - 'Launching bug reporter', + list($log_file, $pid) = unity_exec($func, $build_target, /*$quit = */ true, /*$batchmode = */ true); + + watch_running_process( + $pid, + $log_file, + array( + 'Exiting batchmode successfully', + 'Batchmode quit successfully invoked - shutting down!' + ), + array( + 'Build Finished, Result: Failure', + 'UnityException:', + 'Aborting batchmode due to failure', + 'Launching bug reporter', + 'Unrecognized assets cannot be included in AssetBundles:' + ), + true, + -1, + //ignored errors: + array( + //NOTE: weird editor crash, sometimes happens on exit after batch task is actually done + // seems like it's never been fixed though issue tracker says otherwise (https://vk.cc/bYpyUS) + "Fatal Error! GetManagerFromContext: pointer to object of manager 'MonoManager' is NULL (table index 5)" + ), + + //noted warnings: they don't abort execution but show up at the end of the log if command fails + array( ': error CS', - 'Unrecognized assets cannot be included in AssetBundles:' - ) - ); - } - catch(Exception $e) - { - throw $e; - } + ) + ); } function unity_run_proc($shared_cmd) @@ -115,6 +116,19 @@ function unity_run_proc($shared_cmd) return trim($out[0]); } +function unity_kill() +{ + $proc_id = unity_find_proc_id(); + if($proc_id) + { + echo "Found Unity process '$proc_id', killing it...\n"; + system("kill -9 $proc_id"); + sleep(5); + } + else + echo "No Unity process found to kill\n"; +} + function unity_find_proc_id() { global $GAME_ROOT; @@ -294,7 +308,7 @@ function run_mono($exe_file) $exe_file = normalize_path($exe_file, !is_win()); $mono_path = realpath(dirname($mono_bin) . '/../lib/mono/unity'); - putenv("MONO_PATH=$mono_path"); //To LOCATION_PATH? + putenv("MONO_PATH=$mono_path"); $cmd = "$mono_bin $exe_file"; shell($cmd); }