From a0b371aae5869e08546fb1f60776b3fb30372a20 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Wed, 26 Jun 2024 16:53:53 +0200 Subject: [PATCH 1/8] feat(compile): add Amber version, fix #181 --- src/compiler.rs | 3 ++- src/header.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 5ee7c1c7..7dd5a339 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -125,7 +125,8 @@ impl AmberCompiler { } result.push(block.translate(&mut meta)); let res = result.join("\n"); - format!("{}\n{}", include_str!("header.sh"), res) + let header = include_str!("header.sh"); + format!("{}\n{}", &header.replace("|version|", option_env!("CARGO_PKG_VERSION").unwrap()), res) } pub fn compile(&self) -> Result<(Vec, String), Message> { diff --git a/src/header.sh b/src/header.sh index 8d4dfb04..6fb5b0fc 100644 --- a/src/header.sh +++ b/src/header.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -# Written in [Amber](https://amber-lang.com/) +# Written in [Amber](https://amber-lang.com/) - |version| From 1afabeb26f05cc1e7a1a8b578ba6cba8af8b7c5d Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Jul 2024 14:35:07 +0200 Subject: [PATCH 2/8] Update src/compiler.rs Co-authored-by: Phoenix Himself --- src/compiler.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 7dd5a339..58e0f2fd 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -125,8 +125,12 @@ impl AmberCompiler { } result.push(block.translate(&mut meta)); let res = result.join("\n"); - let header = include_str!("header.sh"); - format!("{}\n{}", &header.replace("|version|", option_env!("CARGO_PKG_VERSION").unwrap()), res) + let header = [ + include_str!("header.sh"), + "version:", option_env!("CARGO_PKG_VERSION").unwrap(), + "date:", Local::now().format("%Y-%m-%d %H:%M:%S").to_string() + ].join(" "); + format!("{}\n{}", header, res) } pub fn compile(&self) -> Result<(Vec, String), Message> { From 58dbf276129d99d88bf57f5dcba01408fa161834 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Jul 2024 14:35:13 +0200 Subject: [PATCH 3/8] Update src/header.sh Co-authored-by: Phoenix Himself --- src/header.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/header.sh b/src/header.sh index 6fb5b0fc..8d4dfb04 100644 --- a/src/header.sh +++ b/src/header.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -# Written in [Amber](https://amber-lang.com/) - |version| +# Written in [Amber](https://amber-lang.com/) From f73d0c7bdeacc56e8448593ffc270630f65db75d Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Jul 2024 18:10:50 +0200 Subject: [PATCH 4/8] review --- src/compiler.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler.rs b/src/compiler.rs index 58e0f2fd..5be81f3e 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -1,3 +1,5 @@ +extern crate chrono; +use chrono::prelude::*; use crate::modules::block::Block; use crate::rules; use crate::translate::check_all_blocks; From 5d6af19058ac5e6b64d2ff3adcaf95e9e69904f5 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Jul 2024 18:13:46 +0200 Subject: [PATCH 5/8] fix(cargo): updated --- Cargo.lock | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 156 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index eb4a0867..71508cd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,6 +16,7 @@ name = "amber" version = "0.3.3-alpha" dependencies = [ "assert_cmd", + "chrono", "clap", "colored", "heraclitus-compiler", @@ -25,6 +26,21 @@ dependencies = [ "tempfile", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "0.6.14" @@ -112,18 +128,44 @@ dependencies = [ "serde", ] +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + [[package]] name = "capitalize" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "702cfe2f052c6542d55a9924efef63dd315c168cc4f315a824fb0f47da4e11c8" +[[package]] +name = "cc" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.52.5", +] + [[package]] name = "clap" version = "4.5.4" @@ -180,6 +222,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "difflib" version = "0.4.0" @@ -240,6 +288,29 @@ dependencies = [ "pad", ] +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -255,6 +326,15 @@ dependencies = [ "either", ] +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -273,6 +353,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + [[package]] name = "memchr" version = "2.7.4" @@ -294,6 +380,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + [[package]] name = "pad" version = "0.1.6" @@ -481,6 +573,69 @@ dependencies = [ "libc", ] +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 68ea90d9..9cbe7862 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ colored = "2.0.0" itertools = "0.11.0" clap = { version = "4.4.18", features = ["derive"] } tempfile = "3.10.1" +chrono = "0.4.38" [dev-dependencies] assert_cmd = "2.0.14" From 83952e484d15d11c86a706af8ed2f844ba19a07f Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Jul 2024 18:34:24 +0200 Subject: [PATCH 6/8] fix(chrono): no errors --- src/compiler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler.rs b/src/compiler.rs index 5be81f3e..dc45a10d 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -130,7 +130,7 @@ impl AmberCompiler { let header = [ include_str!("header.sh"), "version:", option_env!("CARGO_PKG_VERSION").unwrap(), - "date:", Local::now().format("%Y-%m-%d %H:%M:%S").to_string() + "date:", Local::now().format("%Y-%m-%d %H:%M:%S").to_string().as_str() ].join(" "); format!("{}\n{}", header, res) } From 4628a944ae66934c5dbc025510e87ce582253ff5 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Mon, 1 Jul 2024 19:09:05 +0200 Subject: [PATCH 7/8] fix(compiler): added bash comment --- src/compiler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler.rs b/src/compiler.rs index dc45a10d..3ffffc18 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -129,7 +129,7 @@ impl AmberCompiler { let res = result.join("\n"); let header = [ include_str!("header.sh"), - "version:", option_env!("CARGO_PKG_VERSION").unwrap(), + "# version:", option_env!("CARGO_PKG_VERSION").unwrap(), "date:", Local::now().format("%Y-%m-%d %H:%M:%S").to_string().as_str() ].join(" "); format!("{}\n{}", header, res) From bc8829dab8bf6ba717ad322d2e41ba257e8589ba Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Wed, 3 Jul 2024 10:58:28 +0200 Subject: [PATCH 8/8] fix(compiler): empty space --- src/compiler.rs | 6 +++--- src/header.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 3ffffc18..7805b265 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -129,9 +129,9 @@ impl AmberCompiler { let res = result.join("\n"); let header = [ include_str!("header.sh"), - "# version:", option_env!("CARGO_PKG_VERSION").unwrap(), - "date:", Local::now().format("%Y-%m-%d %H:%M:%S").to_string().as_str() - ].join(" "); + &("# version: ".to_owned() + option_env!("CARGO_PKG_VERSION").unwrap().to_string().as_str()), + &("# date: ".to_owned() + Local::now().format("%Y-%m-%d %H:%M:%S").to_string().as_str()) + ].join("\n"); format!("{}\n{}", header, res) } diff --git a/src/header.sh b/src/header.sh index 8d4dfb04..2a798551 100644 --- a/src/header.sh +++ b/src/header.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -# Written in [Amber](https://amber-lang.com/) +# Written in [Amber](https://amber-lang.com/) \ No newline at end of file