Skip to content

Commit

Permalink
make --version printing compatible with juliac (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored Nov 19, 2024
1 parent ad205bc commit 829dc34
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
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 @@ function sprint_showerror_juliac(err::Exception)
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, '.')
end
if !isempty(v.build)
print(io, '+')
@inline join(io, v.build, '.')
end
return
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

0 comments on commit 829dc34

Please sign in to comment.