]> granicus.if.org Git - php/commitdiff
- Embryonic project file generation. Use buildconf --add-project-files and hopefully...
authorSteph Fox <sfox@php.net>
Wed, 9 Jul 2008 08:15:46 +0000 (08:15 +0000)
committerSteph Fox <sfox@php.net>
Wed, 9 Jul 2008 08:15:46 +0000 (08:15 +0000)
- Please read the README before complaining.

@Stas, Rob - please test.

win32/build/DSP.README [new file with mode: 0644]
win32/build/block.template.dsw [new file with mode: 0644]
win32/build/buildconf.js
win32/build/config.w32
win32/build/confutils.js
win32/build/projectgen.js [new file with mode: 0644]
win32/build/template.dsp [new file with mode: 0644]
win32/build/template.dsw [new file with mode: 0644]

diff --git a/win32/build/DSP.README b/win32/build/DSP.README
new file mode 100644 (file)
index 0000000..9a67d51
--- /dev/null
@@ -0,0 +1,38 @@
+MSVC++ project file generation
+==============================
+
+The project files generated by projectgen.js are in no way intended
+for building with. There is already a perfectly good Windows build
+system in place. These files are only intended for use in debugging
+and profiling, and are very unlikely to create working binaries.
+
+With this in mind, the script will only generate basic .dsp files
+for the modules that are currently configured, and a single project
+workspace file to rule them all.
+
+The switch for project file generation is a buildconf switch and
+not a configure switch:
+
+> buildconf --add-project-files
+> configure ...
+
+The resulting workspace file should appear at /win32/php.dsw after
+configure is run.
+
+If the .dsw hasn't generated in a sane way, the most likely reason
+will be that the template files have become corrupted. They need DOS
+line endings (CR/LF) in order to function. The affected files are:
+
+/win32/build/block.template.dsw
+/win32/build/template.dsp
+/win32/build/template.dsw
+
+Simply save them with DOS line endings, and bug it to me if basic
+project file generation still fails (as in, you ran the command and
+configure again after saving, and you have a working copy of MSVS
+installed, but clicking on the workspace doesn't give you anything).
+
+- Steph
+sfox@php.net
+
+July 2008
diff --git a/win32/build/block.template.dsw b/win32/build/block.template.dsw
new file mode 100644 (file)
index 0000000..9f78f6e
--- /dev/null
@@ -0,0 +1,14 @@
+Project: "EXTNAME"=..\ADDRESS - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name main
+    End Project Dependency
+}}}
+
+###############################################################################
index 641758bb94646b527099b794b04ea9a4dd27bf66..0aa0a51ba157375fdb2f28634b0666fb783a542b 100644 (file)
   +----------------------------------------------------------------------+
 */
 
-/* $Id: buildconf.js,v 1.13.2.2.2.1.2.2 2008-06-23 07:55:03 pajoye Exp $ */
+/* $Id: buildconf.js,v 1.13.2.2.2.1.2.3 2008-07-09 08:15:46 sfox 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");
@@ -203,6 +204,11 @@ function buildconf_process_args()
                        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;
+               }
        }
 }
 
@@ -212,6 +218,16 @@ buildconf_process_args();
 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");
 
index d57ef2d522661bf236586d879133cec52d9ef53f..3d744284e5b139b31f15c14116fb530892aa78b7 100644 (file)
@@ -364,3 +364,10 @@ if (PHP_SNAPSHOT_TEMPLATE == "no") {
 DEFINE('SNAPSHOT_TEMPLATE', PHP_SNAPSHOT_TEMPLATE);
 
 ARG_ENABLE('summary', 'Enable configuration summary', 'yes');
+
+if (PHP_DSP != "no") {
+       if (FSO.FolderExists("tmp")) {
+               FSO.DeleteFolder("tmp");
+       }
+       FSO.CreateFolder("tmp");
+}
index 0b515ddaa9c1167657bd382b4708b5cd143e4cbf..bd7e70f2e672eeb74c219a57fe11ca6c02c917fc 100644 (file)
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-// $Id: confutils.js,v 1.60.2.1.2.8.2.22 2008-07-07 13:51:35 pajoye Exp $
+// $Id: confutils.js,v 1.60.2.1.2.8.2.23 2008-07-09 08:15:46 sfox Exp $
 
 var STDOUT = WScript.StdOut;
 var STDERR = WScript.StdErr;
@@ -26,6 +26,7 @@ var FSO = WScript.CreateObject("Scripting.FileSystemObject");
 var MFO = null;
 var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive");
 var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles");
+var DSP_FLAGS = new Array();
 
 /* Store the enabled extensions (summary + QA check) */
 var extensions_enabled = new Array();
