Skip to content

Commit 32e7432

Browse files
committed
Add library stripping to reduce binary size
1 parent 1140921 commit 32e7432

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, ss]
66
pull_request:
7-
branches: [main]
7+
branches: [main, ss]
88

99
jobs:
1010
lint:

scripts/build.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ if (Deno.build.os === "windows") {
8484
"TOP=..\\",
8585
CFLAGS,
8686
);
87+
88+
// Strip the Windows DLL
89+
console.log(`%cStripping ${lib}...`, "color: #888");
90+
try {
91+
// Use link.exe with /SUBSYSTEM:WINDOWS /STRIP options
92+
$("link", `/EDIT`, `/SUBSYSTEM:WINDOWS`, `/STRIP`, `${lib}`);
93+
} catch (e) {
94+
console.log(`%cWarning: Stripping failed, using unstripped library: ${e.message}`, "color: #ff0");
95+
}
96+
8797
await Deno.copyFile(
8898
new URL(`../sqlite/build/${lib}`, import.meta.url),
8999
new URL(`../build/${libWithArch}`, import.meta.url),
@@ -104,10 +114,19 @@ if (Deno.build.os === "windows") {
104114
"8",
105115
CFLAGS,
106116
);
117+
118+
// Strip the library to remove debug symbols and reduce size
119+
console.log(`%cStripping ${lib}...`, "color: #888");
120+
try {
121+
$("strip", `--strip-unneeded`, `.libs/${lib}`);
122+
} catch (e) {
123+
console.log(`%cWarning: Stripping failed, using unstripped library: ${e.message}`, "color: #ff0");
124+
}
125+
107126
await Deno.copyFile(
108127
new URL(`../sqlite/build/.libs/${lib}`, import.meta.url),
109128
new URL(`../build/${libWithArch}`, import.meta.url),
110129
);
111130
}
112131

113-
console.log(`%c${libWithArch} built`, "color: #0f0");
132+
console.log(`%c${libWithArch} built and stripped`, "color: #0f0");

0 commit comments

Comments
 (0)