tools: acrn-crashlog: version control patch for binaries

This patch is the version control patch for the binaries
of acrn-crashlog.

Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
This commit is contained in:
CHEN Gang 2018-05-16 06:47:04 +00:00 committed by lijinxia
parent 047ffc3f92
commit d4b4c03cde
7 changed files with 65 additions and 7 deletions

View File

@ -1,3 +1,6 @@
MAJOR_VERSION=1
MINOR_VERSION=0
BASEDIR := $(shell pwd)
LIBS = -lpthread -lxml2 -lcrypto -lrt -lsystemd -ltelemetry
@ -10,7 +13,7 @@ LDFLAGS += $(LIBS) -Wl,--gc-sections
TARGET = $(BUILDDIR)/acrnprobe/bin/acrnprobe
all: check_dirs $(TARGET)
all: include/version.h check_dirs $(TARGET)
$(BUILDDIR)/acrnprobe/obj/%.o:%.c
$(CC) -c $(CFLAGS) $< -o $@
@ -35,6 +38,9 @@ $(BUILDDIR)/acrnprobe/bin/acrnprobe: $(BUILDDIR)/acrnprobe/obj/main.o \
clean:
@echo "Clean objects and binaries"
@if [ -e include/version.h ]; then \
$(RM) -f include/version.h; \
fi
@if [ -d $(BUILDDIR)/acrnprobe/obj ]; then \
find $(BUILDDIR)/acrnprobe/obj -name "*.o" -exec $(RM) {} \; 2>&1 || exit 0; \
fi
@ -45,6 +51,19 @@ clean:
$(RM) -r $(BUILDDIR)/acrnprobe/obj ; \
fi
include/version.h:
touch include/version.h
@COMMIT=`git log -1 --pretty=format:%h . 2>/dev/null`;\
DIRTY=`git diff --name-only $(BASEDIR)`;\
if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\
TIME=`date "+%Y-%m-%d %H:%M:%S"`;\
cat $(BASEDIR)/../license_header > include/version.h;\
echo "#define AP_MAJOR_VERSION $(MAJOR_VERSION)" >> include/version.h;\
echo "#define AP_MINOR_VERSION $(MINOR_VERSION)" >> include/version.h;\
echo "#define AP_BUILD_VERSION "\""$$PATCH"\""" >> include/version.h;\
echo "#define AP_BUILD_TIME "\""$$TIME"\""" >> include/version.h;\
echo "#define AP_BUILD_USER "\""$(USER)"\""" >> include/version.h
check_dirs:
@if [ ! -d $(BUILDDIR)/acrnprobe/bin ]; then \
mkdir -p $(BUILDDIR)/acrnprobe/bin ; \

View File

@ -20,10 +20,10 @@
#include "event_handler.h"
#include "channels.h"
#include "log_sys.h"
#include "version.h"
#define CONFIG_INSTALL "/usr/share/defaults/telemetrics/acrnprobe.xml"
#define CONFIG_CUSTOMIZE "/etc/acrnprobe.xml"
#define VERSION "1.0"
void usage(void)
{
@ -79,7 +79,10 @@ int main(int argc, char *argv[])
usage();
return 0;
case 'V':
printf(VERSION "\n");
printf("version is %d.%d-%s, build by %s@%s\n",
AP_MAJOR_VERSION, AP_MINOR_VERSION,
AP_BUILD_VERSION, AP_BUILD_USER,
AP_BUILD_TIME);
return 0;
case '?':
usage();

View File

@ -0,0 +1,5 @@
/*
* Copyright (C) <2018> Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/

View File

@ -1,4 +1,7 @@
all: check_obj usercrash_s usercrash_c debugger
MAJOR_VERSION=1
MINOR_VERSION=0
all: include/version.h check_obj usercrash_s usercrash_c debugger
CURRDIR := $(shell pwd)
INCLUDE += -I $(CURRDIR)/include/
@ -30,6 +33,19 @@ debugger: $(BUILDDIR)/usercrash/obj/debugger.o \
$(BUILDDIR)/usercrash/obj/%.o:%.c
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
include/version.h:
touch include/version.h
@COMMIT=`git log -1 --pretty=format:%h . 2>/dev/null`;\
DIRTY=`git diff --name-only $(CURRDIR)`;\
if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\
TIME=`date "+%Y-%m-%d %H:%M:%S"`;\
cat $(CURRDIR)/../license_header > include/version.h;\
echo "#define UC_MAJOR_VERSION $(MAJOR_VERSION)" >> include/version.h;\
echo "#define UC_MINOR_VERSION $(MINOR_VERSION)" >> include/version.h;\
echo "#define UC_BUILD_VERSION "\""$$PATCH"\""" >> include/version.h;\
echo "#define UC_BUILD_TIME "\""$$TIME"\""" >> include/version.h;\
echo "#define UC_BUILD_USER "\""$(USER)"\""" >> include/version.h
check_obj:
@if [ ! -d $(BUILDDIR)/usercrash/bin ]; then \
mkdir -p $(BUILDDIR)/usercrash/bin ; \
@ -41,6 +57,9 @@ check_obj:
.PHONY:clean
clean:
@echo "Clean objects and binaries"
@if [ -e include/version.h ]; then \
$(RM) -f include/version.h; \
fi
@if [ -d $(BUILDDIR)/usercrash/obj ]; then \
find $(BUILDDIR)/usercrash/obj -name "*.o" -exec $(RM) {} \; 2>&1 || exit 0; \
fi

View File

@ -30,6 +30,7 @@
#include "packet.h"
#include "log_sys.h"
#include "protocol.h"
#include "version.h"
/**
* Usercrash works as C/S model: usercrash_c works as usercrash client to
@ -185,7 +186,10 @@ int main(int argc, char *argv[])
if (argc > 1) {
if (strcmp(argv[1], "-v") == 0) {
printf("usercrash_c version is 1.0\n");
printf("version is %d.%d-%s, build by %s@%s\n",
UC_MAJOR_VERSION, UC_MINOR_VERSION,
UC_BUILD_VERSION, UC_BUILD_USER,
UC_BUILD_TIME);
return 0;
}
if (strcmp(argv[1], "-h") == 0) {

View File

@ -10,6 +10,7 @@
#include <unistd.h>
#include "crash_dump.h"
#include "log_sys.h"
#include "version.h"
/**
* Debugger can work without server when uses "debugger pid" commands to
@ -33,7 +34,10 @@ int main(int argc, char *argv[])
if (argc > 1) {
if (strcmp(argv[1], "-v") == 0) {
printf("debugger version is 1.0\n");
printf("version is %d.%d-%s, build by %s@%s\n",
UC_MAJOR_VERSION, UC_MINOR_VERSION,
UC_BUILD_VERSION, UC_BUILD_USER,
UC_BUILD_TIME);
return 0;
}
if (strcmp(argv[1], "-h") == 0) {

View File

@ -42,6 +42,7 @@
#include "packet.h"
#include "protocol.h"
#include "log_sys.h"
#include "version.h"
#define FILE_PATH_LEN_MAX 256
@ -389,7 +390,10 @@ int main(int argc, char *argv[])
while ((opt = getopt(argc, argv, "vh")) != -1) {
switch (opt) {
case 'v':
printf("usercrash_s version is 1.0\n");
printf("version is %d.%d-%s, build by %s@%s\n",
UC_MAJOR_VERSION, UC_MINOR_VERSION,
UC_BUILD_VERSION, UC_BUILD_USER,
UC_BUILD_TIME);
break;
case 'h':
print_usage();