build: dll_link.py improved to handle both i686 and x86-64 Windows…

… executable formats inspection.
This commit is contained in:
Jehan 2020-10-02 02:06:26 +02:00
parent 8f8f7e497a
commit cdb61d829e
2 changed files with 16 additions and 4 deletions

View File

@ -357,7 +357,7 @@ win64-nightly:
- gimp-w64
script:
- apt-get update
- apt-get install -y --no-install-recommends python3 binutils-mingw-w64-x86-64
- apt-get install -y --no-install-recommends python3 binutils-mingw-w64-x86-64 file
# Package ressources.
- mkdir -p ${GIMP_DISTRIB}
@ -427,7 +427,7 @@ win32-nightly:
- gimp-w32
script:
- apt-get update
- apt-get install -y --no-install-recommends python3 binutils-mingw-w64-i686
- apt-get install -y --no-install-recommends python3 binutils-mingw-w64-i686 file
# Package ressources.
- mkdir -p ${GIMP_DISTRIB}

View File

@ -62,8 +62,20 @@ def main():
def recursive(filename):
# Check if DLL exist in /bin folder, if true extract depencies too.
if os.path.exists(filename):
result = subprocess.run(
['x86_64-w64-mingw32-objdump', '-p', filename], stdout=subprocess.PIPE)
objdump = None
result = subprocess.run(['file', filename], stdout=subprocess.PIPE)
file_type = result.stdout.decode('utf-8')
if 'PE32+' in file_type:
objdump = 'x86_64-w64-mingw32-objdump'
elif 'PE32' in file_type:
objdump = 'i686-w64-mingw32-objdump'
if objdump is None:
sys.stderr.write('File type of {} unknown: {}\n'.format(filename, file_type))
sys.exit(os.EX_UNAVAILABLE)
result = subprocess.run([objdump, '-p', filename], stdout=subprocess.PIPE)
out = result.stdout.decode('utf-8')
# Parse lines with DLL Name instead of lib*.dll directly
items = re.findall(r"DLL Name: \S+.dll", out, re.MULTILINE)