1#![cfg_attr(feature = "tco", allow(incomplete_features))]
2#![cfg_attr(feature = "tco", feature(explicit_tail_calls))]
3
4pub mod args;
5pub mod commands;
6pub mod default;
7pub mod input;
8pub mod util;
9
10use std::process::{Command, Stdio};
11
12use eyre::{Context, Result};
13pub use openvm_build::{get_rustup_toolchain_name, DEFAULT_RUSTUP_TOOLCHAIN_NAME};
14
15#[cfg(all(feature = "cuda", feature = "tco"))]
16pub const OPENVM_VERSION_MESSAGE: &str = concat!(
17 "v",
18 env!("CARGO_PKG_VERSION"),
19 " (",
20 env!("VERGEN_GIT_SHA"),
21 ") [cuda, tco]"
22);
23
24#[cfg(all(feature = "cuda", feature = "aot", not(feature = "tco")))]
25pub const OPENVM_VERSION_MESSAGE: &str = concat!(
26 "v",
27 env!("CARGO_PKG_VERSION"),
28 " (",
29 env!("VERGEN_GIT_SHA"),
30 ") [cuda, aot]"
31);
32
33#[cfg(all(feature = "cuda", not(feature = "tco"), not(feature = "aot")))]
34pub const OPENVM_VERSION_MESSAGE: &str = concat!(
35 "v",
36 env!("CARGO_PKG_VERSION"),
37 " (",
38 env!("VERGEN_GIT_SHA"),
39 ") [cuda]"
40);
41
42#[cfg(all(not(feature = "cuda"), feature = "tco"))]
43pub const OPENVM_VERSION_MESSAGE: &str = concat!(
44 "v",
45 env!("CARGO_PKG_VERSION"),
46 " (",
47 env!("VERGEN_GIT_SHA"),
48 ") [tco]"
49);
50
51#[cfg(all(not(feature = "cuda"), feature = "aot", not(feature = "tco")))]
52pub const OPENVM_VERSION_MESSAGE: &str = concat!(
53 "v",
54 env!("CARGO_PKG_VERSION"),
55 " (",
56 env!("VERGEN_GIT_SHA"),
57 ") [aot]"
58);
59
60#[cfg(all(not(feature = "cuda"), not(feature = "tco"), not(feature = "aot")))]
61pub const OPENVM_VERSION_MESSAGE: &str = concat!(
62 "v",
63 env!("CARGO_PKG_VERSION"),
64 " (",
65 env!("VERGEN_GIT_SHA"),
66 ")"
67);
68
69#[allow(dead_code)]
70trait CommandExecutor {
71 fn run(&mut self) -> Result<()>;
72}
73
74impl CommandExecutor for Command {
75 fn run(&mut self) -> Result<()> {
76 self.stderr(Stdio::inherit())
77 .stdout(Stdio::inherit())
78 .stdin(Stdio::inherit())
79 .output()
80 .with_context(|| format!("while executing `{:?}`", &self))
81 .map(|_| ())
82 }
83}
84
85#[allow(unreachable_code)]
86pub fn is_supported_target() -> bool {
87 #[cfg(all(target_arch = "x86_64", target_os = "linux"))]
88 return true;
89
90 #[cfg(all(target_arch = "aarch64", target_os = "linux"))]
91 return true;
92
93 #[cfg(all(target_arch = "x86_64", target_os = "macos"))]
94 return true;
95
96 #[cfg(all(target_arch = "aarch64", target_os = "macos"))]
97 return true;
98
99 false
100}
101
102pub fn get_target() -> String {
103 target_lexicon::HOST.to_string()
104}