Compare commits

...

2 Commits

Author SHA1 Message Date
Cutieguwu
0fad1b74bc Try to work on build some more. 2026-02-15 12:25:03 -05:00
Cutieguwu
a9fb52d8d7 Bump version numbers. 2026-02-15 09:50:36 -05:00
10 changed files with 124 additions and 18 deletions

8
Cargo.lock generated
View File

@@ -144,7 +144,7 @@ checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32"
[[package]] [[package]]
name = "cli" name = "cli"
version = "0.1.0" version = "0.2.0"
dependencies = [ dependencies = [
"clap", "clap",
] ]
@@ -330,7 +330,7 @@ dependencies = [
[[package]] [[package]]
name = "io" name = "io"
version = "0.1.0" version = "0.2.0"
dependencies = [ dependencies = [
"derive_more", "derive_more",
"subprocess", "subprocess",
@@ -344,7 +344,7 @@ checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]] [[package]]
name = "java" name = "java"
version = "0.1.0" version = "0.2.0"
dependencies = [ dependencies = [
"bytesize", "bytesize",
"derive_more", "derive_more",
@@ -433,7 +433,7 @@ dependencies = [
[[package]] [[package]]
name = "raven" name = "raven"
version = "0.1.0" version = "0.2.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytesize", "bytesize",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cli" name = "cli"
version = "0.1.0" version = "0.2.0"
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true

View File

@@ -8,3 +8,28 @@ pub struct Class {
pub path: PathBuf, pub path: PathBuf,
pub checksum: String, pub checksum: String,
} }
impl Class {
pub fn is_updated(&self) -> crate::Result<bool> {
// If the path is local and that file has not been updated.
Ok(self.checksum == sha256::try_digest(self.path.clone())?)
}
pub fn update(&mut self) -> crate::Result<()> {
self.checksum = sha256::try_digest(self.path.clone())?;
Ok(())
}
}
// TODO: Make it clearer that this is for general files,
// not nests.
impl TryFrom<PathBuf> for Class {
type Error = crate::Error;
fn try_from(value: PathBuf) -> Result<Self, Self::Error> {
Ok(Self {
path: value.clone(),
checksum: sha256::try_digest(value)?,
})
}
}

View File

@@ -7,7 +7,8 @@ use crate::package::PackageHandler;
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct Dependency { pub struct Dependency {
name: String, name: String,
version: Version, #[serde(skip_serializing_if = "<Option<_>>::is_none")]
version: Option<Version>,
pub checksum: String, pub checksum: String,
#[serde(skip_serializing_if = "<Option<_>>::is_none")] #[serde(skip_serializing_if = "<Option<_>>::is_none")]
source: Option<String>, // Path / URL source: Option<String>, // Path / URL
@@ -24,13 +25,19 @@ impl Dependency {
// TODO: Convert from reverse domain name to path. // TODO: Convert from reverse domain name to path.
return self.name.clone(); return self.name.clone();
} }
pub fn is_updated(&self) -> crate::Result<bool> {
// If the path is local and that file has not been updated.
Ok(self.source.as_ref().is_some_and(|path| is_url(path))
&& self.checksum == sha256::try_digest(self.source.as_ref().unwrap())?)
}
} }
impl From<PackageHandler> for Dependency { impl From<PackageHandler> for Dependency {
fn from(value: PackageHandler) -> Self { fn from(value: PackageHandler) -> Self {
Dependency { Dependency {
name: value.name(), name: value.name(),
version: value.version(), version: Some(value.version()),
checksum: String::new(), checksum: String::new(),
source: None, source: None,
} }

View File

@@ -1,8 +1,10 @@
use std::hash::Hash; use std::hash::Hash;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use fs::expand_files;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::class::Class;
use crate::prey::{F_PREY_LOCK, F_PREY_TOML, Prey, PreyLock}; use crate::prey::{F_PREY_LOCK, F_PREY_TOML, Prey, PreyLock};
/// Hashing is only based off the Prey. /// Hashing is only based off the Prey.
@@ -15,6 +17,8 @@ pub struct PackageHandler {
} }
impl PackageHandler { impl PackageHandler {
const DIR_JAVA: &str = "java/";
pub fn new<P: AsRef<Path>>(package_root: P, target_dir: P) -> crate::Result<Self> { 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(); 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 { pub fn entry_point(&self) -> PathBuf {
self.prey.entry_point() self.prey.entry_point()
} }
@@ -39,6 +41,34 @@ impl PackageHandler {
pub fn version(&self) -> semver::Version { pub fn version(&self) -> semver::Version {
self.prey.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 { impl Hash for PackageHandler {

View File

@@ -1,13 +1,14 @@
use std::collections::HashSet; use std::collections::HashSet;
use std::fs::{File, OpenOptions}; use std::fs::{File, OpenOptions};
use std::io::Read; use std::io::Read;
use std::path::PathBuf; use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::class::Class; use crate::class::Class;
use crate::meta::Meta; use crate::meta::Meta;
use crate::package::Package; use crate::package::Package;
use crate::prelude::Dependency;
pub const F_PREY_TOML: &str = "Prey.toml"; pub const F_PREY_TOML: &str = "Prey.toml";
pub const F_PREY_LOCK: &str = "Prey.lock"; pub const F_PREY_LOCK: &str = "Prey.lock";
@@ -53,11 +54,19 @@ impl TryFrom<File> for Prey {
} }
/// Data struct /// Data struct
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] #[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)]
pub struct PreyLock { pub struct PreyLock {
classes: HashSet<Class>, pub classes: HashSet<Class>,
} }
impl PreyLock {
pub fn with_class(&mut self, class: Class) -> &mut Self {
self.classes.insert(class);
self
}
}
/// Load the PreyLock from Prey.lock file.
impl TryFrom<PathBuf> for PreyLock { impl TryFrom<PathBuf> for PreyLock {
type Error = crate::Error; type Error = crate::Error;
@@ -76,3 +85,21 @@ impl TryFrom<File> for PreyLock {
Ok(toml::from_str(buf.as_str())?) Ok(toml::from_str(buf.as_str())?)
} }
} }
impl From<Vec<PathBuf>> for PreyLock {
fn from(value: Vec<PathBuf>) -> Self {
let mut lock = Self::default();
lock.classes = value
.iter()
.filter_map(|f| {
let dep = Class::try_from(f.to_owned());
if dep.is_ok() {
Some(dep.unwrap())
} else {
None
}
})
.collect();
lock
}
}

View File

@@ -3,13 +3,12 @@ use std::fs::{OpenOptions, read_dir};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use fs::{self, expand_files}; use fs::expand_files;
use io::run_process; use io::run_process;
use java::{self, JAVA_EXT_CLASS, JAVA_EXT_SOURCE}; use java::{JAVA_EXT_CLASS, JAVA_EXT_SOURCE};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::Error; use crate::Error;
use crate::dependency::Dependency;
use crate::nest::{F_NEST_LOCK, F_NEST_TOML, Nest, NestLock}; use crate::nest::{F_NEST_LOCK, F_NEST_TOML, Nest, NestLock};
use crate::package::PackageHandler; use crate::package::PackageHandler;
use crate::prey::F_PREY_TOML; use crate::prey::F_PREY_TOML;
@@ -140,6 +139,24 @@ impl WorkspaceHandler {
// This is the naive build // This is the naive build
pub fn build(&mut self) -> crate::Result<()> { pub fn build(&mut self) -> crate::Result<()> {
let mut targets = vec![];
for (_name, mut handler) in self.packages.clone() {
targets.append(&mut handler.get_update_targets()?);
}
let compiler = java::compiler::CompilerBuilder::new()
.class_path(Self::DIR_TARGET)
.class_path(Self::DIR_TARGET)
.build();
for target in targets {
// Possibly come up with a source file handler for this?
if let Ok(_) = compiler.clone().compile(target) {
// No, this does not run O(1)
}
}
Ok(()) Ok(())
} }

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "io" name = "io"
version = "0.1.0" version = "0.2.0"
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true

View File

@@ -3,7 +3,7 @@
[package] [package]
name = "java" name = "java"
version = "0.1.0" version = "0.2.0"
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "raven" name = "raven"
version = "0.1.0" version = "0.2.0"
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true