mz_deploy/project/compiler/
cache.rs1use std::collections::BTreeMap;
19use std::path::{Path, PathBuf};
20use thiserror::Error;
21
22pub(crate) mod build_artifact;
23pub(crate) mod project_cache;
24pub(crate) mod schema;
25
26pub(crate) use build_artifact::BuildArtifact;
27pub(crate) use project_cache::ProjectCache;
28
29pub(crate) const DB_FILE: &str = "build_artifact.db";
30
31pub(crate) fn db_path(
33 root: &Path,
34 profile: &str,
35 profile_suffix: Option<&str>,
36 variables: &BTreeMap<String, String>,
37) -> PathBuf {
38 root.join(crate::types::BUILD_DIR)
39 .join(super::COMPILER_DIR)
40 .join(super::profile_namespace(profile, profile_suffix, variables))
41 .join(DB_FILE)
42}
43
44#[derive(Debug, Error)]
45pub enum CacheError {
46 #[error("failed to create compiler cache directory: {path}")]
47 DirectoryCreationFailed {
48 path: PathBuf,
49 #[source]
50 source: std::io::Error,
51 },
52 #[error("failed to open build artifact database: {path}")]
53 DatabaseOpenFailed {
54 path: PathBuf,
55 #[source]
56 source: rusqlite::Error,
57 },
58 #[error("failed to operate on build artifact database: {path}")]
59 DatabaseOperationFailed {
60 path: PathBuf,
61 #[source]
62 source: rusqlite::Error,
63 },
64 #[error("failed to read cached source file: {path}")]
65 FileReadFailed {
66 path: PathBuf,
67 #[source]
68 source: std::io::Error,
69 },
70}