forked from Cutieguwu/raven
Try to work on build some more.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
use std::hash::Hash;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use fs::expand_files;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::class::Class;
|
||||
use crate::prey::{F_PREY_LOCK, F_PREY_TOML, Prey, PreyLock};
|
||||
|
||||
/// Hashing is only based off the Prey.
|
||||
@@ -15,6 +17,8 @@ pub struct PackageHandler {
|
||||
}
|
||||
|
||||
impl PackageHandler {
|
||||
const DIR_JAVA: &str = "java/";
|
||||
|
||||
pub fn new<P: AsRef<Path>>(package_root: P, target_dir: P) -> crate::Result<Self> {
|
||||
let package_root = package_root.as_ref().to_path_buf();
|
||||
|
||||
@@ -26,8 +30,6 @@ impl PackageHandler {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn update_class_cache(&self) {}
|
||||
|
||||
pub fn entry_point(&self) -> PathBuf {
|
||||
self.prey.entry_point()
|
||||
}
|
||||
@@ -39,6 +41,34 @@ impl PackageHandler {
|
||||
pub fn version(&self) -> semver::Version {
|
||||
self.prey.version()
|
||||
}
|
||||
|
||||
pub fn get_update_targets(&mut self) -> crate::Result<Vec<&mut Class>> {
|
||||
let mut targets = vec![];
|
||||
|
||||
if self.prey_lock.is_none() {
|
||||
// Try to pass a reference to the class so that there's mutability of the object
|
||||
// available at the workspace level instead of parsing all the way down the
|
||||
// tree. How I do this, idk. My brain is friend from a few days of JS.
|
||||
|
||||
self.prey_lock = Some(PreyLock::from(expand_files(Self::DIR_JAVA)?));
|
||||
return Ok(self
|
||||
.prey_lock
|
||||
.clone()
|
||||
.unwrap()
|
||||
.classes
|
||||
.iter()
|
||||
.map(|mut *class| &mut class)
|
||||
.collect());
|
||||
}
|
||||
|
||||
for mut tracked in self.prey_lock.unwrap().classes {
|
||||
if !tracked.is_updated()? {
|
||||
targets.push(&mut tracked);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(targets)
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for PackageHandler {
|
||||
|
||||
Reference in New Issue
Block a user