hholzgra Wed Jul 2 13:37:32 2003 EDT
Modified files:
/pear/PECL_Gen Extension.php ExtensionParser.php pecl-gen
/pear/PECL_Gen/Tools Platform.php
Log:
platform specific stuff now has its own helper class
Index: pear/PECL_Gen/Extension.php
diff -u pear/PECL_Gen/Extension.php:1.6 pear/PECL_Gen/Extension.php:1.7
--- pear/PECL_Gen/Extension.php:1.6 Mon Jun 30 07:46:44 2003
+++ pear/PECL_Gen/Extension.php Wed Jul 2 13:37:32 2003
@@no-spam -17,13 +17,15 @@no-spam
require_once "PECL/Gen/Release.php";
+ require_once "PECL/Gen/Tools/Platform.php";
+
// }}}
/**
* A class that generates PECL extension soure and documenation files
*
* @no-spam public
- * @no-spam $Id: Extension.php,v 1.6 2003/06/30 11:46:44 hholzgra Exp $
+ * @no-spam $Id: Extension.php,v 1.7 2003/07/02 17:37:32 hholzgra Exp $
*/
class PECL_Gen_Extension extends PEAR {
@@no-spam -74,7 +76,7 @@no-spam
*
* @no-spam string
*/
- var $platform = "all";
+ var $platform = null;
/**
@@no-spam -161,6 +163,8 @@no-spam
$this->headers = array();
$this->release = new PECL_Gen_Release;
+
+ $this->platform = new PECL_Gen_Tools_Platform("all");
}
// }}}
@@no-spam -207,29 +211,16 @@no-spam
function set_platform($type)
{
- switch (strtolower($type)) {
- case "all":
- $this->platform = "all";
- return true;
- case "win":
- case "win23":
- case "windows":
- case "microsoft":
- $this->platform = "win";
- return true;
- case "unix":
- case "posix":
- case "gnu":
- $this->platform = "unix";
- return true;
- default:
- break;
+ $this->platform = new PECL_Gen_Tools_Platform($type);
+ if (PEAR::isError($this->platform)) {
+ return $this->platform;
}
- return $this->raiseError("'$type' is not a supported implementation platform");
+ return true;
}
+
// {{{ member adding functions
/**
@@no-spam -453,12 +444,12 @@no-spam
}
// generate project files for configure (unices and similar platforms like cygwin)
- if ($this->platform === "all" || in_array("unix", $this->platform)) {
+ if ($this->platform->test("unix")) {
$this->write_config_m4($dirpath);
}
// generate project files for Windows platform (VisualStudio/C++ V6)
- if ($this->platform === "all" || in_array("win32", $this->platform)) {
+ if ($this->platform->test("windows")) {
$this->write_ms_devstudio_dsp($dirpath);
}
@@no-spam -1211,7 +1202,7 @@no-spam
$first = true;
foreach ($this->libs as $lib) {
- if (is_array($lib['platform']) && !in_array("unix", $lib['platform'])) {
+ if (!$lib["platform"]->test("unix")) {
continue;
}
@@no-spam -1276,7 +1267,7 @@no-spam
// add libraries from <deps> section
if (count($this->libs)) {
foreach ($this->libs as $lib) {
- if (is_array($lib['platform']) && !in_array("win32", $lib['platform'])) {
+ if (!$lib["platform"]->test("windows")) {
continue;
}
$winlibs .= " $lib[name].lib";
@@no-spam -1546,8 +1537,8 @@no-spam
foreach (array("conf", "c", "h") as $type) {
foreach ($this->package_files[$type] as $file) {
- echo " <file role=\"src\">$file</file>\n";
- }
+ echo " <file role=\"src\">$file</file>\n";
+ }
}
echo " </dir>\n";
@@no-spam -1588,14 +1579,14 @@no-spam
$fp = fopen("$dirpath/.cvsignore", "w");
// unix specific entries
- if ($this->platform === "all" || in_array("unix", $this->platform)) {
+ if ($this->platform->test("unix")) {
fputs($fp, "*.lo\n");
fputs($fp, "*.la\n");
fputs($fp, ".deps\n");
}
// windows specific entries
- if ($this->platform === "all" || in_array("win", $this->platform)) {
+ if ($this->platform->test("windows")) {
fputs($fp, "*.plg\n");
fputs($fp, "*.opt\n");
fputs($fp, "*.ncb\n");
@@no-spam -1624,6 +1615,27 @@no-spam
$dirpath = $this->name;
}
+ $msg = "Your extension has been created in directory $dirpath.\n";
+ if (!isset($this->readme)) {
+ $msg.= "See $dirpath/README for further instructions.\n";
+ }
+
+ return $msg;
+ }
+
+
+ /**
+ * Generate README file (custom or default)
+ *
+ * @no-spam private
+ * @no-spam string directory to write to
+ */
+ function write_readme($dirpath)
+ {
+ $fp = fopen("$dirpath/README", "w");
+
+ fputs($fp, "");
+
$config_option = isset($this->with['attr']) ? "--with" : "--enable";
$config_option.= $this->name;
?>
@@no-spam -1634,10 +1646,11 @@no-spam
3. $ ./configure [<?php echo $config_option; ?>]
4. $ make
-...
+See the README file for more infos in compiling, editing and testing.
<?php
+
+ fclose($fp);
}
-
}
?>
Index: pear/PECL_Gen/ExtensionParser.php
diff -u pear/PECL_Gen/ExtensionParser.php:1.3 pear/PECL_Gen/ExtensionParser.php:1.4
--- pear/PECL_Gen/ExtensionParser.php:1.3 Sun Jun 29 13:24:00 2003
+++ pear/PECL_Gen/ExtensionParser.php Wed Jul 2 13:37:32 2003
@@no-spam -457,12 +457,17 @@no-spam
{
$this->extension->libs[$attr['name']] = $attr;
if (isset($attr['platform'])) {
- if ($attr['platform'] != "all") {
- $this->extension->libs[$attr['name']]['platform'] = split("[[:space:]]*,[[:space:]]*", trim($attr['platform']));
- }
+ $platform = new PECL_Gen_Tools_Platform($attr["platform"]);
} else {
- $this->extension->libs[$attr['name']]['platform'] = "all";
+ $platform = new PECL_Gen_Tools_Platform("all");
}
+
+ if (PEAR::isError($platform)) {
+ return $platform;
+ }
+
+ $this->extension->libs[$attr['name']]['platform'] = $platform;
+ return true;
}
function tagstart_deps_header($attr)
Index: pear/PECL_Gen/pecl-gen
diff -u pear/PECL_Gen/pecl-gen:1.9 pear/PECL_Gen/pecl-gen:1.10
--- pear/PECL_Gen/pecl-gen:1.9 Wed Jul 2 11:59:14 2003
+++ pear/PECL_Gen/pecl-gen Wed Jul 2 13:37:32 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.9 2003/07/02 15:59:14 hholzgra Exp $
+* @no-spam $Id: pecl-gen,v 1.10 2003/07/02 17:37:32 hholzgra Exp $
*/
// includes
@@no-spam -136,7 +136,7 @@no-spam
}
if (!$options->have("quiet")) {
- $ext->success_msg($extname);
+ echo $ext->success_msg($extname);
}
}
@@no-spam -212,7 +212,7 @@no-spam
}
if (!$options->have("quiet")) {
- $ext->success_msg($extname);
+ echo $extension->success_msg($extension->name);
}
exit(0);
Index: pear/PECL_Gen/Tools/Platform.php
diff -u pear/PECL_Gen/Tools/Platform.php:1.1 pear/PECL_Gen/Tools/Platform.php:1.2
--- pear/PECL_Gen/Tools/Platform.php:1.1 Wed Jul 2 12:54:46 2003
+++ pear/PECL_Gen/Tools/Platform.php Wed Jul 2 13:37:32 2003
@@no-spam -72,12 +72,12 @@no-spam
case "win23":
case "windows":
case "microsoft":
- return isset($this->platform["win"]);
+ return isset($this->platforms["win"]);
case "unix":
case "posix":
case "gnu":
- return ($this->platform["unix"]);
+ return ($this->platforms["unix"]);
default:
return false;