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

Fix: Chop git suffix from LibLLVM::VERSION #13699

Merged
merged 2 commits into from
Aug 17, 2023

Conversation

HOMODELUNA
Copy link
Contributor

No description provided.

@@ -10,7 +10,7 @@ end
{% end %}
@[Link(ldflags: {{"`#{LibLLVM::LLVM_CONFIG} --libs --system-libs --ldflags#{" --link-static".id if flag?(:static)}#{" 2> /dev/null".id unless flag?(:win32)}`"}})]
lib LibLLVM
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify}}
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub(/git/,"")}}
Copy link
Member

Choose a reason for hiding this comment

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

For future reviewers: Note there is no equivalent to String#rchop for StringLiteral which might've been nice for this.

@@ -10,7 +10,7 @@ end
{% end %}
@[Link(ldflags: {{"`#{LibLLVM::LLVM_CONFIG} --libs --system-libs --ldflags#{" --link-static".id if flag?(:static)}#{" 2> /dev/null".id unless flag?(:win32)}`"}})]
lib LibLLVM
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify}}
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub(/git/,"")}}
Copy link
Contributor

@Sija Sija Jul 24, 2023

Choose a reason for hiding this comment

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

Could be tweaked a bit:

Suggested change
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub(/git/,"")}}
VERSION = {{ `#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub(/git$/, "") }}

Copy link
Member

@straight-shoota straight-shoota Jul 24, 2023

Choose a reason for hiding this comment

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

Hm, actually there's no need for a regex:

Suggested change
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub(/git/,"")}}
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub("git","")}}

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no StringLiteral#sub, either

Copy link
Contributor

@Sija Sija Jul 24, 2023

Choose a reason for hiding this comment

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

@straight-shoota There is, if you want to remove the git from the end of the string only.

Copy link
Member

Choose a reason for hiding this comment

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

@HOMODELUNA WDYT of making it work with the string instead of the redex as proposed by @straight-shoota?

Copy link
Contributor

Choose a reason for hiding this comment

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

That wouldn't work either, the macro StringLiteral#gsub requires a RegexLiteral first argument

Copy link
Contributor

Choose a reason for hiding this comment

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

And of course, moving the .gsub or .sub outside {{ ... }} isn't an option as LibLLVM::VERSION's initializer must be a literal

Copy link
Member

Choose a reason for hiding this comment

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

Okay, so we leave everything as it is. Sorry for all the confusion 🙇

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO $ should be added, still.

Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

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

Let's add it as is, and if at some point we see the need to restrict further the regex (i.e., to be at the end as suggested by Sija), we do it then.

@beta-ziliani beta-ziliani added this to the 1.10.0 milestone Jul 26, 2023
@HertzDevil
Copy link
Contributor

This still needs formatting

@beta-ziliani beta-ziliani removed this from the 1.10.0 milestone Jul 26, 2023
@beta-ziliani
Copy link
Member

ah good catch

@straight-shoota straight-shoota added this to the 1.10.0 milestone Aug 16, 2023
@straight-shoota straight-shoota changed the title trim git suffix for LibLLVM::VERSION Fix: Chop git suffix from LibLLVM::VERSION Aug 17, 2023
@straight-shoota straight-shoota merged commit 996f0eb into crystal-lang:master Aug 17, 2023
52 of 53 checks passed
Blacksmoke16 pushed a commit to Blacksmoke16/crystal that referenced this pull request Dec 11, 2023
Co-authored-by: Johannes Müller <straightshoota@gmail.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants