Skip to content

Commit

Permalink
Enhance build version with Git information.
Browse files Browse the repository at this point in the history
  • Loading branch information
hungte committed Nov 5, 2014
1 parent 5809b04 commit 6c91553
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,5 +9,6 @@ var.h
/local.h
common/sys/big5.c
mbbsd/mbbsd
mbbsd/testmbbsd
mbbsd/testsz
mbbsd/vers.c
31 changes: 17 additions & 14 deletions mbbsd/cal.c
Expand Up @@ -516,12 +516,17 @@ give_money_ui(const char *userid)
return 0;
}

// in vers.c
extern const char *build_remote;
extern const char *build_origin;
extern const char *build_hash;
extern const char *build_time;

int
p_sysinfo(void)
{
const char *cpuloadstr;
int load;
extern char *compile_time;
#ifdef DETECT_CLIENT
extern Fnv32_t client_code;
#endif
Expand All @@ -538,13 +543,13 @@ p_sysinfo(void)
showtitle("系統資訊", BBSNAME);
move(2, 0);
prints("您現在位於 " TITLE_COLOR BBSNAME ANSI_RESET " (" MYIP ")\n"
"系統負載情況: %s\n"
"線上服務人數: %d/%d\n"
"系統負載: %s\n"
"線上人數: %d/%d\n"
#ifdef DETECT_CLIENT
"client code: %8.8X\n"
"ClientCode: %8.8X\n"
#endif
"編譯時間: %s\n"
"起始時間: %s\n",
"起始時間: %s\n"
"編譯時間: %s\n",
cpuloadstr, SHM->UTMPnumber,
#ifdef DYMAX_ACTIVE
// XXX check the related logic in mbbsd.c
Expand All @@ -556,25 +561,23 @@ p_sysinfo(void)
#ifdef DETECT_CLIENT
client_code,
#endif
compile_time, Cdatelite(&start_time));
Cdatelite(&start_time),
build_time);
if (*build_remote) {
prints("編譯版本: %s %s %s\n", build_remote, build_origin, build_hash);
}

#ifdef REPORT_PIAIP_MODULES
outs("\n" ANSI_COLOR(1;30)
"Modules powered by piaip:\n"
"\ttelnet/vkbd protocol, vtuikit, ALOHA fixer, BRC v3\n"
"\ttelnet/vkbd protocol, vtuikit, BRC v3, ...\n"
"\tpiaip's Common Chat Window (CCW)\n"
#if defined(USE_PIAIP_MORE) || defined(USE_PMORE)
"\tpmore (piaip's more) 2007 w/Movie\n"
#endif
#ifdef HAVE_GRAYOUT
"\tGrayout Advanced Control 淡入淡出特效系統\n"
#endif
#ifdef EDITPOST_SMARTMERGE
"\tSmart Merge 修文自動合併\n"
#endif
#ifdef EXP_EDIT_UPLOAD
"\t(EXP) Editor Uploader 長文上傳\n"
#endif
#if defined(USE_PFTERM)
"\t(EXP) pfterm (piaip's flat terminal, Perfect Term)\n"
#endif
Expand Down
31 changes: 12 additions & 19 deletions util/newvers.sh
Expand Up @@ -4,25 +4,18 @@
LC_ALL=C
export LC_ALL

t=`date`

# are we working in CVS?
if [ -d ".svn" ] ; then

#determine branch
branch=`svn info | grep '^URL: ' | sed 's/.*\/pttbbs\/\([a-zA-Z0-9_\-\.]*\)\/pttbbs\/.*/\1/'`
branch="$branch "

#determine rev
rev=`svn info | grep Revision | sed 's/Revision: /r/'`

if [ "$rev" != "" ]
then
t="$t, $branch$rev"
fi

build_remote="$(git config --get remote.origin.url 2>/dev/null)"
build_origin="$(git rev-parse --short origin/master 2>/dev/null)"
build_hash="$(git rev-parse --short HEAD 2>/dev/null)"
[ "${build_hash}" = "${build_origin}" ] && build_origin=""
if ! git diff --quiet 2>/dev/null; then
build_hash="${build_hash} M"
fi
build_time="$(date)"

cat << EOF > vers.c
const char * const compile_time = "${t}";
cat >vers.c <<EOF
const char *build_remote = "${build_remote}";
const char *build_origin = "${build_origin}";
const char *build_hash = "${build_hash}";
const char *build_time = "${build_time}";
EOF

0 comments on commit 6c91553

Please sign in to comment.