aboutsummaryrefslogtreecommitdiff
path: root/patio-to-cranelift/src/main.rs
blob: e000dbd27c200a90a7b58b122356eafc2f41f159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::path::PathBuf;

use clap::Parser;

/// Compile Patio compilation units into object files using Cranelift.
#[derive(clap::Parser, Debug)]
struct Args {
    /// The Patio compilation unit to compile.
    source_paths: Vec<PathBuf>,

    /// The LLVM triple to target.
    #[arg(long)]
    target: String,

    /// The name of the main function. If set, this will add a C-style `main`
    /// function that calls the given main function, and converts the return
    /// value into an int32.
    #[arg(long)]
    main: Option<String>,
}

fn main() {
    let args = Args::parse();

    for source_path in args.source_paths {
        patio_to_cranelift::compile(&source_path, &args.target, args.main.as_deref()).unwrap();
    }
}