[project] Get swift project name
github-actions opened this issue · 1 comments
github-actions commented
mod generator;
use crate::device::Device;
use crate::watch::Event;
use crate::{state::State, Result};
use generator::ProjectGenerator;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
use tokio::sync::MutexGuard;
use xbase_proto::BuildSettings;
use xcodeproj::pbxproj::PBXTargetPlatform;
use xcodeproj::XCodeProject;
/// Project Inner
#[derive(Debug)]
pub enum ProjectInner {
None,
XCodeProject(XCodeProject),
Swift,
}
impl Default for ProjectInner {
fn default() -> Self {
Self::None
}
}
/// Represent XcodeGen Project
#[derive(Default, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Project {
/// Project Name or rather xproj generated file name.
pub name: String,
/// The list of targets in the project mapped by name
pub targets: HashMap<String, PBXTargetPlatform>,
/// Root directory
#[serde(skip)]
pub root: PathBuf,
/// Connected Clients
#[serde(default)]
pub clients: Vec<i32>,
/// Ignore Patterns
#[serde(default)]
pub ignore_patterns: Vec<String>,
/// Generator
pub generator: ProjectGenerator,
#[serde(skip)]
/// XCodeProject Data
inner: ProjectInner,
}
impl Project {
pub async fn new(root: &std::path::PathBuf) -> Result<Self> {
let mut project = Self::default();
project.generator = ProjectGenerator::new(root);
project.inner = if root.join("Package.swift").exists() {
tracing::debug!("[Project] Kind: \"Swift\"",);
// TODO(project): Get swift project name
project.name = "UnknownSwiftProject".into();
ProjectInner::Swift
} else {
let xcodeproj = XCodeProject::new(root)?;
project.name = xcodeproj.name().to_owned();
project.targets = xcodeproj.targets_platform();
tracing::debug!("[New Project] name: {:?}", project.name);
tracing::debug!("[New Project] Kind: \"XCodeProject\"");
tracing::debug!("[New Project] Generator: \"{:?}\"", project.generator);
tracing::debug!("[New Project] targets: {:?}", project.targets);
ProjectInner::XCodeProject(xcodeproj)
};
project
.ignore_patterns
.extend(gitignore_to_glob_patterns(root).await?);
project.ignore_patterns.extend(vec![
"**/.git/**".into(),
"**/.*".into(),
"**/build/**".into(),
"**/buildServer.json".into(),
github-actions commented
Closed in 79ea745