From f41ec73a056da22fa414383f1ed14a71059f27a1 Mon Sep 17 00:00:00 2001 From: raj_mathe Date: Wed, 30 Mar 2022 18:00:21 +0200 Subject: [PATCH] master > master: src - rust --- code/rust/.env | 4 + code/rust/.gitignore | 54 ++++ code/rust/Cargo.lock | 569 ++++++++++++++++++++++++++++++++++++ code/rust/Cargo.toml | 22 ++ code/rust/LICENSE | 0 code/rust/Makefile | 98 +++++++ code/rust/README.md | 3 + code/rust/dist/VERSION | 1 + code/rust/src/core/mod.rs | 1 + code/rust/src/core/utils.rs | 25 ++ code/rust/src/lib.rs | 1 + code/rust/src/main.rs | 15 + 12 files changed, 793 insertions(+) create mode 100644 code/rust/.env create mode 100644 code/rust/.gitignore create mode 100644 code/rust/Cargo.lock create mode 100644 code/rust/Cargo.toml create mode 100644 code/rust/LICENSE create mode 100644 code/rust/Makefile create mode 100644 code/rust/README.md create mode 100644 code/rust/dist/VERSION create mode 100644 code/rust/src/core/mod.rs create mode 100644 code/rust/src/core/utils.rs create mode 100644 code/rust/src/lib.rs create mode 100644 code/rust/src/main.rs diff --git a/code/rust/.env b/code/rust/.env new file mode 100644 index 0000000..6605cf0 --- /dev/null +++ b/code/rust/.env @@ -0,0 +1,4 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Environment variables +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +APPNAME=ads2 diff --git a/code/rust/.gitignore b/code/rust/.gitignore new file mode 100644 index 0000000..ab5b940 --- /dev/null +++ b/code/rust/.gitignore @@ -0,0 +1,54 @@ +* +!/.gitignore + +################################################################ +# MAIN FOLDER +################################################################ + +!/.env +!/Makefile +!/README.md +!/LICENSE + +!/Cargo.toml +!/Cargo.lock + +################################################################ +# PROJECT FILES +################################################################ + +!/src +!/src/**/ +!/src/**/*.rs + +!/tests +!/tests/**/ +!/tests/**/*.rs + +!/src + +!/assets +!/assets/**/ + +!/dist +!/dist/VERSION + +################################################################ +# AUXLIARY +################################################################ + +/logs + +################################################################ +# ARTEFACTS +################################################################ + +/**/__pycache__ +/**/.DS_Store +/**/__archive__* + +################################################################ +# Git Keep +################################################################ + +!/**/.gitkeep diff --git a/code/rust/Cargo.lock b/code/rust/Cargo.lock new file mode 100644 index 0000000..fb547ba --- /dev/null +++ b/code/rust/Cargo.lock @@ -0,0 +1,569 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ads2" +version = "0.0.0" +dependencies = [ + "argparse", + "closure", + "dyn-fmt", + "itertools", + "numpy", + "regex 1.5.5 (git+https://github.com/rust-lang/regex.git)", + "rust-embed", + "textwrap", + "yaml-rust", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "argparse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f8ebf5827e4ac4fd5946560e6a99776ea73b596d80898f357007317a7141e47" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "closure" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6173fd61b610d15a7566dd7b7620775627441c4ab9dac8906e17cb93a24b782" + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "dyn-fmt" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a0836c9bd73a9d3ca55b0effc5b1eedf96dd13ef994389bcac6d4d33c46188" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "indoc" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7906a9fababaeacb774f72410e497a1d18de916322e33797bb2cd29baa23c9e" +dependencies = [ + "unindent", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "libc" +version = "0.2.121" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" + +[[package]] +name = "linked-hash-map" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" + +[[package]] +name = "lock_api" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "matrixmultiply" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +dependencies = [ + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "ndarray" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec23e6762830658d2b3d385a75aa212af2f67a4586d4442907144f3bb6a1ca8" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "rawpointer", +] + +[[package]] +name = "num-complex" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "numpy" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "383ae168529a39fc97cbc1d9d4fa865377731a519bc27553ed96f50594de7c45" +dependencies = [ + "libc", + "ndarray", + "num-complex", + "num-traits", + "pyo3", +] + +[[package]] +name = "once_cell" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "pyo3" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a378727d5fdcaafd15b5afe9842cff1c25fdc43f62a162ffda2263c57ad98703" +dependencies = [ + "cfg-if", + "indoc", + "libc", + "parking_lot", + "pyo3-build-config", + "pyo3-ffi", + "pyo3-macros", + "unindent", +] + +[[package]] +name = "pyo3-build-config" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fbb27a3e96edd34c13d97d0feefccc90a79270c577c66e19d95af8323823dfc" +dependencies = [ + "once_cell", +] + +[[package]] +name = "pyo3-ffi" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b719fff844bcf3f911132112ec06527eb195f6a98e0c42cf97e1118929fd4ea" +dependencies = [ + "libc", + "pyo3-build-config", +] + +[[package]] +name = "pyo3-macros" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f795e52d3320abb349ca28b501a7112154a87f353fae1c811deecd58e99cfa9b" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e03aa57a3bb7b96982958088df38302a139df4eef54671bc595f26556cb75b" +dependencies = [ + "proc-macro2", + "pyo3-build-config", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "redox_syscall" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.6.25 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex" +version = "1.5.5" +source = "git+https://github.com/rust-lang/regex.git#258bdf798a14f50529c1665e84cc8a3a9e2c90fc" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.6.25 (git+https://github.com/rust-lang/regex.git)", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "git+https://github.com/rust-lang/regex.git#258bdf798a14f50529c1665e84cc8a3a9e2c90fc" + +[[package]] +name = "rust-embed" +version = "6.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40377bff8cceee81e28ddb73ac97f5c2856ce5522f0b260b763f434cdfae602" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94e763e24ba2bf0c72bc6be883f967f794a019fafd1b86ba1daff9c91a7edd30" +dependencies = [ + "proc-macro2", + "quote", + "rust-embed-utils", + "syn", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "7.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad22c7226e4829104deab21df575e995bfbc4adfad13a595e387477f238c1aec" +dependencies = [ + "sha2", + "walkdir", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer", + "cfg-if", + "cpufeatures", + "digest", + "opaque-debug", +] + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + +[[package]] +name = "smawk" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" + +[[package]] +name = "syn" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "textwrap" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unicode-linebreak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a52dcaab0c48d931f7cc8ef826fa51690a08e1ea55117ef26f89864f532383f" +dependencies = [ + "regex 1.5.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "unindent" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514672a55d7380da379785a4d70ca8386c8883ff7eaae877be4d2081cebe73d8" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "git+https://github.com/chyh1990/yaml-rust.git#da52a68615f2ecdd6b7e4567019f280c433c1521" +dependencies = [ + "linked-hash-map", +] diff --git a/code/rust/Cargo.toml b/code/rust/Cargo.toml new file mode 100644 index 0000000..6574b02 --- /dev/null +++ b/code/rust/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "ads2" +version = "0.0.0" +authors = [ "raj_mathe" ] + +[workspace] +members = [ + ".", +] + +[dependencies] +rust-embed = { version = "6.3.0" } +closure = { version = "0.3.0" } +dyn-fmt = { version = "0.3.0" } + +argparse = { version = "0.2.2" } +regex = { git = "https://github.com/rust-lang/regex.git", version = "1.5.4" } +yaml-rust = { git = "https://github.com/chyh1990/yaml-rust.git", version = "0.4.4" } +textwrap = { version = "0.14.2" } + +itertools = { version = "0.10.3" } +numpy = { version = "0.16.2" } diff --git a/code/rust/LICENSE b/code/rust/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/code/rust/Makefile b/code/rust/Makefile new file mode 100644 index 0000000..7805793 --- /dev/null +++ b/code/rust/Makefile @@ -0,0 +1,98 @@ +SHELL:=/usr/bin/env bash +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Makefile +# NOTE: Do not change the contents of this file! +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +include .env + +################################ +# VARIABLES +################################ + +ARTEFACT_NAME:=${APPNAME} +ifeq ($(OS),Windows_NT) +ARTEFACT_NAME:=${APPNAME}.exe +endif + +################################ +# Macros +################################ + +define create_folder_if_not_exists + @if ! [ -d "$(1)" ]; then mkdir "$(1)"; fi +endef + +define create_folder_if_not_exists + @touch "$(1)"; +endef + +define delete_if_file_exists + @if [ -f "$(1)" ]; then rm "$(1)"; fi +endef + +define delete_if_folder_exists + @if [ -d "$(1)" ]; then rm -rf "$(1)"; fi +endef + +define clean_all_files + @find . -type f -name "$(1)" -exec basename {} \; + @find . -type f -name "$(1)" -exec rm {} \; 2> /dev/null +endef + +define clean_all_folders + @find . -type d -name "$(1)" -exec basename {} \; + @find . -type d -name "$(1)" -exec rm -rf {} \; 2> /dev/null +endef + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# TARGETS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +################################ +# BASIC TARGETS: setup, build, run +################################ +setup: check-system-requirements setup-no-checks +setup-no-checks: + @cargo update +build: check-system-requirements build-no-checks +build-no-checks: + @$(call delete_if_file_exists,"dist/${ARTEFACT_NAME}") + @#$(call delete_if_file_exists,"Cargo.lock") + @cargo build --release + @cp "target/release/${ARTEFACT_NAME}" "dist/" +run-precheck: + @if ! [ -f "dist/${ARTEFACT_NAME}" ]; then \ + echo "No artefact found! Run `make build` first"; \ + exit 1; \ + fi +run: + @make run-precheck + @dist/${ARTEFACT_NAME}; +all: setup build run +################################ +# TARGETS: testing +################################ +unit-test: unit-tests +unit-tests: + cargo test +################################ +# AUXILIARY (INTERNAL TARGETS) +################################ +check-system-requirements: + @if ! ( cargo version >> /dev/null 2> /dev/null ); then \ + echo "Install Rust cargo first."; \ + exit 1; \ + fi + @cargo version +################################ +# TARGETS: clean +################################ +clean: + @echo "All system artefacts will be force removed." + @$(call clean_all_files,.DS_Store) + @echo "All build artefacts will be force removed." + @$(call clean_all_folders,target) + @$(call delete_if_file_exists,dist/${ARTEFACT_NAME}) + @cargo clean + @exit 0 diff --git a/code/rust/README.md b/code/rust/README.md new file mode 100644 index 0000000..7eaefdf --- /dev/null +++ b/code/rust/README.md @@ -0,0 +1,3 @@ +# ADS2 - Implementierung in Rust # + +(_Noch nicht implementiert_) diff --git a/code/rust/dist/VERSION b/code/rust/dist/VERSION new file mode 100644 index 0000000..77d6f4c --- /dev/null +++ b/code/rust/dist/VERSION @@ -0,0 +1 @@ +0.0.0 diff --git a/code/rust/src/core/mod.rs b/code/rust/src/core/mod.rs new file mode 100644 index 0000000..b5614dd --- /dev/null +++ b/code/rust/src/core/mod.rs @@ -0,0 +1 @@ +pub mod utils; diff --git a/code/rust/src/core/utils.rs b/code/rust/src/core/utils.rs new file mode 100644 index 0000000..57b6860 --- /dev/null +++ b/code/rust/src/core/utils.rs @@ -0,0 +1,25 @@ +// ---------------------------------------------------------------- +// IMPORTS +// ---------------------------------------------------------------- + +extern crate regex; + +use self::regex::Regex; + +// ---------------------------------------------------------------- +// METHODS get regex +// ---------------------------------------------------------------- + +/// Constructs RegEx and panics if error. +pub fn construct_regex(pattern: &str) -> Regex { + return Regex::new(pattern) + .expect("Invalid regex construction!"); +} + +// ---------------------------------------------------------------- +// METHOD hello world +// ---------------------------------------------------------------- + +pub fn greet() { + println!("Hello world!"); +} diff --git a/code/rust/src/lib.rs b/code/rust/src/lib.rs new file mode 100644 index 0000000..5a7ca06 --- /dev/null +++ b/code/rust/src/lib.rs @@ -0,0 +1 @@ +pub mod core; diff --git a/code/rust/src/main.rs b/code/rust/src/main.rs new file mode 100644 index 0000000..735774f --- /dev/null +++ b/code/rust/src/main.rs @@ -0,0 +1,15 @@ +// ---------------------------------------------------------------- +// IMPORTS +// ---------------------------------------------------------------- + +extern crate ads2; + +use ads2::core::utils; + +// ---------------------------------------------------------------- +// MAIN METHOD +// ---------------------------------------------------------------- + +fn main() { + utils::greet(); +}