From 2cf18531999f785dcb95da55bb9935bd5ea0ae0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=B6rgens?= Date: Thu, 9 Jan 2025 18:51:20 +0800 Subject: [PATCH] Rename bubble sort to quadratic sort (#820) In preparation for https://github.com/scroll-tech/ceno/pull/813 Also stop hard-coding the examples in the examples-builder. --- Cargo.lock | 3 +++ ceno_host/tests/test_elf.rs | 2 +- examples-builder/Cargo.toml | 3 +++ examples-builder/build.rs | 24 ++++++------------- ...bubble_sorting.rs => quadratic_sorting.rs} | 0 5 files changed, 14 insertions(+), 18 deletions(-) rename examples/examples/{bubble_sorting.rs => quadratic_sorting.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index ef8dbb072..e5fc6dd4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,6 +280,9 @@ dependencies = [ [[package]] name = "ceno-examples" version = "0.1.0" +dependencies = [ + "glob", +] [[package]] name = "ceno_emul" diff --git a/ceno_host/tests/test_elf.rs b/ceno_host/tests/test_elf.rs index 6831ac9eb..39d132751 100644 --- a/ceno_host/tests/test_elf.rs +++ b/ceno_host/tests/test_elf.rs @@ -137,7 +137,7 @@ fn test_bubble_sorting() -> Result<()> { let all_messages = messages_to_strings(&ceno_host::run( CENO_PLATFORM, - ceno_examples::bubble_sorting, + ceno_examples::quadratic_sorting, &hints, )); for msg in &all_messages { diff --git a/examples-builder/Cargo.toml b/examples-builder/Cargo.toml index 00104ec3c..5e0ae79d0 100644 --- a/examples-builder/Cargo.toml +++ b/examples-builder/Cargo.toml @@ -7,3 +7,6 @@ license.workspace = true name = "ceno-examples" repository.workspace = true version.workspace = true + +[build-dependencies] +glob = "0.3" diff --git a/examples-builder/build.rs b/examples-builder/build.rs index 10d79d4f3..20b49b8d1 100644 --- a/examples-builder/build.rs +++ b/examples-builder/build.rs @@ -1,3 +1,4 @@ +use glob::glob; use std::{ fs::{File, read_dir}, io::{self, Write}, @@ -5,22 +6,6 @@ use std::{ process::Command, }; -/// Add each example to this list. -/// -/// Contact Matthias, if your examples get complicated enough to need their own crates, instead of just being one file. -const EXAMPLES: &[&str] = &[ - "ceno_rt_alloc", - "ceno_rt_io", - "ceno_rt_mem", - "ceno_rt_mini", - "ceno_rt_panic", - "ceno_rt_keccak", - "hints", - "sorting", - "median", - "bubble_sorting", - "hashing", -]; const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); fn rerun_all_but_target(dir: &Path) { @@ -51,7 +36,12 @@ fn build_elfs() { io::stderr().write_all(&output.stderr).unwrap(); panic!("cargo build of examples failed."); } - for example in EXAMPLES { + // Contact Matthias, if your examples get complicated enough to need their own crates, instead of just being one file. + for example in glob("../examples/examples/*.rs") + .unwrap() + .map(Result::unwrap) + { + let example = example.file_stem().unwrap().to_str().unwrap(); writeln!( dest, r#"#[allow(non_upper_case_globals)] diff --git a/examples/examples/bubble_sorting.rs b/examples/examples/quadratic_sorting.rs similarity index 100% rename from examples/examples/bubble_sorting.rs rename to examples/examples/quadratic_sorting.rs