forked 6ad82c3339 and refactored to combine prey.toml with nest.toml. The WorkspaceHandler.discover_packages() function is very broken

This commit is contained in:
2026-02-22 23:19:26 -05:00
parent 6ad82c3339
commit 3654d76340
32 changed files with 335 additions and 333 deletions

View File

@@ -35,6 +35,8 @@ ron = "0.12.0"
sha256 = "1.6"
subprocess = "1.0"
toml = "1.0"
tree-sitter = "0.22"
tree-sitter-java = "0.21.0"
derive_more = { version = "2.1", features = ["display", "from"] }
semver = { version = "1.0",features = ["serde"] }

3
Test1/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# Automatically added by Raven
target/
*.class

10
Test1/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

14
Test1/.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="app" />
<module name="core" />
</profile>
</annotationProcessing>
</component>
</project>

20
Test1/.idea/jarRepositories.xml generated Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

12
Test1/.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK" />
</project>

6
Test1/.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

1
Test1/.java-version Normal file
View File

@@ -0,0 +1 @@
25

4
Test1/Nest.toml Normal file
View File

@@ -0,0 +1,4 @@
[package]
name = "Test1"
version = "0.1.0"
entry_point = "app"

2
Test1/app/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
target/
*.class

7
Test1/app/Prey.toml Normal file
View File

@@ -0,0 +1,7 @@
[package]
name = "app"
version = "0.1.0"
entry_point = "com/raven/Main.java"
[dependencies]
code = {path = "../core"}

23
Test1/app/pom.xml Normal file
View File

@@ -0,0 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.raven</groupId>
<artifactId>multi-module-demo</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>app</artifactId>
<dependencies>
<dependency>
<groupId>com.raven</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,7 @@
package com.raven;
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

View File

@@ -0,0 +1,5 @@
public class Test {
public static void main(String[] args) {
System.out.println("This is a test.");
}
}

2
Test1/core/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
target/
*.class

4
Test1/core/Prey.toml Normal file
View File

@@ -0,0 +1,4 @@
[package]
name = "core"
version = "0.1.0"
entry_point = "com/raven/Main.java"

15
Test1/core/pom.xml Normal file
View File

@@ -0,0 +1,15 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.raven</groupId>
<artifactId>multi-module-demo</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>core</artifactId>
</project>

View File

@@ -0,0 +1,7 @@
package com.raven;
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

View File

@@ -0,0 +1,5 @@
public class Test {
public static void main(String[] args) {
System.out.println("This is a test.");
}
}

18
Test1/pom.xml Normal file
View File

@@ -0,0 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.raven</groupId>
<artifactId>multi-module-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>core</module>
<module>app</module>
</modules>
</project>

View File

@@ -1,11 +1,9 @@
pub mod class;
pub mod dependency;
pub mod error;
pub mod meta;
pub mod nest;
pub mod package;
pub mod prelude;
pub mod prey;
pub mod workspace;
pub use error::{Error, Result};

View File

@@ -1,40 +0,0 @@
use std::path::PathBuf;
use semver::Version;
use serde::{Deserialize, Serialize};
/// Data struct
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct Meta {
pub name: String,
pub version: Version,
#[serde(skip_serializing_if = "<Option<_>>::is_none")]
pub authors: Option<Vec<String>>,
#[serde(skip_serializing_if = "<Option<_>>::is_none")]
pub repository: Option<String>,
#[serde(skip_serializing_if = "<Option<_>>::is_none")]
pub license: Option<String>,
#[serde(skip_serializing_if = "<Option<_>>::is_none")]
pub license_file: Option<PathBuf>,
}
impl Meta {
pub fn new<S: ToString>(name: S) -> Self {
let mut meta = Self::default();
meta.name = name.to_string();
meta
}
}
impl Default for Meta {
fn default() -> Self {
Meta {
name: String::from("Main"),
version: Version::new(0, 1, 0),
authors: None,
repository: None,
license: None,
license_file: None,
}
}
}

