corge/command/compilation_database/
compilation_database_path.rs

1use anyhow::{Context, Result};
2use std::path::PathBuf;
3
4pub struct CompilationDatabasePath {
5    pub json: PathBuf,
6}
7
8impl CompilationDatabasePath {
9    pub fn create(project_path: &PathBuf) -> Result<Self> {
10        let compilation_database_path = project_path.join("compilation_database");
11
12        let this = Self {
13            json: compilation_database_path.join("compile_commands.json")
14        };
15
16        std::fs::create_dir_all(&compilation_database_path)
17            .context("Failed to create compilation database directory")?;
18
19        Ok(this)
20    }
21}