Re: Re: Patch for generator - allow compiling against multiple gtk versions

From: Date: Sat, 27 Jan 2007 09:12:47 +0000
Subject: Re: Re: Patch for generator - allow compiling against multiple gtk versions
References: 1 2  Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-3594@lists.php.net to get a copy of this message
OK, I did some research now: Cairo (introduced in GTK+ 2.8) has no Windows 98/ME/NT4 support. Effectively this means we're stuck with the last of the 2.6 series for the win98 build, which isn't so cool - I'm 99% certain the filechooser API wasn't ever fixed in 2.6, for example. We could of course try building for win98 against GTK 2.8 libs/headers and ask Madeleine to test - it's not clear to me how much Cairo is used internally in 2.8.*. Or we could just assume the Gimp pages are correct in their assessment of Windows platforms vs GTK versions (http://gimp-win.sourceforge.net/stable.html) and not waste her time. Another little snippet is from Tor's site (http://www.gimp.org/~tml/gimp/win32/downloads.html) where he states that his distributed development DLLs use the MSCVRT runtime: "Specifically, this means that you should not use newer versions of the Microsoft compiler than Visual C 6 without knowing exactly what you are doing." (He also mentions GTK+ 2.8 vs Win98, so Madeleine's off the hook!) According to dependency walker, the DLLs in the libglade dev pack and on the GTK FTP homepage are also both built with VC6, even for the 2.10 series. This obviously affects the hoped-for shift to V8 for XP distros, but it's good news for the win98 crowd. Kind of. Win98/ME/NT4 will need VC6, PHP version 5.2.0 and GTK version 2.6.10 - that means the *only* changing element for them will be the PHP-GTK source as it matures. Actual releases will consist of the updated php-gtk2.dll and any php-gtk extensions that will work within those constraints, and there's absolutely no reason to make those users download everything else every time. It might be okay to use later PHP extensions (see Frank's earlier note) but I'm very much inclined to say 'just make do with this until you can upgrade your OS or move to *nix', because there's no reason to expect win32 API usage in extensions to remain portable now, and we don't have a good way to monitor that shift. Thoughts? - Steph ----- Original Message ----- From: "Elizabeth Smith" <emsmith@elizabethmariesmith.com> To: <php-gtk-dev@lists.php.net> Sent: Friday, January 26, 2007 3:21 AM Subject: [PHP-GTK-DEV] Re: Patch for generator - allow compiling against multiple gtk versions
Using this with the current build system will require some patching of the configure files so -v 2.6 or whatever is passed to the generator.php file. The configure files will also need to do gtk version autodetection and allow the user to specify a version. Anant said he'd manage the ./configure stuff for normal build systems and I'm almost finished with the fixes to the MSVC build system to allow this to work (I had some additional enhancements for the windows build system, including dealing with unknown/deprecated compile flags in msvc 2005 and adding --enable-debug-pack so I'll send it all in one shot). If no version is passed to the generator, 2.6 is always assumed.
Here are patches for the windows build system - this moves the source file building stuff out of the buildconf.js and into the configwin32 like the extensions. It also fixes deprecated compile flags on MSVC 2005, adds --enable-debug-pack to the release compile, adds manifest packing for newer msvc compilers, and checks the gtk lib version while allowing a command line override. Thanks, Elizabeth Smith
--------------------------------------------------------------------------------
Index: buildconf.js =================================================================== RCS file: /repository/php-gtk/win32/buildconf.js,v retrieving revision 1.7 diff -u -r1.7 buildconf.js --- buildconf.js 31 Oct 2005 11:44:42 -0000 1.7 +++ buildconf.js 25 Jan 2007 23:42:22 -0000 @@ -43,22 +43,6 @@ return t; } -function gen_functions() { - - /* generate source and header files for exported PHP-GTK functions */ - temp.WriteLine("/* usage: php generator.php [-l logfile] [-o overridesfile] [-p prefix] [-c functionclass ] [-r typesfile] [-f savefile] defsfile */"); - temp.WriteLine("mkdir win32\\logs"); - temp.WriteLine("php -q generator\\generator.php -l win32\\logs\\config_atk.log -o ext\\gtk+\\atk.overrides -p atk ext\\gtk+\\atk.defs > ext\\gtk+\\gen_atk.c"); - temp.WriteLine("php -q generator\\generator.php -l win32\\logs\\config_pango.log -o ext\\gtk+\\pango.overrides -p pango ext\\gtk+\\pango.defs > ext\\gtk+\\gen_pango.c"); - temp.WriteLine("php -q generator\\generator.php -l win32\\logs\\config_gdk.log -o ext\\gtk+\\gdk.overrides -p gdk -r ext\\gtk+\\atk-types.defs -r ext\\gtk+\\pango-types.defs ext\\gtk+\\gdk.defs > ext\\gtk+\\gen_gdk.c"); - temp.WriteLine("php -q generator\\generator.php -l win32\\logs\\config_gtk.log -o ext\\gtk+\\gtk.overrides -p gtk -r ext\\gtk+\\atk-types.defs -r ext\\gtk+\\pango-types.defs -r ext\\gtk+\\gdk-types.defs ext\\gtk+\\gtk.defs > ext\\gtk+\\gen_gtk.c"); - temp.WriteLine('grep -h "^PHP_GTK_EXPORT_CE" ext\\gtk+\\gen_atk.c | sed -e "s/^/PHP_GTK_API extern /" > ext\\gtk+\\gen_atk.h'); - temp.WriteLine('grep -h "^PHP_GTK_EXPORT_CE" ext\\gtk+\\gen_pango.c | sed -e "s/^/PHP_GTK_API extern /" > ext\\gtk+\\gen_pango.h'); - temp.WriteLine('grep -h "^PHP_GTK_EXPORT_CE" ext\\gtk+\\gen_gdk.c | sed -e "s/^/PHP_GTK_API extern /" > ext\\gtk+\\gen_gdk.h'); - temp.WriteLine('grep -h "^PHP_GTK_EXPORT_CE" ext\\gtk+\\gen_gtk.c | sed -e "s/^/PHP_GTK_API extern /" > ext\\gtk+\\gen_gtk.h'); - return; -} - function Module_Item(module_name, config_path, dir_line, content) { this.module_name = module_name; @@ -165,8 +149,6 @@ } } -gen_functions(); - // Write the head of the configure script C.WriteLine("/* This file is automatically generated from win32/confutils.js */"); C.Write(file_get_contents("win32/confutils.js")); Index: config.w32.in =================================================================== RCS file: /repository/php-gtk/win32/config.w32.in,v retrieving revision 1.12 diff -u -r1.12 config.w32.in --- config.w32.in 17 Jun 2006 14:47:08 -0000 1.12 +++ config.w32.in 26 Jan 2007 00:29:31 -0000 @@ -14,6 +14,9 @@ PATH_PROG('link', WshShell.Environment("Process").Item("PATH"), "LD"); PATH_PROG('nmake'); +// Try locating manifest tool +PATH_PROG('mt', WshShell.Environment("Process").Item("PATH"), "MT"); + // we don't want to define LIB, as that will override the default library path set in that env var PATH_PROG('lib', null, 'MAKE_LIB'); PATH_PROG('php'); @@ -46,6 +49,53 @@ ARG_WITH('php-build', 'Path to where you extracted http://www.php.net/extra/win32build.zip. Assumes that it is a sibling of this source dir (..\\php_build) if not specified', 'no'); ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); +ARG_ENABLE('version', 'gtk library version you wish to build against, overrides automatically detected version', '2.6'); +/* pick up the version from gtk/gtkversion.h */ + +STDOUT.Write("Checking for gtk\\gtkversion.h ... "); + +function get_gtk_version(requested) +{ + var env, i, file, found, vin, major, minor; + + env = WshShell.Environment("Process").Item('INCLUDE'); + env = env.split(";"); + for (i = 0; i < env.length; i++) { + file = glob(env[i] + "\\gtk\\gtkversion.h"); + if (file) { + found = true; + break; + } + } + + if (found == true) { + STDOUT.WriteLine(" <in default path>"); + } else { + STDOUT.WriteLine(" <not found>"); + } + + vin = file_get_contents(file); + + regex = new RegExp("GTK_MAJOR_VERSION\\s+\\(([0-9]+)\\)"); + regex.exec(vin); + major = RegExp.$1; + + regex = new RegExp("GTK_MINOR_VERSION\\s+\\(([0-9]+)\\)"); + regex.exec(vin); + minor = RegExp.$1; + + max = major + '.' + minor; + + if (!PHP_GTK_VERSION.length || PHP_GTK_VERSION > max) + { + PHP_GTK_VERSION = max; + } + + STDOUT.Write("Library definitions for " + PHP_GTK_VERSION + " will be used"); + STDERR.WriteBlankLines(1); +} +get_gtk_version(PHP_GTK_VERSION); + // stick objects somewhere outside of the source tree ARG_ENABLE('object-out-dir', 'Alternative location for binary objects during build', ''); if (PHP_GTK_OBJECT_OUT_DIR.length) { @@ -56,6 +106,10 @@ } ARG_ENABLE('debug', 'Compile with debugging symbols', "no"); +ARG_ENABLE('debug-pack', 'Release binaries with external debug symbols (--enable-debug must not be specified)', 'no'); +if (PHP_GTK_DEBUG == "yes" && PHP_GTK_DEBUG_PACK == "yes") { + ERROR("Use of both --enable-debug and --enable-debug-pack not allowed."); +} // Set some debug-specific options if (PHP_GTK_DEBUG == "yes") { @@ -76,16 +130,24 @@ DEFINE("DLL_LDFLAGS", "/dll /machine:I386"); // PHP-GTK DLL link flags DEFINE("PHP_GTK_LDFLAGS", "$(DLL_LDFLAGS)"); +// PHP-GTK compiler flags +DEFINE("CFLAGS", "/nologo"); // General libs DEFINE("LIBS", "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib"); if (PHP_GTK_DEBUG == "yes") { - DEFINE("CFLAGS", "/nologo /LDd /MDd /Gm /ZI /GZ /I . /I ..\\ /I ..\\.. /I main /I ..\\main /I ext /I ..\\ext /I ..\\php5\\main /I ..\\php5\\Zend /I ..\\php5\\TSRM /D ZEND_WIN32 /D ZTS=1 /D ZEND_DEBUG=1 /D PHP_WIN32 /D WIN32 /D _DEBUG /D _WINDOWS /D _MBCS /D _USRDLL"); + ADD_FLAG("CFLAGS", "/LDd /MDd /Gm /ZI /Od /I . /I ..\\ /I ..\\.. /I main /I ..\\main /I ext /I ..\\ext /I ..\\php5\\main /I ..\\php5\\Zend /I ..\\php5\\TSRM /D ZEND_WIN32 /D ZTS=1 /D ZEND_DEBUG=1 /D PHP_WIN32 /D WIN32 /D _DEBUG /D _WINDOWS /D _MBCS /D _USRDLL"); ADD_FLAG("LDFLAGS", "/debug"); } else { - DEFINE("CFLAGS", "/nologo /MD /W3 /GX /O2 /I . /I ..\\ /I ..\\.. /I main /I ..\\main /I ext /I ..\\ext /I ..\\php5\\main /I ..\\php5\\Zend /I ..\\php5\\TSRM /D ZEND_WIN32 /D ZTS=1 /D ZEND_DEBUG=0 /D PHP_WIN32 /D WIN32 /D NDEBUG /D _WINDOWS /D _MBCS /D _USRDLL");
+      // Generate external debug files when --enable-debug-pack is
specified + if (PHP_GTK_DEBUG_PACK == "yes") { + ADD_FLAG("CFLAGS", "/Zi"); + ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf"); + }
+      ADD_FLAG("CFLAGS", "/LD /MD /W3 /Ox /I . /I ..\\ /I ..\\.. /I main
/I ..\\main /I ext /I ..\\ext /I ..\\php5\\main /I ..\\php5\\Zend /I ..\\php5\\TSRM /D ZEND_WIN32 /D ZTS=1 /D ZEND_DEBUG=0 /D PHP_WIN32 /D WIN32 /D NDEBUG /D _WINDOWS /D _MBCS /D _USRDLL"); + } if (VCVERS < 14) { @@ -96,7 +158,16 @@ if (VCVERS >= 14) { // fun stuff: MS deprecated ANSI stdio and similar functions - disable warnings // GS hardens the binary against buffer overruns - ADD_FLAG('CFLAGS', '/GS /wd4996 '); + ADD_FLAG('CFLAGS', '/EHsc /GS /wd4996 '); + if (PHP_GTK_DEBUG == "yes") + { + // Set some debug/release specific options + ADD_FLAG('CFLAGS', ' /RTC1 '); + } +} +else +{ + ADD_FLAG('CFLAGS', '/GX'); } if (PHP_GTK_PHP_BUILD == 'no') { Index: confutils.js =================================================================== RCS file: /repository/php-gtk/win32/confutils.js,v retrieving revision 1.19 diff -u -r1.19 confutils.js --- confutils.js 17 Jul 2006 17:00:09 -0000 1.19 +++ confutils.js 26 Jan 2007 03:16:38 -0000 @@ -302,9 +302,6 @@ } WScript.Quit(1); - } else { // not --help - - generate_source(); } // Now set any defaults we might have missed out earlier @@ -668,6 +665,7 @@ MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(" + EXT + "_GLOBAL_OBJS)" + res_var); MFO.WriteLine("\t" + ld + " /out:$(BUILD_DIR)\\" + dllname + " $(" + EXT + "_LDFLAGS)" + dllflags + " $(LDFLAGS) $(" + EXT + "_GLOBAL_OBJS) $(LIBS_" + EXT + ")" + dep_libs + " $(LIBS)" + res_var); + MFO.WriteLine("\t-@$(_VC_MANIFEST_EMBED_DLL)"); MFO.WriteBlankLines(1); MFO.WriteLine(dllname + ": $(BUILD_DIR)\\" + dllname); @@ -938,6 +936,7 @@ } } + generate_source(); STDOUT.WriteLine("Generating source files - this may take a few seconds"); WScript.Sleep(3500); check_generation(); @@ -968,6 +967,16 @@ MF.WriteLine(keys[i] + "=" + configure_subst.Item(keys[i]) + " "); } + MF.WriteLine("!if $(MT) == \"\""); + MF.WriteBlankLines(1); + MF.WriteLine("_VC_MANIFEST_EMBED_DLL="); + MF.WriteBlankLines(1); + MF.WriteLine("!else"); + MF.WriteBlankLines(1); + MF.WriteLine("_VC_MANIFEST_EMBED_DLL= $(MT) -nologo -manifest $@.manifest -outputresource:$@;2"); + MF.WriteBlankLines(1); + MF.WriteLine("!endif"); + MF.WriteBlankLines(1); MF.WriteLine("all: $(EXT_TARGETS)");
--------------------------------------------------------------------------------
Index: config.w32 =================================================================== RCS file: /repository/php-gtk/ext/gtk+/config.w32,v retrieving revision 1.5 diff -u -r1.5 config.w32 --- config.w32 24 Oct 2006 12:46:14 -0000 1.5 +++ config.w32 25 Jan 2007 23:59:50 -0000 @@ -11,11 +11,28 @@ CHECK_HEADER("pango/pangowin32.h") && CHECK_LIB("pangowin32-1.0.lib", "php-gtk") && CHECK_HEADER("gdk-pixbuf/gdk-pixbuf.h") && CHECK_LIB("gdk_pixbuf-2.0.lib", "php-gtk") && CHECK_HEADER("gdk/gdk.h") && CHECK_LIB("gdk-win32-2.0.lib", "php-gtk") && - CHECK_HEADER("gtk/gtk.h") && CHECK_LIB("gtk-win32-2.0.lib", "php-gtk")) { + CHECK_HEADER("gtk/gtk.h") && CHECK_LIB("gtk-win32-2.0.lib", "php-gtk")) +{ ADD_FLAG("CFLAGS_PHP_GTK", "/I ext\\gtk+ /I ..\\ext\\gtk+ /D HAVE_PHP_GTK=1"); EXTENSION("php-gtk", "gen_atk.c gen_gdk.c gen_gtk.c gen_pango.c php_gdk.c php_gtk+.c php_gtk+_types.c phpg_custom_tree_model.c", true); // always shared AC_DEFINE("HAVE_PHP_GTK", 1, "PHP-GTK enabled"); + + /* Create the file if it doesn't exist */ + var temp = FSO.OpenTextFile("win32\\temp.bat", 8); + /* generate source and header files for exported PHP-GTK functions */ + temp.WriteLine("/* usage: php generator.php [-l logfile] [-o overridesfile] [-p prefix] [-c functionclass ] [-r typesfile] [-f savefile] defsfile */"); + temp.WriteLine("mkdir win32\\logs"); + temp.WriteLine("php -q generator\\generator.php -l win32\\logs\\config_atk.log -o ext\\gtk+\\atk.overrides -p atk ext\\gtk+\\atk.defs -v " + PHP_GTK_VERSION + " > ext\\gtk+\\gen_atk.c"); + temp.WriteLine("php -q generator\\generator.php -l win32\\logs\\config_pango.log -o ext\\gtk+\\pango.overrides -p pango ext\\gtk+\\pango.defs -v " + PHP_GTK_VERSION + " > ext\\gtk+\\gen_pango.c"); + temp.WriteLine("php -q generator\\generator.php -l win32\\logs\\config_gdk.log -o ext\\gtk+\\gdk.overrides -p gdk -r ext\\gtk+\\atk-types.defs -v " + PHP_GTK_VERSION + " -r ext\\gtk+\\pango-types.defs ext\\gtk+\\gdk.defs > ext\\gtk+\\gen_gdk.c"); + temp.WriteLine("php -q generator\\generator.php -l win32\\logs\\config_gtk.log -o ext\\gtk+\\gtk.overrides -p gtk -r ext\\gtk+\\atk-types.defs -v " + PHP_GTK_VERSION + " -r ext\\gtk+\\pango-types.defs -r ext\\gtk+\\gdk-types.defs ext\\gtk+\\gtk.defs > ext\\gtk+\\gen_gtk.c"); + temp.WriteLine('grep -h "^PHP_GTK_EXPORT_CE" ext\\gtk+\\gen_atk.c | sed -e "s/^/PHP_GTK_API extern /" > ext\\gtk+\\gen_atk.h'); + temp.WriteLine('grep -h "^PHP_GTK_EXPORT_CE" ext\\gtk+\\gen_pango.c | sed -e "s/^/PHP_GTK_API extern /" > ext\\gtk+\\gen_pango.h'); + temp.WriteLine('grep -h "^PHP_GTK_EXPORT_CE" ext\\gtk+\\gen_gdk.c | sed -e "s/^/PHP_GTK_API extern /" > ext\\gtk+\\gen_gdk.h'); + temp.WriteLine('grep -h "^PHP_GTK_EXPORT_CE" ext\\gtk+\\gen_gtk.c | sed -e "s/^/PHP_GTK_API extern /" > ext\\gtk+\\gen_gtk.h'); + temp.Close(); + }
--------------------------------------------------------------------------------
-- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.gtk.dev (#3594) next »