1
//! Type for holds the Targets build details
2

            
3
use serde::{Deserialize, Serialize};
4

            
5
use crate::domain::target::TargetKind;
6

            
7
/// [`TargetAttribute`] - The type for holding the build details of every
8
/// user defined target
9
/// * `output_name`- The name with which the final byproduct will be generated
10
/// * `sources` - The sources to be included in the compilation of this target
11
/// * `extra_args` - Holds extra arguments that the user wants to introduce
12
/// * `kind` - Determined which type of byproduct will be generated (binary, library...)
13
///
14
/// ### Tests
15
///
16
/// ```rust
17
/// use zork::config_file::target::TargetAttribute;
18
/// use zork::domain::target::TargetKind;
19
/// const CONFIG_FILE_MOCK: &str = r#"
20
///     #[target.executable]
21
///     output_name = "some_executable"
22
///     sources = [ '*.cpp' ]
23
///     extra_args = ['-Wall']
24
///     kind = "Executable"
25
/// "#;
26
///
27
/// let config: TargetAttribute = toml::from_str(CONFIG_FILE_MOCK)
28
///    .expect("A failure happened parsing the Zork toml file");
29
///
30
/// assert_eq!(config.output_name, Some("some_executable"));
31
/// assert_eq!(config.sources, vec!["*.cpp"]);
32
/// assert_eq!(config.extra_args, Some(vec!["-Wall"]));
33
/// assert_eq!(config.kind, Some(TargetKind::Executable));
34
/// ```
35
/// > Note: TOML table are toml commented (#) to allow us to parse
36
/// > the inner attributes as the direct type that they belongs to.
37
/// > That commented tables aren't the real TOML, they are just there
38
/// > for testing and exemplification purposes of the inner attributes
39
/// > of the configuration file.
40
///
41
/// For a test over a real example, please look at the
42
/// [`zork::config_file::ZorkConfigFile`] doc-test
43
174
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
44
pub struct TargetAttribute<'a> {
45
    pub output_name: Option<&'a str>,
46
    pub sources: Vec<&'a str>,
47
    pub extra_args: Option<Vec<&'a str>>,
48
    pub kind: Option<TargetKind>,
49
}