[gimp/wip/Jehan/fix-jpexl-deps] build: test.



commit 87275f783fc2c003296bc46101b532a04fd7c310
Author: Jehan <jehan girinstud io>
Date:   Mon Oct 4 17:03:22 2021 +0200

    build: test.

 build/windows/gitlab-ci/dll_link.py           | 49 ++++++++++++++++-----------
 build/windows/gitlab-ci/package-gimp-msys2.sh |  3 +-
 2 files changed, 31 insertions(+), 21 deletions(-)
---
diff --git a/build/windows/gitlab-ci/dll_link.py b/build/windows/gitlab-ci/dll_link.py
index 4c1330ccdc..b972b0400e 100755
--- a/build/windows/gitlab-ci/dll_link.py
+++ b/build/windows/gitlab-ci/dll_link.py
@@ -34,9 +34,10 @@ bindir = 'bin'
 # Functions
 
 # Main function
-def main(binary, srcdir, destdir, debug):
-  sys.stdout.write("{} (INFO): searching for dependencies of {} in {}\n".format(os.path.basename(__file__), 
binary, srcdir))
-  find_dependencies(binary, srcdir)
+def main(binary, srcdirs, destdir, debug):
+  sys.stdout.write("{} (INFO): searching for dependencies of {} in {}.\n".format(os.path.basename(__file__),
+                                                                                 binary, ', '.join(srcdirs)))
+  find_dependencies(os.path.abspath(binary), srcdirs)
   if args.debug:
     print("Running in debug mode (no DLL moved)")
     if len(dlls) > 0:
@@ -58,13 +59,23 @@ def main(binary, srcdir, destdir, debug):
       sys.stdout.write("\n\t- ".join(installed_dlls))
       print()
   else:
-    copy_dlls(dlls - sys_dlls, srcdir, destdir)
+    copy_dlls(dlls - sys_dlls, destdir)
 
-def find_dependencies(obj, srcdir):
+def find_dependencies(obj, srcdirs):
   '''
   List DLLs of an object file in a recursive way.
   '''
-  if os.path.exists(obj):
+  if not os.path.isabs(obj):
+    for srcdir in srcdirs:
+      abs_dll = os.path.join(srcdir, bindir, dll)
+      if find_dependencies(abs_dll, srcdirs):
+        dlls.add(abs_dll)
+        return True
+    else:
+      # Found in none of the srcdirs: consider it a system DLL
+      sys_dlls.add(os.path.basename(obj))
+      return False
+  elif os.path.exists(obj):
     # If DLL exists, extract dependencies.
     objdump = None
 
@@ -92,33 +103,33 @@ def find_dependencies(obj, srcdir):
     for match in re.finditer(r"DLL Name: *(\S+.dll)", out, re.MULTILINE):
       dll = match.group(1)
       if dll not in dlls:
-        dlls.add(dll)
-        next_dll = os.path.join(srcdir, bindir, dll)
-        find_dependencies(next_dll, srcdir)
+        find_dependencies(dll, srcdirs)
+
+    return True
   else:
-    # Otherwise, it is a system DLL
-    sys_dlls.add(os.path.basename(obj))
+    return False
 
 # Copy a DLL set into the /destdir/bin directory
-def copy_dlls(dll_list, srcdir, destdir):
+def copy_dlls(dll_list, destdir):
   destbin = os.path.join(destdir, bindir)
   os.makedirs(destbin, exist_ok=True)
   for dll in dll_list:
-    full_file_name = os.path.join(srcdir, bindir, dll)
-    if os.path.isfile(full_file_name):
-      if not os.path.exists(os.path.join(destbin, dll)):
-        sys.stdout.write("{} (INFO): copying {} to {}\n".format(os.path.basename(__file__), full_file_name, 
destbin))
-        shutil.copy(full_file_name, destbin)
+    if os.path.isfile(dll):
+      if not os.path.exists(os.path.join(destbin, os.path.basename(dll))):
+        sys.stdout.write("{} (INFO): copying {} to {}\n".format(os.path.basename(__file__), dll, destbin))
+        shutil.copy(dll, destbin)
     else:
-      sys.stderr.write("Missing DLL: {}\n".format(full_file_name))
+      sys.stderr.write("Missing DLL: {}\n".format(dll))
       sys.exit(os.EX_DATAERR)
 
 if __name__ == "__main__":
   parser = argparse.ArgumentParser()
   parser.add_argument('--debug', dest='debug', action = 'store_true', default = False)
   parser.add_argument('bin')
-  parser.add_argument('src')
+  parser.add_argument('src', nargs='+')
   parser.add_argument('dest')
   args = parser.parse_args(sys.argv[1:])
 
+  print("args.src: {}".format(args.src))
+  print("args.dest: {}".format(args.dest))
   main(args.bin, args.src, args.dest, args.debug)
diff --git a/build/windows/gitlab-ci/package-gimp-msys2.sh b/build/windows/gitlab-ci/package-gimp-msys2.sh
index 2819dd3d4b..0d9dd4220b 100644
--- a/build/windows/gitlab-ci/package-gimp-msys2.sh
+++ b/build/windows/gitlab-ci/package-gimp-msys2.sh
@@ -230,8 +230,7 @@ done
 # Libraries for GObject Introspection.
 
 cp -fr ${MSYS_PREFIX}/bin/libgirepository-1.0-1.dll ${GIMP_DISTRIB}/bin/
-python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/libgirepository-1.0-1.dll ${GIMP_PREFIX}/ 
${GIMP_DISTRIB}
-python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/libgirepository-1.0-1.dll ${MSYS_PREFIX}/ 
${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/libgirepository-1.0-1.dll ${GIMP_PREFIX}/ 
${MSYS_PREFIX}/ ${GIMP_DISTRIB}
 
 for dll in ${GIMP_DISTRIB}/lib/python3.9/site-packages/*/*.dll; do
   python3 build/windows/gitlab-ci/dll_link.py $dll ${GIMP_PREFIX}/ ${GIMP_DISTRIB};


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