Explore whether compile command generatorion require building all targets.
kkharji opened this issue · 0 comments
kkharji commented
pub async fn generate_build_commands(&self) -> Result<()> {
use crate::xcode::append_build_root;
use xclog::{XCCompilationDatabase, XCCompileCommand};
let mut compile_commands: Vec<XCCompileCommand> = vec![];
for (target, _) in self.targets.iter() {
let build_args = append_build_root(
&self.root,
None,
vec![
"clean".into(),
"build".into(),
"-scheme".into(),
// NOTE: does scheme name differ?
self.name.clone(),
"-target".into(),
target.to_string(),
"-configuration".into(),
// NOTE: Should configuration differ?
"Debug".into(),
],
)?;
println!("{build_args:#?}");
let compile_db = XCCompilationDatabase::generate(&self.root, &build_args).await?;
compile_db
.into_iter()
.for_each(|cmd| compile_commands.push(cmd));
}
tracing::debug!("Compile Commands: {compile_commands:#?}");
let json = serde_json::to_vec_pretty(&compile_commands)?;
tokio::fs::write(self.root.join(".compile"), &json).await?;
Ok(())
}
Was going to include it in #70 but it would be better to explore it after starting to depend on xcodeproj