Compare commits

..

No commits in common. "master" and "v2.15.1" have entirely different histories.

3 changed files with 18 additions and 34 deletions

View File

@ -9,19 +9,15 @@ class TaskmanArtefact
private array $sources_fn = array();
private array $sources_spec = array();
private iterable $sources = array();
//cached array of source indices which affected staleness of this artefact
private array $sources_affected = array();
//cached array of exact source files affected by incremental file changes
private array $sources_changed = array();
private array $sources_changed_fn = array();
private bool $force_stale = false;
private array $sources_affected = array();
function __construct(\taskman\TaskmanTask $task, string $path, array $sources_spec, bool $force_stale = false)
function __construct(\taskman\TaskmanTask $task, string $path, array $sources_spec)
{
$this->task = $task;
$this->path = $path;
$this->sources_spec = $sources_spec;
$this->force_stale = $force_stale;
}
function getTask() : \taskman\TaskmanTask
@ -93,6 +89,13 @@ class TaskmanArtefact
{
if(!isset($this->sources_affected[$idx]))
{
//NOTE: more conservative implementation which always checks for staleness
//$sources = $this->task->getFileChanges() != null ?
// //tries to match changed files with sources spec
// $this->getChangedSources($idx) :
// $this->getSources($idx);
//$this->sources_affected[$idx] = is_stale($this->getPath(), $sources);
//NOTE: if there any file changes we simply check if there are any changed sources,
// and if yes then we mark the artefact as affected
if($this->task->getFileChanges() != null)
@ -131,9 +134,6 @@ class TaskmanArtefact
foreach($all_src_specs as $src_idx => $src_spec)
{
if($this->force_stale)
$this->sources_affected[$src_idx] = true;
//[[dir1, dir2, ..], [ext1, ext2, ..]]
if(is_array($src_spec) && count($src_spec) == 2 &&
is_array($src_spec[0]) && is_array($src_spec[1]))
@ -379,12 +379,12 @@ class TaskmanDirFiles implements \ArrayAccess, \Countable, \Iterator
}
}
function is_stale(string $path, iterable $deps) : bool
function is_stale(string $file, iterable $deps) : bool
{
if(!is_file($path) && !is_dir($path))
if(!is_file($file))
return true;
$fmtime = filemtime($path);
$fmtime = filemtime($file);
foreach($deps as $dep)
{

View File

@ -23,7 +23,6 @@ function _collect_tasks() : array
global $TASKMAN_TASKS;
global $TASKMAN_TASK_ALIASES;
global $TASKMAN_FILE_CHANGES;
global $TASKMAN_STALE_ARTEFACTS;
$TASKMAN_TASKS = array();
$TASKMAN_TASK_ALIASES = array();
@ -45,7 +44,7 @@ function _collect_tasks() : array
else
$func = $args[1];
$task = new \taskman\TaskmanTask($func, $name, $props, $TASKMAN_FILE_CHANGES, $TASKMAN_STALE_ARTEFACTS);
$task = new \taskman\TaskmanTask($func, $name, $props, $TASKMAN_FILE_CHANGES);
}
else
throw new Exception("Task '$name' is invalid");
@ -173,7 +172,6 @@ function _process_argv(array &$argv)
global $TASKMAN_NO_DEPS;
global $TASKMAN_FILE_CHANGES;
global $TASKMAN_SHOW_BENCH;
global $TASKMAN_STALE_ARTEFACTS;
$filtered = array();
$process_defs = false;
@ -216,10 +214,6 @@ function _process_argv(array &$argv)
{
$TASKMAN_SHOW_BENCH = true;
}
else if($v == '--stale')
{
$TASKMAN_STALE_ARTEFACTS = true;
}
else if($v == '-c')
{
if(!isset($argv[$i+1]))

View File

@ -16,7 +16,6 @@ $GLOBALS['TASKMAN_LOGGER'] = '\taskman\internal\_default_logger';
$GLOBALS['TASKMAN_ERROR_HANDLER'] = null;
$GLOBALS['TASKMAN_START_TIME'] = 0;
$GLOBALS['TASKMAN_FILES_CHANGES'] = null;
$GLOBALS['TASKMAN_STALE_ARTEFACTS'] = false;
$GLOBALS['TASKMAN_SHOW_BENCH'] = false;
include_once(__DIR__ . '/internal.inc.php');
@ -57,15 +56,8 @@ class TaskmanTask
private ?TaskmanFileChanges $file_changes;
private bool $stale_artefacts = false;
function __construct(
\Closure $func,
string $name,
array $props = array(),
?TaskmanFileChanges $file_changes = null,
bool $stale_artefacts = false
)
function __construct(\Closure $func, string $name,
array $props = array(), ?TaskmanFileChanges $file_changes = null)
{
$refl = new \ReflectionFunction($func);
$this->file = $refl->getFileName();
@ -76,8 +68,6 @@ class TaskmanTask
$this->props = $props;
$this->file_changes = $file_changes;
$this->stale_artefacts = $stale_artefacts;
}
function getName() : string
@ -146,7 +136,7 @@ class TaskmanTask
if(is_array($specs))
{
foreach($specs as $dst => $src_spec)
$artefacts[] = new artefact\TaskmanArtefact($this, $dst, $src_spec, $this->stale_artefacts);
$artefacts[] = new artefact\TaskmanArtefact($this, $dst, $src_spec);
}
return $artefacts;