Skip to content

Commit

Permalink
Default to twsearch for the cargo run and cargo test.
Browse files Browse the repository at this point in the history
This is done by specifing a single default package in the top-level `Cargo.toml`: rust-lang/cargo#7290
  • Loading branch information
lgarron committed Aug 24, 2023
1 parent 7b89b1d commit f92a0f2
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ members = [
"src/cpp",
"src/rs",
]
default-members = [
"src/rs"
]
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,19 @@ test-rs-all: \
test-rs-orientation_packer \
test-rs-no_orientation_mod

TEST_RS = cargo test --package twsearch

.PHONY: test-rs-default
test-rs-default:
${TEST_RS}
cargo test

.PHONY: test-rs-orientation_packer
test-rs-orientation_packer:
${TEST_RS} --features orientation_packer
cargo test --features orientation_packer

.PHONY: test-rs-no_orientation_mod
test-rs-no_orientation_mod:
${TEST_RS} --features no_orientation_mod
cargo test --features no_orientation_mod

BENCHMARK_RS = cargo run --package twsearch --release --example benchmark
BENCHMARK_RS = cargo run --release --example benchmark

.PHONY: benchmark-rs-all
benchmark-rs-all: \
Expand Down
2 changes: 2 additions & 0 deletions src/cpp/examples/lib/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ impl CliCommand {
CliCommand::Cpp() => &[],
CliCommand::Rust() => &[
"run",
"--package",
"twsearch-cpp-wrapper",
"--quiet", // Suppress deprecation warnings for transitive dependencies (`buf_redux`, `multipart`): https://github.com/tomaka/rouille/issues/271
"--",
"search",
Expand Down
8 changes: 6 additions & 2 deletions src/rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ no_orientation_mod = []

[dependencies]
cityhash = "0.1.1"
clap = "4.3.24"
clap = { version = "4.3.24", features = ["derive"] }
clap_complete = "4.3.2"
cubing = "0.5.4"
derive_more = "0.99.17"
serde = "1.0.186"
serde = { version = "1.0.186", features = ["derive", "rc"] }

[dev-dependencies]
wait-timeout = "0.2.0"

[lib]
path = "./mod.rs"

[[bin]]
name = "twsearch"
path = "./cli/main.rs"
27 changes: 27 additions & 0 deletions src/rs/cli/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use std::process::exit;

use twsearch::_internal::cli::{get_options_cpp_wrapper, CliCommand};

fn main() {
let args = get_options_cpp_wrapper();

let result: Result<(), String> = match args.command {
CliCommand::Completions(_completions_args) => {
panic!("Completions should have been printed during options parsing, followed by program exit.");
}
CliCommand::Search(_search_command_args) => todo!(),
CliCommand::Serve(_serve_command_args) => {
eprintln!("Skipping `serve` command.");
Ok(())
}
// TODO: consolidate def-only arg implementations.
CliCommand::SchreierSims(_schreier_sims_command_args) => todo!(),
CliCommand::GodsAlgorithm(_gods_algorithm_args) => todo!(),
CliCommand::TimingTest(_args) => todo!(),
CliCommand::CanonicalAlgs(_args) => todo!(),
};
if let Err(err) = result {
eprintln!("{}", err);
exit(1);
}
}

0 comments on commit f92a0f2

Please sign in to comment.