Base dirs now can be configured via config_set_base_dirs(..) call, further removing global props dependencies

This commit is contained in:
Pavel Shevaev 2023-05-25 18:44:59 +03:00
parent 2e965dcf98
commit 91ed9344f3
1 changed files with 9 additions and 27 deletions

View File

@ -3,6 +3,7 @@ namespace taskman;
use Exception;
$GLOBALS['CONFIG_GLOBAL_DEPS'] = array();
$GLOBALS['CONFIG_BASE_DIRS'] = array();
$GLOBALS['CONFIG_INIT_WORKER_FUNC'] = null;
task('config_worker', function(array $args)
@ -29,24 +30,16 @@ task('config_worker', function(array $args)
}
});
function config_set_base_dirs(array $dirs)
{
global $CONFIG_BASE_DIRS;
$CONFIG_BASE_DIRS = array_map(function($d) { return normalize_path($d); }, $dirs);
}
function config_base_dirs()
{
static $dirs = null;
if($dirs === null)
{
if(is("CONFIGS_BASE_DIR"))
{
$dirs = get("CONFIGS_BASE_DIR");
if(is_string($dirs))
$dirs = array($dirs);
}
else
$dirs = array(get("UNITY_ASSETS_DIR") . "/Configs");
$dirs = array_map(function($d) { return normalize_path($d); }, $dirs);
}
return $dirs;
global $CONFIG_BASE_DIRS;
return $CONFIG_BASE_DIRS;
}
function config_map_base_dir($file, $normalized = false, $strict = true, $dirs = null)
@ -103,17 +96,6 @@ function config_get_global_deps()
return $CONFIG_GLOBAL_DEPS;
}
function config_get_build_ext_dir()
{
global $GAME_ROOT;
return "$GAME_ROOT/build/ext_config/";
}
function config_get_bundle_ext_path()
{
return config_get_build_ext_dir() . "/configs/" . get("CONFIGS_BUNDLE_NAME");
}
function config_scan_files()
{
return scan_files_rec(config_base_dirs(), array('conf.js'));