Skip to content

Commit 978044f

Browse files
committed
fix: Bundle some additional files on Windows
I hope we can get away with less than 45MB of icons...
1 parent fac607a commit 978044f

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

windows/build.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,20 @@
2424
f"{TARGET_DIR}/system76-keyboard-configurator.exe",
2525
}
2626

27-
DLL_RE = r"(?<==> ).*\\mingw32\\bin\\(\S+.dll)"
27+
DLL_RE = r"(?<==> )(.*\\mingw32)\\bin\\(\S+.dll)"
2828

2929

3030
# Use ntldd to find the mingw dlls required by a .exe
3131
def find_depends(exe):
3232
output = subprocess.check_output(['ntldd.exe', '-R', exe], universal_newlines=True)
3333
dlls = set()
34+
mingw_dir = None
3435
for l in output.splitlines():
3536
m = re.search(DLL_RE, l, re.IGNORECASE)
3637
if m:
37-
dlls.add((m.group(0), m.group(1)))
38-
return dlls
38+
dlls.add((m.group(0), m.group(2)))
39+
mingw_dir = m.group(1)
40+
return mingw_dir, dlls
3941

4042

4143
# Build application with rustup
@@ -46,8 +48,11 @@ def find_depends(exe):
4648

4749
# Generate set of all required dlls
4850
dlls = set()
51+
mingw_dir = None
4952
for i in EXES:
50-
dlls = dlls.union(find_depends(i))
53+
mingw_dir_new, dlls_new = find_depends(i)
54+
dlls = dlls.union(dlls_new)
55+
mingw_dir = mingw_dir or mingw_dir_new
5156

5257
# Generate libraries.wxi
5358
with open('libraries.wxi', 'w') as f:
@@ -71,8 +76,18 @@ def find_depends(exe):
7176
print(f"Strip {i} -> out/{filename}")
7277
subprocess.check_call([f"strip.exe", '-o', f"out/{filename}", i])
7378
for src, filename in dlls:
74-
print(f"Copy {src} -> out/{filename}")
75-
shutil.copy(f"{src}", 'out')
79+
dest = "out/" + filename
80+
print(f"Copy {src} -> {dest}")
81+
shutil.copy(src, 'out')
82+
83+
# Copy icons and other data
84+
os.mkdir("out/share")
85+
os.mkdir("out/lib")
86+
for i in ('share/icons', 'lib/p11-kit', 'lib/gdk-pixbuf-2.0'):
87+
src = mingw_dir + '\\' + i.replace('/', '\\')
88+
dest = "out/" + i
89+
print(f"Copy {src} -> {dest}")
90+
shutil.copytree(src, dest)
7691

7792
# Extract crate version from cargo
7893
meta_str = subprocess.check_output(CARGO + ["metadata", "--format-version", "1", "--no-deps"])

0 commit comments

Comments
 (0)