@@ -1039,6 +1040,10 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)
                ADD_FLAG("SAPI_TARGETS", makefiletarget);
        }
 
+       if (PHP_DSP != "no") {
+               generate_dsp_file(sapiname, configure_module_dirname, file_list, false);
+       }
+
        MFO.WriteBlankLines(1);
        sapi_enabled[sapi_enabled.length] = [sapiname];
 }
@@ -1203,6 +1208,11 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
                DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')');
        }
        ADD_FLAG("CFLAGS_" + EXT, cflags);
+
+       if (PHP_DSP != "no") {
+               generate_dsp_file(extname, configure_module_dirname, file_list, shared);
+       }
+
        extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static'];
 }
 
@@ -1449,10 +1459,20 @@ function generate_files()
                }
        }
 
+       if (PHP_DSP != "no") {
+               generate_dsp_file("TSRM", "TSRM", null, false);
+               generate_dsp_file("Zend", "Zend", null, false);
+               generate_dsp_file("win32", "win32", null, false);
+               generate_dsp_file("main", "main", null, false);
+               generate_dsp_file("streams", "main\\streams", null, false);
+               generate_dsp_flags();
+       }
+
        STDOUT.WriteLine("Generating files...");
        generate_makefile();
        generate_internal_functions();
        generate_config_h();
+
        STDOUT.WriteLine("Done.");
        STDOUT.WriteBlankLines(1);
        write_summary();
@@ -1577,6 +1597,12 @@ function ADD_FLAG(name, flags, target)
                configure_subst.Remove(name);
        }
        configure_subst.Add(name, flags);
+
+       if (PHP_DSP != "no") {
+               if (flags && (name.substr(name.length-3) != "PHP") && (name.substr(0, 7) == "CFLAGS_")) {
+                       DSP_FLAGS[DSP_FLAGS.length] = new Array(name, flags);
+               }
+       }
 }
 
 function get_define(name)
