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

make --version printing compatible with juliac #103

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 19 additions & 0 deletions src/juliac.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@
end
end

# juliac-compatible print(::IO, ::VersionNumber) with explicitly `@inline`d `join` calls...
function print_vnum_juliac(io::IO, v::VersionNumber)
v == typemax(VersionNumber) && return print(io, "∞")
print(io, v.major)
print(io, '.')
print(io, v.minor)
print(io, '.')
print(io, v.patch)
if !isempty(v.prerelease)
print(io, '-')
@inline join(io, v.prerelease, '.')

Check warning on line 83 in src/juliac.jl

View check run for this annotation

Codecov / codecov/patch

src/juliac.jl#L74-L83

Added lines #L74 - L83 were not covered by tests
end
if !isempty(v.build)
print(io, '+')
@inline join(io, v.build, '.')

Check warning on line 87 in src/juliac.jl

View check run for this annotation

Codecov / codecov/patch

src/juliac.jl#L85-L87

Added lines #L85 - L87 were not covered by tests
end
return

Check warning on line 89 in src/juliac.jl

View check run for this annotation

Codecov / codecov/patch

src/juliac.jl#L89

Added line #L89 was not covered by tests
end

# juliac-compatible `Base.tempdir` and `Base.mktempdir` without logging and deferred cleanup
function tempdir_juliac()
buf = Base.StringVector(Base.Filesystem.AVG_PATH - 1)
Expand Down
8 changes: 7 additions & 1 deletion src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const juliac = @load_preference("juliac", false)
const printstyled = printstyled_juliac
const mktempdir = mktempdir_juliac
const sprint_showerror = sprint_showerror_juliac
const print_vnum = print_vnum_juliac
else
# const stdin = Base.stdin
# const stdout = Base.stdout
Expand All @@ -24,6 +25,7 @@ else
const printstyled = Base.printstyled
const mktempdir = Base.mktempdir
sprint_showerror(err::Exception) = sprint(showerror, err)
const print_vnum = Base.print
end

supports_color(io) = get(io, :color, false)
Expand Down Expand Up @@ -149,7 +151,11 @@ function print_help()
end

function print_version()
println(stdout, "runic version $(RUNIC_VERSION), julia version $(VERSION)")
print(stdout, "runic version ")
print_vnum(stdout, RUNIC_VERSION)
print(stdout, ", julia version ")
print_vnum(stdout, VERSION)
println(stdout)
return
end

Expand Down