From 03d426f6a6c17605154fff5a4ec3021d611932da Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 23 Dec 2003 15:33:13 +0000 Subject: [PATCH] implement our own tiny little dependcy tracker and use it to build distros. --- win32/build/Makefile | 11 +++++--- win32/build/deplister.c | 60 +++++++++++++++++++++++++++++++++++++++++ win32/build/mkdist.php | 37 +++++++++++++------------ 3 files changed, 85 insertions(+), 23 deletions(-) create mode 100644 win32/build/deplister.c diff --git a/win32/build/Makefile b/win32/build/Makefile index 5f81e5a34b..16061724d4 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -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 index 0000000000..8c998571bc --- /dev/null +++ b/win32/build/deplister.c @@ -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 | + +----------------------------------------------------------------------+ +*/ + +/* $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 +#include + +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 + */ diff --git a/win32/build/mkdist.php b/win32/build/mkdist.php index 39a12a65db..64952591d6 100644 --- a/win32/build/mkdist.php +++ b/win32/build/mkdist.php @@ -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"; } -- 2.40.0