Skip to content

Commit 3892764

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

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
@@ -18,18 +18,20 @@
1818
f"{TARGET_DIR}/system76-keyboard-configurator.exe",
1919
}
2020

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

2323

2424
# Use ntldd to find the mingw dlls required by a .exe
2525
def find_depends(exe):
2626
output = subprocess.check_output(['ntldd.exe', '-R', exe], universal_newlines=True)
2727
dlls = set()
28+
mingw_dir = None
2829
for l in output.splitlines():
2930
m = re.search(DLL_RE, l, re.IGNORECASE)
3031
if m:
31-
dlls.add((m.group(0), m.group(1)))
32-
return dlls
32+
dlls.add((m.group(0), m.group(2)))
33+
mingw_dir = m.group(1)
34+
return mingw_dir, dlls
3335

3436

3537
# Build application with rustup
@@ -40,8 +42,11 @@ def find_depends(exe):
4042

4143
# Generate set of all required dlls
4244
dlls = set()
45+
mingw_dir = None
4346
for i in EXES:
44-
dlls = dlls.union(find_depends(i))
47+
mingw_dir_new, dlls_new = find_depends(i)
48+
dlls = dlls.union(dlls_new)
49+
mingw_dir = mingw_dir or mingw_dir_new
4550

4651
# Generate libraries.wxi
4752
with open('libraries.wxi', 'w') as f:
@@ -65,8 +70,18 @@ def find_depends(exe):
6570
print(f"Strip {i} -> out/{filename}")
6671
subprocess.check_call([f"strip.exe", '-o', f"out/{filename}", i])
6772
for src, filename in dlls:
68-
print(f"Copy {src} -> out/{filename}")
69-
shutil.copy(f"{src}", 'out')
73+
dest = "out/" + filename
74+
print(f"Copy {src} -> {dest}")
75+
shutil.copy(src, 'out')
76+
77+
# Copy icons and other data
78+
os.mkdir("out/share")
79+
os.mkdir("out/lib")
80+
for i in ('share/icons', 'lib/p11-kit', 'lib/gdk-pixbuf-2.0'):
81+
src = mingw_dir + '\\' + i.replace('/', '\\')
82+
dest = "out/" + i
83+
print(f"Copy {src} -> {dest}")
84+
shutil.copytree(src, dest)
7085

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

0 commit comments

Comments
 (0)