Skip to content

Commit

Permalink
clean up Cargo.tomls (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi authored May 29, 2024
1 parent 301512e commit 103effc
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 47 deletions.
34 changes: 19 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
[workspace]
resolver = "2"

members = ["ast", "host", "runtime", "transform", "util"]

[workspace.lints.clippy]
alloc_instead_of_core = "warn"
std_instead_of_core = "warn"
std_instead_of_alloc = "warn"
absolute_paths = "warn"
field_reassign_with_default = "allow"
missing_safety_doc = "allow"
new_ret_no_self = "allow"

[package]
name = "hvm64"
version = "0.3.0"
version.workspace = true
edition = "2021"
description = "HVM-Core is a massively parallel Interaction Combinator evaluator."
license = "MIT"

[workspace.package]
version = "0.3.0"

[[bin]]
name = "hvm64"
path = "src/main.rs"
Expand Down Expand Up @@ -57,3 +46,18 @@ highlight_error = { git = "https://github.com/tjjfvi/rust_highlight_error/", bra
[[test]]
name = "tests"
harness = false

[lints]
workspace = true

[workspace]
resolver = "2"

[workspace.lints.clippy]
alloc_instead_of_core = "warn"
std_instead_of_core = "warn"
std_instead_of_alloc = "warn"
absolute_paths = "warn"
field_reassign_with_default = "allow"
missing_safety_doc = "allow"
new_ret_no_self = "allow"
2 changes: 1 addition & 1 deletion ast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hvm64-ast"
version = "0.3.0"
version.workspace = true
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion host/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hvm64-host"
version = "0.3.0"
version.workspace = true
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hvm64-runtime"
version = "0.3.0"
version.workspace = true
edition = "2021"

[lib]
Expand Down
8 changes: 3 additions & 5 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ mod include_files;

pub use include_files::*;

use std::{
collections::{BTreeMap, BTreeSet},
fmt::Write,
hash::{DefaultHasher, Hasher},
};
use alloc::collections::{BTreeMap, BTreeSet};
use core::{fmt::Write, hash::Hasher};
use std::hash::DefaultHasher;

use crate::prelude::*;
use hvm64_host::Host;
Expand Down
2 changes: 1 addition & 1 deletion src/compile/include_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub fn create_temp_hvm(host: &Host) -> Result<(), io::Error> {
r#"
[workspace]
resolver = "2"
package.version = "0.0.0"
members = ["util", "runtime", "gen"]
Expand All @@ -60,7 +61,6 @@ members = ["util", "runtime", "gen"]
r#"
[package]
name = "hvm64-gen"
version = "0.3.0"
edition = "2021"
[lib]
Expand Down
32 changes: 14 additions & 18 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ mod compile;
mod args;
mod full;

use crate::prelude::*;

use core::time::Duration;
use std::{
env::consts::{DLL_PREFIX, DLL_SUFFIX},
env::{
self,
consts::{DLL_PREFIX, DLL_SUFFIX},
},
ffi::OsStr,
fs, io,
path::PathBuf,
process::{self, Stdio},
time::{Duration, Instant},
time::Instant,
};

use self::full::{CliMode, FullCli};
Expand All @@ -21,12 +27,13 @@ use clap::Parser;

use hvm64_ast::{Book, Net, Tree};
use hvm64_host::Host;
use hvm64_runtime::{DynDef, Heap, Port, Trg};
use hvm64_runtime::{trace, DynDef, Heap, Port, Trg};
use hvm64_transform::Transform;
use hvm64_util::pretty_num;

fn main() {
if cfg!(feature = "trace") {
hvm64_runtime::trace::set_hook();
trace::set_hook();
}

let cli = FullCli::parse();
Expand Down Expand Up @@ -70,7 +77,7 @@ fn main() {
};

if cfg!(feature = "trace") {
hvm64_runtime::trace::_read_traces(usize::MAX);
trace::_read_traces(usize::MAX);
}
}

Expand Down Expand Up @@ -124,7 +131,7 @@ fn load_book(files: &[PathBuf], transform_args: TransformArgs) -> Book {
}

fn load_dylibs(host: &mut Host, include: &[PathBuf]) {
let current_dir = std::env::current_dir().unwrap();
let current_dir = env::current_dir().unwrap();

for file in include {
unsafe {
Expand Down Expand Up @@ -163,7 +170,7 @@ fn load_dylibs(host: &mut Host, include: &[PathBuf]) {
});

// Leak the lib to avoid unloading it, as code from it is still referenced.
std::mem::forget(lib);
mem::forget(lib);
}
}
}
Expand Down Expand Up @@ -198,17 +205,6 @@ fn print_stats(net: &hvm64_runtime::Net, elapsed: Duration) {
eprintln!("RPS : {:.3} M", (net.rwts.total() as f64) / (elapsed.as_millis() as f64) / 1000.0);
}

fn pretty_num(n: u64) -> String {
n.to_string()
.as_bytes()
.rchunks(3)
.rev()
.map(|x| std::str::from_utf8(x).unwrap())
.flat_map(|x| ["_", x])
.skip(1)
.collect()
}

/// Compiles the `.hvm` directory, appending the provided `args` to `cargo`.
fn compile_temp_hvm() -> Result<(), io::Error> {
let output = process::Command::new("cargo")
Expand Down
3 changes: 2 additions & 1 deletion tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::{
error::Error,
fs,
io::Read,
process::{Command, ExitStatus, Stdio},
};
Expand Down Expand Up @@ -253,5 +254,5 @@ fn test_cli_compile() {
[#13 #1]
"###);

std::fs::remove_file("examples/arithmetic").unwrap();
fs::remove_file("examples/arithmetic").unwrap();
}
3 changes: 2 additions & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use core::str::FromStr;
use dyntest::{dyntest, DynTester};
use hvm64_transform::pre_reduce::PreReduce;
use std::{fs, path::Path, str::FromStr};
use std::{fs, path::Path};

use hvm64_ast::{self as ast, Book, Net};
use hvm64_host::Host;
Expand Down
2 changes: 1 addition & 1 deletion tests/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use hvm64_ast::{Book, Net};
use hvm64_transform::{eta_reduce::EtaReduce, inline::Inline, pre_reduce::PreReduce, prune::Prune, TransformError};

use core::str::FromStr;
use insta::assert_snapshot;
use std::str::FromStr;

mod loaders;
use loaders::*;
Expand Down
2 changes: 1 addition & 1 deletion transform/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hvm64-transform"
version = "0.3.0"
version.workspace = true
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hvm64-util"
version = "0.3.0"
version.workspace = true
edition = "2021"

[dependencies]
Expand Down

0 comments on commit 103effc

Please sign in to comment.