cvs: php4 /pear/scripts pearize.in

From: Date: Tue, 28 Aug 2001 11:18:14 +0000
Subject: cvs: php4 /pear/scripts pearize.in
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-676@lists.php.net to get a copy of this message
ssb Tue Aug 28 07:18:14 2001 EDT Modified files: /php4/pear/scripts pearize.in Log: * started work on php file support Index: php4/pear/scripts/pearize.in diff -u php4/pear/scripts/pearize.in:1.3 php4/pear/scripts/pearize.in:1.4 --- php4/pear/scripts/pearize.in:1.3 Tue Aug 28 04:52:03 2001 +++ php4/pear/scripts/pearize.in Tue Aug 28 07:18:08 2001 @@ -1,12 +1,14 @@ #!@prefix@/bin/php -Cq <?php // -*- PHP -*- -main($argc, $argv, $HTTP_ENV_VARS); +main($argc, $argv, $_ENV); // {{{ main() function main(&$argc, &$argv, &$env) { + global $debug; + $debug = false; $file = check_options($argc, $argv, $env); parse_package_file($file); make_makefile_in($env); @@ -15,11 +17,30 @@ // }}} // {{{ check_options() -function check_options(&$argc, &$argv, &$env) +function check_options($argc, $argv, $env) { - $file = $argv[1]; + global $debug; + array_shift($argv); + while ($argv[0]{0} == '-' && $argv[0] != '-') { + $opt = array_shift($argv); + switch ($opt) { + case '--': { + break 2; + } + case '-d': { + $debug = true; + break; + } + default: { + die("pearize: unrecognized option `$opt'\n"); + } + } + } + $file = array_shift($argv); if (empty($file)) { $file = "package.xml"; + } elseif ($file == '-') { + $file = "php://stdin"; } return $file; } @@ -29,14 +50,16 @@ function make_makefile_in(&$env) { - global $libdata; - if (sizeof($libdata) == 0) { - exit; - } elseif (sizeof($libdata) > 1) { + global $libdata, $debug; + if (sizeof($libdata) > 1) { die("No support yet for multiple libraries in one package.\n"); } - $wp = @fopen("Makefile.in", "w"); + if ($debug) { + $wp = fopen("php://stdout", "w"); + } else { + $wp = @fopen("Makefile.in", "w"); + } if (is_resource($wp)) { print "Creating Makefile.in..."; flush(); @@ -44,17 +67,22 @@ die("Could not create Makefile.in in current directory.\n"); } + $who = $env["USER"]; + $when = gmdate('Y-m-d h:i'); + fwrite($wp, "# This file was generated by `pearize' by $who at $when GMT\n\n"); + foreach ($libdata as $lib => $info) { extract($info); - $_who = $env["USER"]; - $_when = gmdate('Y-m-d h:i'); - fwrite($wp, "# This file was generated by `pearize' by $_who at $_when GMT + fwrite($wp, "\ INCLUDES = $includes LTLIBRARY_NAME = lib{$lib}.la LTLIBRARY_SOURCES = $sources LTLIBRARY_SHARED_NAME = {$lib}.la LTLIBRARY_SHARED_LIBADD = $libadd "); + } + + if (sizeof($libdata) > 0) { fwrite($wp, "include \$(top_srcdir)/build/dynlib.mk\n"); } fclose($wp); @@ -67,12 +95,15 @@ function parse_package_file($file) { global $in_file, $curlib, $curelem, $libdata, $cdata; + global $currinstalldir, $baseinstalldir; $in_file = false; $curlib = ''; $curelem = ''; $libdata = array(); $cdata = array(); + $baseinstalldir = array(); + $currinstalldir = array(); $xp = xml_parser_create(); xml_set_element_handler($xp, "start_handler", "end_handler"); @@ -94,10 +125,13 @@ function start_handler($xp, $elem, $attrs) { - global $cdata, $in_file, $curelem; + global $cdata, $in_file, $curelem, $curfile, $filerole; + global $baseinstalldir, $currinstalldir; switch ($elem) { case "FILE": { - switch ($attrs['ROLE']) { + $curfile = ''; + $filerole = $attrs['ROLE']; + switch ($filerole) { case "ext": { $in_file = true; $cdata = array(); @@ -109,6 +143,17 @@ } break; } + case "DIR": { + $cdir = $currinstalldir[sizeof($currinstalldir)-1]; + $bdir = $baseinstalldir[sizeof($baseinstalldir)-1]; + array_push($currinstalldir, "$cdir/{$attrs[NAME]}"); + if (isset($attrs["BASEINSTALLDIR"])) { + array_push($baseinstalldir, "$bdir/{$attrs[BASEINSTALLDIR]}"); + } else { + array_push($baseinstalldir, $bdir); + } + break; + } case "INCLUDES": case "LIBNAME": case "LIBADD": @@ -125,6 +170,7 @@ function end_handler($xp, $elem) { global $in_file, $curlib, $curelem, $libdata, $cdata; + global $baseinstalldir, $currinstalldir; switch ($elem) { case "FILE": { if ($in_file === true) { @@ -138,6 +184,11 @@ } break; } + case "DIR": { + array_pop($currinstalldir); + array_pop($baseinstalldir); + break; + } } } @@ -146,8 +197,12 @@ function cdata_handler($xp, $data) { - global $curelem, $cdata; + global $curelem, $cdata, $curfile; switch ($curelem) { + case "FILE": { + $curfile .= $data; + break; + } case "INCLUDES": case "LIBADD": case "LIBNAME":

« previous php.pear.cvs (#676) next »