From 171a4fa4d15c4be14d63fdc5d258610bb26bd162 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 11 Sep 2021 21:18:09 +0530 Subject: restructure repo into bin, lib and macros --- Cargo.lock | 104 ------------------------------------------------------ Cargo.toml | 14 ++++---- bin/Cargo.toml | 8 +++++ bin/src/main.rs | 3 ++ lib/Cargo.toml | 8 +++++ lib/src/lib.rs | 7 ++++ macros/Cargo.toml | 8 +++++ macros/src/lib.rs | 7 ++++ readme.md | 35 ++++++++++++++++++ src/main.rs | 3 -- 10 files changed, 82 insertions(+), 115 deletions(-) delete mode 100644 Cargo.lock create mode 100644 bin/Cargo.toml create mode 100644 bin/src/main.rs create mode 100644 lib/Cargo.toml create mode 100644 lib/src/lib.rs create mode 100644 macros/Cargo.toml create mode 100644 macros/src/lib.rs create mode 100644 readme.md delete mode 100644 src/main.rs diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index f09d0c9..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,104 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "anyhow" -version = "1.0.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf" - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "cbitset" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29b6ad25ae296159fb0da12b970b2fe179b234584d7cd294c891e2bbb284466b" -dependencies = [ - "num-traits", -] - -[[package]] -name = "countme" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" - -[[package]] -name = "hashbrown" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" - -[[package]] -name = "memoffset" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" -dependencies = [ - "autocfg", -] - -[[package]] -name = "nix-analyzer" -version = "0.1.0" -dependencies = [ - "anyhow", - "rnix", -] - -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", -] - -[[package]] -name = "rnix" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b37f8af07a0354606141df076458660af7e22238e4117a041c21c548080addd" -dependencies = [ - "cbitset", - "rowan", - "smol_str", -] - -[[package]] -name = "rowan" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b36e449f3702f3b0c821411db1cbdf30fb451726a9456dce5dabcd44420043" -dependencies = [ - "countme", - "hashbrown", - "memoffset", - "rustc-hash", - "text-size", -] - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "smol_str" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b203e79e90905594272c1c97c7af701533d42adaab0beb3859018e477d54a3b0" - -[[package]] -name = "text-size" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "288cb548dbe72b652243ea797201f3d481a0609a967980fcc5b2315ea811560a" diff --git a/Cargo.toml b/Cargo.toml index d7f3afa..adfe5d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,8 @@ -[package] -name = "nix-analyzer" -version = "0.1.0" -edition = "2018" +[workspace] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +members = [ + "bin", + "lib", + "macros" +] -[dependencies] -anyhow = "1.0" -rnix = "0.9.0" diff --git a/bin/Cargo.toml b/bin/Cargo.toml new file mode 100644 index 0000000..57cff11 --- /dev/null +++ b/bin/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "bin" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/bin/src/main.rs b/bin/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/bin/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/lib/Cargo.toml b/lib/Cargo.toml new file mode 100644 index 0000000..49e2e49 --- /dev/null +++ b/lib/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "lib" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/lib/src/lib.rs b/lib/src/lib.rs new file mode 100644 index 0000000..31e1bb2 --- /dev/null +++ b/lib/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/macros/Cargo.toml b/macros/Cargo.toml new file mode 100644 index 0000000..6a47e03 --- /dev/null +++ b/macros/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "macros" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/macros/src/lib.rs b/macros/src/lib.rs new file mode 100644 index 0000000..31e1bb2 --- /dev/null +++ b/macros/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..9a9e0ca --- /dev/null +++ b/readme.md @@ -0,0 +1,35 @@ +## nix-analyzer + +`nix-analyzer` intends to be a static analysis tool for the +Nix programming language. + +For the time-being, `nix-analyzer` works only with ASTs +produced by the `rnix-parser` crate and does not evaluate +any nix code. + +## Architecture + +`nix-analyzer` has the following components: + +- `bin`: the CLI/entrypoint +- `lib`: library of lints and utilities to define these + lints +- `macros`: procedural macros to help define a lint + +### `bin` + +This is the main point of interaction between `nix-analyzer` +and the end user. It's output is human-readable and should +also support JSON/errorfmt outputs for external tools to +use. + +### `lib` + +A library of AST-based lints and utilities to help write +those lints. It should be easy for newcomers to write lints +without being familiar with the rest of the codebase. + +### `macros` + +This crate intends to be a helper layer to declare lints and +their metadata. diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} -- cgit v1.2.3