Skip to content

Commit

Permalink
Merge branch 'main' into close-by-drop-on-explicit-close
Browse files Browse the repository at this point in the history
  • Loading branch information
AZWN committed Jun 13, 2024
2 parents 385b582 + 169d9d9 commit b2095bf
Show file tree
Hide file tree
Showing 166 changed files with 303,549 additions and 276 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scopegraphs-render-docs/doc/** linguist-vendored
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# will have compiled files and executables
debug/
target/
doc/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand All @@ -18,4 +17,8 @@ Cargo.lock
.idea/

*.dot
.direnv
*.mmd

.direnv

**/render-docs
29 changes: 29 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,38 @@ members = [
"scopegraphs",
"scopegraphs-macros",
"scopegraphs-regular-expressions",
"scopegraphs-render-docs",
]
default-members = [
"scopegraphs",
"scopegraphs-macros",
"scopegraphs-regular-expressions",
"scopegraphs-render-docs",
]

[workspace.package]
version = "0.3.2"
authors = [
"Aron Zwaan <[email protected]>",
"Jonathan Dönszelmann <[email protected]>"
]
description = "A well-documented port of scopegraphs to Rust"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.75"
repository = "https://github.com/metaborg/rust-scopegraphs"
documentation = "https://docs.rs/scopegraphs"

[workspace.dependencies]
quote = "1"
syn = "2"
proc-macro2 = "1"
thiserror = "1"

# note this version should stay lower.
# Scopegraphs is a dev-dependency of scopegraphs-macros, and we deploy scopegraphs macros first.
# By that time, scopegraphs is not yet released at the right version.
scopegraphs = { path = "./scopegraphs", version = "0.3" }
scopegraphs-macros = { path = "./scopegraphs-macros", version = "0.3.2" }
scopegraphs-regular-expressions = { path = "./scopegraphs-regular-expressions", version = "0.3.2" }
scopegraphs-render-docs = { path = "./scopegraphs-render-docs", version = "0.3.2" }
9 changes: 9 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
watch-docs:
cargo +nightly watch -s 'cargo +nightly docs-rs -p scopegraphs && browser-sync start --ss target/x86_64-unknown-linux-gnu/doc -s target/x86_64-unknown-linux-gnu/doc --directory --no-open'

publish:
cargo publish -p scopegraphs-render-docs
sleep 10
cargo publish -p scopegraphs-regular-expressions
sleep 10
cargo publish -p scopegraphs-macros
sleep 10
cargo publish -p scopegraphs
1 change: 1 addition & 0 deletions examples
70 changes: 64 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,71 @@
};
in {
devShells.default = pkgs.mkShell rec {
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
targets = [ "wasm32-unknown-unknown" ];
extensions = [ "rust-src" "rust-analyzer" ];
};
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
buildInputs = with pkgs; [
# necessary for building wgpu in 3rd party packages (in most cases)
libxkbcommon
wayland
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
alsa-lib
fontconfig
freetype
shaderc
directx-shader-compiler
pkg-config
cmake
mold # could use any linker, needed for rustix (but mold is fast)

buildInputs = with pkgs; [ trunk rustToolchain cargo-watch ];
libGL
vulkan-headers
vulkan-loader
vulkan-tools
vulkan-tools-lunarg
vulkan-extension-layer
vulkan-validation-layers # don't need them *strictly* but immensely helpful

cargo-nextest
cargo-fuzz
cargo-watch

# nice for developing wgpu itself
typos

# if you don't already have rust installed through other means,
# this shell.nix can do that for you with this below
yq # for tomlq below
rustup

# nice tools
gdb
rr
evcxr
valgrind
renderdoc
just

# for this project
nodePackages.browser-sync
];

shellHook = ''
export RUSTC_VERSION="$(tomlq -r .toolchain.channel rust-toolchain.toml)"
export PATH="$PATH:''${CARGO_HOME:-~/.cargo}/bin"
export PATH="$PATH:''${RUSTUP_HOME:-~/.rustup/toolchains/$RUSTC_VERSION-x86_64-unknown-linux/bin}"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${
builtins.toString (pkgs.lib.makeLibraryPath buildInputs)
}";
# for this project
cargo install cargo-docs-rs
rustup default $RUSTC_VERSION
rustup toolchain add nightly
rustup component add rust-src rust-analyzer
'';
};
});
}
31 changes: 13 additions & 18 deletions scopegraphs-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
[package]
name = "scopegraphs-macros"
version = "0.2.9"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = [
"Aron Zwaan <[email protected]>",
"Jonathan Dönszelmann <[email protected]>"
]
description = "A port of scopegraphs (https://pl.ewi.tudelft.nl/research/projects/scope-graphs/) to Rust"
repository = "https://github.com/metaborg/rust-scopegraphs/"
rust-version = "1.75"

