From 20d59bc767315104b785dc137cc609a48bb9d785 Mon Sep 17 00:00:00 2001 From: Stefan Ellmauthaler <71695780+ellmau@users.noreply.github.com> Date: Thu, 3 Mar 2022 13:37:14 +0100 Subject: [PATCH] REORGANISE with workspace (#29) Reorganise the structure of the repository to have a workspace with the library and the binary. --- bin/Cargo.lock => Cargo.lock | 116 ++++++++++++++++++++++++---- Cargo.toml | 47 +---------- bin/Cargo.toml | 10 ++- lib/Cargo.toml | 44 +++++++++++ lib/LICENSE | 1 + lib/README.md | 1 + build.rs => lib/build.rs | 2 +- {src => lib/src}/adf.rs | 0 {src => lib/src}/adfbiodivine.rs | 0 {src => lib/src}/datatypes.rs | 0 {src => lib/src}/datatypes/adf.rs | 0 {src => lib/src}/datatypes/bdd.rs | 0 {src => lib/src}/lib.rs | 0 {src => lib/src}/obdd.rs | 6 +- {src => lib/src}/obdd/vectorize.rs | 0 {src => lib/src}/parser.rs | 0 {src => lib/src}/test.rs | 0 {tests => lib/tests}/test_loader.rs | 0 {tests => lib/tests}/test_template | 0 19 files changed, 159 insertions(+), 68 deletions(-) rename bin/Cargo.lock => Cargo.lock (88%) create mode 100644 lib/Cargo.toml create mode 120000 lib/LICENSE create mode 120000 lib/README.md rename build.rs => lib/build.rs (95%) rename {src => lib/src}/adf.rs (100%) rename {src => lib/src}/adfbiodivine.rs (100%) rename {src => lib/src}/datatypes.rs (100%) rename {src => lib/src}/datatypes/adf.rs (100%) rename {src => lib/src}/datatypes/bdd.rs (100%) rename {src => lib/src}/lib.rs (100%) rename {src => lib/src}/obdd.rs (99%) rename {src => lib/src}/obdd/vectorize.rs (100%) rename {src => lib/src}/parser.rs (100%) rename {src => lib/src}/test.rs (100%) rename {tests => lib/tests}/test_loader.rs (100%) rename {tests => lib/tests}/test_template (100%) diff --git a/bin/Cargo.lock b/Cargo.lock similarity index 88% rename from bin/Cargo.lock rename to Cargo.lock index 43b5d52..18df324 100644 --- a/bin/Cargo.lock +++ b/Cargo.lock @@ -8,11 +8,15 @@ version = "0.2.1" dependencies = [ "biodivine-lib-bdd", "derivative", + "env_logger 0.9.0", "lexical-sort", "log", "nom", + "quickcheck", + "quickcheck_macros", "serde", "serde_json", + "test-log", ] [[package]] @@ -23,7 +27,7 @@ dependencies = [ "assert_cmd", "assert_fs", "clap", - "env_logger", + "env_logger 0.9.0", "log", "predicates", "serde", @@ -97,7 +101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcfb460c1131729ec8d797ce0be49ec102506e764ce62f20a40056516851c5" dependencies = [ "fxhash", - "rand", + "rand 0.7.3", ] [[package]] @@ -131,9 +135,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.1.3" +version = "3.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f8c0e2a6b902acc18214e24a6935cdaf8a8e34231913d4404dcaee659f65a1" +checksum = "ced1892c55c910c1219e98d6fc8d71f6bddba7905866ce740066d8bfea859312" dependencies = [ "atty", "bitflags", @@ -148,9 +152,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.1.2" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d42c94ce7c2252681b5fed4d3627cc807b13dfc033246bd05d5b252399000e" +checksum = "da95d038ede1a964ce99f49cbe27a7fb538d1da595e4b4f70b8c8f338d17bf16" dependencies = [ "heck", "proc-macro-error", @@ -198,6 +202,16 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "env_logger" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" version = "0.9.0" @@ -252,7 +266,18 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -510,6 +535,28 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "quickcheck" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" +dependencies = [ + "env_logger 0.8.4", + "log", + "rand 0.8.5", +] + +[[package]] +name = "quickcheck_macros" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b22a693222d716a9587786f37ac3f6b4faedb5b80c23914e7303ff5a1d8016e9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "quote" version = "1.0.15" @@ -525,13 +572,22 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.16", "libc", "rand_chacha", - "rand_core", + "rand_core 0.5.1", "rand_hc", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_core 0.6.3", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -539,7 +595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", ] [[package]] @@ -548,7 +604,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.5", ] [[package]] @@ -557,7 +622,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] @@ -680,9 +745,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] @@ -694,10 +759,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b" [[package]] -name = "textwrap" -version = "0.14.2" +name = "test-log" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" +checksum = "eb78caec569a40f42c078c798c0e35b922d9054ec28e166f0d6ac447563d91a4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thread_local" @@ -746,6 +822,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 9c752e0..bbabfdd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,44 +1,3 @@ -[package] -name = "adf_bdd" -version = "0.2.1" -authors = ["Stefan Ellmauthaler "] -edition = "2021" -repository = "https://github.com/ellmau/adf-obdd/" -license = "GPL-3.0-only" -exclude = ["res/", "./flake*", "flake.lock", "*.nix", ".envrc", "_config.yml"] - -description = "Library to solve grounded, complete, and stable ADF-semantics by utilising OBDDs - ordered binary decision diagrams" -build = "build.rs" - -[lib] -name="adf_bdd" -path = "src/lib.rs" -test = true -doctest = true # Documentation examples are tested by default. -bench = true # Is benchmarked by default. -doc = true # Is documented by default. -harness = true # Use libtest harness. -edition = "2021" # The edition of the target. -crate-type = ["lib"] # The crate types to generate. - -[dependencies] -log = { version = "0.4"} -nom = "7.1.0" -lexical-sort = "0.3.1" -serde = { version = "1.0", features = ["derive","rc"] } -serde_json = "1.0" -biodivine-lib-bdd = "0.3.0" -derivative = "2.2.0" - -[dev-dependencies] -test-log = "0.2" -env_logger = "0.9" -quickcheck = "1" -quickcheck_macros = "1" - -[features] -default = ["adhoccounting", "variablelist" ] -adhoccounting = [] # count models ad-hoc - disable if counting is not needed -importexport = [] -variablelist = [ "HashSet" ] -HashSet = [] \ No newline at end of file +[workspace] +members=[ "lib", "bin" ] +default-members = [ "lib" ] \ No newline at end of file diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 3dd92f9..c8b322c 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -14,7 +14,7 @@ name = "adf_bdd" path = "src/main.rs" [dependencies] -adf_bdd = { path = "../" } +adf_bdd = { path = "../lib", default-features = false } clap = {version = "3.1.3", features = [ "derive", "cargo", "env" ]} log = { version = "0.4", features = [ "max_level_trace", "release_max_level_info" ] } serde = { version = "1.0", features = ["derive","rc"] } @@ -27,6 +27,8 @@ predicates = "2.1" assert_fs = "1.0" [features] -default = ["adhoccounting"] -adhoccounting = [] # count models ad-hoc - disable if counting is not needed -importexport = [] \ No newline at end of file +default = ["adhoccounting", "variablelist", "adf_bdd/default" ] +adhoccounting = ["adf_bdd/adhoccounting"] # count models ad-hoc - disable if counting is not needed +importexport = ["adf_bdd/importexport"] +variablelist = [ "HashSet", "adf_bdd/variablelist" ] +HashSet = ["adf_bdd/HashSet"] \ No newline at end of file diff --git a/lib/Cargo.toml b/lib/Cargo.toml new file mode 100644 index 0000000..4a8365a --- /dev/null +++ b/lib/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "adf_bdd" +version = "0.2.1" +authors = ["Stefan Ellmauthaler "] +edition = "2021" +repository = "https://github.com/ellmau/adf-obdd/" +license = "GPL-3.0-only" +exclude = ["res/", "./flake*", "flake.lock", "*.nix", ".envrc", "_config.yml", "tarpaulin-report.*", "*~"] + +description = "Library to solve grounded, complete, and stable ADF-semantics by utilising OBDDs - ordered binary decision diagrams" +build = "build.rs" + +[lib] +name="adf_bdd" +path = "src/lib.rs" +test = true +doctest = true # Documentation examples are tested by default. +bench = true # Is benchmarked by default. +doc = true # Is documented by default. +harness = true # Use libtest harness. +edition = "2021" # The edition of the target. +crate-type = ["lib"] # The crate types to generate. + +[dependencies] +log = { version = "0.4"} +nom = "7.1.0" +lexical-sort = "0.3.1" +serde = { version = "1.0", features = ["derive","rc"] } +serde_json = "1.0" +biodivine-lib-bdd = "0.3.0" +derivative = "2.2.0" + +[dev-dependencies] +test-log = "0.2" +env_logger = "0.9" +quickcheck = "1" +quickcheck_macros = "1" + +[features] +default = ["adhoccounting", "variablelist" ] +adhoccounting = [] # count models ad-hoc - disable if counting is not needed +importexport = [] +variablelist = [ "HashSet" ] +HashSet = [] \ No newline at end of file diff --git a/lib/LICENSE b/lib/LICENSE new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/lib/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/lib/README.md b/lib/README.md new file mode 120000 index 0000000..32d46ee --- /dev/null +++ b/lib/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/build.rs b/lib/build.rs similarity index 95% rename from build.rs rename to lib/build.rs index 33174ea..f12c3ca 100644 --- a/build.rs +++ b/lib/build.rs @@ -17,7 +17,7 @@ fn gen_tests() { let destination = Path::new(&out_dir).join("tests.rs"); let mut test_file = File::create(&destination).unwrap(); - if let Ok(test_data_directory) = read_dir("./res/adf-instances/instances/") { + if let Ok(test_data_directory) = read_dir("../res/adf-instances/instances/") { // write test file header, put `use`, `const` etc there write_header(&mut test_file); diff --git a/src/adf.rs b/lib/src/adf.rs similarity index 100% rename from src/adf.rs rename to lib/src/adf.rs diff --git a/src/adfbiodivine.rs b/lib/src/adfbiodivine.rs similarity index 100% rename from src/adfbiodivine.rs rename to lib/src/adfbiodivine.rs diff --git a/src/datatypes.rs b/lib/src/datatypes.rs similarity index 100% rename from src/datatypes.rs rename to lib/src/datatypes.rs diff --git a/src/datatypes/adf.rs b/lib/src/datatypes/adf.rs similarity index 100% rename from src/datatypes/adf.rs rename to lib/src/datatypes/adf.rs diff --git a/src/datatypes/bdd.rs b/lib/src/datatypes/bdd.rs similarity index 100% rename from src/datatypes/bdd.rs rename to lib/src/datatypes/bdd.rs diff --git a/src/lib.rs b/lib/src/lib.rs similarity index 100% rename from src/lib.rs rename to lib/src/lib.rs diff --git a/src/obdd.rs b/lib/src/obdd.rs similarity index 99% rename from src/obdd.rs rename to lib/src/obdd.rs index 25ddbad..1df1969 100644 --- a/src/obdd.rs +++ b/lib/src/obdd.rs @@ -106,8 +106,10 @@ impl Bdd { pub fn restrict(&mut self, tree: Term, var: Var, val: bool) -> Term { let node = self.nodes[tree.0]; #[cfg(feature = "variablelist")] - if !self.var_deps[tree.value()].contains(&var) { - return tree; + { + if !self.var_deps[tree.value()].contains(&var) { + return tree; + } } #[allow(clippy::collapsible_else_if)] // Readability of algorithm > code-elegance diff --git a/src/obdd/vectorize.rs b/lib/src/obdd/vectorize.rs similarity index 100% rename from src/obdd/vectorize.rs rename to lib/src/obdd/vectorize.rs diff --git a/src/parser.rs b/lib/src/parser.rs similarity index 100% rename from src/parser.rs rename to lib/src/parser.rs diff --git a/src/test.rs b/lib/src/test.rs similarity index 100% rename from src/test.rs rename to lib/src/test.rs diff --git a/tests/test_loader.rs b/lib/tests/test_loader.rs similarity index 100% rename from tests/test_loader.rs rename to lib/tests/test_loader.rs diff --git a/tests/test_template b/lib/tests/test_template similarity index 100% rename from tests/test_template rename to lib/tests/test_template