[PATCH] Static dependency errors
[email protected] ("Steph Fox")
| Newsgroups | php.internals.win |
|---|---|
| Message-ID | <00e201c8e9d5$8ef49a80$a7bd614d@foxbox> |
Hi all,
The attached patch ('ware DOS!) introduces a new configure switch, currently
"--disable-build-errors" but I'm open to suggestions there.
When build-errors is disabled, the two scenarios that can cause configure to
stop mid-way (static lib with a hard dependency on a shared lib or static
lib with a hard dependency on a missing static lib) will instead throw a
"BUILD ERROR" (equivalent to the existing WARNING) and disable the offending
static library.
If the switch isn't invoked, configure just dies. It has been this way from
inception for the first of those conditions, but only for the last 6 months
for the (much more common) second. I was responsible for adding that second
error, the rationale at the time being that the actual **build** used to
fail without prior warning.
In an off-list exchange with Rob, he wrote that he'd rather have faulty
static extensions disabled by default and use a configure switch to force a
full error. I'm the other way around on that, but if Rob's is the majority
opinion it would be trivial to make it work that way.
Why do I think this is important? Primarily because of the changes that have
been made to local config.w32 files to work around the existing situation.
Most of the internals developers (including/especially PECL devs) develop
under *nix-based systems, so I think making it very, very simple to write a
Windows configuration file is crucial for them - not to mention for any
Windows-based 'newbs' who may happen along. The focus has always been on
keeping PHP development simple; we should avoid any complications filtering
down to extension authors where possible.
To test, you'll need to revert the local config.w32 changes locally (because
otherwise all the dependency logic is skipped). Easiest is to just alter
ext/dom/config.w32 as below and do:
configure --without-libxml --disable-build-errors
/* ext/dom/config.w32 */
ARG_WITH("dom", "DOM support", "yes");
if (PHP_DOM == "yes") {
EXTENSION("dom", "php_dom.c attr.c document.c domerrorhandler.c \
domstringlist.c domexception.c namelist.c processinginstruction.c \
cdatasection.c documentfragment.c domimplementation.c element.c \
node.c string_extend.c characterdata.c documenttype.c \
domimplementationlist.c entity.c nodelist.c text.c comment.c \
domconfiguration.c domimplementationsource.c entityreference.c \
notation.c xpath.c dom_iterators.c typeinfo.c domerror.c \
domlocator.c namednodemap.c userdatahandler.c");
ADD_EXTENSION_DEP('dom', 'libxml')
AC_DEFINE("HAVE_DOM", 1, "DOM support");
}
Thanks,
- Steph
build_errors.txt
(text/plain, 3.7 KB)
Index: win32/build/config.w32
===================================================================
RCS file: /repository/php-src/win32/build/config.w32,v
retrieving revision 1.40.2.8.2.10.2.27
diff -u -r1.40.2.8.2.10.2.27 config.w32
--- win32/build/config.w32 14 Jul 2008 10:15:31 -0000 1.40.2.8.2.10.2.27
+++ win32/build/config.w32 19 Jul 2008 19:08:26 -0000
@@ -365,6 +365,7 @@
DEFINE('SNAPSHOT_TEMPLATE', PHP_SNAPSHOT_TEMPLATE);
+ARG_ENABLE('build-errors', 'Disable dependency-related errors', 'yes');
ARG_ENABLE('summary', 'Enable configuration summary', 'yes');
if (PHP_DSP != "no") {
Index: win32/build/confutils.js
===================================================================
RCS file: /repository/php-src/win32/build/confutils.js,v
retrieving revision 1.60.2.1.2.8.2.27
diff -u -r1.60.2.1.2.8.2.27 confutils.js
--- win32/build/confutils.js 19 Jul 2008 19:02:59 -0000 1.60.2.1.2.8.2.27
+++ win32/build/confutils.js 19 Jul 2008 19:12:07 -0000
@@ -1110,6 +1110,13 @@
MESSAGE("\tstatic " + extname + " cannot depend on shared " + dependson + ": " + dependson + "support disabled");
return false;
}
+
+ if (PHP_BUILD_ERRORS == "no") {
+ BUILD_ERROR("static " + extname + " cannot depend on shared " + dependson);
+ disable_static_module(EXT);
+ return false;
+ }
+
ERROR("static " + extname + " cannot depend on shared " + dependson);
}
@@ -1120,6 +1127,7 @@
} else {
if (dep_present == "no") {
+
if (ext_shared) {
WARNING(extname + " cannot be built: missing dependency, " + dependson + " not found");
@@ -1133,6 +1141,12 @@
}
+ if (PHP_BUILD_ERRORS == "no") {
+ BUILD_ERROR("Cannot build " + extname + "; " + dependson + " not enabled");
+ disable_static_module(EXT);
+ return false;
+ }
+
ERROR("Cannot build " + extname + "; " + dependson + " not enabled");
return false;
}
@@ -1348,6 +1362,33 @@
return false;
}
+function disable_static_module(EXT)
+{
+ var clflag = " $(CFLAGS_" + EXT + ")";
+ var ldflag = " $(LDFLAGS_" + EXT + ")";
+ var lib = " $(LIBS_" + EXT + ")";
+ var obj = " $(" + EXT + "_GLOBAL_OBJS)";
+ var ext = EXT.toLowerCase();
+ var extreg = new RegExp('\r\n.+' + ext + '\\S+');
+
+ configure_hdr.Add("HAVE_" + EXT, new Array(0, ""));
+
+ static_cflags = configure_subst.Item("STATIC_EXT_CFLAGS");
+ configure_subst.Item("STATIC_EXT_CFLAGS") = static_cflags.replace(clflag, "");
+ static_ldflags = configure_subst.Item("STATIC_EXT_LDFLAGS");
+ configure_subst.Item("STATIC_EXT_LDFLAGS") = static_ldflags.replace(ldflag, "");
+ static_libs = configure_subst.Item("STATIC_EXT_LIBS");
+ configure_subst.Item("STATIC_EXT_LIBS") = static_libs.replace(lib, "");
+ static_objs = configure_subst.Item("STATIC_EXT_OBJS");
+ configure_subst.Item("STATIC_EXT_OBJS") = static_objs.replace(obj, "");
+
+ extension_include_code = extension_include_code.replace(extreg, "");
+ extension_module_ptrs = extension_module_ptrs.replace(extreg, "");
+ extensions_enabled.pop();
+
+ return;
+}
+
function generate_internal_functions()
{
var infile, outfile;
@@ -1681,7 +1722,11 @@
var item = new Array(value, comment);
if (configure_hdr.Exists(name)) {
var orig_item = configure_hdr.Item(name);
- STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + orig_item[0]);
+ if (orig_item[0] == 0) {
+ configure_hdr.Remove(name);
+ } else {
+ STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + orig_item[0]);
+ }
} else {
configure_hdr.Add(name, item);
}
@@ -1698,6 +1743,12 @@
WScript.Quit(3);
}
+function BUILD_ERROR(msg)
+{
+ STDERR.WriteLine("BUILD ERROR: " + msg);
+ STDERR.WriteBlankLines(1);
+}
+
function WARNING(msg)
{
STDERR.WriteLine("WARNING: " + msg);