diff --git a/.gitignore b/.gitignore index 97fc8e85c..8e5220c8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # Files generated by the configure script .manual.xml .revcheck.json -manual.xml version.xml sources.xml # File use to generate entities by configure script diff --git a/chm/manual.chm.xml b/chm/manual.chm.xml new file mode 100644 index 000000000..ca60d431b --- /dev/null +++ b/chm/manual.chm.xml @@ -0,0 +1,7 @@ + + &CHMEdition; + &chmonly.aboutchm; + &chmonly.usingchm; + &chmonly.search; + &chmonly.integration; + diff --git a/configure.php b/configure.php index 078c66e53..af4d9d5b2 100755 --- a/configure.php +++ b/configure.php @@ -27,6 +27,17 @@ echo "configure.php on PHP " . phpversion() . "\n\n"; +// init_argv() +// init_checks() +// init_clean() +// xml_configure() +// xml_parse() +// xml_xinclude() +// xml_validate() +// phd_sources() +// phd_version() +// php_history() + const RNG_SCHEMA_DIR = __DIR__ . DIRECTORY_SEPARATOR . 'docbook' . DIRECTORY_SEPARATOR . 'docbook-v5.2-os' . DIRECTORY_SEPARATOR . 'rng' . DIRECTORY_SEPARATOR; const RNG_SCHEMA_FILE = RNG_SCHEMA_DIR . 'docbook.rng'; const RNG_SCHEMA_XINCLUDE_FILE = RNG_SCHEMA_DIR . 'docbookxi.rng'; @@ -81,6 +92,29 @@ function usage() // {{{ HELPCHUNK; } // }}} +function realpain( string $path , bool $touch = false , bool $mkdir = false ) : string +{ + // pain is real + + // care for external XML tools (realpath() everywhere) + // care for Windows builds (foward slashes everywhere) + // avoid `cd` and chdir() like the plague + + $path = str_replace( "\\" , '/' , $path ); + + if ( $mkdir && ! file_exists( $path ) ) + mkdir( $path , recursive: true ); + + if ( $touch && ! file_exists( $path ) ) + touch( $path ); + + $res = realpath( $path ); + if ( is_string( $res ) ) + $path = $res; + + return $path; +} + function errbox($msg) { $len = strlen($msg)+4; $line = "+" . str_repeat("-", $len) . "+"; @@ -251,7 +285,7 @@ function generate_sources_file() // {{{ echo 'Iterating over files for sources info... '; $en_dir = "{$ac['rootdir']}/{$ac['EN_DIR']}"; $source_langs = array( - array('base', $ac['srcdir'], array('manual.xml.in', 'funcindex.xml')), + array('base', $ac['srcdir'], array('manual.xml', 'funcindex.xml')), array('en', $en_dir, find_xml_files($en_dir)), ); if ($ac['LANG'] !== 'en') { @@ -630,12 +664,6 @@ function getFileModificationHistory(): array { } -// We shouldn't be globbing for this. autoconf requires you to tell it which files to use, we should do the same -// Notice how doing it this way results in generating less than half as many files. -$infiles = array( - 'manual.xml.in', -); - // Show local repository status to facilitate debug $repos = array(); @@ -659,19 +687,45 @@ function getFileModificationHistory(): array { $output = str_replace( "\n\n" , "\n" , $output ); echo "\n" , trim( $output ) . "\n\n"; -foreach ($infiles as $in) { - $in = chop("{$ac['basedir']}/{$in}"); - $out = substr($in, 0, -3); - echo "Generating {$out}... "; - if (generate_output_file($in, $out, $ac)) { - echo "done\n"; - } else { - echo "fail\n"; - errors_are_bad(117); +xml_configure(); +function xml_configure() +{ + global $ac; + $lang = $ac["LANG"]; + $conf = []; + + $conf[] = ""; + + if ( $lang == 'en' ) + { + realpain( __DIR__ . "/temp/empty" , touch: true ); + $trans1 = realpain( __DIR__ . "/temp/empty" ); + $trans2 = realpain( __DIR__ . "/temp/empty" ); + $trans3 = realpain( __DIR__ . "/temp/empty" ); + } + else + { + $trans1 = realpain( __DIR__ . "/../$lang/language-defs.ent" ); + $trans2 = realpain( __DIR__ . "/../$lang/language-snippets.ent" ); + $trans3 = realpain( __DIR__ . "/../$lang/extensions.ent" ); } + $conf[] = ""; + $conf[] = ""; + $conf[] = ""; + + if ( $ac['CHMENABLED'] == 'yes' ) + { + $chmpath = realpain( __DIR__ . "/chm/manual.chm.xml" ); + $conf[] = ""; + } + else + $conf[] = ""; + + file_put_contents( __DIR__ . "/temp/manual.conf" , implode( "\n" , $conf ) ); } + if ($ac['SEGFAULT_ERROR'] === 'yes') { libxml_use_internal_errors(true); } diff --git a/manual.xml.in b/manual.xml similarity index 89% rename from manual.xml.in rename to manual.xml index 39213558c..0678298e2 100644 --- a/manual.xml.in +++ b/manual.xml @@ -1,39 +1,33 @@ - + -@TRANSLATION_ONLY_INCL_BEGIN@ - - - - -%language-defs; -%extensions; -%language-snippets; -@TRANSLATION_ONLY_INCL_END@ - - - - - + + +%configure; + + +%translation-defs; +%translation-snippets; +%translation-extensions; + + + + + %language-defs.default; %extensions.default; %language-snippets.default; - - - - - + + + - - %global.entities; %file.entities; %frontpage.entities; ]> - + &PHPManual; &bookinfo; @@ -465,15 +459,7 @@ - @CHMONLY_INCL_BEGIN@ - - &CHMEdition; - &chmonly.aboutchm; - &chmonly.usingchm; - &chmonly.search; - &chmonly.integration; - - @CHMONLY_INCL_END@ + &manual.chmonly;