cargo_openvm/
lib.rs

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