Re: Re: Patch for generator - allow compiling against multiple gtk versions
| From: | Steph Fox | Date: | Fri, 26 Jan 2007 19:05:28 +0000 |
| Subject: | Re: Re: Patch for generator - allow compiling against multiple gtk versions | ||
| References: | 1 2 3 4 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-3586@lists.php.net to get a copy of this message | ||
Hi,
This is part two of the build patch, which allows a --enable-libversion configure switch. It also checks the gtkversion.h file to see the version available to build against (it only allows less than or equal to the version found as a configure switch) and then passes that to the generator.php file with the -v switch.Thanks, Elizabeth!
I had to move the file generation writing out of buildconf and into the gtk extension config.w32 file (like the other extensions)I'll figure out what you mean by that later... - Steph
Thanks, Elizabeth Smith--------------------------------------------------------------------------------
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 26 Jan 2007 18:57:14 -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_LIBVERSION + " > 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_LIBVERSION + " > 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_LIBVERSION + " -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_LIBVERSION + " -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(); + }--------------------------------------------------------------------------------
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 18:55:53 -0000 @@ -46,6 +46,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('libversion', '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_libversion(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_LIBVERSION.length || PHP_GTK_LIBVERSION > max) + { + PHP_GTK_LIBVERSION = max; + } + + STDOUT.Write("Library definitions for " + PHP_GTK_LIBVERSION + " will be used"); + STDERR.WriteBlankLines(1); +} +get_gtk_version(PHP_GTK_LIBVERSION); + // 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) { 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 18:54:02 -0000 @@ -302,9 +302,6 @@ } WScript.Quit(1); - } else { // not --help - - generate_source(); } // Now set any defaults we might have missed out earlier @@ -937,6 +934,7 @@ FSO.CreateFolder(bd); } } + generate_source(); STDOUT.WriteLine("Generating source files - this may take a few seconds"); WScript.Sleep(3500);--------------------------------------------------------------------------------
-- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php