Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compile): add Amber version, fix #181 #245

Merged
merged 9 commits into from
Jul 3, 2024
Merged

Conversation

Mte90
Copy link
Member

@Mte90 Mte90 commented Jun 26, 2024

Fix #181

@Mte90 Mte90 added the enhancement New feature or request label Jun 26, 2024
@Mte90 Mte90 requested review from Ph0enixKM and b1ek June 26, 2024 14:54
@b1ek
Copy link
Member

b1ek commented Jun 27, 2024

what if we add some more info to it? like date of compilation, source hash, author/license label, etc..

but that would also mean that primive approach won't do and we would have to use a templating engine. i would suggest tinytemplate, which only dependency is serde which im pretty sure clap already depends on

@Mte90
Copy link
Member Author

Mte90 commented Jun 27, 2024

I think that the date is a good idea but about the rest is too much for what the project is right now.

src/compiler.rs Outdated Show resolved Hide resolved
src/header.sh Outdated Show resolved Hide resolved
Mte90 and others added 2 commits July 1, 2024 14:35
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>
@Mte90 Mte90 requested a review from Ph0enixKM July 1, 2024 12:35
Copy link
Collaborator

@Ph0enixKM Ph0enixKM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build now fails because it requires Local from chrono library. Please add the library to dependencies in Cargo.toml (Try cargo add chrono) and import it in the top of the file with:

extern crate chrono;
use chrono::prelude::*;

@Mte90

This comment was marked as outdated.

@Mte90
Copy link
Member Author

Mte90 commented Jul 1, 2024

I don't know how to fix the cargo.lock conflict, suggestions?

@Mte90 Mte90 requested a review from Ph0enixKM July 1, 2024 16:48
@Ph0enixKM
Copy link
Collaborator

I'll handle this. For now I think we can accept the incoming changes and recompile the code. You could also remove the lock temporarily and see if recompilation will work with the newly created one. Not sure if this is the right way to resolve Cargo.lock conflicts but this has worked for me ever since

@Mte90
Copy link
Member Author

Mte90 commented Jul 1, 2024

Locally everything works on building (already tried).

@Ph0enixKM
Copy link
Collaborator

I know. It's that when you pull the master then you get the conflict

@Ph0enixKM
Copy link
Collaborator

Resolved conflicts

@Ph0enixKM
Copy link
Collaborator

@Mte90 at some point when running tests there is this error:

Screenshot 2024-07-01 at 19 05 24

Can you check what produces it?

@Mte90
Copy link
Member Author

Mte90 commented Jul 1, 2024

generate a sh code like this:

#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
 version: 0.3.3-alpha date: 2024-07-01 19:08:09
echo 1

@Mte90
Copy link
Member Author

Mte90 commented Jul 1, 2024

Now add a comment

@Ph0enixKM
Copy link
Collaborator

@b1ek can you take a look?

@Mte90
Copy link
Member Author

Mte90 commented Jul 2, 2024

I can confirm that now works:

#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
 # version: 0.3.3-alpha date: 2024-07-02 10:13:14
echo 1

@Mte90
Copy link
Member Author

Mte90 commented Jul 3, 2024

The output now:

#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
# version: 0.3.3-alpha
# date: 2024-07-03 10:58:09
echo 1

@Mte90 Mte90 requested review from Ph0enixKM and b1ek July 3, 2024 08:59
src/compiler.rs Outdated
Comment on lines 131 to 132
include_str!("header.sh"),
"# version:", option_env!("CARGO_PKG_VERSION").unwrap(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mte90 sorry for nitpicking, but can we remove that first space on the line with # version?

Suggested change
include_str!("header.sh"),
"# version:", option_env!("CARGO_PKG_VERSION").unwrap(),
include_str!("header.sh").trim_end(),
"\n# version:", option_env!("CARGO_PKG_VERSION").unwrap(),

@Ph0enixKM Ph0enixKM merged commit d158dbf into amber-lang:master Jul 3, 2024
1 check passed
Mte90 added a commit to Mte90/Amber that referenced this pull request Jul 3, 2024
* feat(compile): add Amber version, fix amber-lang#181

* Update src/compiler.rs

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* Update src/header.sh

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* review

* fix(cargo): updated

* fix(chrono): no errors

* fix(compiler): added bash comment

* fix(compiler): empty space

---------

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Show the amber version used to compile the bash script in the top comment
3 participants