-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix: Chop git suffix from LibLLVM::VERSION
#13699
Conversation
src/llvm/lib_llvm.cr
Outdated
@@ -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/,"")}} |
There was a problem hiding this comment.
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.
src/llvm/lib_llvm.cr
Outdated
@@ -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/,"")}} |
There was a problem hiding this comment.
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:
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub(/git/,"")}} | |
VERSION = {{ `#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub(/git$/, "") }} |
There was a problem hiding this comment.
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:
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub(/git/,"")}} | |
VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify.gsub("git","")}} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 🙇
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
This still needs formatting |
ah good catch |
LibLLVM::VERSION
Co-authored-by: Johannes Müller <straightshoota@gmail.com>
No description provided.