gwynne Tue Jun 26 00:10:59 2007 UTC
Added files:
/livedocs build.php
Removed files:
/livedocs build-ops.in
Modified files:
/livedocs build.sh config.php.in configure.in
Log:
Port the index/toc/notes builder to PHP, simplify the build system a little.
build.php can be run directly, or build.sh uses the configured php to run it.
build-ops was only used by build.sh, which is now a simple wrapper
http://cvs.php.net/viewvc.cgi/livedocs/build.sh?r1=1.34&r2=1.35&diff_format=u
Index: livedocs/build.sh
diff -u livedocs/build.sh:1.34 livedocs/build.sh:1.35
--- livedocs/build.sh:1.34 Tue Jun 19 23:33:48 2007
+++ livedocs/build.sh Tue Jun 26 00:10:59 2007
@@ -1,91 +1,5 @@
#!/bin/sh
-. ./build-ops
+PHP=`grep "define('PHP_PATH', *" config.php | awk '{ n=match($0,", "); print
substr($0, n+3, length($0)-n-5); }'`
+${PHP} ./build.php
-exec > "${BUILDLOG}" 2>&1
-
-echo "####################"
-
-#if test -n "$NOTES_MIRROR$NOTES_TOKEN" ; then
- echo "Building user notes"
- TOKEN=$NOTES_TOKEN
- export TOKEN
- ${PHP} "${LIVEDOCS}/mk_notes.php" "${OUTPUTDIR}" "${GENDIR}"
${NOTES_MIRROR}
-#fi
-
-# running ./buildconf
-cd "${PHPDOC}"
-autoconf
-
-# Making indexes for every language
-curpath=`pwd`
-for i in ${LANGUAGES};
-do
- if test "$CONFIGURE_PHP_DOC" != "no" ; then
- echo -n "Configuring ${BUILDTYPE} for $i: "
- date
- cd "${PHPDOC}"
- if ! ./configure --with-lang=$i --with-php="${PHP}"
$PHPDOC_CONFIG_OPTS ; then
- continue
- fi
- fi
-
- cd "${GENDIR}"
-
- # Making TOC as SQL insertion script if we're doing the english build
- if test "$i" = "en"; then
- echo -n "Making TOC: "
- date
-
- if test -e "${LIVEDOCS}/toc_${BUILDTYPE}.xsl"; then
- XSLTFILE="toc_${BUILDTYPE}.xsl"
- else
- XSLTFILE=toc.xsl
- fi
-
- if ! ${XSLTPROC} "${LIVEDOCS}/${XSLTFILE}"
"${PHPDOC}/manual.xml" > "${GENDIR}/toc-ugly.xml" ; then
- continue
- fi
-
- #Just for debuging
- #xmllint --format ${GENDIR}/toc-ugly.xml > ${GENDIR}/toc.xml
-
- ${PHP} "${LIVEDOCS}/mktoc.php" "${GENDIR}/toc-ugly.xml" >
"${GENDIR}/toc-insert.sql"
- fi
-
- echo -n "Making index for $i: "
- date
- ${PHP} "${LIVEDOCS}/mkindex.php" "${PHPDOC}" $i "${GENDIR}" ${BUILDTYPE}
- mv "${GENDIR}/livedoc-idx.$i.sqlite" "${OUTPUTDIR}"
- # create output dir
- mkdir -p "${OUTPUTDIR}/$i"
- chmod 0777 "${OUTPUTDIR}/$i"
- # remove cached manual pages
- rm -f "${OUTPUTDIR}/$i/*${FILECACHE_EXT}"
- # make search cache database
- mv "${GENDIR}/livedoc-cache-idx.$i.sqlite" "${OUTPUTDIR}/$i/"
- chmod 0666 "${OUTPUTDIR}/$i/livedoc-cache-idx.$i.sqlite"
-
- if test "$i" = "en"; then
- echo "Copying image examples from ${PHPDOC}/en"
- mkdir "${OUTPUTDIR}/figures"
- for folder in `find "${PHPDOC}/en" -type d -name figures`; do
- echo $folder
- sect=`dirname ${folder} | xargs basename`
- for file in ${folder}/*; do
- if test -f "$file"; then
- name=`basename "${file}"`
- echo cp "${file}"
"${OUTPUTDIR}/figures/${sect}.${name}"
- fi
- done
- done
- echo "Done"
- fi
-
- cd $curpath
-done;
-
-echo -n "End: "
-date
-
-rm -f "${GENDIR}/toc-ugly.xml" "${GENDIR}/toc-insert.sql"
http://cvs.php.net/viewvc.cgi/livedocs/config.php.in?r1=1.13&r2=1.14&diff_format=u
Index: livedocs/config.php.in
diff -u livedocs/config.php.in:1.13 livedocs/config.php.in:1.14
--- livedocs/config.php.in:1.13 Tue Jun 19 23:22:52 2007
+++ livedocs/config.php.in Tue Jun 26 00:10:59 2007
@@ -19,10 +19,17 @@
// | the ./configure call |
// +----------------------------------------------------------------------+
//
-// $Id: config.php.in,v 1.13 2007/06/19 23:22:52 philip Exp $
+// $Id: config.php.in,v 1.14 2007/06/26 00:10:59 gwynne Exp $
+define('PHP_PATH', '@PHP@');
+define('BUILD_LOG', '@BUILDLOG@');
define('FALLBACK_LANG', 'en');
define('PHPDOC', '@PHPDOC@');
+define('GENDIR', '@GENDIR@');
+define('XSLTPROC_PATH', '@XSLTPROC@');
+define('NOTES_MIRROR', '@NOTES_MIRROR@');
+define('NOTES_TOKEN', '@NOTES_TOKEN@');
+define('LIVEDOCS', '@LIVEDOCS@');
define('OUTPUTDIR', '@OUTPUTDIR@');
if (!defined('FORCE_DYNAMIC')) { // could already be defined by pregenerate.php
define('FORCE_DYNAMIC', @FORCE_DYNAMIC@);
http://cvs.php.net/viewvc.cgi/livedocs/configure.in?r1=1.35&r2=1.36&diff_format=u
Index: livedocs/configure.in
diff -u livedocs/configure.in:1.35 livedocs/configure.in:1.36
--- livedocs/configure.in:1.35 Tue Jun 19 23:22:52 2007
+++ livedocs/configure.in Tue Jun 26 00:10:59 2007
@@ -1,5 +1,5 @@
## A configure script
-## $Id: configure.in,v 1.35 2007/06/19 23:22:52 philip Exp $
+## $Id: configure.in,v 1.36 2007/06/26 00:10:59 gwynne Exp $
AC_PREREQ(2.13)
AC_INIT(livedoc.php)
@@ -132,7 +132,7 @@
AC_SUBST(NOTES_MIRROR)
AC_SUBST(NOTES_TOKEN)
-AC_OUTPUT(build-ops config.php .htaccess)
+AC_OUTPUT(config.php .htaccess)
if ! test -d "$OUTPUTDIR" ; then
AC_MSG_ERROR([HEY!! You should probably mkdir $OUTPUTDIR...])
http://cvs.php.net/viewvc.cgi/livedocs/build.php?view=markup&rev=1.1
Index: livedocs/build.php
+++ livedocs/build.php
<?php
require_once dirname( __FILE__ ) . '/config.php';
$PHP = PHP_PATH;
$BUILDLOG = BUILD_LOG;
$PHPDOC = PHPDOC;
$BUILDTYPE = BUILD_TYPE;
$LIVEDOCS = LIVEDOCS;
$OUTPUTDIR = OUTPUTDIR;
$GENDIR = GENDIR;
$XSLTPROC = XSLTPROC_PATH;
$FILECACHE_EXT = FILECACHE_EXT;
$LANGUAGES = LANGUAGES;
$NOTES_MIRROR = NOTES_MIRROR;
$NOTES_TOKEN = NOTES_TOKEN;
function buildmsg( $message ) {
static $log_file = NULL;
if ( isset( $_ENV[ 'BUILD_PHP_DEBUG' ] ) ) {
print "{$message}\n";
return;
}
if ( $log_file === NULL ) {
if ( ( $log_file = fopen( $GLOBALS[ 'BUILDLOG' ], 'w' ) ) ===
FALSE )
die( "Error opening build log.\n" );
}
fprintf( $log_file, "%s\n", $message );
}
/*
function call_php_file( $file, $params ) {
if ( file_exists( $file ) ) {
$old_argc = $_SERVER[ 'argc' ];
$old_argv = $_SERVER[ 'argv' ];
$_SERVER[ 'argc' ] = count( $params ) + 1;
$_SERVER[ 'argv' ] = array_merge( array( $file ), $params );
if ( isset( $GLOBALS[ 'argc' ] ) ) $GLOBALS[ 'argc' ] =
$_SERVER[ 'argc' ];
if ( isset( $GLOBALS[ 'argv' ] ) ) $GLOBALS[ 'argv' ] =
$_SERVER[ 'argv' ];
if ( isset( $ENV[ 'argc' ] ) ) $ENV[ 'argc' ] = $_SERVER[
'argc' ];
if ( isset( $ENV[ 'argv' ] ) ) $ENV[ 'argv' ] = $_SERVER[
'argv' ];
require_once $file;
$_SERVER[ 'argc' ] = $old_argc;
$_SERVER[ 'argv' ] = $old_argv;
if ( isset( $GLOBALS[ 'argc' ] ) ) $GLOBALS[ 'argc' ] =
$_SERVER[ 'argc' ];
if ( isset( $GLOBALS[ 'argv' ] ) ) $GLOBALS[ 'argv' ] =
$_SERVER[ 'argv' ];
if ( isset( $ENV[ 'argc' ] ) ) $ENV[ 'argc' ] = $_SERVER[
'argc' ];
if ( isset( $ENV[ 'argv' ] ) ) $ENV[ 'argv' ] = $_SERVER[
'argv' ];
}
}
*/
function sneaky_shell_exec( $command ) {
exec( $command, $output, $result );
foreach ( $output as $line )
buildmsg( trim( substr( $line, strrpos( $line, "\r" ) ) ) );
return $result;
}
function parse_options() {
// No Console_Getopt, no decent getopt() implementation; just use the
old environment vars for now
define( 'CONFIGURE_PHP_DOC', isset( $_ENV[ 'CONFIGURE_PHP_DOC' ] ) ?
$_ENV[ 'CONFIGURE_PHP_DOC' ] : TRUE );
define( 'PHPDOC_CONFIG_OPTS', isset( $_ENV[ 'PHPDOC_CONFIG_OPTS' ] ) ?
$_ENV[ 'PHPDOC_CONFIG_OPTS' ] : '' );
}
// ----------------------------------------------------------------------------
// FIXME: Instead of buffering all shell output in memory before writing to
file, use proc_open() with file descriptors and append the data directly to the
build.log
parse_options();
buildmsg( '####################' );
// if ( strlen( "{$NOTES_MIRROR}{$NOTES_TOKEN}" ) != 0 ) {
buildmsg( "Building user notes" );
putenv( "TOKEN={$NOTES_TOKEN}" );
sneaky_shell_exec( "{$PHP} -f \"{$LIVEDOCS}/mk_notes.php\"
\"{$OUTPUTDIR}\" \"{$GENDIR}\" \"{$NOTES_MIRROR}\"" );
// }
chdir( $PHPDOC );
if ( CONFIGURE_PHP_DOC )
if ( sneaky_shell_exec( "autoconf" ) != 0 )
die( "autoconf in {$PHPDOC} failed!" );
$curpath = getcwd();
foreach ( explode( ' ', $LANGUAGES ) as $i ) {
if ( CONFIGURE_PHP_DOC ) {
buildmsg( "Configuring {$BUILDTYPE} for {$i}: " . date(
DATE_RFC2822 ) );
chdir( $PHPDOC );
if ( sneaky_shell_exec( "./configure --with-lang=" .
escapeshellarg( $i ) . " --with-php=\"{$PHP}\" " . PHPDOC_CONFIG_OPTS ) != 0 )
continue;
}
chdir( $GENDIR );
if ( $i == 'en' ) {
buildmsg( "Making TOC: " . date( DATE_RFC2822 ) );
if ( file_exists( "{$LIVEDOCS}/toc_{$BUILDTYPE}.xsl" ) )
$XSLTFILE = "toc_{$BUILDTYPE}.xsl";
else
$XSLTFILE = "toc.xsl";
if ( sneaky_shell_exec( "{$XSLTPROC} --output
\"{$GENDIR}/toc-ugly.xml\" \"{$LIVEDOCS}/{$XSLTFILE}\"
\"{$PHPDOC}/manual.xml\"" ) != 0 )
continue;
// For debugging:
// sneaky_shell_exec( "xmllint --format
\"{$GENDIR}/toc-ugly.xml\" > {$GENDIR}/toc.xml" );
sneaky_shell_exec( "{$PHP} -f \"{$LIVEDOCS}/mktoc.php\" >
\"{$GENDIR}/toc-insert.sql\"" );
}
buildmsg( "Making index for {$i}: " . date( DATE_RFC2822 ) );
sneaky_shell_exec( "{$PHP} -f \"{$LIVEDOCS}/mkindex.php\" \"{$PHPDOC}\"
{$i} \"{$GENDIR}\" \"{$BUILDTYPE}\"" );
rename( "{$GENDIR}/livedoc-idx.{$i}.sqlite",
"{$OUTPUTDIR}/livedoc-idx.{$i}.sqlite" );
// Create output dir
@mkdir( "{$OUTPUTDIR}/{$i}", 0777, TRUE );
// Remove old cache
foreach ( glob( "{$OUTPUTDIR}/{$i}/*{$FILECACHE_EXT}" ) as $f )
@unlink( $f );
// Make search cache database
rename( "{$GENDIR}/livedoc-cache-idx.{$i}.sqlite",
"{$OUTPUTDIR}/{$i}/licedoc-cache-idx.{$i}.sqlite" );
chmod( "{$OUTPUTDIR}/{$i}/livedoc-cache-idx.{$i}.sqlite", 0666 );
if ( $i == 'en' ) {
buildmsg( "Copying image examples from {$PHPDOC}/en" );
@mkdir( "{$OUTPUTDIR}/figures", 0777, TRUE );
foreach( explode( "\n", trim( shell_exec( "find
\"{$PHPDOC}/en\" -type d -and -name figures" ) ) ) as $folder ) {
buildmsg( $folder );
$sect = basename( dirname( $folder ) );
foreach ( glob( "{$folder}/*" ) as $file ) {
if ( is_file( $file ) ) {
$name = basename( $file );
copy( $file,
"{$OUTPUTDIR}/figures/{$sect}.{$name}" );
}
}
}
buildmsg( "Done" );
}
chdir( $curpath );
}
buildmsg( "End: " . date( DATE_RFC2822 ) );
@unlink( "{$GENDIR}/toc-ugly.xml" );
@unlink( "{$GENDIR}/toc-insert.sql" );
?>