Skip to content

Commit

Permalink
Replace build.rs with generate.rs
Browse files Browse the repository at this point in the history
Add `generate.sh` script
  • Loading branch information
yukibtc committed Dec 23, 2024
1 parent bfd3894 commit 1b1af0c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 35 deletions.
10 changes: 10 additions & 0 deletions contrib/scripts/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RUST_DIR="${SCRIPT_DIR}/../../rust"

cd "${RUST_DIR}"

cargo run --bin generate --features codegen
1 change: 1 addition & 0 deletions contrib/scripts/precommit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -exuo pipefail

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

"${DIR}/generate.sh" # Generate dart output
"${DIR}/check-fmt.sh" # Format the code
"${DIR}/check-crate.sh" # Check crate
"${DIR}/check-flutter.sh" # Check flutter
3 changes: 0 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
default:
@just --list

build:
cd rust && cargo build

precommit:
@bash contrib/scripts/precommit.sh

Expand Down
48 changes: 21 additions & 27 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ publish = false
[lib]
crate-type = ["cdylib", "staticlib"]

[[bin]]
name = "generate"
path = "generate.rs"
required-features = ["codegen"]

[features]
default = []
codegen = ["dep:flutter_rust_bridge_codegen"]

[dependencies]
anyhow = "1.0"
flutter_rust_bridge = "=2.0.0"
flutter_rust_bridge_codegen = { version = "=2.0.0", optional = true }
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "3b988fb13e0ea39c13dad116bd63333ea5d2bc36", default-features = false, features = ["all-nips", "tor"] }

[build-dependencies]
flutter_rust_bridge_codegen = "=2.0.0"

[profile.release]
opt-level = 'z' # Optimize for size.
lto = true # Enable Link Time Optimization
Expand Down
2 changes: 0 additions & 2 deletions rust/build.rs → rust/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use lib_flutter_rust_bridge_codegen::codegen;
use lib_flutter_rust_bridge_codegen::codegen::Config;

fn main() {
println!("cargo:rerun-if-changed=src/api");

// Execute code generator with auto-detected config
codegen::generate(
Config::from_config_file("../flutter_rust_bridge.yaml")
Expand Down

0 comments on commit 1b1af0c

Please sign in to comment.