Compare commits

...

3 Commits

Author SHA1 Message Date
27f784e1f0 Fixed raven build to build from anywhere inside of a raven project. 2026-01-26 22:26:21 -05:00
Olivia Brooks
aa851f7616 Add clap version, authors; Update metadata. 2026-01-26 22:21:10 -05:00
Olivia Brooks
dafc6ea885 Fix pathing issues. 2026-01-26 21:51:15 -05:00
3 changed files with 29 additions and 22 deletions

View File

@@ -2,23 +2,27 @@
name = "raven"
version = "0.1.0"
edition = "2024"
authors = ["Olivia Brooks", "Adrian Long"]
repository = "https://gitea.cutieguwu.ca/Cutieguwu/raven"
license = "MIT"
publish = false
[dependencies]
anyhow = "1.0"
bytesize = "2.3"
ron = "0.12"
sha256 = "1.6.0"
sha256 = "1.6"
subprocess = "0.2"
toml = "0.9"
[dependencies.serde]
version = "1.0"
features =["derive"]
[dependencies.clap]
version = "4.5"
features = ["derive"]
features = ["cargo", "derive"]
[dependencies.semver]
version = "1.0"
features = ["serde"]
[dependencies.serde]
version = "1.0"
features =["derive"]

View File

@@ -5,6 +5,8 @@ use clap::{ArgAction, Parser, Subcommand};
pub static CONFIG: LazyLock<Args> = LazyLock::new(|| Args::parse());
#[derive(Debug, Parser)]
#[clap(author, version)]
#[command(help_template = "{author-section}\n{usage-heading} {usage}\n\n{all-args}")]
pub struct Args {
#[command(subcommand)]
pub command: Command,

View File

@@ -17,14 +17,6 @@ use nest::{Class, NEST, NestLock};
use anyhow::Context;
use bytesize::ByteSize;
const DIR_TARGET: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("target/"));
const DIR_SRC: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("src/"));
const DIR_MAIN: LazyLock<PathBuf> = LazyLock::new(|| DIR_SRC.join("main/"));
const DIR_TEST: LazyLock<PathBuf> = LazyLock::new(|| DIR_SRC.join("test/"));
const F_NEST_TOML: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("Nest.toml"));
const F_NEST_LOCK: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("Nest.lock"));
pub static PROJECT_ROOT: LazyLock<PathBuf> = LazyLock::new(|| {
// Start from CWD
let cwd = std::env::current_dir().expect("Failed to get current working directory");
@@ -44,6 +36,14 @@ pub static PROJECT_ROOT: LazyLock<PathBuf> = LazyLock::new(|| {
probe
});
const DIR_TARGET: LazyLock<PathBuf> = LazyLock::new(|| PROJECT_ROOT.join("target/"));
const DIR_SRC: LazyLock<PathBuf> = LazyLock::new(|| PROJECT_ROOT.join("src/"));
const DIR_MAIN: LazyLock<PathBuf> = LazyLock::new(|| DIR_SRC.join("main/"));
const DIR_TEST: LazyLock<PathBuf> = LazyLock::new(|| DIR_SRC.join("test/"));
const F_NEST_TOML: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("Nest.toml"));
const F_NEST_LOCK: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("Nest.lock"));
fn main() -> anyhow::Result<()> {
// Ensure that Nest.toml exists, if the requested command depends upon it.
if CONFIG.command.depends_on_nest() && NEST.is_err() {
@@ -91,11 +91,7 @@ fn init() -> anyhow::Result<()> {
.context("Unable to convert OsStr to str")?
.to_owned();
// Make src, target, tests
for dir in [DIR_SRC, DIR_MAIN, DIR_TARGET, DIR_TEST] {
std::fs::create_dir_all(dir.clone())?;
}
// ORDER MATTERS. THIS MUST COME FIRST.
// Make config file.
if let Result::Ok(mut f) = OpenOptions::new()
.write(true)
@@ -129,6 +125,11 @@ fn init() -> anyhow::Result<()> {
)?;
}
// Make src, target, tests
for dir in [DIR_SRC, DIR_MAIN, DIR_TARGET, DIR_TEST] {
std::fs::create_dir_all(dir.clone())?;
}
// Make src/main/Main.java
if let Result::Ok(mut f) = OpenOptions::new().write(true).create_new(is_empty).open(
DIR_MAIN
@@ -185,7 +186,7 @@ fn new(project_name: String) -> anyhow::Result<()> {
}
fn build() -> anyhow::Result<()> {
let mut targets: Vec<PathBuf> = crate::fs::expand_files(DIR_SRC.as_path())?
let mut targets: Vec<PathBuf> = crate::fs::expand_files(PROJECT_ROOT.clone().join(DIR_SRC.as_path()))?
.into_iter()
.filter(|f| {
f.extension()
@@ -254,7 +255,7 @@ fn test(assertions: bool) -> anyhow::Result<(Option<String>, Option<String>)> {
.compile(DIR_TEST.as_path())?;
// Change cwd to avoid Java pathing issues.
crate::env::set_cwd(PROJECT_ROOT.join(DIR_TARGET.as_path()))?;
crate::env::set_cwd(DIR_TARGET.as_path())?;
java::JVMBuilder::new()
.assertions(assertions)
@@ -267,5 +268,5 @@ fn test(assertions: bool) -> anyhow::Result<(Option<String>, Option<String>)> {
fn clean() {
let _ = std::fs::remove_file(PROJECT_ROOT.join(F_NEST_LOCK.as_path()));
let _ = std::fs::remove_dir_all(PROJECT_ROOT.join(DIR_TARGET.as_path()));
let _ = std::fs::remove_dir_all(DIR_TARGET.join("/*").as_path());
}