bricks/build/compile_commands.rs
1use serde::Serialize;
2
3#[derive(Debug, Serialize)]
4#[serde(transparent)]
5pub struct CompileDatabase(Vec<CompileCommand>);
6
7impl CompileDatabase {
8 pub fn new() -> Self {
9 CompileDatabase(Vec::new())
10 }
11
12 pub fn push(&mut self, cmd: CompileCommand) {
13 self.0.push(cmd);
14 }
15}
16
17impl Default for CompileDatabase {
18 fn default() -> Self {
19 Self::new()
20 }
21}
22
23#[derive(Debug, Serialize)]
24pub struct CompileCommand {
25 /// The working directory of the compilation. All paths specified in the command or file fields must be either absolute or relative to this directory.
26 pub directory: String,
27 /// The compile command as a single shell-escaped string. Arguments may be shell quoted and escaped following platform conventions, with " and \ being the only special characters. Shell expansion is not supported.
28 pub command: String,
29 /// The main translation unit source processed by this compilation step.
30 /// This is used by tools as the key into the compilation database.
31 /// There can be multiple command objects for the same file, for example if the same source file is compiled with different configurations.
32 pub file: String,
33}