Skip to content

Commit

Permalink
Overhaul of version.jl, removal of COMMIT file, now stores all COMMIT…
Browse files Browse the repository at this point in the history
…-related information in base/build_h.jl, completely available to julia programs

Changes the contents of `VERSION` to 0.2.0, from 0.2
  • Loading branch information
staticfloat committed Jul 25, 2013
1 parent 2000ea0 commit 45bfe19
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 107 deletions.
11 changes: 2 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,8 @@ $(BUILD)/share/man/man1/julia.1: doc/man/julia.1 | $(BUILD)/share/julia
@mkdir -p $(BUILD)/share/man/man1
@cp $< $@

COMMIT:
@#this is a .PHONY target so that it will always run
echo `git rev-parse --short HEAD`-$(OS)-$(ARCH) \(`date +"%Y-%m-%d %H:%M:%S"`\) > COMMIT

# use sys.ji if it exists, otherwise run two stages
$(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.ji: VERSION base/*.jl base/pkg/*.jl base/linalg/*.jl base/sparse/*.jl $(BUILD)/share/julia/helpdb.jl $(BUILD)/share/man/man1/julia.1
@$(MAKE) $(QUIET_MAKE) COMMIT
$(QUIET_JULIA) cd base && \
(test -f $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys.ji || $(call spawn,$(JULIA_EXECUTABLE)) -bf sysimg.jl) && $(call spawn,$(JULIA_EXECUTABLE)) -f sysimg.jl || echo "*** This error is usually fixed by running 'make clean'. If the error persists, try 'make cleanall'. ***"

Expand Down Expand Up @@ -99,9 +94,7 @@ endif
ifeq ($(OS), WINNT)
cp $(JULIAHOME)/contrib/windows/*.bat $(PREFIX)
endif
cp $(JULIAHOME)/VERSION $(PREFIX)/share/julia/VERSION
$(MAKE) $(QUIET_MAKE) COMMIT
cp $(JULIAHOME)/COMMIT $(PREFIX)/share/julia/COMMIT


dist:
rm -fr julia-*.tar.gz julia-*.exe julia-$(JULIA_COMMIT)
Expand Down Expand Up @@ -174,7 +167,7 @@ distclean: cleanall
.PHONY: default debug release julia-debug julia-release \
test testall test-* clean distclean cleanall \
run-julia run-julia-debug run-julia-release run \
COMMIT install dist
install dist

test: release
@$(MAKE) $(QUIET_MAKE) -C test default
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2
0.2.0
61 changes: 59 additions & 2 deletions base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,30 @@ include ../Make.inc

PCRE_CONST = 0x[0-9a-fA-F]+|[-+]?\s*[0-9]+

all: pcre_h.jl errno_h.jl build_h.jl file_constants.jl uv_constants.jl
# These are all the values needed for the RawVersionInfo struct
version_string = $(shell cat ../VERSION)
commit = $(shell git rev-parse HEAD 2>/dev/null)
commit_short = $(shell git rev-parse --short HEAD 2>/dev/null)
build_number = $(shell echo $$(git describe --tags --long 2>/dev/null) | awk -F- '{print $$(NF-1);}')
git_tag = $(shell git describe --tags --abbrev=0 2>/dev/null)
prerelease = $(shell [ -z "$(git_tag)" -o "$(git_tag)" = "v$(version_string)" ] && echo false || echo true)

git_branch = $(shell git branch 2>/dev/null | sed -n '/\* /s///p')
git_time = $(shell git log -1 --pretty=format:%ct 2>/dev/null)
ifneq ($(git_time), )
ifeq ($(OS), Darwin)
date_string = "$(shell date -jr $(git_time) -u '+%Y-%m-%d %H:%M:%S %Z')"

This comment has been minimized.

Copy link
@StefanKarpinski

StefanKarpinski Jul 27, 2013

Member

I hate to be that guy, but this is problematic because I use GNU date on OS X :-\

This comment has been minimized.

Copy link
@staticfloat

staticfloat via email Jul 27, 2013

Author Member

This comment has been minimized.

Copy link
@StefanKarpinski

StefanKarpinski Jul 27, 2013

Member

The only thing to do seems to be to try the GNU version and if it fails, on Darwin fall back on the system version. Or you could hardcode the full path /bin/date on OS X. That seems unlikely to change and avoids probably-common situation where someone has overlaid GNU coreutils via brew or MacPorts.

This comment has been minimized.

Copy link
@staticfloat

staticfloat Jul 28, 2013

Author Member

I like your second idea best. 25e53a9

else
date_string = "$(shell date --date=@$(git_time) -u '+%Y-%m-%d %H:%M:%S %Z')"
endif
else
date_string = ""
endif
dirty = $(shell [ -z "$(shell git status --porcelain 2>/dev/null)" ] && echo "false" || echo "true" )



all: pcre_h.jl errno_h.jl build_h.jl.phony file_constants.jl uv_constants.jl

pcre_h.jl:
$(QUIET_PERL) $(CPP) -dM $(shell $(PCRE_CONFIG) --prefix)/include/pcre.h | perl -nle '/^\s*#define\s+PCRE_(\w*)\s*\(?($(PCRE_CONST))\)?\s*$$/ and print "const $$1 = uint32($$2)"' | sort > $@
Expand All @@ -17,7 +40,7 @@ file_constants.jl: ../src/file_constants.h
uv_constants.jl: ../src/uv_constants.h
$(QUIET_PERL) ${CC} -E -P "-I$(LIBUV_INC)" -DJULIA ../src/uv_constants.h | tail -n 12 > $@

build_h.jl: ../Make.inc build.h Makefile
build_h.jl.phony:

This comment has been minimized.

Copy link
@StefanKarpinski

StefanKarpinski Jul 30, 2013

Member

What's up with this? This is now getting built every single time I run make.

This comment has been minimized.

Copy link
@staticfloat

staticfloat Jul 30, 2013

Author Member

Yes, this has to happen to see if the git commit has changed, etc... What should not be happening is that it prints out the PERL line. I had some discussion about changing the definition of $(QUIET_PERL) in the makefiles, I'll fix this up soon.

$(QUIET_PERL) $(CC) -E -P build.h -I../src/support | grep . > $@
@echo "const ARCH = :$(ARCH)" >> $@
ifeq ($(OS),$(BUILD_OS))
Expand All @@ -34,6 +57,40 @@ else
@echo "const USE_BLAS64 = false" >> $@
endif

@echo "immutable BuildInfo" >> $@
@echo " version_string::ASCIIString" >> $@
@echo " commit::ASCIIString" >> $@
@echo " commit_short::ASCIIString" >> $@
@echo " branch::ASCIIString" >> $@
@echo " build_number::Int" >> $@
@echo " date_string::ASCIIString" >> $@
@echo " dirty::Bool" >> $@
@echo " prerelease::Bool" >> $@
@echo "end" >> $@


@echo "const BUILD_INFO = BuildInfo( \
'\"$(version_string)\"', \
'\"$(commit)\"', \
'\"$(commit_short)\"', \
'\"$(git_branch)\"', \
$(build_number), \
'\"$(date_string)\"', \
$(dirty), \
$(prerelease) \
)" | xargs >> $@

@# This to ensure that we always rebuild this file, but only when it is modified do we touch build_h.jl,
@# ensuring we rebuild the system image as infrequently as possible
@if ! cmp -s build_h.jl $@; then \
mv $@ build_h.jl; \
else \
rm -f $@; \
fi

.PHONY: build_h.jl.phony



clean:
rm -f *# *~
Expand Down
2 changes: 1 addition & 1 deletion base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ end

include("base.jl")
include("reflection.jl")
include("promotion.jl") # We need promote_type() before we can use composite types
include("build_h.jl")
include("c.jl")

Expand All @@ -54,7 +55,6 @@ include("expr.jl")
include("error.jl")

# core numeric operations & types
include("promotion.jl")
include("bool.jl")
include("number.jl")
include("int.jl")
Expand Down
2 changes: 1 addition & 1 deletion base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ end
# system information

function versioninfo(io::IO=STDOUT, verbose::Bool=false)
println(io, "Julia $version_string")
println(io, "Julia Version $VERSION")
println(io, commit_string)
println(io, "Platform Info:")
println(io, " System: ", Sys.OS_NAME, " (", Sys.MACHINE, ")")
Expand Down
104 changes: 11 additions & 93 deletions base/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,106 +149,24 @@ hash(v::VersionNumber) = hash([v.(n) for n in VersionNumber.names])

## julia version info

let
local version::VersionNumber
if isfile("$JULIA_HOME/../../VERSION")
version = readchomp("$JULIA_HOME/../../VERSION")
elseif isfile("$JULIA_HOME/../share/julia/VERSION")
version = readchomp("$JULIA_HOME/../share/julia/VERSION")
else
println("ERROR: VERSION file not found")
error()
end

expected = ErrorException("don't copy this code, it's for breaking out of uv_run during boot-strapping only")
acceptable = ErrorException("failure: unknown exception!")

outctim,ps = readsfrom(`git log -1 --pretty=format:%ct`)
ps.closecb = function(proc)
if proc.exit_code!=0
acceptable.msg = string("failed process: ",proc," [",proc.exit_code,"]")
error(acceptable)
end

ctim = int(readall(proc.out.buffer))

outdesc,ps = readsfrom(`git describe --tags --dirty --long --abbrev=40`)
ps.closecb = function(proc)
if proc.exit_code!=0
acceptable.msg = string("failed process: ",proc," [",proc.exit_code,"]")
error(acceptable)
end

description = readchomp(proc.out.buffer)
m = match(r"^(v\d+(?:\.\d+)+)-(\d+)-g([0-9a-f]{40})(-dirty)?$", description)
if m == nothing
error(acceptable)
end
tag = convert(VersionNumber, m.captures[1])
commits_after_tag = int(m.captures[2])
commit = m.captures[3]
dirty = m.captures[4] != nothing

commit_short = commit[1:9]

if commits_after_tag > 0
field = tag < version ? version.prerelease : version.build
field = tuple(field..., commits_after_tag, "r$commit_short")
if dirty
field = tuple(field..., "dirty")
end
tag = VersionNumber(
version.major,
version.minor,
version.patch,
tag < version ? field : version.prerelease,
tag < version ? version.build : field,
)
end
isotime = strftime("%Y-%m-%d %H:%M:%S", ctim)
global const commit_string = "Commit $commit_short $isotime" * (dirty ? "*" : "")

global const VERSION = tag
global const VERSION_COMMIT = commit
error(expected)
end
end
try
run_event_loop() # equivalent to wait_exit() on a more sane version of the previous
# block of code, but Scheduler doesn't exist during bootstrapping
# so we do what we must, but don't do this in user-land code or you'll regret it
catch err
if err != expected
if isfile("$JULIA_HOME/../../COMMIT")
global const commit_string = readchomp("$JULIA_HOME/../../COMMIT")
elseif isfile("$JULIA_HOME/../share/julia/COMMIT")
global const commit_string = readchomp("$JULIA_HOME/../share/julia/COMMIT")
else
global const commit_string = ""
end
global const VERSION = version
global const VERSION_COMMIT = ""
if err == acceptable
println("Warning: git failed in version.jl")
println(' ',' ',err.msg)
println()
else
rethrow(err)
end
end
end
end
begin
const version_string = "Version $VERSION"
# Include build number if we've got at least some distance from a tag (e.g. a release)
prerelease = BUILD_INFO.prerelease ? "-prerelease" : ""
build_number = BUILD_INFO.build_number != 0 ? "+$(BUILD_INFO.build_number)" : ""
global const VERSION = convert( VersionNumber, "$(BUILD_INFO.version_string)$(prerelease)$(build_number)")
branch_prefix = (BUILD_INFO.branch == "master") ? "" : "$(BUILD_INFO.branch)/"
dirty_suffix = BUILD_INFO.dirty ? "*" : ""
global const commit_string = (BUILD_INFO.commit == "") ? "" : "Commit $(branch_prefix)$(BUILD_INFO.commit_short)$(dirty_suffix) $(BUILD_INFO.date_string)"

const banner_plain =
"""
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http:https://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | $version_string
_/ |\\__'_|_|_|\\__'_| | $commit_string
| | |_| | | | (_| | | Version $VERSION
_/ |\\__'_|_|_|\\__'_| | "$commit_string"
|__/ | $(Sys.MACHINE)
"""
Expand All @@ -264,7 +182,7 @@ const banner_color =
$(d1)(_)$(jl) | $(d2)(_)$(tx) $(d4)(_)$(tx) | Documentation: http:https://docs.julialang.org
$(jl)_ _ _| |_ __ _$(tx) | Type \"help()\" to list help topics
$(jl)| | | | | | |/ _` |$(tx) |
$(jl)| | |_| | | | (_| |$(tx) | $version_string
$(jl)| | |_| | | | (_| |$(tx) | Version $VERSION
$(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | $commit_string
$(jl)|__/$(tx) | $(Sys.MACHINE)
Expand Down

0 comments on commit 45bfe19

Please sign in to comment.