Skip to contentSkip to conversation

scripts/nsis.py: Run dependency check for each DLL file only once

PATCH Applied Stefan Weil via 4 participants 4 messages Jan 11, 2025 – Jan 14, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/nsis.py: Run dependency check for each DLL file only once

Each DLL should only be checked once for dependencies, but several hundred (781 in my test) unneeded checks were done.

Now the script is significantly faster (16 s in my build).

---
 scripts/nsis.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
scripts/nsis.py +5 -5
index d0914c88a7..d0ac61f6ab 100644
@@ -37,10 +37,10 @@ def find_deps(exe_or_dll, search_path, analyzed_deps):
 
         analyzed_deps.add(dep)
         # locate the dll dependencies recursively
-        rdeps = find_deps(dll, search_path, analyzed_deps)
+        analyzed_deps, rdeps = find_deps(dll, search_path, analyzed_deps)
         deps.extend(rdeps)
 
-    return deps
+    return analyzed_deps, deps
 
 def main():
     parser = argparse.ArgumentParser(description="QEMU NSIS build helper.")
@@ -92,18 +92,18 @@ def main():
         dlldir = os.path.join(destdir + prefix, "dll")
         os.mkdir(dlldir)
 
+        analyzed_deps = set()
         for exe in glob.glob(os.path.join(destdir + prefix, "*.exe")):
             signcode(exe)
 
             # find all dll dependencies
-            deps = set(find_deps(exe, search_path, set()))
+            analyzed_deps, deps = find_deps(exe, search_path, analyzed_deps)
+            deps = set(deps)
             deps.remove(exe)
 
             # copy all dlls to the DLLDIR
             for dep in deps:
                 dllfile = os.path.join(dlldir, os.path.basename(dep))
-                if (os.path.exists(dllfile)):
-                    continue
                 print("Copying '%s' to '%s'" % (dep, dllfile))
                 shutil.copy(dep, dllfile)
 
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 39 lines · Stefan Weil via

Each DLL should only be checked once for dependencies, but several hundred (781 in my test) unneeded checks were done.

Now the script is significantly faster (16 s in my build).

---
  scripts/nsis.py | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
scripts/nsis.py +5 -3
index d0914c88a7..d0ac61f6ab 100644
@@ -37,10 +37,10 @@ def find_deps(exe_or_dll, search_path, analyzed_deps):
 
          analyzed_deps.add(dep)
          # locate the dll dependencies recursively
-        rdeps = find_deps(dll, search_path, analyzed_deps)
+        analyzed_deps, rdeps = find_deps(dll, search_path, analyzed_deps)
          deps.extend(rdeps)
 
-    return deps
+    return analyzed_deps, deps
 
  def main():
      parser = argparse.ArgumentParser(description="QEMU NSIS build helper.")
@@ -92,18 +92,18 @@ def main():
          dlldir = os.path.join(destdir + prefix, "dll")
          os.mkdir(dlldir)
 
+        analyzed_deps = set()
          for exe in glob.glob(os.path.join(destdir + prefix, "*.exe")):
              signcode(exe)
 
              # find all dll dependencies
-            deps = set(find_deps(exe, search_path, set()))
+            analyzed_deps, deps = find_deps(exe, search_path, analyzed_deps)
+            deps = set(deps)

scripts/nsis.py def main(): · line 109

Quoted 10 lines
scripts/nsis.py +0 -2
              deps.remove(exe)
 
              # copy all dlls to the DLLDIR
              for dep in deps:
                  dllfile = os.path.join(dlldir, os.path.basename(dep))
-                if (os.path.exists(dllfile)):
-                    continue
                  print("Copying '%s' to '%s'" % (dep, dllfile))
                  shutil.copy(dep, dllfile)
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Stefan Weil via
Quoted 39 lines · Stefan Weil via

Each DLL should only be checked once for dependencies, but several hundred (781 in my test) unneeded checks were done.

Now the script is significantly faster (16 s in my build).

---
  scripts/nsis.py | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
scripts/nsis.py +5 -3
index d0914c88a7..d0ac61f6ab 100644
@@ -37,10 +37,10 @@ def find_deps(exe_or_dll, search_path, analyzed_deps):
 
          analyzed_deps.add(dep)
          # locate the dll dependencies recursively
-        rdeps = find_deps(dll, search_path, analyzed_deps)
+        analyzed_deps, rdeps = find_deps(dll, search_path, analyzed_deps)
          deps.extend(rdeps)
 
-    return deps
+    return analyzed_deps, deps
 
  def main():
      parser = argparse.ArgumentParser(description="QEMU NSIS build helper.")
@@ -92,18 +92,18 @@ def main():
          dlldir = os.path.join(destdir + prefix, "dll")
          os.mkdir(dlldir)
 
+        analyzed_deps = set()
          for exe in glob.glob(os.path.join(destdir + prefix, "*.exe")):
              signcode(exe)
 
              # find all dll dependencies
-            deps = set(find_deps(exe, search_path, set()))
+            analyzed_deps, deps = find_deps(exe, search_path, analyzed_deps)
+            deps = set(deps)

scripts/nsis.py def main(): · line 109

Quoted 10 lines
scripts/nsis.py +0 -2
              deps.remove(exe)
 
              # copy all dlls to the DLLDIR
              for dep in deps:
                  dllfile = os.path.join(dlldir, os.path.basename(dep))
-                if (os.path.exists(dllfile)):
-                    continue
                  print("Copying '%s' to '%s'" % (dep, dllfile))
                  shutil.copy(dep, dllfile)
 
Applied
#3 lore raw
In reply to Stefan Weil via
Quoted 6 lines · Stefan Weil via

Each DLL should only be checked once for dependencies, but several hundred (781 in my test) unneeded checks were done.

Now the script is significantly faster (16 s in my build).

Queued to maintainer/jan-2025, thanks.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro