Adding bhl_make_upm_package(..)
This commit is contained in:
parent
09c71a0469
commit
852b90dc7a
62
bhl.inc.php
62
bhl.inc.php
|
@ -12,6 +12,10 @@ task('bhl_clean_cache', function()
|
|||
bhl_clean_cache();
|
||||
});
|
||||
|
||||
task('bhl_make_upm_package', function() {
|
||||
bhl_make_upm_package();
|
||||
});
|
||||
|
||||
function bhl_proj_file()
|
||||
{
|
||||
return get('BHL_PROJ_FILE');
|
||||
|
@ -246,3 +250,61 @@ function bhl_validate_func_ref($module, $func, array $signature)
|
|||
if(!preg_match($signature_pattern, $module_src))
|
||||
throw new Exception("Func '$func' signature '".implode(',', $signature)."' not found in module '$module'");
|
||||
}
|
||||
|
||||
function bhl_upm_path()
|
||||
{
|
||||
global $GAME_ROOT;
|
||||
$pkg_dir = get("UNITY_ASSETS_DIR") . '/../Packages/bhl';
|
||||
return $pkg_dir;
|
||||
}
|
||||
|
||||
function bhl_clean_upm_package()
|
||||
{
|
||||
ensure_rm(bhl_upm_path() . '/Runtime/code/');
|
||||
}
|
||||
|
||||
function bhl_make_upm_package()
|
||||
{
|
||||
global $GAME_ROOT;
|
||||
|
||||
$pkg_dir = bhl_upm_path();
|
||||
ensure_mkdir($pkg_dir);
|
||||
|
||||
$srcs = array();
|
||||
$lines = file(bhl_dir() . '/bhl.cs');
|
||||
$started = false;
|
||||
foreach($lines as $line)
|
||||
{
|
||||
if(!$started && strpos($line, 'static readonly string[] VM_SRC = new string[] {') !== false)
|
||||
{
|
||||
$started = true;
|
||||
continue;
|
||||
}
|
||||
else if($started && strpos($line, '};') !== false)
|
||||
break;
|
||||
else if($started)
|
||||
{
|
||||
$mask = trim($line);
|
||||
$mask = str_replace('$"{BHL_ROOT}/', '', $mask);
|
||||
$mask = str_replace('",', '', $mask);
|
||||
$srcs = array_merge($srcs, glob(bhl_dir() . '/' . $mask));
|
||||
}
|
||||
}
|
||||
|
||||
$trgs = array();
|
||||
$changed = false;
|
||||
foreach($srcs as $src)
|
||||
{
|
||||
$trg = $pkg_dir . '/Runtime/code/' . str_replace(bhl_dir(), '', $src);
|
||||
if(!is_file($trg) || file_get_contents($src) != file_get_contents($trg))
|
||||
$changed = true;
|
||||
$trgs[$src] = $trg;
|
||||
}
|
||||
|
||||
if($changed)
|
||||
{
|
||||
bhl_clean_upm_package();
|
||||
foreach($trgs as $src => $trg)
|
||||
ensure_copy($src, $trg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue