This commit is contained in:
Pavel Shevaev 2023-04-14 11:35:45 +03:00
commit c32d6ba9ec
1 changed files with 46 additions and 32 deletions

View File

@ -20,17 +20,7 @@ task('unity', function()
task('unity_kill', function() task('unity_kill', function()
{ {
$proc_id = unity_find_proc_id(); unity_kill();
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_exec($func, $build_target = "", $quit = true, $batchmode = true) 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); return array($log_file, $pid);
} }
function unity_batch_exec($func, $build_target = "", $notify = true) function unity_batch_exec($func, $build_target = "")
{ {
global $GAME_ROOT; global $GAME_ROOT;
try unity_kill();
{
list($log_file, $pid) = unity_exec($func, $build_target, /*$quit = */ true, /*$batchmode = */ true); 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( array(
'Exiting batchmode successfully' 'Exiting batchmode successfully',
'Batchmode quit successfully invoked - shutting down!'
), ),
array( array(
'Build Finished, Result: Failure', 'Build Finished, Result: Failure',
'UnityException:',
'Aborting batchmode due to failure', 'Aborting batchmode due to failure',
'Launching bug reporter', 'Launching bug reporter',
': error CS',
'Unrecognized assets cannot be included in AssetBundles:' '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) function unity_run_proc($shared_cmd)
{ {
@ -115,6 +116,19 @@ function unity_run_proc($shared_cmd)
return trim($out[0]); 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() function unity_find_proc_id()
{ {
global $GAME_ROOT; global $GAME_ROOT;
@ -294,7 +308,7 @@ function run_mono($exe_file)
$exe_file = normalize_path($exe_file, !is_win()); $exe_file = normalize_path($exe_file, !is_win());
$mono_path = realpath(dirname($mono_bin) . '/../lib/mono/unity'); $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"; $cmd = "$mono_bin $exe_file";
shell($cmd); shell($cmd);
} }