wez             Mon Dec 22 20:54:07 2003 EDT

  Modified files:              
    /php-src/win32/build        buildconf.js 
  Log:
  win32 buildconf now honours extension dependencies and will
  try its best to ensure that the config.w32 files are amalgamated
  in such a way that modules are processed before their dependents.
  
  
Index: php-src/win32/build/buildconf.js
diff -u php-src/win32/build/buildconf.js:1.7 php-src/win32/build/buildconf.js:1.8
--- php-src/win32/build/buildconf.js:1.7        Mon Dec 22 10:01:05 2003
+++ php-src/win32/build/buildconf.js    Mon Dec 22 20:54:07 2003
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: buildconf.js,v 1.7 2003/12/22 15:01:05 wez Exp $ */
+/* $Id: buildconf.js,v 1.8 2003/12/23 01:54:07 wez Exp $ */
 // This generates a configure script for win32 build
 
 WScript.StdOut.WriteLine("Rebuilding configure.js");
@@ -24,7 +24,7 @@
 var C = FSO.CreateTextFile("configure.js", true);
 
 var modules = "";
-var seen = new Array();
+var MODULES = WScript.CreateObject("Scripting.Dictionary");
 
 function file_get_contents(filename)
 {
@@ -34,6 +34,15 @@
        return t;
 }
 
+function Module_Item(module_name, config_path, dir_line, deps, content)
+{
+       this.module_name = module_name;
+       this.config_path = config_path;
+       this.dir_line = dir_line;
+       this.deps = deps;
+       this.content = content;
+}
+
 function find_config_w32(dirname)
 {
        if (!FSO.FolderExists(dirname)) {
@@ -43,6 +52,9 @@
        var f = FSO.GetFolder(dirname);
        var     fc = new Enumerator(f.SubFolders);
        var c, i, ok, n;
+       var item = null;
+       var re_dep_line = new 
RegExp("ADD_EXTENSION_DEP\\([^,]*\\s*,\\s*['\"]([^'\"]+)['\"]\\);", "gm");
+       
        for (; !fc.atEnd(); fc.moveNext())
        {
                ok = true;
@@ -54,13 +66,7 @@
                        continue;
                        
        //      WScript.StdOut.WriteLine("checking " + dirname + "/" + n);
-               for (i = 0; i < seen.length; i++) {
-                       if (seen[i] == n) {
-                               ok = false;
-                               break;
-                       }
-               }
-               if (!ok) {
+               if (MODULES.Exists(n)) {
                        WScript.StdOut.WriteLine("Skipping " + dirname + "/" + n + " 
-- already have a module with that name");
                        continue;
                }
@@ -68,13 +74,78 @@
                        
                c = FSO.BuildPath(fc.item(), "config.w32");
                if (FSO.FileExists(c)) {
-                       //WScript.StdOut.WriteLine(c);
-                       modules += "configure_module_dirname = 
condense_path(FSO.GetParentFolderName('" + c.replace(new RegExp('(["\\\\])', "g"), 
'\\$1') + "'));\r\n";
-                       modules += file_get_contents(c);
+//                     WScript.StdOut.WriteLine(c);
+
+                       var dir_line = "configure_module_dirname = 
condense_path(FSO.GetParentFolderName('"
+                                                               + c.replace(new 
RegExp('(["\\\\])', "g"), '\\$1') + "'));\r\n";
+                       var contents = file_get_contents(c);
+                       var deps = new Array();
+
+                       // parse out any deps from the file
+                       var calls = contents.match(re_dep_line);
+                       if (calls != null) {
+                               for (i = 0; i < calls.length; i++) {
+                                       // now we need the extension name out of this 
thing
+                                       if (calls[i].match(re_dep_line)) {
+//                                             WScript.StdOut.WriteLine("n depends on 
" + RegExp.$1);
+                                               deps[deps.length] = RegExp.$1;
+                                       }
+                               }
+                       }
+
+                       item = new Module_Item(n, c, dir_line, deps, contents);
+                       MODULES.Add(n, item);
+               }
+       }
+}
+
+function emit_module(item)
+{
+       return item.dir_line + item.content;
+}
+
+function emit_dep_modules(module_names)
+{
+       var i, mod_name, j;
+       var output = "";
+
+       for (i in module_names) {
+               mod_name = module_names[i];
+
+               if (!MODULES.Exists(mod_name)) {
+                       output += emit_module(item);
+                       continue;
+               }
                
-                       seen[seen.length] = n;
+               item = MODULES.Item(mod_name);
+               output += emit_dep_modules(item.deps);  
+       }
+
+       return output;
+}
+
+function gen_modules()
+{
+       var module_names = (new VBArray(MODULES.Keys())).toArray();
+       var i, mod_name, j;
+       var item;
+       var output = "";
+
+       // first, look for modules with empty deps; emit those first
+       for (i in module_names) {
+               mod_name = module_names[i];
+               item = MODULES.Item(mod_name);
+               if (item.deps.length == 0) {
+                       MODULES.Remove(mod_name);
+                       output += emit_module(item);
                }
        }
+
+       // now we are left with modules that have dependencies on other modules
+       module_names = (new VBArray(MODULES.Keys())).toArray();
+       output += emit_dep_modules(module_names);
+
+       return output;
 }
 
 if (FSO.FileExists("ZendEngine2\\OBJECTS2_HOWTO")) {
@@ -90,12 +161,19 @@
 
 // Pull in code from sapi and extensions
 modules = file_get_contents("win32/build/config.w32");
+
 // Pick up confs from TSRM and Zend if present
 find_config_w32(".");
 find_config_w32("sapi");
 find_config_w32("ext");
 find_config_w32("pecl");
 find_config_w32("..\\pecl");
+find_config_w32("pecl\\rpc");
+find_config_w32("..\\pecl\\rpc");
+
+// Now generate contents of module based on MODULES, chasing dependencies
+// to ensure that dependent modules are emitted first
+modules += gen_modules();
 
 // Look for ARG_ENABLE or ARG_WITH calls
 re = new RegExp("(ARG_(ENABLE|WITH)\([^;]+\);)", "gm");

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to