Compare commits
No commits in common. "master" and "v3.10.2" have entirely different histories.
|
@ -1,29 +0,0 @@
|
||||||
|
|
||||||
name: Publish PHP Package
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Get tag name
|
|
||||||
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: zip and send
|
|
||||||
run: |
|
|
||||||
ls -la
|
|
||||||
apt-get update -y
|
|
||||||
apt-get install -y zip
|
|
||||||
cd ../
|
|
||||||
zip -r ${{ gitea.event.repository.name }}.zip ${{ gitea.event.repository.name }} -x '*.git*'
|
|
||||||
curl -v \
|
|
||||||
--user composer-pbl:${{ secrets.COMPOSER_PSWD }} \
|
|
||||||
--upload-file ${{ gitea.event.repository.name }}.zip \
|
|
||||||
https://git.bit5.ru/api/packages/bit/composer?version=${{ env.TAG }}
|
|
132
bhl.inc.php
132
bhl.inc.php
|
@ -12,6 +12,10 @@ task('bhl_clean_cache', function()
|
||||||
bhl_clean_cache();
|
bhl_clean_cache();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
task('bhl_make_upm_package', function() {
|
||||||
|
bhl_make_upm_package();
|
||||||
|
});
|
||||||
|
|
||||||
class BhlProj
|
class BhlProj
|
||||||
{
|
{
|
||||||
public static ?BhlProj $active = null;
|
public static ?BhlProj $active = null;
|
||||||
|
@ -19,7 +23,6 @@ class BhlProj
|
||||||
public string $file_path;
|
public string $file_path;
|
||||||
public array $inc_dirs = array();
|
public array $inc_dirs = array();
|
||||||
public array $src_dirs = array();
|
public array $src_dirs = array();
|
||||||
public array $defines = array();
|
|
||||||
public array $bindings_sources;
|
public array $bindings_sources;
|
||||||
public array $postproc_sources;
|
public array $postproc_sources;
|
||||||
public string $postproc_dll;
|
public string $postproc_dll;
|
||||||
|
@ -120,7 +123,16 @@ function bhl_dir() : string
|
||||||
|
|
||||||
function bhl_shell(string $cmd, &$ret_var, &$ret_out)
|
function bhl_shell(string $cmd, &$ret_var, &$ret_out)
|
||||||
{
|
{
|
||||||
shell_try(bhl_dir()."/bhl $cmd", $ret_var, $ret_out);
|
$prev_path = mono_try_override_path();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
shell_try(bhl_dir()."/bhl $cmd", $ret_var, $ret_out);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mono_try_restore_path($prev_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bhl_shell_ensure(string $cmd)
|
function bhl_shell_ensure(string $cmd)
|
||||||
|
@ -156,9 +168,11 @@ function bhl_run(bool $debug = true, bool $force = false, bool $exit_on_err = tr
|
||||||
if(!$exit_on_err)
|
if(!$exit_on_err)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if($debug)
|
else
|
||||||
echo "BHL BUNDLE: total " . kb_len(filesize($result_file)) . ", CRC " . hexdec(hash_file('CRC32', $result_file, false)) . "\n";
|
echo "BHL BUNDLE: total " . kb_len(filesize($result_file)) . ", CRC " . hexdec(hash_file('CRC32', $result_file, false)) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@touch($result_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bhl_handle_error_result(array $ret_out, string $err_file, bool $exit = true)
|
function bhl_handle_error_result(array $ret_out, string $err_file, bool $exit = true)
|
||||||
|
@ -199,7 +213,7 @@ function bhl_handle_error_result(array $ret_out, string $err_file, bool $exit =
|
||||||
function bhl_clean()
|
function bhl_clean()
|
||||||
{
|
{
|
||||||
bhl_clean_cache();
|
bhl_clean_cache();
|
||||||
bhl_shell("clean", $ret, $out);
|
bhl_shell_ensure("clean");
|
||||||
}
|
}
|
||||||
|
|
||||||
function bhl_clean_cache()
|
function bhl_clean_cache()
|
||||||
|
@ -257,36 +271,16 @@ function bhl_validate_func_ref(string $module_file, string $func_full_name, arra
|
||||||
if(sizeof($signature) == 0)
|
if(sizeof($signature) == 0)
|
||||||
throw new Exception("Signature is invalid");
|
throw new Exception("Signature is invalid");
|
||||||
|
|
||||||
|
//NOTE: we can't validate if the function is actually in a namespace
|
||||||
|
// but was passed without a namespace prefix
|
||||||
$name_items = explode('.', $func_full_name);
|
$name_items = explode('.', $func_full_name);
|
||||||
$func = array_pop($name_items);
|
$func = end($name_items);
|
||||||
$namespace = implode('.', $name_items);
|
|
||||||
|
|
||||||
$module_src = file_get_contents($module_file);
|
$module_src = file_get_contents($module_file);
|
||||||
$module_src = _bhl_remove_comments($module_src);
|
|
||||||
|
|
||||||
if(!$module_src)
|
if(!$module_src)
|
||||||
throw new Exception("Bad module file '{$module_file}'");
|
throw new Exception("Bad module file '{$module_file}'");
|
||||||
|
|
||||||
$ns_chunks = _bhl_split_by_namespaces($module_src);
|
|
||||||
|
|
||||||
$module_chunks = array();
|
|
||||||
if($namespace)
|
|
||||||
{
|
|
||||||
if(!isset($ns_chunks[$namespace]))
|
|
||||||
throw new Exception("No namespace '$namespace' found in '$module_file'");
|
|
||||||
|
|
||||||
foreach($ns_chunks[$namespace] as $ns_src)
|
|
||||||
$module_chunks[] = $ns_src;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!isset($ns_chunks['']))
|
|
||||||
throw new Exception("No global namespace found in '$module_file'");
|
|
||||||
|
|
||||||
foreach($ns_chunks[''] as $ns_src)
|
|
||||||
$module_chunks[] = $ns_src;
|
|
||||||
}
|
|
||||||
|
|
||||||
$signature_pattern = '';
|
$signature_pattern = '';
|
||||||
$signature_pattern .= '~func\s+';
|
$signature_pattern .= '~func\s+';
|
||||||
if($signature[0] !== 'void')
|
if($signature[0] !== 'void')
|
||||||
|
@ -308,58 +302,64 @@ function bhl_validate_func_ref(string $module_file, string $func_full_name, arra
|
||||||
$signature_pattern .= '\s*\)';
|
$signature_pattern .= '\s*\)';
|
||||||
$signature_pattern .= '~';
|
$signature_pattern .= '~';
|
||||||
|
|
||||||
foreach($module_chunks as $module_chunk_src)
|
if(!preg_match($signature_pattern, $module_src))
|
||||||
{
|
throw new Exception("Func '$func' signature '".implode(',', $signature)."' not found in module '$module_file'");
|
||||||
if(preg_match($signature_pattern, $module_chunk_src))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception("Func '$func_full_name(".implode(',', $signature).")' not found in '$module_file'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _bhl_remove_comments(string $txt) : string
|
function bhl_upm_path() : string
|
||||||
{
|
{
|
||||||
//block comments
|
global $GAME_ROOT;
|
||||||
if(strpos($txt, '/*') !== false)
|
$pkg_dir = get("UNITY_ASSETS_DIR") . '/../Packages/bhl';
|
||||||
{
|
return $pkg_dir;
|
||||||
$regex = '~/\*.*?\*/~s';
|
|
||||||
$txt = preg_replace_callback(
|
|
||||||
$regex,
|
|
||||||
//preserve the new lines for better error reporting
|
|
||||||
function($m) { return str_repeat("\n", substr_count($m[0], "\n")); },
|
|
||||||
$txt);
|
|
||||||
}
|
|
||||||
//line comments
|
|
||||||
$txt = preg_replace("~\s*(?<!:)//.*~", "\n", $txt);
|
|
||||||
return $txt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _bhl_split_by_namespaces(string $src) : array
|
function bhl_clean_upm_package()
|
||||||
{
|
{
|
||||||
$nss = array();
|
ensure_rm(bhl_upm_path() . '/Runtime/code/');
|
||||||
|
}
|
||||||
|
|
||||||
$chunks = preg_split('~^\s*(namespace\s+[^\{]+){~m', $src, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
|
function bhl_make_upm_package()
|
||||||
|
{
|
||||||
|
global $GAME_ROOT;
|
||||||
|
|
||||||
for($i=0;$i<count($chunks);)
|
$pkg_dir = bhl_upm_path();
|
||||||
|
ensure_mkdir($pkg_dir);
|
||||||
|
|
||||||
|
$srcs = array();
|
||||||
|
$lines = file(bhl_dir() . '/bhl.cs');
|
||||||
|
$started = false;
|
||||||
|
foreach($lines as $line)
|
||||||
{
|
{
|
||||||
$chunk = $chunks[$i];
|
if(!$started && strpos($line, 'static readonly string[] VM_SRC = new string[] {') !== false)
|
||||||
if(strpos(ltrim($chunk), 'namespace ') === 0)
|
|
||||||
{
|
{
|
||||||
$ns = trim(substr(ltrim($chunk), 9));
|
$started = true;
|
||||||
$body = $chunks[$i+1];
|
continue;
|
||||||
if(!isset($nss[$ns]))
|
|
||||||
$nss[$ns] = array();
|
|
||||||
$nss[$ns][] = $body;
|
|
||||||
$i+=2;
|
|
||||||
}
|
}
|
||||||
else
|
else if($started && strpos($line, '};') !== false)
|
||||||
|
break;
|
||||||
|
else if($started)
|
||||||
{
|
{
|
||||||
if(!isset($nss['']))
|
$mask = trim($line);
|
||||||
$nss[''] = array();
|
$mask = str_replace('$"{BHL_ROOT}/', '', $mask);
|
||||||
$nss[''][] = $chunk;
|
$mask = str_replace('",', '', $mask);
|
||||||
++$i;
|
$srcs = array_merge($srcs, glob(bhl_dir() . '/' . $mask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $nss;
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
namespace metagen_php;
|
namespace metagen_php;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
function flt_bhl_ref($val, $name, $data, $str_args)
|
function flt_bhl_ref($val, $name, $struct, $str_args)
|
||||||
{
|
{
|
||||||
if(!$val)
|
if(!$val)
|
||||||
return $val;
|
return $val;
|
||||||
|
|
Loading…
Reference in New Issue