Skip to content

Commit 1b1af0c

Browse files
committed
Replace build.rs with generate.rs
Add `generate.sh` script
1 parent bfd3894 commit 1b1af0c

File tree

6 files changed

+42
-35
lines changed

6 files changed

+42
-35
lines changed

contrib/scripts/generate.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
RUST_DIR="${SCRIPT_DIR}/../../rust"
7+
8+
cd "${RUST_DIR}"
9+
10+
cargo run --bin generate --features codegen

contrib/scripts/precommit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -exuo pipefail
44

55
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
66

7+
"${DIR}/generate.sh" # Generate dart output
78
"${DIR}/check-fmt.sh" # Format the code
89
"${DIR}/check-crate.sh" # Check crate
910
"${DIR}/check-flutter.sh" # Check flutter

justfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
44
default:
55
@just --list
66

7-
build:
8-
cd rust && cargo build
9-
107
precommit:
118
@bash contrib/scripts/precommit.sh
129

rust/Cargo.lock

Lines changed: 21 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ publish = false
77
[lib]
88
crate-type = ["cdylib", "staticlib"]
99

10+
[[bin]]
11+
name = "generate"
12+
path = "generate.rs"
13+
required-features = ["codegen"]
14+
15+
[features]
16+
default = []
17+
codegen = ["dep:flutter_rust_bridge_codegen"]
18+
1019
[dependencies]
1120
anyhow = "1.0"
1221
flutter_rust_bridge = "=2.0.0"
22+
flutter_rust_bridge_codegen = { version = "=2.0.0", optional = true }
1323
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "3b988fb13e0ea39c13dad116bd63333ea5d2bc36", default-features = false, features = ["all-nips", "tor"] }
1424

15-
[build-dependencies]
16-
flutter_rust_bridge_codegen = "=2.0.0"
17-
1825
[profile.release]
1926
opt-level = 'z' # Optimize for size.
2027
lto = true # Enable Link Time Optimization

rust/build.rs renamed to rust/generate.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ use lib_flutter_rust_bridge_codegen::codegen;
66
use lib_flutter_rust_bridge_codegen::codegen::Config;
77

88
fn main() {
9-
println!("cargo:rerun-if-changed=src/api");
10-
119
// Execute code generator with auto-detected config
1210
codegen::generate(
1311
Config::from_config_file("../flutter_rust_bridge.yaml")

0 commit comments

Comments
 (0)