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




commit eb717391d0e8c179ed54b8ff56964b5d65f63a01
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.

 build/windows/crossbuild-gitlab-ci/dll_link.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/build/windows/crossbuild-gitlab-ci/dll_link.py b/build/windows/crossbuild-gitlab-ci/dll_link.py
index 710dda1c08..695c39f768 100755
--- a/build/windows/crossbuild-gitlab-ci/dll_link.py
+++ b/build/windows/crossbuild-gitlab-ci/dll_link.py
@@ -62,8 +62,19 @@ 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
+
+    file_type = subprocess.run(['file', filename], stdout=subprocess.PIPE)
+    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]