hholzgra Thu Jul 3 07:31:19 2003 EDT
Modified files:
/pear/PECL_Gen Extension.php
Log:
README generation
code snippet adding re-enabled
version number prepared for mileston 0.7 release
Index: pear/PECL_Gen/Extension.php
diff -u pear/PECL_Gen/Extension.php:1.7 pear/PECL_Gen/Extension.php:1.8
--- pear/PECL_Gen/Extension.php:1.7 Wed Jul 2 13:37:32 2003
+++ pear/PECL_Gen/Extension.php Thu Jul 3 07:31:19 2003
@@no-spam -25,7 +25,7 @@no-spam
* A class that generates PECL extension soure and documenation files
*
* @no-spam public
- * @no-spam $Id: Extension.php,v 1.7 2003/07/02 17:37:32 hholzgra Exp $
+ * @no-spam $Id: Extension.php,v 1.8 2003/07/03 11:31:19 hholzgra Exp $
*/
class PECL_Gen_Extension extends PEAR {
@@no-spam -220,6 +220,11 @@no-spam
}
+ function add_code($type, $code)
+ {
+ $this->code[$type][] = $code;
+ }
+
// {{{ member adding functions
@@no-spam -418,6 +423,9 @@no-spam
// generate complete source code
$this->generate_source($dirpath);
+ // generate README file
+ $this->write_readme($dirpath);
+
// generate DocBook XML documantation for PHP manual
$manpath = $dirpath . "/manual/" . str_replace('_', '-', $this->name);
if (!@no-spam"-p $manpath")) {
@@no-spam -1632,24 +1640,109 @@no-spam
*/
function write_readme($dirpath)
{
- $fp = fopen("$dirpath/README", "w");
-
- fputs($fp, "");
-
$config_option = isset($this->with['attr']) ? "--with" : "--enable";
$config_option.= $this->name;
+
+ ob_start();
?>
+This is a standalone PHP extension created using PECL_Gen <?php echo self::version(); ?>
+
+
+HACKING
+=======
+
+There are two ways to modify an extension created using PECL_Gen:
+
+1) you can modify the generated code as with any other PHP extension
+
+2) you can add custom code to the PECL_Gen XML source and re-run pecl-gen
+
+The 2nd approach may look a bit complicated but you have be aware that any
+manual changes to the generated code will be lost if you ever change the
+XML specs and re-run PECL-Gen. All changes done before have to be applied
+to the newly generated code again.
+Adding code snippets to the XML source itself on the other hand may be a
+bit more complicated but this way your custom code will always be in the
+generated code no matter how often you rerun PECL_Gen.
+
+<?php if ($this->platform->test("unix")): ?>
+
+BUILDING ON UNIX etc.
+=====================
+
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
+1. $ ./phpize
+2. $ ./configure [<?php echo $config_option; ?>]
+3. $ make
+[4. $ make test ] # NOTE: this doesn't work right now *)
+5. $ [sudo] make install
+
+*) this is a general problem with "make test" and standalone extensions
+ (that is being worked on) so please don't blame PECL_Gen for this
+
+<?php endif; ?>
+
+<?php if ($this->platform->test("windows")): ?>
+
+BUILDING ON WINDOWS
+===================
+
+The extension provides the VisualStudio V6 project file
+
+ <?php echo $this->extname.".dsp" ?>
+
+To compile the extension you open this file using VisualStudio,
+select the apropriate configuration for your installation
+(either "Release_TS" or "Debug_TS") and create "php_<?php echo $this->name; ?>.dll"
+
+After successfull compilation you have to copy the newly
+created "php_<?php echo $this->name; ?>.dll" to the PHP
+extension directory (default: C:\PHP\extensions).
+
+<?php endif; ?>
+
+TESTING
+=======
+
+You can now load the extension using a php.ini directive
+
+ extension="php_<?php echo $this->name; ?>.[so|dll]"
+
+or load it at runtime using the dl() function
+
+ dl("php_<?php echo $this->name; ?>.[so|dll]");
+
+The extension should now be available, you can test this
+using the extension_loaded() function:
+
+ if (extension_loaded(<?php echo $this->name; ?>))
+ echo "<?php echo $this->name; ?> loaded :)";
+ else
+ echo "something is wrong :(";
+
+The extension will also add its own block to the output
+of phpinfo();
-See the README file for more infos in compiling, editing and testing.
<?php
+
+ $fp = fopen("$dirpath/README", "w");
+ fputs($fp, ob_get_contents());
+ ob_end_clean();
fclose($fp);
+ }
+
+
+ /**
+ * Current version number
+ *
+ * @no-spam public
+ * @no-spam string version
+ */
+ static function version()
+ {
+ return "0.7.0";
}
}