Skip to content

Commit

Permalink
FREEZE.indexed
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Jan 19, 2025
1 parent 73bbe09 commit 3178bd0
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# TODO: remove this once we're no longer compiling C++ with Rust.
[future-incompat-report]
frequency = "never"

[alias]
tool-run-bin = ["run", "--quiet", "--package", "cargo-bin", "--"]
87 changes: 85 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"src/rs",
"src/rs-ffi",
"src/rs-wasm",
"tools/cargo-run-bin"
]
default-members = [
"src/rs"
Expand Down
2 changes: 1 addition & 1 deletion Makefiles/rust-ffi.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
build-rust-ffi:
cargo build --release --package twsearch-ffi
mkdir -p "./.temp"
cargo bin cbindgen --crate twsearch-ffi --lang c --cpp-compat --output "./.temp/twsearch-ffi.h" # TODO: install `cbindgen`
cargo tool-run-bin cbindgen --crate twsearch-ffi --lang c --cpp-compat --output "./.temp/twsearch-ffi.h" # TODO: install `cbindgen`
cat "./.temp/twsearch-ffi.h" | sed "s#\[..\];#;#g" | sed "s#\[.\];#;#g" | sed "s#const uint8_t#const char#g" > "./target/release/libtwsearch_ffi.h"

.PHONY: test-rust-ffi # TODO: non-PHONY?
Expand Down
2 changes: 1 addition & 1 deletion Makefiles/rust-wasm.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.PHONY: build-rust-wasm
build-rust-wasm:
rm -rf "./.temp/rust-wasm"
cargo bin wasm-pack build --release --target web --out-dir "../../.temp/rust-wasm" src/rs-wasm
cargo tool-run-bin wasm-pack build --release --target web --out-dir "../../.temp/rust-wasm" src/rs-wasm
bun run script/node-esm-compat.ts
bun run "./script/build-wasm-package.ts"

Expand Down
8 changes: 8 additions & 0 deletions tools/cargo-run-bin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "cargo-bin"
version.workspace = true
license.workspace = true
edition.workspace = true

[dependencies]
cargo-run-bin = { version = "1.7.4", features = ["cli"] }
1 change: 1 addition & 0 deletions tools/cargo-run-bin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This package must be named `cargo-bin`, because `cargo-run-bin` needs to believe its binary is `cargo-bin`: <https://github.com/dustinblackman/cargo-run-bin/issues/21#issuecomment-2600372315> (even though [`cargo-bin`](https://crates.io/crates/cargo-bin) is also a separate thing that exists).
17 changes: 17 additions & 0 deletions tools/cargo-run-bin/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::{env, process};

fn main() {
for argument in env::args() {
println!("{argument}");
}
let res = cargo_run_bin::cli::run();

dbg!(&res);

// Only reached if run-bin code fails, otherwise process exits early from within
// binary::run.
if let Err(res) = res {
eprintln!("\x1b[31m{}\x1b[0m", format!("run-bin failed: {res}"));
process::exit(1);
}
}

0 comments on commit 3178bd0

Please sign in to comment.