-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id: buildconf.js,v 1.13.2.2.2.1.2.5 2009-01-02 12:18:21 kalle Exp $ */
-// This generates a configure script for win32 build
-
-WScript.StdOut.WriteLine("Rebuilding configure.js");
-var FSO = WScript.CreateObject("Scripting.FileSystemObject");
-var C = FSO.CreateTextFile("configure.js", true);
-var B = FSO.CreateTextFile("configure.bat", true);
-var DSP = false;
-
-var modules = "";
-var MODULES = WScript.CreateObject("Scripting.Dictionary");
-var module_dirs = new Array();
-
-function file_get_contents(filename)
-{
- var F = FSO.OpenTextFile(filename, 1);
- var t = F.ReadAll();
- F.Close();
- 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)) {
- return;
- }
-
- 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;
- /* check if we already picked up a module with the same dirname;
- * if we have, don't include it here */
- n = FSO.GetFileName(fc.item());
-
- if (n == 'CVS' || n == 'tests')
- continue;
-
- // WScript.StdOut.WriteLine("checking " + dirname + "/" + n);
- if (MODULES.Exists(n)) {
- WScript.StdOut.WriteLine("Skipping " + dirname + "/" + n + " -- already have a module with that name");
- continue;
- }
-
- c = FSO.BuildPath(fc.item(), "config.w32");
- if (FSO.FileExists(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);
- }
- }
-}
-
-// Emit core modules array. This is used by a snapshot
-// build to override a default "yes" value so that external
-// modules don't break the build by becoming statically compiled
-function emit_core_module_list()
-{
- var module_names = (new VBArray(MODULES.Keys())).toArray();
- var i, mod_name, j;
- var item;
- var output = "";
-
- C.WriteLine("core_module_list = new Array(");
-
- // first, look for modules with empty deps; emit those first
- for (i in module_names) {
- mod_name = module_names[i];
- C.WriteLine("\"" + mod_name.replace(/_/g, "-") + "\",");
- }
-
- C.WriteLine("false // dummy");
-
- C.WriteLine(");");
-}
-
-
-function emit_module(item)
-{
- return item.dir_line + item.content;
-}
-
-function emit_dep_modules(module_names)
-{
- var i, mod_name, j;
- var output = "";
- var item = null;
-
- for (i in module_names) {
- mod_name = module_names[i];
-
- if (MODULES.Exists(mod_name)) {
- item = MODULES.Item(mod_name);
- MODULES.Remove(mod_name);
- if (item.deps.length) {
- output += emit_dep_modules(item.deps);
- }
- output += emit_module(item);
- }
- }
-
- 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;
-}
-
-// Process buildconf arguments
-function buildconf_process_args()
-{
- args = WScript.Arguments;
-
- for (i = 0; i < args.length; i++) {
- arg = args(i);
- // If it is --foo=bar, split on the equals sign
- arg = arg.split("=", 2);
- argname = arg[0];
- if (arg.length > 1) {
- argval = arg[1];
- } else {
- argval = null;
- }
-
- if (argname == '--add-modules-dir' && argval != null) {
- WScript.StdOut.WriteLine("Adding " + argval + " to the module search path");
- module_dirs[module_dirs.length] = argval;
- }
-
- if (argname == '--add-project-files') {
- WScript.StdOut.WriteLine("Adding dsp templates into the mix");
- DSP = true;
- }
- }
-}
-
-buildconf_process_args();
-
-// Write the head of the configure script
-C.WriteLine("/* This file automatically generated from win32/build/confutils.js */");
-C.Write(file_get_contents("win32/build/confutils.js"));
-
-// If project files were requested, pull in the code to generate them
-if (DSP == true) {
- C.WriteLine('PHP_DSP="yes"');
- C.WriteBlankLines(1);
- C.Write(file_get_contents("win32/build/projectgen.js"));
-} else {
- C.WriteLine('PHP_DSP="no"');
- C.WriteBlankLines(1);
-}
-
-// 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");
-emit_core_module_list();
-
-// If we have not specified any module dirs let's add some defaults
-if (module_dirs.length == 0) {
- find_config_w32("pecl");
- find_config_w32("..\\pecl");
- find_config_w32("pecl\\rpc");
- find_config_w32("..\\pecl\\rpc");
-} else {
- for (i = 0; i < module_dirs.length; i++) {
- find_config_w32(module_dirs[i]);
- }
-}
-
-// 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");
-calls = modules.match(re);
-for (i = 0; i < calls.length; i++) {
- item = calls[i];
- C.WriteLine("try {");
- C.WriteLine(item);
- C.WriteLine("} catch (e) {");
- C.WriteLine('\tSTDOUT.WriteLine("problem: " + e);');
- C.WriteLine("}");
-}
-
-C.WriteBlankLines(1);
-C.WriteLine("conf_process_args();");
-C.WriteBlankLines(1);
-
-// Comment out the calls from their original positions
-modules = modules.replace(re, "/* $1 */");
-C.Write(modules);
-
-C.WriteBlankLines(1);
-C.Write(file_get_contents("win32/build/configure.tail"));
-
-B.WriteLine("@echo off");
-B.WriteLine("cscript /nologo configure.js %*");
+/*\r
+ +----------------------------------------------------------------------+\r
+ | PHP Version 5 |\r
+ +----------------------------------------------------------------------+\r
+ | Copyright (c) 1997-2008 The PHP Group |\r
+ +----------------------------------------------------------------------+\r
+ | This source file is subject to version 3.01 of the PHP license, |\r
+ | that is bundled with this package in the file LICENSE, and is |\r
+ | available through the world-wide-web at the following url: |\r
+ | http://www.php.net/license/3_01.txt |\r
+ | If you did not receive a copy of the PHP license and are unable to |\r
+ | obtain it through the world-wide-web, please send a note to |\r
+ | license@php.net so we can mail you a copy immediately. |\r
+ +----------------------------------------------------------------------+\r
+ | Author: Wez Furlong <wez@thebrainroom.com> |\r
+ +----------------------------------------------------------------------+\r
+*/\r
+\r
+/* $Id: buildconf.js,v 1.13.2.2.2.1.2.5 2009-01-02 12:18:21 kalle Exp $ */\r
+// This generates a configure script for win32 build\r
+\r
+WScript.StdOut.WriteLine("Rebuilding configure.js");\r
+var FSO = WScript.CreateObject("Scripting.FileSystemObject");\r
+var C = FSO.CreateTextFile("configure.js", true);\r
+var B = FSO.CreateTextFile("configure.bat", true);\r
+var DSP = false;\r
+\r
+var modules = "";\r
+var MODULES = WScript.CreateObject("Scripting.Dictionary");\r
+var module_dirs = new Array();\r
+\r
+function file_get_contents(filename)\r
+{\r
+ var F = FSO.OpenTextFile(filename, 1);\r
+ var t = F.ReadAll();\r
+ F.Close();\r
+ return t;\r
+}\r
+\r
+function Module_Item(module_name, config_path, dir_line, deps, content)\r
+{\r
+ this.module_name = module_name;\r
+ this.config_path = config_path;\r
+ this.dir_line = dir_line;\r
+ this.deps = deps;\r
+ this.content = content;\r
+}\r
+\r
+function find_config_w32(dirname)\r
+{\r
+ if (!FSO.FolderExists(dirname)) {\r
+ return;\r
+ }\r
+\r
+ var f = FSO.GetFolder(dirname);\r
+ var fc = new Enumerator(f.SubFolders);\r
+ var c, i, ok, n;\r
+ var item = null;\r
+ var re_dep_line = new RegExp("ADD_EXTENSION_DEP\\([^,]*\\s*,\\s*['\"]([^'\"]+)['\"].*\\)", "gm");\r
+ \r
+ for (; !fc.atEnd(); fc.moveNext())\r
+ {\r
+ ok = true;\r
+ /* check if we already picked up a module with the same dirname;\r
+ * if we have, don't include it here */\r
+ n = FSO.GetFileName(fc.item());\r
+ \r
+ if (n == '.svn' || n == 'tests')\r
+ continue;\r
+ \r
+ // WScript.StdOut.WriteLine("checking " + dirname + "/" + n);\r
+ if (MODULES.Exists(n)) {\r
+ WScript.StdOut.WriteLine("Skipping " + dirname + "/" + n + " -- already have a module with that name");\r
+ continue;\r
+ }\r
+\r
+ c = FSO.BuildPath(fc.item(), "config.w32");\r
+ if (FSO.FileExists(c)) {\r
+// WScript.StdOut.WriteLine(c);\r
+\r
+ var dir_line = "configure_module_dirname = condense_path(FSO.GetParentFolderName('"\r
+ + c.replace(new RegExp('(["\\\\])', "g"), '\\$1') + "'));\r\n";\r
+ var contents = file_get_contents(c);\r
+ var deps = new Array();\r
+\r
+ // parse out any deps from the file\r
+ var calls = contents.match(re_dep_line);\r
+ if (calls != null) {\r
+ for (i = 0; i < calls.length; i++) {\r
+ // now we need the extension name out of this thing\r
+ if (calls[i].match(re_dep_line)) {\r
+// WScript.StdOut.WriteLine("n depends on " + RegExp.$1);\r
+ deps[deps.length] = RegExp.$1;\r
+\r
+ }\r
+ }\r
+ }\r
+\r
+ item = new Module_Item(n, c, dir_line, deps, contents);\r
+ MODULES.Add(n, item);\r
+ }\r
+ }\r
+}\r
+\r
+// Emit core modules array. This is used by a snapshot\r
+// build to override a default "yes" value so that external\r
+// modules don't break the build by becoming statically compiled\r
+function emit_core_module_list()\r
+{\r
+ var module_names = (new VBArray(MODULES.Keys())).toArray();\r
+ var i, mod_name, j;\r
+ var item;\r
+ var output = "";\r
+\r
+ C.WriteLine("core_module_list = new Array(");\r
+\r
+ // first, look for modules with empty deps; emit those first\r
+ for (i in module_names) {\r
+ mod_name = module_names[i];\r
+ C.WriteLine("\"" + mod_name.replace(/_/g, "-") + "\",");\r
+ }\r
+\r
+ C.WriteLine("false // dummy");\r
+\r
+ C.WriteLine(");");\r
+}\r
+\r
+\r
+function emit_module(item)\r
+{\r
+ return item.dir_line + item.content;\r
+}\r
+\r
+function emit_dep_modules(module_names)\r
+{\r
+ var i, mod_name, j;\r
+ var output = "";\r
+ var item = null;\r
+\r
+ for (i in module_names) {\r
+ mod_name = module_names[i];\r
+\r
+ if (MODULES.Exists(mod_name)) {\r
+ item = MODULES.Item(mod_name);\r
+ MODULES.Remove(mod_name);\r
+ if (item.deps.length) {\r
+ output += emit_dep_modules(item.deps);\r
+ }\r
+ output += emit_module(item);\r
+ }\r
+ }\r
+\r
+ return output;\r
+}\r
+\r
+function gen_modules()\r
+{\r
+ var module_names = (new VBArray(MODULES.Keys())).toArray();\r
+ var i, mod_name, j;\r
+ var item;\r
+ var output = "";\r
+\r
+ // first, look for modules with empty deps; emit those first\r
+ for (i in module_names) {\r
+ mod_name = module_names[i];\r
+ item = MODULES.Item(mod_name);\r
+ if (item.deps.length == 0) {\r
+ MODULES.Remove(mod_name);\r
+ output += emit_module(item);\r
+ }\r
+ }\r
+\r
+ // now we are left with modules that have dependencies on other modules\r
+ module_names = (new VBArray(MODULES.Keys())).toArray();\r
+ output += emit_dep_modules(module_names);\r
+\r
+ return output;\r
+}\r
+\r
+// Process buildconf arguments\r
+function buildconf_process_args()\r
+{\r
+ args = WScript.Arguments;\r
+\r
+ for (i = 0; i < args.length; i++) {\r
+ arg = args(i);\r
+ // If it is --foo=bar, split on the equals sign\r
+ arg = arg.split("=", 2);\r
+ argname = arg[0];\r
+ if (arg.length > 1) {\r
+ argval = arg[1];\r
+ } else {\r
+ argval = null;\r
+ }\r
+\r
+ if (argname == '--add-modules-dir' && argval != null) {\r
+ WScript.StdOut.WriteLine("Adding " + argval + " to the module search path");\r
+ module_dirs[module_dirs.length] = argval;\r
+ }\r
+\r
+ if (argname == '--add-project-files') {\r
+ WScript.StdOut.WriteLine("Adding dsp templates into the mix");\r
+ DSP = true;\r
+ }\r
+ }\r
+}\r
+\r
+buildconf_process_args();\r
+\r
+// Write the head of the configure script\r
+C.WriteLine("/* This file automatically generated from win32/build/confutils.js */");\r
+C.Write(file_get_contents("win32/build/confutils.js"));\r
+\r
+// If project files were requested, pull in the code to generate them\r
+if (DSP == true) {\r
+ C.WriteLine('PHP_DSP="yes"');\r
+ C.WriteBlankLines(1);\r
+ C.Write(file_get_contents("win32/build/projectgen.js"));\r
+} else {\r
+ C.WriteLine('PHP_DSP="no"');\r
+ C.WriteBlankLines(1);\r
+}\r
+\r
+// Pull in code from sapi and extensions\r
+modules = file_get_contents("win32/build/config.w32");\r
+\r
+// Pick up confs from TSRM and Zend if present\r
+find_config_w32(".");\r
+find_config_w32("sapi");\r
+find_config_w32("ext");\r
+emit_core_module_list();\r
+\r
+// If we have not specified any module dirs let's add some defaults\r
+if (module_dirs.length == 0) {\r
+ find_config_w32("pecl");\r
+ find_config_w32("..\\pecl");\r
+ find_config_w32("pecl\\rpc");\r
+ find_config_w32("..\\pecl\\rpc");\r
+} else {\r
+ for (i = 0; i < module_dirs.length; i++) {\r
+ find_config_w32(module_dirs[i]);\r
+ }\r
+}\r
+\r
+// Now generate contents of module based on MODULES, chasing dependencies\r
+// to ensure that dependent modules are emitted first\r
+modules += gen_modules();\r
+\r
+// Look for ARG_ENABLE or ARG_WITH calls\r
+re = new RegExp("(ARG_(ENABLE|WITH)\([^;]+\);)", "gm");\r
+calls = modules.match(re);\r
+for (i = 0; i < calls.length; i++) {\r
+ item = calls[i];\r
+ C.WriteLine("try {");\r
+ C.WriteLine(item);\r
+ C.WriteLine("} catch (e) {");\r
+ C.WriteLine('\tSTDOUT.WriteLine("problem: " + e);');\r
+ C.WriteLine("}");\r
+}\r
+\r
+C.WriteBlankLines(1);\r
+C.WriteLine("conf_process_args();");\r
+C.WriteBlankLines(1);\r
+\r
+// Comment out the calls from their original positions\r
+modules = modules.replace(re, "/* $1 */");\r
+C.Write(modules);\r
+\r
+C.WriteBlankLines(1);\r
+C.Write(file_get_contents("win32/build/configure.tail"));\r
+\r
+B.WriteLine("@echo off");\r
+B.WriteLine("cscript /nologo configure.js %*");\r