version.workspace = true
edition.workspace = true
license.workspace = true
authors.workspace = true
description.workspace = true
repository.workspace = true
rust-version.workspace = true

[lib]
proc-macro = true

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

[dependencies]
syn = { version = "2.0.29", features = [] }
quote = "1.0.33"
scopegraphs-regular-expressions = { path = "../scopegraphs-regular-expressions", features = ["dot"], version = "0.2.0" }
proc-macro2 = "1.0.69"
syn.workspace = true
quote.workspace = true
proc-macro2.workspace = true

scopegraphs-regular-expressions = { workspace = true, features = ["dot"] }

[dev-dependencies]
scopegraphs = { path = "../scopegraphs" }
scopegraphs.workspace = true

[features]
dot = ["scopegraphs-regular-expressions/dot"]
24 changes: 22 additions & 2 deletions scopegraphs-macros/src/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,41 @@ pub fn impl_label(input: DeriveInput) -> TokenStream {
}

let mut variant_names = Vec::new();
let mut variant_numbers = Vec::new();

for variant in variants {
for (num, variant) in variants.into_iter().enumerate() {
if !variant.fields.is_empty() {
return quote_spanned!(
variant.span() => compile_error!("cannot derive Label for an enum with fields on variants");
)
.into();
}

if variant.discriminant.is_some() {
return quote_spanned!(
variant.span() => compile_error!("cannot derive Label for an enum with custom discriminated variants. Use `Label::to_usize()`");
)
.into();
}

variant_names.push(variant.ident);
variant_numbers.push(num);
}
let num_variants = variant_numbers.len();

let name = input.ident;
quote! {
impl scopegraphs::Label for #name {
unsafe impl scopegraphs::Label for #name {
type Array<T> = [T; #num_variants];

fn to_usize(&self) -> usize {
match *self {
#(
Self::#variant_names => #variant_numbers
),*
}
}

fn iter() -> impl Iterator<Item = Self> {
[
#(
Expand Down
27 changes: 11 additions & 16 deletions scopegraphs-regular-expressions/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
[package]
name = "scopegraphs-regular-expressions"
version = "0.2.10"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = [
"Aron Zwaan <[email protected]>",
"Jonathan Dönszelmann <[email protected]>"
]
description = "A port of scopegraphs (https://pl.ewi.tudelft.nl/research/projects/scope-graphs/) to Rust"
repository = "https://github.com/metaborg/rust-scopegraphs/"
rust-version = "1.75"
version.workspace = true
edition.workspace = true
license.workspace = true
authors.workspace = true
description.workspace = true
repository.workspace = true
rust-version.workspace = true


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
syn = { version = "2.0.29", default-features = false, features = ["parsing", "derive", "printing", "clone-impls"] }
quote = { version = "1.0.33" }
proc-macro2 = "1.0.69"
thiserror = "1.0.50"
syn.workspace = true
quote.workspace = true
proc-macro2.workspace = true
thiserror.workspace = true

[features]
dot = []
Expand Down
6 changes: 6 additions & 0 deletions scopegraphs-render-docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/target
**/*.rs.bk
Cargo.lock
.idea/

render-docs
Loading

0 comments on commit b2095bf

Please sign in to comment.