Add initial Rust project setup

This commit is contained in:
Tim Süberkrüb 2022-08-23 20:48:20 +02:00
commit a14f66b5ad
19 changed files with 1354 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

73
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,73 @@
---
name: Rust CI
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/cargo@v1
with:
command: check
args: --tests --benches
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/cargo@v1
with:
command: test
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --tests --benches -- -D warnings

22
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,22 @@
---
name: Lint Code Base
on: [push, pull_request]
jobs:
build:
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter/slim@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
# Rust
target
# direnv
.direnv

1075
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

8
Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[workspace]
members = [
"syntax",
"parser",
"core",
"app",
]

13
app/Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "app"
version = "0.1.0"
edition = "2021"
[dependencies]
# cli
clap = { version = "3", features = ["derive"] }
reedline = "0.10"
# workspace members
core = { path = "../core" }
syntax = { path = "../syntax" }
parser = { path = "../parser" }

1
app/src/main.rs Normal file
View file

@ -0,0 +1 @@
fn main() {}

9
core/Cargo.toml Normal file
View file

@ -0,0 +1,9 @@
[package]
name = "core"
version = "0.1.0"
edition = "2021"
[dependencies]
# workspace members
syntax = { path = "../syntax" }
parser = { path = "../parser" }

1
core/src/lib.rs Normal file
View file

@ -0,0 +1 @@

76
flake.lock generated Normal file
View file

@ -0,0 +1,76 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1659610603,
"narHash": "sha256-LYgASYSPYo7O71WfeUOaEUzYfzuXm8c8eavJcel+pfI=",
"owner": "nix-community",
"repo": "naersk",
"rev": "c6a45e4277fa58abd524681466d3450f896dc094",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1661239106,
"narHash": "sha256-C5OCLnrv2c4CHs9DMEtYKkjJmGL7ySAZ1PqPkHBonxQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "963d27a0767422be9b8686a8493dcade6acee992",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1661239106,
"narHash": "sha256-C5OCLnrv2c4CHs9DMEtYKkjJmGL7ySAZ1PqPkHBonxQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "963d27a0767422be9b8686a8493dcade6acee992",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2"
}
}
},
"root": "root",
"version": 7
}

31
flake.nix Normal file
View file

@ -0,0 +1,31 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { self, flake-utils, naersk, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs) {
inherit system;
};
naersk' = pkgs.callPackage naersk {};
in rec {
# For `nix build` & `nix run`:
defaultPackage = naersk'.buildPackage {
src = ./.;
};
# For `nix develop`:
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rustc cargo rustfmt clippy ];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
}
);
}

14
parser/Cargo.toml Normal file
View file

@ -0,0 +1,14 @@
[package]
name = "parser"
version = "0.1.0"
edition = "2021"
[dependencies]
lalrpop = "0.19"
lalrpop-util = "0.19"
# workspace members
syntax = { path = "../syntax" }
[build-dependencies.lalrpop]
version = "0.19"
features = ["lexer"]

3
parser/build.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
lalrpop::process_root().unwrap();
}

1
parser/src/lib.rs Normal file
View file

@ -0,0 +1 @@

1
rustfmt.toml Normal file
View file

@ -0,0 +1 @@
use_small_heuristics = "Max"

7
scripts/git-hooks/pre-commit Executable file
View file

@ -0,0 +1,7 @@
# Pre-commit hook
# Place into `.git/hooks` or use `git config core.hooksPath scripts/git-hooks`
# from the root of the repository
cargo test
cargo clippy --tests --benches -- -Dwarnings
cargo fmt -- --check

13
syntax/Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "syntax"
version = "0.1.0"
edition = "2021"
[dependencies]
# serde
serde = { version = "1", features = ["rc"], optional = true }
serde_derive = { version = "1", optional = true }
[features]
default = ["use-serde"]
use-serde = ["serde", "serde_derive"]

1
syntax/src/lib.rs Normal file
View file

@ -0,0 +1 @@