pub struct CompileCommands {
pub entries: Vec<CompileEntry>,
pub content_hash: Option<String>,
}Expand description
A parsed compilation database with duplicate translation units removed.
Fields§
§entries: Vec<CompileEntry>Distinct translation units, in the order first seen.
content_hash: Option<String>A hash of the document this was read from, retained as provenance.
Per-entry build identities use normalized compiler settings instead; this database-wide value would make an unrelated added translation unit invalidate every existing partition.
Implementations§
Source§impl CompileCommands
impl CompileCommands
Sourcepub fn read(path: &Path) -> Result<Self, CompileCommandsError>
pub fn read(path: &Path) -> Result<Self, CompileCommandsError>
Read and parse a compile_commands.json file at path.
§Errors
Returns CompileCommandsError if the file cannot be read or is not a
JSON array of { "file": ..., "directory": ... } objects.
Sourcepub fn read_with_limit(
path: &Path,
max_bytes: u64,
) -> Result<Self, CompileCommandsError>
pub fn read_with_limit( path: &Path, max_bytes: u64, ) -> Result<Self, CompileCommandsError>
Read and parse a compilation database after enforcing max_bytes.
§Errors
Returns CompileCommandsError::TooLarge before reading an oversized
file, or the same failures as Self::read for an otherwise readable
file.
Sourcepub fn translation_unit_count(&self) -> usize
pub fn translation_unit_count(&self) -> usize
Number of distinct translation units.
Sourcepub fn source_file_count(&self) -> usize
pub fn source_file_count(&self) -> usize
Number of distinct source files across those translation units.
Lower than Self::translation_unit_count wherever a file is compiled
more than one way, which is the case the fragment side has to avoid
registering twice.
Sourcepub fn build_partitions(&self) -> BTreeMap<String, Vec<&CompileEntry>>
pub fn build_partitions(&self) -> BTreeMap<String, Vec<&CompileEntry>>
Group entries by the C/C++ build configuration they describe.
A partition contains every command with identical semantic settings;
source paths deliberately do not participate in its identity. That
lets two ordinary translation units share one scan while keeping a
duplicated source with different -D settings in separate partitions.
Trait Implementations§
Source§impl Clone for CompileCommands
impl Clone for CompileCommands
Source§fn clone(&self) -> CompileCommands
fn clone(&self) -> CompileCommands
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more