Skip to content

Commit 6bfe310

Browse files
fix: wasm profile and small fixes
1 parent 08e2082 commit 6bfe310

File tree

5 files changed

+25
-57
lines changed

5 files changed

+25
-57
lines changed

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
3+
"rust-analyzer.cargo.features": [],
4+
"protoc": {
5+
"options": ["-I/${workspaceRoot}/confidence-resolver/protos"]
6+
}
7+
}

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ members = [
77
"confidence-resolver",
88
"confidence-cloudflare-resolver"
99
]
10+
11+
12+
[profile.wasm]
13+
inherits = "release"
14+
opt-level = "z"
15+
lto = true
16+
codegen-units = 1
17+
panic = "unwind"
18+
strip = "symbols"

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ resolver-lint:
2525

2626
rust-guest:
2727
@echo "Building rust-guest (wasm32-unknown-unknown)..."
28-
cargo build -p rust-guest --target wasm32-unknown-unknown --release
28+
cargo build -p rust-guest --target wasm32-unknown-unknown --profile wasm
29+
@echo "Final WASM size: $$(/bin/ls -lh target/wasm32-unknown-unknown/release/rust_guest.wasm | awk '{print $$5}')"
2930

3031
rust-guest-lint:
3132
@echo "Linting rust-guest (wasm32-unknown-unknown)..."
@@ -62,5 +63,6 @@ run-java-host: rust-guest
6263
test: resolver-test
6364

6465
lint: resolver-lint cloudflare-lint rust-guest-lint
66+
cargo fmt --all --check
6567

6668
build: resolver cloudflare rust-guest

confidence-resolver/build.rs

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,55 +21,22 @@ fn main() -> Result<()> {
2121

2222
let mut config = prost_build::Config::new();
2323

24-
config.type_attribute(
24+
[
2525
"confidence.flags.admin.v1.ClientResolveInfo.EvaluationContextSchemaInstance",
26-
"#[derive(Eq, PartialOrd, Ord)]",
27-
);
28-
29-
config.type_attribute(
3026
"confidence.flags.admin.v1.ContextFieldSemanticType",
31-
"#[derive(Eq, PartialOrd, Ord)]",
32-
);
33-
34-
config.type_attribute(
3527
"confidence.flags.admin.v1.ContextFieldSemanticType.type",
36-
"#[derive(Eq, Ord, PartialOrd)]",
37-
);
38-
39-
config.type_attribute(
4028
"confidence.flags.admin.v1.ContextFieldSemanticType.VersionSemanticType",
41-
"#[derive(Eq, PartialOrd, Ord)]",
42-
);
43-
44-
config.type_attribute(
4529
"confidence.flags.admin.v1.ContextFieldSemanticType.CountrySemanticType",
46-
"#[derive(Eq, PartialOrd, Ord)]",
47-
);
48-
49-
config.type_attribute(
5030
"confidence.flags.admin.v1.ContextFieldSemanticType.TimestampSemanticType",
51-
"#[derive(Eq, PartialOrd, Ord)]",
52-
);
53-
54-
config.type_attribute(
5531
"confidence.flags.admin.v1.ContextFieldSemanticType.DateSemanticType",
56-
"#[derive(Eq, PartialOrd, Ord)]",
57-
);
58-
59-
config.type_attribute(
6032
"confidence.flags.admin.v1.ContextFieldSemanticType.EntitySemanticType",
61-
"#[derive(Eq, PartialOrd, Ord)]",
62-
);
63-
64-
config.type_attribute(
6533
"confidence.flags.admin.v1.ContextFieldSemanticType.EnumSemanticType",
66-
"#[derive(Eq, PartialOrd, Ord)]",
67-
);
68-
69-
config.type_attribute(
7034
"confidence.flags.admin.v1.ContextFieldSemanticType.EnumSemanticType.EnumValue",
71-
"#[derive(Eq, PartialOrd, Ord)]",
72-
);
35+
]
36+
.iter()
37+
.for_each(|&p| {
38+
config.type_attribute(p, "#[derive(Eq, PartialOrd, Ord)]");
39+
});
7340

7441
config
7542
.file_descriptor_set_path(&descriptor_path)

wasm/rust-guest/Cargo.toml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,6 @@ arc-swap = "1.7.1"
2121
prost-build = "0.12"
2222

2323

24-
[profile.release]
25-
# Optimize for size
26-
opt-level = 'z' # Optimize for size instead of speed
27-
lto = true # Enable link-time optimization
28-
codegen-units = 1 # Reduce number of codegen units to increase optimization
29-
panic = 'abort' # Remove panic unwinding code
30-
strip = true # Strip symbols from binary
31-
# Disable incremental compilation
32-
incremental = false
33-
# Disable debug assertions
34-
debug = false
35-
# Disable debug info
36-
debug-assertions = false
37-
# Disable overflow checks
38-
overflow-checks = false
39-
# Disable rpath
40-
rpath = false
4124

4225
[package.metadata.cargo-machete]
4326
ignored = ["prost", "prost-types", "prost-build"]

0 commit comments

Comments
 (0)