Skip to content

Commit df18cd2

Browse files
authored
Idempotent build: file-entities.php (#201)
1 parent 9a64b58 commit df18cd2

File tree

5 files changed

+405
-340
lines changed

5 files changed

+405
-340
lines changed

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
manual.xml
55
version.xml
66
sources.xml
7-
entities/file-entities.ent
8-
temp/
97
# File use to generate entities by configure script
108
fileModHistory.php
11-
scripts/file-entities.php
9+
10+
11+
# A plece for all temporary or generated files (idempotent build)
12+
temp/

configure.php

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,6 @@ function abspath($path) // {{{
134134
return str_replace('\\', '/', function_exists('realpath') ? realpath($path) : $path);
135135
} // }}}
136136

137-
function quietechorun($e) // {{{
138-
{
139-
// enclose in "" on Windows for PHP < 5.3
140-
if (is_windows() && phpversion() < '5.3') {
141-
$e = '"'.$e.'"';
142-
}
143-
144-
passthru($e);
145-
} // }}}
146-
147137
function find_file($file_array) // {{{
148138
{
149139
$paths = explode(PATH_SEPARATOR, getenv('PATH'));
@@ -327,6 +317,19 @@ function getFileModificationHistory(): array {
327317
return $history_file;
328318
}
329319

320+
if ( true ) # Initial clean up
321+
{
322+
$dir = escapeshellarg( __DIR__ );
323+
$cmd = "git -C $dir clean temp -fdx --quiet";
324+
$ret = 0;
325+
passthru( $cmd , $ret );
326+
if ( $ret != 0 )
327+
{
328+
echo "doc-base/temp clean up FAILED.\n";
329+
exit( 1 );
330+
}
331+
}
332+
330333
$srcdir = dirname(__FILE__);
331334
$workdir = $srcdir;
332335
$basedir = $srcdir;
@@ -635,7 +638,6 @@ function getFileModificationHistory(): array {
635638
// Notice how doing it this way results in generating less than half as many files.
636639
$infiles = array(
637640
'manual.xml.in',
638-
'scripts/file-entities.php.in',
639641
);
640642

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

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

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

741-
quietechorun("\"{$ac['PHP']}\" -q \"{$ac['basedir']}/scripts/file-entities.php\"{$redir}");
742+
{ # file-entities.php
743+
744+
$cmd = array();
745+
$cmd[] = $ac['PHP'];
746+
$cmd[] = __DIR__ . "/scripts/file-entities.php";
747+
if ( $ac["LANG"] != "en" )
748+
$cmd[] = $ac["LANG"];
749+
if ( $ac['CHMENABLED'] == 'yes' )
750+
$cmd[] = '--chmonly';
751+
foreach ( $cmd as & $part )
752+
$part = escapeshellarg( $part );
753+
$ret = 0;
754+
$cmd = implode( ' ' , $cmd );
755+
passthru( $cmd , $ret );
756+
if ( $ret != 0 )
757+
{
758+
echo "doc-base/scripts/file-entities.php FAILED.\n";
759+
exit( 1 );
760+
}
761+
}
742762

743763

744764
checking("for if we should generate a simplified file");

manual.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

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

3030
<!-- Include all external DTD parts defined previously -->
3131
%global.entities;

0 commit comments

Comments
 (0)