|
35 | 35 | //! specification: clang |
36 | 36 | //! compilers: |
37 | 37 | //! - path: /usr/local/bin/cc |
38 | | -//! ignore: always |
39 | | -//! - path: /usr/bin/cc |
40 | 38 | //! ignore: never |
| 39 | +//! - path: /usr/bin/cc |
| 40 | +//! ignore: always |
41 | 41 | //! - path: /usr/bin/c++ |
42 | 42 | //! ignore: conditional |
43 | 43 | //! arguments: |
|
67 | 67 | //! - directory |
68 | 68 | //! format: |
69 | 69 | //! paths: |
70 | | -//! resolver: original |
71 | | -//! relative: false |
| 70 | +//! directory: canonical |
| 71 | +//! file: canonical |
| 72 | +//! output: canonical |
72 | 73 | //! ``` |
73 | 74 | //! |
74 | 75 | //! ```yaml |
@@ -318,23 +319,17 @@ pub struct Compiler { |
318 | 319 | /// - Always: Always ignore the compiler call. |
319 | 320 | /// - Never: Never ignore the compiler call. (Default) |
320 | 321 | /// - Conditional: Ignore the compiler call if the arguments match. |
321 | | -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] |
| 322 | +#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] |
322 | 323 | pub enum IgnoreOrConsider { |
323 | 324 | #[serde(rename = "always", alias = "true")] |
324 | 325 | Always, |
| 326 | + #[default] |
325 | 327 | #[serde(rename = "never", alias = "false")] |
326 | 328 | Never, |
327 | 329 | #[serde(rename = "conditional")] |
328 | 330 | Conditional, |
329 | 331 | } |
330 | 332 |
|
331 | | -/// The default ignore mode is never ignore. |
332 | | -impl Default for IgnoreOrConsider { |
333 | | - fn default() -> Self { |
334 | | - IgnoreOrConsider::Never |
335 | | - } |
336 | | -} |
337 | | - |
338 | 333 | /// Argument lists to match, add or remove. |
339 | 334 | /// |
340 | 335 | /// The `match` field is used to specify the arguments to match. Can be used only with the |
@@ -415,37 +410,44 @@ pub enum OutputFields { |
415 | 410 | /// Format configuration of the JSON compilation database. |
416 | 411 | #[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] |
417 | 412 | pub struct Format { |
| 413 | + #[serde(default)] |
418 | 414 | pub paths: PathFormat, |
419 | 415 | } |
420 | 416 |
|
421 | 417 | /// Format configuration of paths in the JSON compilation database. |
422 | 418 | #[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] |
423 | 419 | pub struct PathFormat { |
424 | 420 | #[serde(default)] |
425 | | - pub resolver: PathResolver, |
426 | | - #[serde(default = "default_disabled")] |
427 | | - pub relative: bool, |
| 421 | + pub directory: DirectoryPathResolver, |
| 422 | + #[serde(default)] |
| 423 | + pub file: FilePathResolver, |
| 424 | + #[serde(default)] |
| 425 | + pub output: FilePathResolver, |
428 | 426 | } |
429 | 427 |
|
430 | | -/// Path resolver configuration. |
431 | | -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] |
432 | | -pub enum PathResolver { |
433 | | - /// The original path is the path as it is passed to the compiler. |
434 | | - #[serde(rename = "original", alias = "is")] |
435 | | - Original, |
436 | | - /// The absolute path from the original path. Symlinks are not resolved. |
437 | | - #[serde(rename = "absolute")] |
438 | | - Absolute, |
439 | | - /// The canonical path is the absolute path with the symlinks resolved. |
| 428 | +#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] |
| 429 | +pub enum DirectoryPathResolver { |
| 430 | + /// The directory path will be resolved to the canonical path. (Default) |
| 431 | + #[default] |
440 | 432 | #[serde(rename = "canonical")] |
441 | 433 | Canonical, |
| 434 | + /// The directory path will be resolved to the relative path to the current working directory. |
| 435 | + #[serde(rename = "relative_to_cwd")] |
| 436 | + RelativeToCwd, |
442 | 437 | } |
443 | 438 |
|
444 | | -/// The default path format is the original path. |
445 | | -impl Default for PathResolver { |
446 | | - fn default() -> Self { |
447 | | - PathResolver::Original |
448 | | - } |
| 439 | +#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] |
| 440 | +pub enum FilePathResolver { |
| 441 | + /// The directory path will be resolved to the canonical path. (Default) |
| 442 | + #[default] |
| 443 | + #[serde(rename = "canonical")] |
| 444 | + Canonical, |
| 445 | + /// The directory path will be resolved to the relative path to the directory attribute. |
| 446 | + #[serde(rename = "relative_to_directory")] |
| 447 | + RelativeToDirectory, |
| 448 | + /// The directory path will be resolved to the relative path to the current working directory. |
| 449 | + #[serde(rename = "relative_to_cwd")] |
| 450 | + RelativeToCwd, |
449 | 451 | } |
450 | 452 |
|
451 | 453 | fn default_disabled() -> bool { |
@@ -538,8 +540,9 @@ mod test { |
538 | 540 | - directory |
539 | 541 | format: |
540 | 542 | paths: |
541 | | - resolver: canonical |
542 | | - relative: false |
| 543 | + directory: canonical |
| 544 | + file: canonical |
| 545 | + output: canonical |
543 | 546 | "#; |
544 | 547 |
|
545 | 548 | let result = Main::from_reader(content).unwrap(); |
@@ -611,8 +614,9 @@ mod test { |
611 | 614 | }, |
612 | 615 | format: Format { |
613 | 616 | paths: PathFormat { |
614 | | - resolver: PathResolver::Canonical, |
615 | | - relative: false, |
| 617 | + directory: DirectoryPathResolver::Canonical, |
| 618 | + file: FilePathResolver::Canonical, |
| 619 | + output: FilePathResolver::Canonical, |
616 | 620 | }, |
617 | 621 | }, |
618 | 622 | }, |
@@ -661,8 +665,9 @@ mod test { |
661 | 665 | }, |
662 | 666 | format: Format { |
663 | 667 | paths: PathFormat { |
664 | | - resolver: PathResolver::Original, |
665 | | - relative: false, |
| 668 | + directory: DirectoryPathResolver::Canonical, |
| 669 | + file: FilePathResolver::Canonical, |
| 670 | + output: FilePathResolver::Canonical, |
666 | 671 | }, |
667 | 672 | }, |
668 | 673 | }, |
@@ -720,8 +725,9 @@ mod test { |
720 | 725 | - file |
721 | 726 | format: |
722 | 727 | paths: |
723 | | - resolver: canonical |
724 | | - relative: true |
| 728 | + directory: relative_to_cwd |
| 729 | + file: relative_to_directory |
| 730 | + output: relative_to_directory |
725 | 731 | "#; |
726 | 732 |
|
727 | 733 | let result = Main::from_reader(content).unwrap(); |
@@ -762,8 +768,9 @@ mod test { |
762 | 768 | }, |
763 | 769 | format: Format { |
764 | 770 | paths: PathFormat { |
765 | | - resolver: PathResolver::Canonical, |
766 | | - relative: true, |
| 771 | + directory: DirectoryPathResolver::RelativeToCwd, |
| 772 | + file: FilePathResolver::RelativeToDirectory, |
| 773 | + output: FilePathResolver::RelativeToCwd, |
767 | 774 | }, |
768 | 775 | }, |
769 | 776 | }, |
|
0 commit comments