Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various updates required for publishing to crates.io #125

Merged
merged 11 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/rust_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:

env:
CARGO_TERM_COLOR: always
NO_COLOR: 1

jobs:
build:
Expand Down
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"petr-parse",
"petr-fmt",
"petr-utils",
"pete",
"petr-cli",
"petr-codegen",
"petr-ast",
"petr-typecheck",
Expand All @@ -15,5 +15,14 @@ members = [
"petr-pkg",
"petr-profiling",
"petr-api",
"petr-playground"
, "stdlib"]
"petr-playground",
"petr-stdlib",
]

[workspace.package]
version = "0.1.0"
edition = "2021"
homepage = "https://petr.sh"
license = "MIT"
repository = "https://github.com/sezna/petr"
authors = ["Alex Hansen <[email protected]>"]
23 changes: 20 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@
alias t := test

test:
CARGO_TERM_COLOR=always NO_COLOR=1 cargo test
cargo test

update-expects:
CARGO_TERM_COLOR=always NO_COLOR=1 UPDATE_EXPECT=1 cargo test
u-exp:
UPDATE_EXPECT=1 cargo test

publish:
cargo publish -p petr-utils
cargo publish -p petr-ast
cargo publish -p petr-profiling
cargo publish -p petr-parse
cargo publish -p petr-fmt
cargo publish -p petr-bind
cargo publish -p petr-resolve
cargo publish -p petr-typecheck
cargo publish -p petr-ir
cargo publish -p petr-vm
cargo publish -p petr-codegen
cargo publish -p petr-pkg
cargo publish -p petr-api
cargo publish -p petr-playground
cargo publish -p petr-cli
18 changes: 0 additions & 18 deletions pete/Cargo.toml

This file was deleted.

28 changes: 17 additions & 11 deletions petr-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
[package]
name = "petr-api"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
repository.workspace = true
homepage.workspace = true
authors.workspace = true

description = "re-exports of useful APIs for the petr compiler"
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
petr-parse = { "path" = "../petr-parse" }
petr-utils = { "path" = "../petr-utils", optional = true }
petr-vm = { "path" = "../petr-vm" }
petr-ir = { "path" = "../petr-ir" }
petr-fmt = { path = "../petr-fmt" }
petr-typecheck = { "path" = "../petr-typecheck" }
petr-resolve = { "path" = "../petr-resolve", optional = true }
petr-pkg = { "path" = "../petr-pkg", optional = true }
petr-parse = { "path" = "../petr-parse", version = "0.1.0" }
petr-utils = { "path" = "../petr-utils", optional = true, version = "0.1.0" }
petr-vm = { "path" = "../petr-vm", version = "0.1.0" }
petr-ir = { "path" = "../petr-ir", version = "0.1.0" }
petr-fmt = { path = "../petr-fmt", version = "0.1.0" }
petr-typecheck = { "path" = "../petr-typecheck", version = "0.1.0" }
petr-resolve = { "path" = "../petr-resolve", version = "0.1.0", optional = true }
petr-pkg = { "path" = "../petr-pkg", version = "0.1.0", optional = true }
termcolor = { version = "1.4", optional = true }
petr-profiling = { path = "../petr-profiling" }
petr-profiling = { path = "../petr-profiling", version = "0.1.0" }
miette = { version = "5.10", optional = true }
thiserror = "1.0"
toml = "0.8"
Expand Down
14 changes: 7 additions & 7 deletions petr-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use std::{
fs,
path::{Path, PathBuf},
rc::Rc,
};

pub use petr_fmt::{format_sources, Formattable, FormatterConfig, FormatterContext};
Expand All @@ -21,6 +20,8 @@ pub use petr_vm::Vm;
use termcolor::{ColorChoice, ColorSpec, StandardStream, WriteColor};

