Skip to content

Commit

Permalink
Add file modification history setup (#120)
Browse files Browse the repository at this point in the history
Copy the appropriate file from the language repo or create an empty one to use

Co-authored-by: haszi <haszika80@gmail.com>
  • Loading branch information
haszi and haszi authored Apr 20, 2024
1 parent 0aaa1ae commit 6a646b8
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function usage() // {{{
--disable-version-files Do not merge the extension specific
version.xml files
--disable-sources-file Do not generate sources.xml file
--disable-history-file Do not copy file modification history file
--disable-libxml-check Disable the libxml 2.7.4+ requirement check
--with-php=PATH Path to php CLI executable [detect]
--with-lang=LANG Language to build [{$acd['LANG']}]
Expand Down Expand Up @@ -295,6 +296,35 @@ function generate_sources_file() // {{{
}
} // }}}

function getFileModificationHistory(): array {
global $ac;

$lang_mod_file = (($ac['LANG'] !== 'en') ? ("{$ac['rootdir']}/{$ac['EN_DIR']}") : ("{$ac['rootdir']}/{$ac['LANGDIR']}")) . "/fileModHistory.php";
$doc_base_mod_file = __DIR__ . "/fileModHistory.php";

if (file_exists($lang_mod_file)) {
$history_file = include $lang_mod_file;
if (is_array($history_file)) {
echo 'Copying modification history file... ';
$isFileCopied = copy($lang_mod_file, $doc_base_mod_file);
echo $isFileCopied ? "done.\n" : "failed.\n";
} else {
echo "Corrupted modification history file found: $lang_mod_file \n";
}
} else {
echo "Modification history file $lang_mod_file not found.\n";
}

if (!is_array($history_file)) {
$history_file = [];
echo "Creating empty modification history file...";
file_put_contents($doc_base_mod_file, "<?php\n\nreturn [];\n");
echo "done.\n";
}

return $history_file;
}

$srcdir = dirname(__FILE__);
$workdir = $srcdir;
$basedir = $srcdir;
Expand Down Expand Up @@ -351,6 +381,7 @@ function generate_sources_file() // {{{
'SEGFAULT_SPEED' => 'yes',
'VERSION_FILES' => 'yes',
'SOURCES_FILE' => 'yes',
'HISTORY_FILE' => 'yes',
'LIBXML_CHECK' => 'yes',
'USE_BROKEN_TRANSLATION_FILENAME' => 'yes',
'OUTPUT_FILENAME' => $srcdir . '/.manual.xml',
Expand Down Expand Up @@ -467,6 +498,10 @@ function generate_sources_file() // {{{
$ac['SOURCES_FILE'] = $v;
break;

case 'history-file':
$ac['SOURCES_FILE'] = $v;
break;

case 'libxml-check':
$ac['LIBXML_CHECK'] = $v;
break;
Expand Down Expand Up @@ -697,6 +732,11 @@ function generate_sources_file() // {{{
generate_sources_file();
}

$history_file = [];
if ($ac['HISTORY_FILE'] === 'yes') {
$history_file = getFileModificationHistory();
}

globbetyglob("{$ac['basedir']}/scripts", 'make_scripts_executable');

$redir = ($ac['quiet'] == 'yes') ? ' > ' . (is_windows() ? 'nul' : '/dev/null') : '';
Expand Down Expand Up @@ -875,4 +915,3 @@ function generate_sources_file() // {{{
errors_are_bad(1); // Tell the shell that this script finished with an error.
}
?>

0 comments on commit 6a646b8

Please sign in to comment.