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

Add message about non-release mode to crystal --version #13254

Merged
merged 5 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ override FLAGS += -D strict_multi_assign -D preview_overload_order $(if $(releas
SPEC_WARNINGS_OFF := --exclude-warnings spec/std --exclude-warnings spec/compiler --exclude-warnings spec/primitives
SPEC_FLAGS := $(if $(verbose),-v )$(if $(junit_output),--junit_output $(junit_output) )$(if $(order),--order=$(order) )
CRYSTAL_CONFIG_LIBRARY_PATH := '$$ORIGIN/../lib/crystal'
CRYSTAL_CONFIG_BUILD_COMMIT := $(shell git rev-parse --short HEAD 2> /dev/null)
CRYSTAL_CONFIG_BUILD_COMMIT ?= $(shell git rev-parse --short HEAD 2> /dev/null)
CRYSTAL_CONFIG_PATH := '$$ORIGIN/../share/crystal/src'
SOURCE_DATE_EPOCH := $(shell (git show -s --format=%ct HEAD || stat -c "%Y" Makefile || stat -f "%m" Makefile) 2> /dev/null)
SOURCE_DATE_EPOCH ?= $(shell (git show -s --format=%ct HEAD || stat -c "%Y" Makefile || stat -f "%m" Makefile) 2> /dev/null)
ifeq ($(shell command -v ld.lld >/dev/null && uname -s),Linux)
EXPORT_CC ?= CC="$(CC) -fuse-ld=lld"
endif
Expand Down
15 changes: 12 additions & 3 deletions src/compiler/crystal/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ module Crystal
end

def self.description
formatted_sha = "[#{build_commit}] " if build_commit
details = [version]
details << "[#{build_commit}]" if build_commit
details << "(#{date})" unless date.empty?
Copy link
Member

Choose a reason for hiding this comment

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

Using an array + join is fine, we can merge it with that. But it's suboptimal.
A better way would be what we had before, just with leading whitespace added to each optional piece. Or String.build could also be an alternative.
This is an optional suggestion, my approval doesn't depend on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated this with String.build just now


development_msg = "\n\nThe compiler was not built in release mode." unless release_mode?

<<-DOC
Crystal #{version} #{formatted_sha}(#{date})
Crystal #{details.join(" ")}

LLVM: #{llvm_version}
Default target: #{self.host_target}
Default target: #{self.host_target}#{development_msg}
DOC
end

Expand All @@ -40,6 +45,10 @@ module Crystal
end
end

def self.release_mode?
{{ flag?(:release) }}
end

@@host_target : Crystal::Codegen::Target?

def self.host_target : Crystal::Codegen::Target
Expand Down