Skip to content

Commit eb87320

Browse files
committed
optimize static library size
1 parent 2ea2088 commit eb87320

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

patches/libchewing.patch

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index 59e012d8..380fead5 100644
2+
index 59e012d8..48dca4c0 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
55
@@ -77,7 +77,7 @@ corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES chewing_capi)
@@ -11,6 +11,15 @@ index 59e012d8..380fead5 100644
1111

1212
if(WITH_SQLITE3)
1313
corrosion_set_features(chewing_capi FEATURES sqlite)
14+
@@ -191,7 +191,7 @@ target_include_directories(libchewing
15+
)
16+
17+
corrosion_set_env_vars(chewing_capi
18+
- CHEWING_DATADIR=${CMAKE_INSTALL_FULL_DATADIR}/libchewing
19+
+ CHEWING_DATADIR="./libchewing"
20+
)
21+
target_link_libraries(libchewing PRIVATE chewing_capi)
22+
target_link_libraries(chewing_capi INTERFACE ${SQLite3_LIBRARIES})
1423
@@ -239,15 +239,17 @@ else()
1524
)
1625
endif()
@@ -44,3 +53,33 @@ index 59e012d8..380fead5 100644
4453

4554
# generate CMake Config files
4655
include(CMakePackageConfigHelpers)
56+
diff --git a/Cargo.toml b/Cargo.toml
57+
index d546d772..abf57c2f 100644
58+
--- a/Cargo.toml
59+
+++ b/Cargo.toml
60+
@@ -41,10 +41,10 @@ tempfile = "3.10.1"
61+
62+
[profile.release]
63+
lto = true
64+
-opt-level = 3
65+
+opt-level = "z"
66+
panic = "abort"
67+
codegen-units = 1
68+
-debug = true
69+
+debug = false
70+
71+
[package.metadata.docs.rs]
72+
features = ["sqlite"]
73+
diff --git a/capi/Cargo.toml b/capi/Cargo.toml
74+
index 517dd9e2..12fefb9e 100644
75+
--- a/capi/Cargo.toml
76+
+++ b/capi/Cargo.toml
77+
@@ -7,7 +7,7 @@ rust-version = "1.88"
78+
edition = "2024"
79+
80+
[lib]
81+
-crate-type = ["rlib", "staticlib"]
82+
+crate-type = ["staticlib"]
83+
84+
[dependencies]
85+
chewing = { version = "0.11.0", path = ".." }

0 commit comments

Comments
 (0)