1use crate::core::Revision;
2use std::path::PathBuf;
3
4use serde::{Deserialize, Serialize};
5use tracing::{self, info};
6
7mod core;
8mod targets;
9
10use targets::local_target;
11
12pub use self::core::{BuildConfig, UserSettings, CMakeSetting};
13
14#[derive(Serialize, Deserialize)]
15pub struct VersionConfig {
16 pub tvm_python_path: PathBuf,
17}
18
19#[tracing::instrument]
21pub fn build(build_config: core::BuildConfig) -> Result<core::BuildResult, core::Error> {
22 info!("tvm_build::build");
23 let rev = build_config.get_revision()?;
24 let target = local_target();
25
26 rev.build_for(&build_config, target)?;
27
28 Ok(core::BuildResult { revision: rev })
32}
33
34pub fn uninstall(revision: String, output_path: Option<String>) -> Result<(), core::Error> {
35 let revision = Revision::new(revision, output_path);
36 let directory = revision.path();
37 std::fs::remove_dir(directory)?;
38 Ok(())
39}
40
41pub fn version_config(revision: String) -> Result<VersionConfig, core::Error> {
42 let rev = Revision::new(revision, None);
43 let version = VersionConfig {
44 tvm_python_path: rev.source_path().join("python").join("tvm"),
45 };
46 Ok(version)
47}