Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace 2 #607

Closed
wants to merge 10 commits into from
Closed
16 changes: 12 additions & 4 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod init;
use shuttle_common::project::ProjectName;
use std::collections::BTreeMap;
use std::ffi::OsString;
use std::fs::{read_to_string, File};
use std::fs::{read_dir, read_to_string, File};
use std::io::stdout;
use std::net::{Ipv4Addr, SocketAddr};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -208,9 +208,17 @@ impl Shuttle {
}

fn find_root_directory(dir: &Path) -> Option<PathBuf> {
dir.ancestors()
.find(|ancestor| ancestor.join("Cargo.toml").exists())
.map(|path| path.to_path_buf())
let ancestors = dir.ancestors();
for p in ancestors {
let has_cargo = read_dir(p)
.unwrap()
.into_iter()
.any(|p| p.unwrap().file_name() == *"Cargo.lock");
if has_cargo {
return Some(PathBuf::from(p));
}
}
None
}

pub fn load_project(&mut self, project_args: &mut ProjectArgs) -> Result<()> {
Expand Down
8 changes: 6 additions & 2 deletions service/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub async fn build_crate(
project_path: &Path,
release_mode: bool,
tx: Sender<Message>,
) -> anyhow::Result<PathBuf> {
) -> anyhow::Result<Vec<PathBuf>> {
let (read, write) = pipe::pipe();
let project_path = project_path.to_owned();

Expand Down Expand Up @@ -144,7 +144,11 @@ pub async fn build_crate(
let opts = get_compile_options(&config, release_mode)?;
let compilation = compile(&ws, &opts);

Ok(compilation?.cdylibs[0].path.clone())
Ok(compilation?
.cdylibs
.into_iter()
.map(|item| item.path)
.collect())
}

pub fn clean_crate(project_path: &Path, release_mode: bool) -> anyhow::Result<Vec<String>> {
Expand Down