Skip to content

Commit

Permalink
formatting and preparing for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tanneberger committed Sep 23, 2024
1 parent 5fb461c commit ad490f7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/backends/cmake_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn gen_cmake_files(app: &App, options: &BuildCommandOptions) -> BuildResult {
println!("reading cmake file ... {:?}", &cmake_file);
let mut content = fs::read_to_string(&cmake_file)?;
let include_statement = "\ninclude(./aggregated_cmake_include.cmake)";
content += &*include_statement;
content += include_statement;

println!("writing cmake file ...");
// overwrite cmake file
Expand Down
2 changes: 1 addition & 1 deletion src/backends/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod pnpm;

pub fn execute_command<'a>(command: &CommandSpec, config: &'a mut Config) -> BatchBuildResults<'a> {
let mut result = BatchBuildResults::new();
let dependencies = Vec::from_iter(config.dependencies.clone().into_iter());
let dependencies = Vec::from_iter(config.dependencies.clone());

match command {
CommandSpec::Build(_build) => {
Expand Down
12 changes: 5 additions & 7 deletions src/package/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl DependencyLock {
error!("checksum does not match aborting!");
}

let lingo_toml_text = fs::read_to_string(&temp.join("Lingo.toml"))?;
let lingo_toml_text = fs::read_to_string(temp.join("Lingo.toml"))?;
let read_toml = toml::from_str::<ConfigFile>(&lingo_toml_text)?.to_config(&temp);

println!(
Expand All @@ -241,8 +241,6 @@ impl DependencyLock {
}
};



self.loaded_dependencies.push(DependencyTreeNode {
name: read_toml.package.name.clone(),
version: read_toml.package.version.clone(),
Expand All @@ -265,18 +263,18 @@ impl DependencyLock {

pub fn create_library_folder(
&self,
source_path: &PathBuf,
source_path: &Path,
target_path: &PathBuf,
) -> anyhow::Result<()> {
fs::create_dir_all(target_path)?;
for (_, dep) in self.dependencies.iter() {
let local_source = source_path.clone().join(&dep.checksum);
let local_source = source_path.join(&dep.checksum);
let find_source = target_path.clone().join(&dep.name);
fs::create_dir_all(&find_source)?;
copy_dir_all(&local_source, &find_source)?;
}

return Ok(());
Ok(())
}

pub fn aggregate_target_properties(&self) -> anyhow::Result<LibraryTargetProperties> {
Expand All @@ -285,6 +283,6 @@ impl DependencyLock {
i.merge(&tp.properties)?;
}

return Ok(i);
Ok(i)
}
}
20 changes: 10 additions & 10 deletions src/package/management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl TryFrom<&PackageLockSource> for PackageDetails {
PackageLockSourceType::TARBALL => ProjectSource::TarBall(Url::from_str(url)?),
PackageLockSourceType::PATH => ProjectSource::Path(PathBuf::from(url)),
},
git_tag: value.rev.clone().map(|rev| GitLock::Rev(rev)),
git_tag: value.rev.clone().map(GitLock::Rev),
git_rev: value.rev.clone(),
})
}
Expand All @@ -84,7 +84,7 @@ impl PackageDetails {
};

// TODO: this produces hard to debug output
let (object, reference) = repo.revparse_ext(&name)?;
let (object, reference) = repo.revparse_ext(name)?;
repo.checkout_tree(&object, None)?;

match reference {
Expand All @@ -108,15 +108,15 @@ impl PackageDetails {
impl DependencyManager {
pub fn from_dependencies(
dependencies: Vec<(String, PackageDetails)>,
target_path: &PathBuf,
target_path: &Path,
) -> anyhow::Result<DependencyManager> {
// create library folder
let library_path = target_path.clone().join(LIBRARY_DIRECTORY);
let library_path = target_path.join(LIBRARY_DIRECTORY);
fs::create_dir_all(&library_path)?;

let mut manager;
let mut lock: DependencyLock;
let lock_file = target_path.clone().join("../Lingo.lock");
let lock_file = target_path.join("../Lingo.lock");

// checks if a Lingo.lock file exists
if lock_file.exists() {
Expand All @@ -126,7 +126,7 @@ impl DependencyManager {

// if a lock file is present it will load the dependencies from it and checks
// integrity of the build directory
if let Ok(()) = lock.init(&target_path.clone().join("lfc_include")) {
if let Ok(()) = lock.init(&target_path.join("lfc_include")) {
return Ok(DependencyManager {
pulling_queue: vec![],
lock,
Expand All @@ -153,7 +153,7 @@ impl DependencyManager {
lock_file.write_all(serialized_toml.as_ref())?;

// moves the selected packages into the include folder
let include_folder = target_path.clone().join("lfc_include");
let include_folder = target_path.join("lfc_include");
lock.create_library_folder(&library_path, &include_folder)
.expect("creating lock folder failed");

Expand Down Expand Up @@ -214,7 +214,7 @@ impl DependencyManager {
// directory where the dependencies will be dropped

// creating the necessary directories
fs::create_dir_all(&library_path)?;
fs::create_dir_all(library_path)?;
fs::create_dir_all(&temporary_path)?;

// cloning the specified package
Expand Down Expand Up @@ -268,7 +268,7 @@ impl DependencyManager {
})
}

fn flatten<'a>(root_nodes: Vec<DependencyTreeNode>) -> anyhow::Result<Vec<DependencyTreeNode>> {
fn flatten(root_nodes: Vec<DependencyTreeNode>) -> anyhow::Result<Vec<DependencyTreeNode>> {
// implementation idea:
// 1. we collect all the version requirements for packages => are the different
// constraints satisfiable ?
Expand Down Expand Up @@ -300,7 +300,7 @@ impl DependencyManager {
sources
.entry(&node.name)
.and_modify(move |value| {
value.push(&node);
value.push(node);
})
.or_insert(vec![&node]);
}
Expand Down

0 comments on commit ad490f7

Please sign in to comment.