xcodeproj/pbxproj/object/build/phase/
script.rs

1use crate::pbxproj::*;
2
3/// Part of [`PBXBuildPhase`] when [`PBXBuildPhaseKind`] is [`RunScript`]
4///
5/// [`RunScript`]: crate::pbxproj::PBXBuildPhaseKind::RunScript
6#[derive(Debug, derive_new::new)]
7pub struct PBXShellScriptBuildPhase<'a> {
8    /// Build phase name.
9    pub name: Option<&'a String>,
10    /// Input paths
11    pub input_paths: Vec<&'a String>,
12    /// Output paths
13    pub output_paths: Vec<&'a String>,
14    /// Path to the shell.
15    pub shell_path: Option<&'a String>,
16    /// Shell script.
17    pub shell_script: Option<&'a String>,
18    /// Show environment variables in the logs.
19    pub show_env_vars_in_log: bool,
20    /// Force script to run in all incremental builds.
21    pub always_out_of_date: bool,
22    /// Path to the discovery .d dependency file
23    pub dependency_file: Option<&'a String>,
24}
25
26impl<'a> AsPBXObject<'a> for PBXShellScriptBuildPhase<'a> {
27    fn as_pbx_object(
28        _id: String,
29        value: &'a PBXHashMap,
30        _objects: &'a PBXObjectCollection,
31    ) -> anyhow::Result<Self>
32    where
33        Self: Sized + 'a,
34    {
35        Ok(Self {
36            name: value.get_string("name"),
37            input_paths: value.try_get_vec("inputPaths")?.as_vec_strings(),
38            output_paths: value.try_get_vec("outputPaths")?.as_vec_strings(),
39            shell_path: value.get_string("shellPath"),
40            shell_script: value.get_string("shellScript"),
41            show_env_vars_in_log: value
42                .get_number("runOnlyForDeploymentPostprocessing")
43                .map(|v| v == &1)
44                .unwrap_or_else(|| true),
45            always_out_of_date: value
46                .get_number("alwaysOutOfDate")
47                .map(|v| v == &1)
48                .unwrap_or_else(|| false),
49            dependency_file: value.get_string("dependencyFile"),
50        })
51    }
52}