Skip to content

Commit

Permalink
Idempotent build: file-entities.php (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfsb authored Dec 10, 2024
1 parent 9a64b58 commit df18cd2
Show file tree
Hide file tree
Showing 5 changed files with 405 additions and 340 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
manual.xml
version.xml
sources.xml
entities/file-entities.ent
temp/
# File use to generate entities by configure script
fileModHistory.php
scripts/file-entities.php


# A plece for all temporary or generated files (idempotent build)
temp/
46 changes: 33 additions & 13 deletions configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,6 @@ function abspath($path) // {{{
return str_replace('\\', '/', function_exists('realpath') ? realpath($path) : $path);
} // }}}

function quietechorun($e) // {{{
{
// enclose in "" on Windows for PHP < 5.3
if (is_windows() && phpversion() < '5.3') {
$e = '"'.$e.'"';
}

passthru($e);
} // }}}

function find_file($file_array) // {{{
{
$paths = explode(PATH_SEPARATOR, getenv('PATH'));
Expand Down Expand Up @@ -327,6 +317,19 @@ function getFileModificationHistory(): array {
return $history_file;
}

if ( true ) # Initial clean up
{
$dir = escapeshellarg( __DIR__ );
$cmd = "git -C $dir clean temp -fdx --quiet";
$ret = 0;
passthru( $cmd , $ret );
if ( $ret != 0 )
{
echo "doc-base/temp clean up FAILED.\n";
exit( 1 );
}
}

$srcdir = dirname(__FILE__);
$workdir = $srcdir;
$basedir = $srcdir;
Expand Down Expand Up @@ -635,7 +638,6 @@ function getFileModificationHistory(): array {
// Notice how doing it this way results in generating less than half as many files.
$infiles = array(
'manual.xml.in',
'scripts/file-entities.php.in',
);

// Show local repository status to facilitate debug
Expand Down Expand Up @@ -736,9 +738,27 @@ function getFileModificationHistory(): array {

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

$redir = ($ac['quiet'] == 'yes') ? ' > ' . (is_windows() ? 'nul' : '/dev/null') : '';

quietechorun("\"{$ac['PHP']}\" -q \"{$ac['basedir']}/scripts/file-entities.php\"{$redir}");
{ # file-entities.php

$cmd = array();
$cmd[] = $ac['PHP'];
$cmd[] = __DIR__ . "/scripts/file-entities.php";
if ( $ac["LANG"] != "en" )
$cmd[] = $ac["LANG"];
if ( $ac['CHMENABLED'] == 'yes' )
$cmd[] = '--chmonly';
foreach ( $cmd as & $part )
$part = escapeshellarg( $part );
$ret = 0;
$cmd = implode( ' ' , $cmd );
passthru( $cmd , $ret );
if ( $ret != 0 )
{
echo "doc-base/scripts/file-entities.php FAILED.\n";
exit( 1 );
}
}


checking("for if we should generate a simplified file");
Expand Down
2 changes: 1 addition & 1 deletion manual.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<!-- These are language independent -->
<!ENTITY % frontpage.entities SYSTEM "../@EN_DIR@/contributors.ent">
<!ENTITY % file.entities SYSTEM "./entities/file-entities.ent">
<!ENTITY % file.entities SYSTEM "./temp/file-entities.ent">

<!-- Include all external DTD parts defined previously -->
%global.entities;
Expand Down
Loading

0 comments on commit df18cd2

Please sign in to comment.