mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Implement extension load-order deps.
This commit is contained in:
parent
22b70fcb31
commit
ed682e570a
9 changed files with 133 additions and 4 deletions
11
acinclude.m4
11
acinclude.m4
|
@ -1920,3 +1920,14 @@ AC_DEFUN(PHP_TEST_BUILD, [
|
|||
LIBS=$old_LIBS
|
||||
])
|
||||
])
|
||||
|
||||
dnl This macro is currently a placeholder in the config.m4 file
|
||||
dnl it is scanned by genif.sh when it builds the internal functions
|
||||
dnl list, so that modules can be init'd in the correct order
|
||||
dnl $1 = name of extension, $2 = extension upon which it depends
|
||||
dnl $3 = optional: if true, it's ok for $2 to have not been configured
|
||||
dnl default is false and should halt the build.
|
||||
dnl See ADD_EXTENSION_DEP in win32 build
|
||||
AC_DEFUN(PHP_ADD_EXTENSION_DEP, [])
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#! /bin/sh
|
||||
|
||||
# $Id: genif.sh,v 1.3 2002-03-22 10:22:41 sas Exp $
|
||||
# $Id: genif.sh,v 1.4 2004-07-18 12:03:51 wez Exp $
|
||||
# replacement for genif.pl
|
||||
|
||||
infile=$1
|
||||
|
@ -17,13 +17,13 @@ if test -z "$infile" || test -z "$srcdir"; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
module_ptrs=$extra_module_ptrs
|
||||
header_list=
|
||||
olddir=`pwd`
|
||||
cd $srcdir
|
||||
|
||||
module_ptrs="$extra_module_ptrs`echo $@ | $awk -f ./build/order_by_dep.awk`"
|
||||
|
||||
for ext in ${1+"$@"} ; do
|
||||
module_ptrs=" phpext_${ext}_ptr,@NEWLINE@$module_ptrs"
|
||||
header_list="$header_list ext/$ext/*.h"
|
||||
done
|
||||
|
||||
|
|
89
build/order_by_dep.awk
Normal file
89
build/order_by_dep.awk
Normal file
|
@ -0,0 +1,89 @@
|
|||
BEGIN {
|
||||
orig_rs = RS;
|
||||
orig_fs = FS;
|
||||
RS=" ";
|
||||
mod_count = 0;
|
||||
SUBSEP=":";
|
||||
}
|
||||
|
||||
function get_deps(module_name, depline, cmd)
|
||||
{
|
||||
# this could probably be made *much* better
|
||||
RS=orig_rs;
|
||||
FS="[(,) \t]+"
|
||||
cmd = "grep PHP_ADD_EXTENSION_DEP ext/" module_name "/config*.m4"
|
||||
while (cmd | getline) {
|
||||
# printf("GOT: %s,%s,%s,%s,%s\n", $1, $2, $3, $4, $5);
|
||||
if (!length($5)) {
|
||||
$5 = 0;
|
||||
}
|
||||
mod_deps[module_name, $4] = $5;
|
||||
}
|
||||
close(cmd)
|
||||
RS=" ";
|
||||
FS=orig_fs;
|
||||
}
|
||||
|
||||
function get_module_index(name, i)
|
||||
{
|
||||
for (i in mods) {
|
||||
if (mods[i] == name) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function do_deps(mod_idx, module_name, mod_name_len, dep, ext, val, depidx)
|
||||
{
|
||||
module_name = mods[mod_idx];
|
||||
mod_name_len = length(module_name);
|
||||
|
||||
for (ext in mod_deps) {
|
||||
if (substr(ext, 0, mod_name_len+1) != module_name SUBSEP) {
|
||||
continue;
|
||||
}
|
||||
val = mod_deps[ext];
|
||||
ext = substr(ext, mod_name_len+2, length(ext)-mod_name_len);
|
||||
|
||||
depidx = get_module_index(ext);
|
||||
if (depidx >= 0) {
|
||||
do_deps(depidx);
|
||||
}
|
||||
}
|
||||
|
||||
#printf(" phpext_%s_ptr,\n", module_name);
|
||||
printf(" phpext_%s_ptr,@NEWLINE@", module_name);
|
||||
delete mods[mod_idx];
|
||||
}
|
||||
|
||||
function count(arr, n, i)
|
||||
{
|
||||
n = 0;
|
||||
for (i in arr)
|
||||
n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
/^[a-zA-Z0-9_-]+/ {
|
||||
# mini hack for pedantic awk
|
||||
gsub("[^a-zA-Z0-9_-]", "", $1)
|
||||
# add each item to array
|
||||
mods[mod_count++] = $1
|
||||
|
||||
# see if it has any module deps
|
||||
get_deps($1);
|
||||
}
|
||||
END {
|
||||
# order it correctly
|
||||
out_count = 0;
|
||||
|
||||
while (count(mods)) {
|
||||
# count down, since we need to assemble it in reverse order
|
||||
for (i = mod_count-1; i >= 0; --i) {
|
||||
if (i in mods) {
|
||||
do_deps(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
configure.in
26
configure.in
|
@ -130,7 +130,31 @@ PHP_RUNPATH_SWITCH
|
|||
PHP_PROG_RE2C
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_AWK
|
||||
|
||||
dnl Some vendors force mawk before gawk; mawk is broken so we don't like that,
|
||||
dnl and check manually
|
||||
dnl AC_PROG_AWK
|
||||
AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
|
||||
case "$AWK" in
|
||||
*mawk)
|
||||
AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
|
||||
;;
|
||||
*gawk)
|
||||
;;
|
||||
bork)
|
||||
AC_MSG_ERROR([Could not find awk; Install GNU awk])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_CHECKING([if $AWK is broken])
|
||||
if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_MSG_ERROR([You should install GNU awk])
|
||||
else
|
||||
AC_MSG_RESULT([no - good!])
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_PROG_YACC
|
||||
if test "$YACC" != "bison -y"; then
|
||||
AC_MSG_WARN([You will need bison if you want to regenerate the PHP parsers.])
|
||||
|
|
|
@ -26,6 +26,7 @@ if test "$PHP_DOM" != "no" && test "$PHP_LIBXML" != "no"; then
|
|||
typeinfo.c domerror.c domlocator.c namednodemap.c userdatahandler.c],
|
||||
$ext_shared)
|
||||
PHP_SUBST(DOM_SHARED_LIBADD)
|
||||
PHP_ADD_EXTENSION_DEP(dom, libxml)
|
||||
], [
|
||||
AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
|
||||
])
|
||||
|
|
|
@ -18,4 +18,5 @@ if test "$PHP_SIMPLEXML" != "no" && test "$PHP_LIBXML" != "no"; then
|
|||
], [
|
||||
AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
|
||||
])
|
||||
PHP_ADD_EXTENSION_DEP(simplexml, libxml)
|
||||
fi
|
||||
|
|
|
@ -10,4 +10,5 @@ if test "$PHP_SPL" != "no"; then
|
|||
fi
|
||||
AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support])
|
||||
PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_sxe.c, $ext_shared)
|
||||
PHP_ADD_EXTENSION_DEP(spl, simplexml)
|
||||
fi
|
||||
|
|
|
@ -47,5 +47,6 @@ if test "$PHP_XML" != "no" && test "$PHP_LIBXML" != "no" -o "$PHP_LIBEXPAT_DIR"
|
|||
|
||||
PHP_NEW_EXTENSION(xml, xml.c $xml_extra_sources, $ext_shared)
|
||||
PHP_SUBST(XML_SHARED_LIBADD)
|
||||
PHP_ADD_EXTENSION_DEP(xml, libxml)
|
||||
AC_DEFINE(HAVE_XML, 1, [ ])
|
||||
fi
|
||||
|
|
|
@ -59,4 +59,5 @@ if test "$PHP_XSL" != "no"; then
|
|||
AC_DEFINE(HAVE_XSL,1,[ ])
|
||||
PHP_NEW_EXTENSION(xsl, php_xsl.c xsltprocessor.c, $ext_shared)
|
||||
PHP_SUBST(XSL_SHARED_LIBADD)
|
||||
PHP_ADD_EXTENSION_DEP(xsl, libxml)
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue