From d97eabb0bc76c942f4063b634c349cc5b10f3318 Mon Sep 17 00:00:00 2001 From: John Stumpo Date: Sat, 27 Nov 2010 00:43:09 -0500 Subject: [PATCH] Generate .def files for the dependency DLLs at the end of the cross-build script. --- .gitignore | 1 + win32/makedefs.py | 122 ++++++++++++++++++++++++++++++++++++++++ win32/makedeps-cross.sh | 5 ++ win32/makedist.sh | 2 +- 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100755 win32/makedefs.py diff --git a/.gitignore b/.gitignore index 4d4e7a532..e6eee0860 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ data/themes/* !data/themes/Uberlight win32/* !win32/*.sh +!win32/*.py diff --git a/win32/makedefs.py b/win32/makedefs.py new file mode 100755 index 000000000..f55f324cb --- /dev/null +++ b/win32/makedefs.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# Script to create .defs from a folder of MinGW implibs and a folder of DLLs. +# Copyright (C) 2010 John Stumpo +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import struct +import sys +import glob +import shlex +import re +import subprocess + +if len(sys.argv) != 4: + sys.stderr.write('''Usage: %s [implib-dir] [dll-dir] [identify-cmd] +For each MinGW-style import library in implib-dir, locates the corresponding +DLL in dll-dir and creates a .def file for it in implib-dir, which MSVC +tools can be run on to create an MSVC-compatible implib. + +identify-cmd is run on each implib to discover what DLL it goes with. It is +split into an argument list using sh-style rules, then the implib name is +added to the end of the argument list. + +The .def files are named [whatever goes after -l to link to the lib].def +''' % sys.argv[0]) + sys.exit(1) + +def make_def(file): + f = open(file, 'rb') + if f.read(2) != 'MZ': + raise ValueError, 'Incorrect magic number in file.' + f.seek(60) + pe_header_offset = struct.unpack('>sys.stderr, 'Could not get a unique DLL name from %s.' % implib + continue + dllname = dllnames[0].rstrip('\n') + + for dll in dlls: + if dll.lower() == dllname.lower(): + def_contents = make_def(os.path.join(sys.argv[2], dll)) + open(os.path.join(sys.argv[1], dash_l_name+'.def'), 'w').write(def_contents) diff --git a/win32/makedeps-cross.sh b/win32/makedeps-cross.sh index 190c59c14..e16a396af 100755 --- a/win32/makedeps-cross.sh +++ b/win32/makedeps-cross.sh @@ -60,6 +60,7 @@ assert_binary_on_path autoreconf assert_binary_on_path libtoolize assert_binary_on_path make assert_binary_on_path pkg-config +assert_binary_on_path python assert_binary_on_path svn assert_binary_on_path tar assert_binary_on_path unzip @@ -277,3 +278,7 @@ if test ! -f "$PREFIX"/build-stamps/ffmpeg; then fi echo "All dependencies done." + +echo -n "Creating .def files... " +python makedefs.py deps/lib deps/bin "$CROSS_DLLTOOL -I" +echo "done" diff --git a/win32/makedist.sh b/win32/makedist.sh index 7000c0e06..f37582bcd 100755 --- a/win32/makedist.sh +++ b/win32/makedist.sh @@ -4,7 +4,7 @@ mkdir -pv dist cp -av deps dist rm -rf dist/deps/build-stamps dist/deps/etc dist/deps/share dist/deps/lib/gettext -rm -vf dist/deps/lib/*.def dist/deps/lib/*.la dist/deps/bin/wine-shwrap dist/deps/bin/pkg-config +rm -vf dist/deps/lib/*.la dist/deps/bin/wine-shwrap dist/deps/bin/pkg-config i586-mingw32msvc-strip --strip-all dist/deps/bin/*.exe dist/deps/bin/*.dll ZIPFILE="fofix-win32-deppack-`date +%Y%m%d`.zip" rm -f "$ZIPFILE"