Making unity_exec(..) more robust and reliable
This commit is contained in:
parent
c632553277
commit
9d9c46a8ef
|
@ -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,32 +57,43 @@ 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
|
||||
{
|
||||
unity_kill();
|
||||
|
||||
list($log_file, $pid) = unity_exec($func, $build_target, /*$quit = */ true, /*$batchmode = */ true);
|
||||
|
||||
watch_running_process($pid, $log_file,
|
||||
watch_running_process(
|
||||
$pid,
|
||||
$log_file,
|
||||
array(
|
||||
'Exiting batchmode successfully'
|
||||
'Exiting batchmode successfully',
|
||||
'Batchmode quit successfully invoked - shutting down!'
|
||||
),
|
||||
array(
|
||||
'Build Finished, Result: Failure',
|
||||
'UnityException:',
|
||||
'Aborting batchmode due to failure',
|
||||
'Launching bug reporter',
|
||||
': error CS',
|
||||
'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',
|
||||
)
|
||||
);
|
||||
}
|
||||
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;
|
||||
|
@ -295,7 +309,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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue