polyhorn_cli/ios/tasks/
build_xcodeproj.rs1use std::process::{Command, Stdio};
2
3use super::{IOSContext, IOSError};
4use crate::core::{Manager, Task};
5
6pub struct BuildXcodeproj {
9 pub scheme: String,
11
12 pub configuration: String,
14
15 pub destination_platform: String,
18
19 pub destination_name: String,
22}
23
24impl Task for BuildXcodeproj {
25 type Context = IOSContext;
26 type Error = IOSError;
27
28 fn verb(&self) -> &str {
29 "Building"
30 }
31
32 fn message(&self) -> &str {
33 "xcodeproj"
34 }
35
36 fn detail(&self) -> &str {
37 ""
38 }
39
40 fn run(
41 &self,
42 context: Self::Context,
43 _manager: &mut Manager,
44 ) -> Result<Self::Context, Self::Error> {
45 let target_dir = context.config.target_dir.join("polyhorn-ios");
46
47 assert!(Command::new("xcrun")
48 .arg("xcodebuild")
49 .arg("-scheme")
50 .arg(&self.scheme)
51 .arg("-configuration")
52 .arg(&self.configuration)
53 .arg("-destination")
54 .arg(format!(
55 "platform={},name={}",
56 self.destination_platform, self.destination_name
57 ))
58 .arg("-derivedDataPath")
59 .arg("derived-data")
60 .stdout(Stdio::null())
61 .current_dir(target_dir)
62 .spawn()
63 .unwrap()
64 .wait()
65 .unwrap()
66 .success());
67
68 Ok(context)
69 }
70}