]> granicus.if.org Git - php/commitdiff
implement our own tiny little dependcy tracker and use
authorWez Furlong <wez@php.net>
Tue, 23 Dec 2003 15:33:13 +0000 (15:33 +0000)
committerWez Furlong <wez@php.net>
Tue, 23 Dec 2003 15:33:13 +0000 (15:33 +0000)
it to build distros.

win32/build/Makefile
win32/build/deplister.c [new file with mode: 0644]
win32/build/mkdist.php

index 5f81e5a34b8cecc82e189c4d9b941d44f1876fe3..16061724d4a004e63dfe182e401f894626f2f716 100644 (file)
@@ -85,7 +85,7 @@ build-snap:
        for %T in ($(SAPI_TARGETS)) do $(MAKE) /nologo "%T"
        for %T in ($(EXT_TARGETS)) do $(MAKE) /nologo "%T"
 
-build-dist:
+build-dist: $(BUILD_DIR)\deplister.exe
        -rmdir /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
        -del /f /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING).zip
        $(BUILD_DIR)\php.exe win32/build/mkdist.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" "$(SNAPSHOT_TEMPLATE)"
@@ -96,10 +96,13 @@ build-dist:
 dist: all build-dist
 snap: build-snap build-dist
 
+$(BUILD_DIR)\deplister.exe:    win32\build\deplister.c
+       $(CL) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) -o$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib
+
 msi-installer: dist
        $(BUILD_DIR)\php.exe ..\php-installer\build-installer.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)"
 
 install: all
-       @copy $(BUILD_DIR)\*.exe $(PHP_PREFIX) /y >null
-       @copy $(BUILD_DIR)\*.dll $(PHP_PREFIX) /y >null
-       
\ No newline at end of file
+       @copy $(BUILD_DIR)\*.exe $(PHP_PREFIX) /y >nul
+       @copy $(BUILD_DIR)\*.dll $(PHP_PREFIX) /y >nul
+       
diff --git a/win32/build/deplister.c b/win32/build/deplister.c
new file mode 100644 (file)
index 0000000..8c99857
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+  +----------------------------------------------------------------------+
+  | PHP Version 5                                                        |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 1997-2003 The PHP Group                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.0 of the PHP license,       |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_0.txt.                                  |
+  | If you did not receive a copy of the PHP license and are unable to   |
+  | obtain it through the world-wide-web, please send a note to          |
+  | license@php.net so we can mail you a copy immediately.               |
+  +----------------------------------------------------------------------+
+  | Author: Wez Furlong <wez@thebrainroom.com>                           |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+/* This little application will list the DLL dependencies for a PE
+ * module to it's stdout for use by distro/installer building tools */
+
+#include <windows.h>
+#include <imagehlp.h>
+
+BOOL CALLBACK StatusRoutine(IMAGEHLP_STATUS_REASON reason,
+               PSTR image_name, PSTR dll_name,
+               ULONG va, ULONG param)
+{
+       switch (reason) {
+               case BindImportModuleFailed:
+                       printf("%s,NOTFOUND\n", dll_name);
+                       return TRUE;
+
+               case BindImportModule:
+                       printf("%s,OK\n", dll_name);
+                       return TRUE;
+       }
+       return TRUE;
+}
+
+/* usage:
+ * deplister.exe path\to\module.exe path\to\symbols\root
+ * */
+
+int main(int argc, char *argv[])
+{
+       return BindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES,
+               argv[1], NULL, argv[2], StatusRoutine); 
+}
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
index 39a12a65db4add1b6f5def29abd54ab9ea8f6daf..64952591d6fef8891a53ab0944913dd3270bed31 100644 (file)
@@ -25,11 +25,6 @@ $per_module_deps = array();
 
 function get_depends($module)
 {
-       // skip this for now; working on a more portable solution
-       // since VC6 ships with an old version of depends.exe that
-       // doesn't have the command line options
-       return;
-
        static $no_dist = array(
                /* windows system dlls that should not be bundled */
                'advapi32.dll', 'comdlg32.dll', 'gdi32.dll', 'kernel32.dll', 'ntdll.dll',
@@ -41,6 +36,12 @@ function get_depends($module)
                /* apache */
                'apachecore.dll',
 
+               /* apache 2 */
+               'libhttpd.dll', 'libapr.dll', 'libaprutil.dll',
+
+               /* pi3web */
+               'piapi.dll', 'pi3api.dll',
+
                /* nsapi */
                'ns-httpd30.dll', 'ns-httpd35.dll', 'ns-httpd36.dll', 'ns-httpd40.dll',
 
@@ -60,24 +61,22 @@ function get_depends($module)
        
        $bd = strtolower(realpath($build_dir));
 
-       $csvname = tempnam($GLOBALS['build_dir'], '_dep');
-       system("depends.exe /c /f:1 /oc:\"$csvname\" \"$module\"", $retcode);
-       $fp = fopen($csvname, "r");
-       $headers = fgetcsv($fp);
+       $cmd = "$GLOBALS[build_dir]\\deplister.exe \"$module\" \"$GLOBALS[build_dir]\"";
+       $proc = proc_open($cmd, 
+                       array(1 => array("pipe", "w")),
+                       $pipes);
+
        $n = 0;
-       while (($line = fgetcsv($fp))) {
+       while (($line = fgetcsv($pipes[1]))) {
                $n++;
-               if ($line[0] == 'D')
-                       continue;
 
-               $dep = strtolower($line[1]);
+               $dep = strtolower($line[0]);
                $depbase = basename($dep);
                /* ignore stuff in our build dir, but only if it is
-            * on of our targets */
-               if (0 == strncmp($dep, $bd, strlen($bd)) &&
-                               (in_array($depbase, $sapi_targets) ||
+            * one of our targets */
+               if (((in_array($depbase, $sapi_targets) ||
                                in_array($depbase, $ext_targets)) ||
-                               $depbase == $phpdll) {
+                               $depbase == $phpdll) && file_exists($GLOBALS['build_dir'] . "/$depbase")) {
                        continue;
                }
                /* ignore some well-known system dlls */
@@ -91,8 +90,8 @@ function get_depends($module)
 
                $per_module_deps[basename($module)][] = $dep;
        }
-       fclose($fp);
-       unlink($csvname);
+       fclose($pipes[1]);
+       proc_close($proc);
 //echo "Module $module [$n lines]\n";
 }