diff --git a/win32/build/projectgen.js b/win32/build/projectgen.js
new file mode 100644 (file)
index 0000000..4dcb082
--- /dev/null
@@ -0,0 +1,185 @@
+function write_src_file(fname, arr)
+{
+       var src = FSO.CreateTextFile(fname, true);
+
+       for (i = 0; i < arr.length; i++) {
+               if (arr[i].length > 1) {
+                       src.WriteLine("# Begin Source File");
+                       src.WriteLine("SOURCE=" + arr[i]);
+                       src.WriteLine("# End Source File");
+                       src.WriteBlankLines(1);
+               }
+       }
+       src.Close();
+       return;
+}
+
+function copy_dsp_files() {
+       var tmp = FSO.GetFolder("tmp");
+       var core = "TSRM Zend main streams win32 standard";
+       var tmpl = file_get_contents("win32\\build\\template.dsw");
+
+       f = new Enumerator(tmp.Files);
+       blocks = "";
+       for (; !f.atEnd(); f.moveNext()) {
+               contents = file_get_contents(f.item());
+               address = contents.slice(0, contents.indexOf("#"));
+               contents = contents.slice(contents.indexOf("#"));
+               dsp = FSO.CreateTextFile(address, true);
+               dsp.Write(contents);
+               dsp.Close();
+               ext = address.slice(address.lastIndexOf("\\")+1, address.length-4);
+               if (!core.match(ext)) {
+                       blocks += file_get_contents("win32\\build\\block.template.dsw");
+                       blocks = blocks.replace("ADDRESS", address);
+                       blocks = blocks.replace("EXTNAME", ext);
+               }
+               FSO.DeleteFile(f.item());
+       }
+       tmpl = tmpl.replace("INSERT", blocks);
+       dsw = FSO.CreateTextFile("win32\\php.dsw", true);
+       dsw.Write(tmpl);
+       dsw.Close();
+       FSO.DeleteFolder("tmp");
+}
+
+function generate_dsp_flags()
+{
+       for (i = 0; i < DSP_FLAGS.length; i++) {
+               name = DSP_FLAGS[i][0];
+               if (DSP_FLAGS.length == i+1 || name != DSP_FLAGS[i+1][0]) {
+                       ext = name.substr(7).toLowerCase();
+                       src = file_get_contents("tmp\\" + ext + ".dsp");
+                       have = "/D HAVE_" + ext.toUpperCase() + "=1";
+                       src = src.replace(have, have + " " + DSP_FLAGS[i][1]);
+                       dsp = FSO.CreateTextFile("tmp\\" + ext + ".dsp", true);
+                       dsp.Write(src);
+                       dsp.Close();
+               }
+       }
+       copy_dsp_files();
+       return;
+}
+
+function generate_dsp_filelist(ext, ext_dir, files)
+{
+       var EXT = ext.toUpperCase();
+       var tabs = new RegExp("[\t\r\n\'\"]", "gm");
+       var ws = new RegExp("\\s+", "g");
+       var dir = FSO.GetFolder(ext_dir);
+       var headers = "";
+
+       if (!files) {
+               files = "";
+               f = new Enumerator(dir.Files);
+               for (; !f.atEnd(); f.moveNext()) {
+                       name = FSO.GetFileName(f.item());
+                       if (name.substr(name.length-2) == ".c") {
+                               files += " ./" + name;
+                       }
+               }
+       } else {
+               files = files.replace(tabs, "");
+               files = "./" + files.replace(/ /g, " ./");
+       }
+       DSP_SOURCES = files.split(" ");
+
+       f = new Enumerator(dir.Files);
+       for (; !f.atEnd(); f.moveNext()) {
+               name = FSO.GetFileName(f.item());
+               if (name.substr(name.length-2) == ".h") {
+                       headers += " ./" + name;
+               }
+       }
+       DSP_HEADERS = headers.split(" ");
+
+       configfile = FSO.BuildPath(ext_dir, "config.w32");
+       if (FSO.FileExists(configfile)) {
+               config = file_get_contents(configfile);
+               if (config.match("ADD_SOURCES")) {
+                       sources = new RegExp("ADD_SOURCES\\([^,]*\\s*,\\s*['\"]([^'\"]+)['\"].*\\)", "gm");
+                       arr = config.match(sources);
+                       line = arr[0].replace(tabs, "");
+                       newarr = line.split(',');
+                       orig_path = newarr[0].replace("ADD_SOURCES(", "");
+                       munged_dir = ext_dir.replace(/\\/g, '/');
+                       orig_path = orig_path.replace("configure_module_dirname", munged_dir);
+                       orig_path = orig_path.replace(" + ", "");
+                       path = orig_path.replace(munged_dir + '/', "");
+
+                       if (path.length > 0) {
+                               subdir = FSO.GetFolder(orig_path);
+                               lib = new Enumerator(subdir.Files);
+                               libheaders = "";
+                               for (; !lib.atEnd(); lib.moveNext()) {
+                                       name = FSO.GetFileName(lib.item());
+                                       if (name.substr(name.length-2) == ".h") {
+                                               libheaders += " ./" + path + "/" + name;
+                                       }
+                               }
+                               DSP_HEADERS = DSP_HEADERS.concat(libheaders.split(" "));
+                       }
+
+                       sources = newarr[1].replace(/\\/g, "");
+                       sources = sources.replace(ws, " ");
+                       path = path ? " ./" + path + "/" : " ./";
+                       sources = sources.replace(/ /g, path);
+                       DSP_SOURCES = DSP_SOURCES.concat(sources.split(" "));
+               }
+       }
+       write_src_file("tmp\\" + ext + ".headers.tmp", DSP_HEADERS);
+       write_src_file("tmp\\" + ext + ".sources.tmp", DSP_SOURCES);
+       return;
+}
+
+function generate_dsp_file(ext, ext_dir, files, shared)
+{
+       var dsp = FSO.CreateTextFile("tmp\\" + ext + ".dsp", true);
+       var tmpl = file_get_contents("win32\\build\\template.dsp");
+       var EXT = ext.toUpperCase();
+
+       tmpl = ext_dir + "\\" + ext + ".dsp" + tmpl;
+
+       extname = new RegExp("extname", "gm");
+       EXTNAME = new RegExp("EXTNAME", "gm");
+       tmpl = tmpl.replace(extname, ext);
+       tmpl = tmpl.replace(EXTNAME, EXT);
+
+       status = PHP_DEBUG == "no" ? 'Release' : 'Debug';
+       STATUS = new RegExp("Status", "gm");
+       tmpl = tmpl.replace(STATUS, status);
+
+       if (PHP_ZTS == "no") {
+               zts = new RegExp("_TS", "gmi");
+               tmpl = tmpl.replace(zts, '');
+       }
+
+       if (PHP_DEBUG != "no") {
+               tmpl = tmpl.replace(/Use_Debug_Libraries 0/g, "Use_Debug_Libraries 1");
+               tmpl = tmpl.replace(/NDEBUG/g, "_DEBUG");
+       }
+
+       cflags = get_define("CFLAGS").replace("$(BASE_INCLUDES)", '/I "..\\.." /I "..\\..\\..\\Zend" /I "..\\..\\TSRM" /I "..\\..\\main" ');
+       basecpp = cflags = cflags.replace('/I "..\\bindlib_w32"', '/I "..\\..\\..\\bindlib_w32"');
+       if (shared) {
+               basecpp += " /D COMPILE_DL_" + EXT;
+       }
+       tmpl = tmpl.replace("BASECPP", basecpp);
+       tmpl = tmpl.replace("BASECPP", cflags + " /D HAVE_" + EXT + "=1");
+       tmpl = tmpl.replace(/BASELIBS/g, get_define("LIBS"));
+       tmpl = tmpl.replace("LOCALLIBS", get_define("PHPLIB"));
+       debug = PHP_DEBUG != "no" ? " /debug" : "";
+       dll = shared ? ' /dll /out:"..\\..\\Debug_TS\\php_' + ext + '.dll"' : "";
+       tmpl = tmpl.replace(/BASELDFLAGS/g, "/nologo" + debug + dll);
+
+       generate_dsp_filelist(ext, ext_dir, files);
+       sources = file_get_contents("tmp\\" + ext + ".sources.tmp");
+       tmpl = tmpl.replace("SOURCEFILES", sources);
+       FSO.DeleteFile("tmp\\" + ext + ".sources.tmp");
+       headers = file_get_contents("tmp\\" + ext + ".headers.tmp");
+       tmpl = tmpl.replace("HEADERFILES", headers);
+       FSO.DeleteFile("tmp\\" + ext + ".headers.tmp");
+       dsp.Write(tmpl);
+       dsp.Close();
+       return;
+}
diff --git a/win32/build/template.dsp b/win32/build/template.dsp
new file mode 100644 (file)
index 0000000..3cebb39
--- /dev/null
@@ -0,0 +1,75 @@
+# Microsoft Developer Studio Project File - Name="extname" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102\r
+\r
+CFG=extname - Win32 Status_TS\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "extname.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "extname.mak" CFG="extname - Win32 Status_TS"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "extname - Win32 Status_TS" (based on "Win32 (x86) Dynamic-Link Library")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""\r
+# PROP Scc_LocalPath ""\r
+CPP=cl.exe\r
+MTL=midl.exe\r
+RSC=rc.exe\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Status_TS"\r
+# PROP BASE Intermediate_Dir "Status_TS"\r
+# PROP BASE Ignore_Export_Lib 0\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Status_TS"\r
+# PROP Intermediate_Dir "Status_TS"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP BASECPP\r
+# ADD CPP BASECPP\r
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 BASELIBS BASELDFLAGS /libpath:"..\..\Status_TS" /libpath:"..\..\..\bindlib_w32\Status"\r
+# ADD LINK32 LOCALLIBS BASELIBS BASELDFLAGS /libpath:"..\..\Status_TS" /libpath:"..\..\..\bindlib_w32\Status"\r
+\r
+# Begin Target\r
+# Name "extname - Win32 Status_TS"\r
+\r
+# Begin Group "Source Files"\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+\r
+SOURCEFILES\r
+# End Group\r
+\r
+# Begin Group "Header Files"\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+\r
+HEADERFILES\r
+# End Group\r
+\r
+# Begin Group "Resource Files"\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# End Group\r
+# End Target\r
+# End Project\r
diff --git a/win32/build/template.dsw b/win32/build/template.dsw
new file mode 100644 (file)
index 0000000..0e95baa
--- /dev/null
@@ -0,0 +1,116 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "TSRM"=..\TSRM\TSRM.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "Zend"=..\Zend\Zend.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name TSRM
+    End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "win32"=.\win32.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "main"=..\main\main.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name Zend
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name TSRM
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name win32
+    End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "streams"=..\main\streams\streams.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name Zend
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name TSRM
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name win32
+    End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "standard"=..\ext\standard\standard.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name main
+    End Project Dependency
+}}}
+
+###############################################################################
+
+INSERT
+
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+