mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-05-13 03:00:26 -04:00
Merge pull request #196 from chriseth/auto_detect_crate
Auto detect crate
This commit is contained in:
@@ -20,14 +20,9 @@ enum Commands {
|
||||
/// and finally to PIL and generates fixed and witness columns.
|
||||
/// Needs `rustup target add riscv32imc-unknown-none-elf`.
|
||||
Rust {
|
||||
/// Input file or directory.
|
||||
/// Input file (rust source file) or directory (containing a crate).
|
||||
file: String,
|
||||
|
||||
/// Compile a full cargo crate with dependencies.
|
||||
#[arg(long)]
|
||||
#[arg(default_value_t = false)]
|
||||
cargo: bool,
|
||||
|
||||
/// Comma-separated list of free inputs (numbers).
|
||||
#[arg(short, long)]
|
||||
#[arg(default_value_t = String::new())]
|
||||
@@ -126,14 +121,12 @@ fn main() {
|
||||
match command {
|
||||
Commands::Rust {
|
||||
file,
|
||||
cargo,
|
||||
inputs,
|
||||
output_directory,
|
||||
force,
|
||||
} => {
|
||||
riscv::compile_rust(
|
||||
&file,
|
||||
cargo,
|
||||
split_inputs(&inputs),
|
||||
Path::new(&output_directory),
|
||||
force,
|
||||
|
||||
@@ -17,21 +17,20 @@ pub mod parser;
|
||||
/// fixed and witness columns.
|
||||
pub fn compile_rust(
|
||||
file_name: &str,
|
||||
full_crate: bool,
|
||||
inputs: Vec<FieldElement>,
|
||||
output_dir: &Path,
|
||||
force_overwrite: bool,
|
||||
) {
|
||||
let riscv_asm = if full_crate {
|
||||
let cargo_toml = if file_name.ends_with("Cargo.toml") {
|
||||
file_name.to_string()
|
||||
} else {
|
||||
format!("{file_name}/Cargo.toml")
|
||||
};
|
||||
compile_rust_crate_to_riscv_asm(&cargo_toml)
|
||||
let riscv_asm = if file_name.ends_with("Cargo.toml") {
|
||||
compile_rust_crate_to_riscv_asm(file_name)
|
||||
} else if fs::metadata(file_name).unwrap().is_dir() {
|
||||
compile_rust_crate_to_riscv_asm(&format!("{file_name}/Cargo.toml"))
|
||||
} else {
|
||||
compile_rust_to_riscv_asm(file_name)
|
||||
};
|
||||
if !output_dir.exists() {
|
||||
fs::create_dir_all(output_dir).unwrap()
|
||||
}
|
||||
for (asm_file_name, contents) in &riscv_asm {
|
||||
let riscv_asm_file_name = output_dir.join(format!(
|
||||
"{}_riscv_{asm_file_name}.asm",
|
||||
|
||||
Reference in New Issue
Block a user