[gimp/wip/Jehan/win32-distrib-job] build: dll_link.py improved to handle both i686 and x86-64 Windows…




commit 397f22c06348c40f397050a74bf74bffbc4b3802
Author: Jehan <jehan girinstud io>
Date:   Fri Oct 2 02:06:26 2020 +0200

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

 .gitlab-ci.yml                                 |  4 ++--
 build/windows/crossbuild-gitlab-ci/dll_link.py | 16 ++++++++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1ba25d03c2..aa62db983d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -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}
diff --git a/build/windows/crossbuild-gitlab-ci/dll_link.py b/build/windows/crossbuild-gitlab-ci/dll_link.py
index 710dda1c08..5a98ca4da7 100755
--- a/build/windows/crossbuild-gitlab-ci/dll_link.py
+++ b/build/windows/crossbuild-gitlab-ci/dll_link.py
@@ -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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]