pub mod error {
use petr_ir::LoweringError;
use petr_utils::SpannedItem;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum PeteError {
Expand All @@ -31,6 +32,8 @@ pub mod error {
#[cfg(not(feature = "no_std"))]
#[error(transparent)]
Pkg(#[from] petr_pkg::error::PkgError),
#[error("Failed to lower code")]
FailedToLower(#[from] SpannedItem<LoweringError>),
}
}

Expand Down Expand Up @@ -153,12 +156,9 @@ pub fn compile(
interner = new_interner;
parse_errs.append(&mut new_parse_errs);
source_map = new_source_map;
let name = Identifier {
id: interner.insert(Rc::from(item.manifest.name)),
};
dependencies.push(petr_resolve::Dependency {
key: item.key,
name,
name: item.manifest.name,
dependencies: item.depends_on,
ast,
});
Expand Down Expand Up @@ -193,8 +193,8 @@ pub fn compile(
// errs.append(&mut type_errs);

timings.start("lowering");
let lowerer: Lowerer = Lowerer::new(type_checker);
let lowerer = Lowerer::new(type_checker);
timings.end("lowering");

Ok(lowerer)
Ok(lowerer?)
}
12 changes: 9 additions & 3 deletions petr-ast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
[package]
name = "petr-ast"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
repository.workspace = true
homepage.workspace = true
authors.workspace = true

description = "AST types for the petr language"
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
petr-utils = { path = "../petr-utils" }
petr-utils = { path = "../petr-utils", version = "0.1.0" }
16 changes: 11 additions & 5 deletions petr-bind/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
[package]
name = "petr-bind"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
repository.workspace = true
homepage.workspace = true
authors.workspace = true

description = "The binding stage of the petr compiler"
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
petr-utils = { path = "../petr-utils" }
petr-ast = { path = "../petr-ast" }
petr-utils = { path = "../petr-utils", version = "0.1.0" }
petr-ast = { path = "../petr-ast", version = "0.1.0" }


[dev-dependencies]
expect-test = "1.5.0"
petr-parse = { path = "../petr-parse" }
petr-parse = { path = "../petr-parse", version = "0.1.0" }
28 changes: 28 additions & 0 deletions petr-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "petr-cli"
version.workspace = true
edition.workspace = true
repository.workspace = true
homepage.workspace = true
authors.workspace = true

license.workspace = true
description = "command line tool for compiling petr code"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.5.4", features = ["derive"] }
petr-api = { "path" = "../petr-api", features = ["fancy", "default"], version = "0.1.0" }
petr-profiling = { "path" = "../petr-profiling", version = "0.1.0" }
petr-resolve = { "path" = "../petr-resolve", version = "0.1.0" }
petr-typecheck = { "path" = "../petr-typecheck", version = "0.1.0" }
thiserror = "1.0"
toml = "0.8"
termcolor = { version = "1.4" }
petr-pkg = { "path" = "../petr-pkg", version = "0.1.0" }
petr-stdlib = { "path" = "../petr-stdlib", version = "0.1.0" }

[[bin]]
name = "pete"
path = "src/main.rs"
2 changes: 1 addition & 1 deletion pete/src/main.rs → petr-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub fn compile(
let mut dependencies = Vec::with_capacity(build_plan.items.len() + 1);

// add the stdlib
let parser = Parser::new_with_existing_interner_and_source_map(stdlib::stdlib(), interner, source_map);
let parser = Parser::new_with_existing_interner_and_source_map(petr_stdlib::stdlib(), interner, source_map);
let (dep_ast, mut new_parse_errs, mut interner, mut source_map) = parser.into_result();
parse_errs.append(&mut new_parse_errs);

Expand Down
File renamed without changes.
12 changes: 9 additions & 3 deletions petr-codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
[package]
name = "petr-codegen"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
repository.workspace = true
homepage.workspace = true
authors.workspace = true

license.workspace = true
description = "Codegen stage of the petr compiler"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
petr-ir = { path = "../petr-ir" }
petr-ir = { path = "../petr-ir", version = "0.1.0" }

cranelift = "0.108.1"
cranelift-native = "0.108.1"
Expand Down
6 changes: 3 additions & 3 deletions petr-fmt/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading