Skip to content

Commit

Permalink
Include git sha in prompt if available
Browse files Browse the repository at this point in the history
The sha will only be included if there is no tag
starting with OTP_R* associated with the sha. This
is because we do not want the sha to show on offical
releases.
  • Loading branch information
garazdawi committed Feb 13, 2013
1 parent 68b804f commit 3e95d5f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
10 changes: 9 additions & 1 deletion erts/emulator/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
include $(ERL_TOP)/make/target.mk
include ../vsn.mk
include $(ERL_TOP)/make/$(TARGET)/otp.mk
include $(TARGET)/gen_git_version.mk


ENABLE_ALLOC_TYPE_VARS = @ENABLE_ALLOC_TYPE_VARS@
HIPE_ENABLED=@HIPE_ENABLED@
Expand Down Expand Up @@ -196,7 +198,7 @@ else
EMU_CC = @EMU_CC@
endif
WFLAGS = @WFLAGS@
CFLAGS = @STATIC_CFLAGS@ $(TYPE_FLAGS) $(FLAVOR_FLAGS) $(DEFS) $(WFLAGS) $(THR_DEFS) $(ARCHCFLAGS)
CFLAGS = @STATIC_CFLAGS@ $(TYPE_FLAGS) $(FLAVOR_FLAGS) $(DEFS) $(WFLAGS) $(THR_DEFS) $(ARCHCFLAGS) $(GIT_VSN)
HCC = @HCC@
LD = @LD@
DEXPORT = @DEXPORT@
Expand Down Expand Up @@ -1006,6 +1008,12 @@ DEP_FLAGS=-MM $(MG_FLAG) $(CFLAGS) $(INCLUDES) -Idrivers/common -Idrivers/$(ERLA
SYS_SRC=$(ALL_SYS_SRC)
endif

.PHONY: $(TARGET)/gen_git_version.mk
$(TARGET)/gen_git_version.mk:
# We touch beam/erl_bif.info.c if we regenerated the git version to force a
# rebuild.
if $(gen_verbose)utils/gen_git_version $@; then touch beam/erl_bif_info.c; fi

.PHONY: depend
ifdef VOID_EMULATOR
depend:
Expand Down
4 changes: 4 additions & 0 deletions erts/emulator/beam/erl_bif_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ static char erts_system_version[] = ("Erlang " ERLANG_OTP_RELEASE
" [no-c-stack-objects]"
#endif
#ifndef OTP_RELEASE
#ifdef ERLANG_GIT_VERSION
" [source-" ERLANG_GIT_VERSION "]"
#else
" [source]"
#endif
#endif
#ifdef ARCH_64
#if HALFWORD_HEAP
Expand Down
40 changes: 40 additions & 0 deletions erts/emulator/utils/gen_git_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

OUTPUT_FILE=$1

if command -v git 2>&1 >/dev/null &&
test -d $ERL_TOP/.git -o -f $ERL_TOP/.git
then
VSN=`git describe --match "OTP_R[0-9][0-9][A-B]*" HEAD`
case "$VSN" in
OTP_R*-g*)
VSN=`echo $VSN | sed -e 's/.*-g\\(.*\\)/\\1/g'` ;;
*) VSN="na" ;;
esac
else
VSN="na"
fi


# Only update the file if there has been a change to
# the version number.
if test -r $OUTPUT_FILE
then
VC=`sed -n -e 's/^.*"\\\\"\\(.*\\)\\\\"".*/\\1/p' < $OUTPUT_FILE`
else
VC=unset
fi
echo "VSN = $VSN"
echo "VC = $VC"
if test "$VSN" != "$VC"
then
echo "# Automatically generated by $0 - DO NOT EDIT." > $OUTPUT_FILE
if test "$VSN" = "na"
then
echo "# GIT_VSN=-DERLANG_GIT_VERSION=\"\\\"$VSN\\\"\"" >> $OUTPUT_FILE
else
echo "GIT_VSN=-DERLANG_GIT_VERSION=\"\\\"$VSN\\\"\"" >> $OUTPUT_FILE
fi
exit 0
fi
exit 1

0 comments on commit 3e95d5f

Please sign in to comment.