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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use crate::core::Revision;
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use tracing::{self, info};
mod core;
mod targets;
use targets::local_target;
pub use self::core::BuildConfig;
#[derive(Serialize, Deserialize)]
pub struct VersionConfig {
pub tvm_python_path: PathBuf,
}
#[tracing::instrument]
pub fn build(build_config: core::BuildConfig) -> Result<core::BuildResult, core::Error> {
info!("tvm_build::build");
let rev = build_config.get_revision()?;
let target = local_target();
match build_config.output_path {
None => (),
_ => panic!("this option is currently disabled"),
};
rev.build_for(&build_config, target)?;
Ok(core::BuildResult { revision: rev })
}
pub fn uninstall(revision: String) -> Result<(), core::Error> {
let directory = core::tvm_build_directory().join(revision);
std::fs::remove_dir(directory)?;
Ok(())
}
pub fn version_config(revision: String) -> Result<VersionConfig, core::Error> {
let rev = Revision::new(revision);
let version = VersionConfig {
tvm_python_path: rev.source_path().join("python").join("tvm"),
};
Ok(version)
}