hholzgra Mon Jun 30 06:36:58 2003 EDT
Modified files:
/pear/PECL_Gen Extension.php pecl-gen
Log:
- will now only purge and overwrite existing target directory
if '--force' is requested on cmd line
- .cvsignore created with platform-specific entries
Index: pear/PECL_Gen/Extension.php
diff -u pear/PECL_Gen/Extension.php:1.4 pear/PECL_Gen/Extension.php:1.5
--- pear/PECL_Gen/Extension.php:1.4 Sun Jun 29 15:02:35 2003
+++ pear/PECL_Gen/Extension.php Mon Jun 30 06:36:57 2003
@@no-spam -23,7 +23,7 @@no-spam
* A class that generates PECL extension soure and documenation files
*
* @no-spam public
- * @no-spam $Id: Extension.php,v 1.4 2003/06/29 19:02:35 hholzgra Exp $
+ * @no-spam $Id: Extension.php,v 1.5 2003/06/30 10:36:57 hholzgra Exp $
*/
class PECL_Gen_Extension extends PEAR {
@@no-spam -397,18 +397,22 @@no-spam
* @no-spam public
* @no-spam string Directory to create (default is ./$this->name)
*/
- function create_extension($dirpath = false)
+ function create_extension($dirpath = false, $force = false)
{
// default: create dir in current working directory,
// dirname is the extensions base name
- if ($dirpath === false) {
+ if (empty($dirpath) || $dirpath == ".") {
$dirpath = "./" . $this->name;
}
// purge and create extension directory
if (file_exists($dirpath)) {
- if (!is_writeable($dirpath) || !@no-spam"-rf $dirpath")) {
- return $this->raiseError("can't purge '$dirpath'");
+ if ($force) {
+ if (!is_writeable($dirpath) || !@no-spam"-rf $dirpath")) {
+ return $this->raiseError("can't purge '$dirpath'");
+ }
+ } else {
+ return $this->raiseError("'$dirpath' already exists, can't create that directory (use '--force' to override)");
}
}
if (!@no-spam"-p $dirpath")) {
@@no-spam -458,6 +462,9 @@no-spam
$this->write_ms_devstudio_dsp($dirpath);
}
+ // generate .cvsignore file entries
+ $this->write_dot_cvsignore($dirpath);
+
// generate EXPERIMENTAL file for unstable release states
$this->write_experimental($dirpath);
@@no-spam -1435,6 +1442,9 @@no-spam
// }}}
+
+
+
/**
* Write authors to the CREDITS file
*
@@no-spam -1566,7 +1576,63 @@no-spam
}
}
+ /**
+ * Write .cvsignore entries
+ *
+ * @no-spam public
+ * @no-spam string directory to write to
+ */
+ function write_dot_cvsignore($dirpath)
+ {
+ // open output file
+ $fp = fopen("$dirpath/.cvsignore", "w");
+ // unix specific entries
+ if ($this->platform === "all" || in_array("unix", $this->platform)) {
+ fputs($fp, "*.lo\n");
+ fputs($fp, "*.la\n");
+ fputs($fp, ".deps\n");
+ }
+
+ // windows specific entries
+ if ($this->platform === "all" || in_array("win", $this->platform)) {
+ fputs($fp, "*.plg\n");
+ fputs($fp, "*.opt\n");
+ fputs($fp, "*.ncb\n");
+ fputs($fp, "Release\n");
+ fputs($fp, "Release_inline\n");
+ fputs($fp, "Debug\n");
+ fputs($fp, "Release_TS\n");
+ fputs($fp, "Release_TSDbg\n");
+ fputs($fp, "Release_TS_inline\n");
+ fputs($fp, "Debug_TS\n");
+ }
+
+ fclose($fp);
+ }
+
+ /**
+ * Describe next steps after successfull extension creation
+ *
+ * @no-spam private
+ * @no-spam string directory where extension was build
+ */
+ function success_msg($dirpath)
+ {
+ $config_option = isset($this->with['attr'] ? "--with" : "--enable";
+ $config_option.= $this->name;
+?>
+To compile your new extension, you will have to execute the following steps:
+
+1. $ cd <?php echo $dirpath ?>
+2. $ ./phpize
+3. $ ./configure [<?php echo $config_option; ?>]
+4. $ make
+
+...
+<?php
+ }
+
}
?>
Index: pear/PECL_Gen/pecl-gen
diff -u pear/PECL_Gen/pecl-gen:1.5 pear/PECL_Gen/pecl-gen:1.6
--- pear/PECL_Gen/pecl-gen:1.5 Sun Jun 29 15:16:15 2003
+++ pear/PECL_Gen/pecl-gen Mon Jun 30 06:36:57 2003
@@no-spam -5,7 +5,7 @@no-spam
* Console script to generate PECL extensions from command line
*
* @no-spam Hartmut Holzgraefe <hartmut@no-spam>
-* @no-spam $Id: pecl-gen,v 1.5 2003/06/29 19:16:15 hholzgra Exp $
+* @no-spam $Id: pecl-gen,v 1.6 2003/06/30 10:36:57 hholzgra Exp $
*/
// includes
@@no-spam -25,6 +25,7 @@no-spam
$options = Console_Getopt::getopt($argv, "h?",
array( "help",
"extname=",
+ "force",
"full-xml",
"no-help",
"proto=",
@@no-spam -45,6 +46,10 @@no-spam
die($err->get_message());
}
+ if (file_exists("./$extname") && !have_option($options, "force")) {
+ die("'$extname' already exists, can't create directory (use '--force' to override)");
+ }
+
if (have_option($options, "proto")) {
$proto_file = get_option_val($options, "proto");
@@no-spam -102,7 +107,7 @@no-spam
}
// and now create the actual PECL extension dir from the collected specs
-$err = $extension->create_extension();
+$err = $extension->create_extension(".", have_option($options, "force"));
if (PEAR::isError($err)) {
die($err->getMessage()." ".$err->getUserInfo());
}
@@no-spam -124,6 +129,7 @@no-spam
-h|--help this message
--extname=module module is the name of your extension
+ --force overwrite existing directories
--proto=file file contains prototypes of functions to create
the following options are inherited from ext_skel