View File

@@ -1,30 +1,42 @@
use std::collections::HashSet;
use std::collections::{BTreeMap, HashSet};
use std::fs::{File, OpenOptions};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
use fs::expand_files;
use crate::class::Class;
use crate::dependency::Dependency;
use crate::meta::Meta;
use crate::workspace::Workspace;
use crate::package::Package;
//use crate::workspace::Workspace;
pub const F_NEST_TOML: &str = "Nest.toml";
pub const F_NEST_LOCK: &str = "Nest.lock";
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DetailedDependency {
pub version: Option<String>,
pub path: Option<String>,
pub git: Option<String>,
pub optional: Option<bool>,
pub features: Option<Vec<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependencySpec {
Simple(String), // serde = "1.0"
Detailed(DetailedDependency), // serde = { version = "...", ... }
}
/// Data struct
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)]
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct Nest {
workspace: Workspace,
meta: Meta,
dependencies: HashSet<Dependency>,
package: Package,
dependencies: Option<BTreeMap<String, DependencySpec>>,
}
impl Nest {
pub fn new<S: ToString>(name: S) -> Self {
Self {
workspace: Workspace::default(),
meta: Meta::new(name),
package: Package::new(name),
dependencies: Default::default(),
}
}
@@ -42,16 +54,20 @@ impl Nest {
.write_all(toml::to_string_pretty(&self)?.as_bytes())?)
}
pub fn default_package(&self) -> PathBuf {
self.workspace.default_package.clone()
pub fn with_entry_point<P: AsRef<Path>>(&mut self, entry_point: P) -> &mut Self {
self.package.entry_point = Some(entry_point.as_ref().to_path_buf());
self
}
pub fn entry_point(&self) -> Option<PathBuf> {
self.package.entry_point.clone()
}
pub fn name(&self) -> String {
self.meta.name.clone()
self.package.name.clone()
}
pub fn set_default_package<P: AsRef<Path>>(&mut self, package: P) {
self.workspace.default_package = package.as_ref().to_path_buf();
pub fn version(&self) -> semver::Version {
self.package.version.clone()
}
}
@@ -59,7 +75,10 @@ impl TryFrom<PathBuf> for Nest {
type Error = crate::Error;
fn try_from(value: PathBuf) -> Result<Self, Self::Error> {
println!("{}", value.to_string_lossy());
let f = OpenOptions::new().read(true).open(value)?;
Self::try_from(f)
}
}
@@ -77,17 +96,54 @@ impl TryFrom<File> for Nest {
/// Data struct
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)]
pub struct NestLock {
classes: HashSet<Class>,
pub dependencies: Vec<Dependency>,
}
impl NestLock {
pub fn new<P: AsRef<Path>>(package_root: P, package_src_root: P) -> crate::Result<Self> {
Ok(Self::from_paths(
expand_files(package_root)?,
package_src_root,
))
}
pub fn write<P: AsRef<Path>>(&self, path: P) -> crate::Result<()> {
let mut path = path.as_ref().to_path_buf();
if path.is_dir() {
path = path.join(F_NEST_LOCK);
}
Ok(OpenOptions::new()
.write(true)
.create(true)
.open(path)?
.write_all(toml::to_string_pretty(&self)?.as_bytes())?)
}
pub fn from_paths<P: AsRef<Path>>(paths: Vec<PathBuf>, package_src_root: P) -> Self {
let mut lock = Self::default();
lock.classes = paths
.iter()
.filter_map(|f| {
let dep = Class::new(package_src_root.as_ref().to_path_buf(), f.to_owned());
if dep.is_ok() {
Some(dep.unwrap())
} else {
None
}
})
.collect();
lock
}
pub fn with_class(&mut self, class: Class) -> &mut Self {
self.classes.insert(class);
self
}
pub fn classes(&mut self) -> &mut HashSet<Class> {
&mut self.classes
}
}
impl TryFrom<PathBuf> for NestLock {

View File

@@ -1,18 +1,18 @@
use std::hash::Hash;
use std::path::{Path, PathBuf};
use semver::Version;
use serde::{Deserialize, Serialize};
use crate::class::Class;
use crate::prey::{F_PREY_LOCK, F_PREY_TOML, Prey, PreyLock};
use crate::nest::{F_NEST_LOCK, Nest, NestLock};
pub const DIR_JAVA: &str = "java/";
/// Hashing is only based off the Prey.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone)]
pub struct PackageHandler {
prey: Prey,
prey_lock: PreyLock,
prey: Nest,
prey_lock: NestLock,
/// Path relative to WORKSPACE/src
package_root: PathBuf,
target_dir: PathBuf,
@@ -21,21 +21,21 @@ pub struct PackageHandler {
impl PackageHandler {
pub fn new<P: AsRef<Path>>(src_dir: P, package_root: P, target_dir: P) -> crate::Result<Self> {
let package_root = src_dir.as_ref().join(package_root.as_ref());
let prey_lock = if let Ok(prey_lock) = PreyLock::try_from(package_root.join(F_PREY_LOCK)) {
let prey_lock = if let Ok(prey_lock) = NestLock::try_from(package_root.join(F_NEST_LOCK)) {
prey_lock
} else {
PreyLock::new(package_root.clone(), package_root.join(DIR_JAVA))?
NestLock::new(package_root.clone(), package_root.join(DIR_JAVA))?
};
Ok(Self {
prey: Prey::try_from(package_root.join(F_PREY_TOML))?,
prey: Nest::try_from(package_root.join(F_NEST_LOCK))?,
prey_lock,
package_root,
target_dir: target_dir.as_ref().to_path_buf(),
})
}
pub fn entry_point(&self) -> PathBuf {
pub fn entry_point(&self) -> Option<PathBuf> {
self.prey.entry_point()
}
@@ -47,7 +47,7 @@ impl PackageHandler {
self.prey.version()
}
pub fn prey_lock(&mut self) -> &mut PreyLock {
pub fn prey_lock(&mut self) -> &mut NestLock {
&mut self.prey_lock
}
@@ -70,16 +70,46 @@ impl PackageHandler {
}
}
impl Hash for PackageHandler {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.prey.hash(state);
}
}
// impl Hash for PackageHandler {
// fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
// self.prey.hash(state);
// }
// }
/// Data struct
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct Package {
pub entry_point: PathBuf,
pub name: String,
pub version: Version,
#[serde(skip_serializing_if = "<Option<_>>::is_none")]
pub authors: Option<Vec<String>>,
#[serde(skip_serializing_if = "<Option<_>>::is_none")]
pub repository: Option<String>,
#[serde(skip_serializing_if = "<Option<_>>::is_none")]
pub license: Option<String>,
#[serde(skip_serializing_if = "<Option<_>>::is_none")]
pub license_file: Option<PathBuf>,
pub entry_point: Option<PathBuf>,
}
//impl Into<Dependency> for Package {}
impl Package {
pub fn new<S: ToString>(name: S) -> Self {
let mut package = Self::default();
package.name = name.to_string();
package
}
}
impl Default for Package {
fn default() -> Self {
Package {
name: String::from("Main"),
version: Version::new(0, 1, 0),
authors: None,
repository: None,
license: None,
license_file: None,
entry_point: None,
}
}
}

View File

@@ -2,8 +2,6 @@
pub use crate::class::Class;
pub use crate::dependency::Dependency;
pub use crate::meta::Meta;
pub use crate::nest::{F_NEST_LOCK, F_NEST_TOML, Nest, NestLock};
pub use crate::package::{Package, PackageHandler};
pub use crate::prey::{F_PREY_LOCK, F_PREY_TOML, Prey, PreyLock};
pub use crate::workspace::{Workspace, WorkspaceHandler};

View File

@@ -1,141 +0,0 @@
use std::collections::HashSet;
use std::fs::{File, OpenOptions};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use fs::expand_files;
use serde::{Deserialize, Serialize};
use crate::class::Class;
use crate::meta::Meta;
use crate::package::Package;
pub const F_PREY_TOML: &str = "Prey.toml";
pub const F_PREY_LOCK: &str = "Prey.lock";
/// Data struct
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
pub struct Prey {
package: Package,
meta: Meta,
}
impl Prey {
pub fn new<S: ToString>(name: S) -> Self {
Self {
package: Package {
entry_point: PathBuf::from(""),
},
meta: Meta::new(name),
}
}
pub fn with_entry_point<P: AsRef<Path>>(&mut self, entry_point: P) -> &mut Self {
self.package.entry_point = entry_point.as_ref().to_path_buf();
self
}
pub fn entry_point(&self) -> PathBuf {
self.package.entry_point.clone()
}
pub fn name(&self) -> String {
self.meta.name.clone()
}
pub fn version(&self) -> semver::Version {
self.meta.version.clone()
}
}
impl TryFrom<PathBuf> for Prey {
type Error = crate::Error;
fn try_from(value: PathBuf) -> Result<Self, Self::Error> {
let f = OpenOptions::new().read(true).open(value)?;
Self::try_from(f)
}
}
impl TryFrom<File> for Prey {
type Error = crate::Error;
fn try_from(mut value: File) -> Result<Self, Self::Error> {
let mut buf = String::new();
value.read_to_string(&mut buf)?;
Ok(toml::from_str(buf.as_str())?)
}
}
/// Data struct
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)]
pub struct PreyLock {
classes: HashSet<Class>,
}
impl PreyLock {
pub fn new<P: AsRef<Path>>(package_root: P, package_src_root: P) -> crate::Result<Self> {
Ok(Self::from_paths(
expand_files(package_root)?,
package_src_root,
))
}
pub fn from_paths<P: AsRef<Path>>(paths: Vec<PathBuf>, package_src_root: P) -> Self {
let mut lock = Self::default();
lock.classes = paths
.iter()
.filter_map(|f| {
let dep = Class::new(package_src_root.as_ref().to_path_buf(), f.to_owned());
if dep.is_ok() {
Some(dep.unwrap())
} else {
None
}
})
.collect();
lock
}
pub fn write<P: AsRef<Path>>(&self, package_root: P) -> crate::Result<()> {
let mut package_root = package_root.as_ref().to_path_buf();
if package_root.is_dir() {
package_root = package_root.join(F_PREY_LOCK);
}
Ok(OpenOptions::new()
.write(true)
.create(true)
.open(package_root)?
.write_all(toml::to_string_pretty(&self)?.as_bytes())?)
}
pub fn with_class(&mut self, class: Class) -> &mut Self {
self.classes.insert(class);
self
}
pub fn classes(&mut self) -> &mut HashSet<Class> {
&mut self.classes
}
}
/// Load the PreyLock from Prey.lock file.
impl TryFrom<PathBuf> for PreyLock {
type Error = crate::Error;
fn try_from(value: PathBuf) -> Result<Self, Self::Error> {
let f = OpenOptions::new().read(true).open(value)?;
Self::try_from(f)
}
}
impl TryFrom<File> for PreyLock {
type Error = crate::Error;
fn try_from(mut value: File) -> Result<Self, Self::Error> {
let mut buf = String::new();
value.read_to_string(&mut buf)?;
Ok(toml::from_str(buf.as_str())?)
}
}

View File

@@ -11,7 +11,6 @@ use subprocess::Exec;
use crate::nest::{F_NEST_LOCK, F_NEST_TOML, Nest, NestLock};
use crate::package::PackageHandler;
use crate::prey::{F_PREY_LOCK, F_PREY_TOML, Prey};
use crate::{Error, package};
#[derive(Debug)]
@@ -23,8 +22,8 @@ pub struct WorkspaceHandler {
}
impl WorkspaceHandler {
const DIR_SRC: &str = "src/";
const DIR_TARGET: &str = "target/";
const DIR_SRC: &'static str = "src/";
const DIR_TARGET: &'static str = "target/";
pub fn new<P: AsRef<Path>>(project_root: P) -> crate::Result<Self> {
let project_root = project_root.as_ref().canonicalize()?;
@@ -43,7 +42,9 @@ impl WorkspaceHandler {
}
pub fn load<P: AsRef<Path>>(project_root: P) -> crate::Result<Self> {
let project_root = project_root.as_ref().canonicalize()?;
println!("{}", project_root.display());
let mut workspace_manager = Self {
nest: Nest::try_from(project_root.join(F_NEST_TOML))?,
@@ -121,8 +122,8 @@ impl WorkspaceHandler {
.destination(Self::DIR_TARGET)
.build();
// No unintentional deep copying anywhere, right?
// Probably not. We'll see.
// cyclic dependencies across packages are not supported.
// construct a hashmap of parent child relationships between all files across all packages.
for handler in self.packages.values_mut() {
let package_src_root = self
.project_root
@@ -135,7 +136,7 @@ impl WorkspaceHandler {
dbg!(&target);
if let Ok(true) = compiler
.clone()
.compile(package_src_root.join(target.path.as_path()))
.compile(vec![package_src_root.join(target.path.as_path())])
{
target.update(package_src_root.as_path())?;
handler
@@ -157,33 +158,42 @@ impl WorkspaceHandler {
entry_point: Option<P>,
assertions: bool,
) -> crate::Result<&mut Self> {
let mut entry_point = if entry_point.is_none() {
self.nest.default_package()
} else {
entry_point.unwrap().as_ref().to_path_buf()
};
if !entry_point.is_file() {
// Use is_file to skip messing with pathing for src/
// If target is not a file (explicit entry point), check if it's a known package
// and use that's package's default entry point.
let mut entry_point = entry_point.expect("No entry point found").as_ref().to_path_buf();
while entry_point.is_file() {
entry_point = self
.packages
.get(&entry_point)
.ok_or(Error::UnknownPackage)?
.entry_point();
.entry_point()
.expect("No entry point found");
}
// let mut entry_point = if entry_point.is_none() {
// self.nest.entry_point()
// } else {
// //entry_point.unwrap().as_ref().to_path_buf()
// };
//
// if !entry_point.is_file() {
// // Use is_file to skip messing with pathing for src/
// // If target is not a file (explicit entry point), check if it's a known package
// // and use that's package's default entry point.
// entry_point = self
// .packages
// .get(&entry_point)
// .ok_or(Error::UnknownPackage)?
// .entry_point();
// }
//
if entry_point.file_name().is_none() {
return Err(Error::UndefinedEntryPoint);
return Err(Error::UndefinedEntryPoint);
}
//
java::runtime::JVMBuilder::new(Self::DIR_TARGET)
.assertions(assertions)
.monitor(true)
.build()
.run(entry_point)?;
Ok(self)
}
@@ -201,7 +211,7 @@ impl WorkspaceHandler {
self.project_root
.join(Self::DIR_SRC)
.join(handler.name())
.join(F_PREY_LOCK),
.join(F_NEST_LOCK),
) {
if err.kind() != std::io::ErrorKind::NotFound {
return Err(Error::from(err));
@@ -216,6 +226,9 @@ impl WorkspaceHandler {
}
/// Add any newly created packages.
/// Prey.toml files designate packages.
/// discover_packages() iterates the filesystem recursively to discover all such packages.
/// discovered packages are stored as a hashmap<PathBuf, PackageHandler> in the WorkspaceHandler.
fn discover_packages(&mut self) -> crate::Result<()> {
// Scan the src/ directory for entries,
// filter out the files,
@@ -227,7 +240,7 @@ impl WorkspaceHandler {
// whole subtree.
//
// Yes, I know this looks like shit.
// That's because it is.
// That's because it is. CON-FUCKING-FIRMED THIS SHIT IS NOT DEBUGGABLE
for file in read_dir(self.project_root.join(Self::DIR_SRC))?
// Get directories
@@ -240,14 +253,14 @@ impl WorkspaceHandler {
})
// Get Prey.toml files
.filter_map(|dir| {
Some(if dir.join(F_PREY_TOML).exists() {
vec![dir.join(F_PREY_TOML)]
Some(if dir.join(F_NEST_TOML).exists() {
vec![dir.join(F_NEST_TOML)]
} else {
expand_files(dir)
.ok()?
.iter()
.filter_map(|file| {
if file.ends_with(PathBuf::from(F_PREY_TOML)) {
if file.ends_with(PathBuf::from(F_NEST_TOML)) {
Some(file.to_owned())
} else {
None
@@ -319,10 +332,10 @@ impl WorkspaceHandler {
if let Result::Ok(mut f) = OpenOptions::new()
.write(true)
.create_new(true)
.open(main.join(F_PREY_TOML))
.open(main.join(F_NEST_TOML))
{
f.write_all(
toml::to_string_pretty(&Prey::new("main").with_entry_point("Main"))?.as_bytes(),
toml::to_string_pretty(&Nest::new("main").with_entry_point("Main"))?.as_bytes(),
)?;
}
@@ -339,10 +352,10 @@ impl WorkspaceHandler {
if let Result::Ok(mut f) = OpenOptions::new()
.write(true)
.create_new(true)
.open(test.join(F_PREY_TOML))
.open(test.join(F_NEST_TOML))
{
f.write_all(
toml::to_string_pretty(&Prey::new("test").with_entry_point("MainTest"))?.as_bytes(),
toml::to_string_pretty(&Nest::new("test").with_entry_point("MainTest"))?.as_bytes(),
)?;
}

View File

View File

@@ -50,7 +50,7 @@ pub struct Compiler {
}
impl Compiler {
pub fn compile<P: AsRef<Path>>(self, path: P) -> Result<bool> {
pub fn compile<P: AsRef<Path>>(self, paths: Vec<P>) -> Result<bool> {
Ok(Exec::cmd(JAVA_BIN_COMPILER)
.args(
self.flags
@@ -58,7 +58,7 @@ impl Compiler {
.into_iter()
.flat_map(|f| Into::<Vec<String>>::into(f)),
)
.arg(path.as_ref().with_extension(JAVA_EXT_SOURCE))
.args(paths.into_iter().map(|p| p.as_ref().with_extension(JAVA_EXT_SOURCE)))
.stdout(Redirection::Pipe)
.detached()
.start()?

View File

@@ -1,6 +1,7 @@
pub mod compiler;
pub mod error;
pub mod runtime;
mod compilation_scheduler;
use std::str::FromStr;

View File

@@ -4,12 +4,15 @@ use anyhow::anyhow;
use cli::{CLI_ARGS, Command};
fn main() -> anyhow::Result<()> {
// type_ is yet unused.
if let Command::New { project_name, .. } = &CLI_ARGS.command {
new(project_name.to_owned())?;
}
let project_root = std::env::current_dir()?;
println!("{}", project_root.display());
let mut wh: WorkspaceHandler = match &CLI_ARGS.command {
Command::New { .. } | Command::Init => WorkspaceHandler::new(project_root),
@@ -17,6 +20,7 @@ fn main() -> anyhow::Result<()> {
}
.map_err(|err| anyhow!(err))?;
match &CLI_ARGS.command {
Command::New { .. } | Command::Init => wh.init(),
Command::Build => wh.build(),

View File

@@ -1,84 +0,0 @@
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<groupId>com.viffx</groupId>
<artifactId>GameEngine</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<lwjgl.version>3.4.0</lwjgl.version>
<lwjgl.natives>natives-windows</lwjgl.natives>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-bom</artifactId>
<version>${lwjgl.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-assimp</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openal</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-stb</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-vulkan</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-assimp</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openal</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-stb</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
</dependencies>
</project>