From: Zhang Wei <wei6.zhang@...>
hv version info is used to tell the user when and where the hv is compiled and built, this change will make it easy to read and undersatnd.
It follows bellow format: remote_branch-stable/unstable-acrn-commit_date-commit_id-dirty DBG(tag-current_commit_id) scenario@board build author date. An example can be as: master-unstable-2022-11-14 12:03:51-6d57f8254-dirty DBG scenario3.1@... build by zhangwei 2022-11-15 05:16:05 Another example: release_3.1-stable-2022-09-27 11:15:42-7fad37e02-dirty DBG(tag: v3.1) scenario3.1@... build by zhangwei 2022-11-15 05:53:38
Tracked-On #8303 Signed-off-by: Zhang Wei wei6.zhang@... --- Makefile | 6 ++++++ hypervisor/Makefile | 19 ++++++++----------- hypervisor/arch/x86/cpu.c | 11 ++++------- hypervisor/debug/shell.c | 11 ++++++++--- 4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile index 69e322b34..0ce8e5c5c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,12 @@ ifneq ($(SCM_VERSION),) SCM_VERSION := "-"$(SCM_VERSION) endif export FULL_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(EXTRA_VERSION)$(SCM_VERSION) +ROMOTE_BRANCH := $(shell [ -d .git ] && git rev-parse --abbrev-ref HEAD) +STABLE_STR := -stable +ifeq ($(EXTRA_VERSION), -unstable) + STABLE_STR := -unstable +endif +export BRANCH_VERSION=$(ROMOTE_BRANCH)$(STABLE_STR) ifdef TARGET_DIR $(warning TARGET_DIR is obsoleted because generated configuration files are now stored in the build directory) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index cd49ae28c..4ba6a9772 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -517,15 +517,16 @@ distclean: PHONY: (VERSION) $(VERSION): $(HV_CONFIG_H) touch $(VERSION) - @if [ "$(BUILD_VERSION)"x = x -o "$(BUILD_TAG)"x = x ];then \ + @if [ "$(BUILD_VERSION)"x = x ];then \ COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\ DIRTY=`git diff-index --name-only HEAD`;\ if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\ - DAILY_TAG=`git tag --merged HEAD|grep "acrn"|tail -n 1`;\ else \ PATCH="$(BUILD_VERSION)"; \ - DAILY_TAG="$(BUILD_TAG)"; \ fi; \ + COMMIT_TAGS=$$(git tag --points-at HEAD|tr -s "\n" " "); \ + COMMIT_TAGS=$$(eval echo $$COMMIT_TAGS);\ + COMMIT_TIME=$$(git log -1 --date=format:"%Y-%m-%d %T" --format=%cd); \ TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%F %T"); \ USER="$${USER:-$$(id -u -n)}"; \ if [ x$(CONFIG_RELEASE) = "xy" ];then BUILD_TYPE="REL";else BUILD_TYPE="DBG";fi;\ @@ -535,21 +536,17 @@ $(VERSION): $(HV_CONFIG_H) echo "" >> $(VERSION); \ echo "#ifndef VERSION_H" >> $(VERSION); \ echo "#define VERSION_H" >> $(VERSION); \ - echo "#define HV_FULL_VERSION "\"$(FULL_VERSION)\""" >> $(VERSION);\ echo "#define HV_API_MAJOR_VERSION $(API_MAJOR_VERSION)U" >> $(VERSION);\ echo "#define HV_API_MINOR_VERSION $(API_MINOR_VERSION)U" >> $(VERSION);\ - echo "#define HV_DAILY_TAG "\""$$DAILY_TAG"\""" >> $(VERSION);\ - echo "#define HV_BUILD_VERSION "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_BRANCH_VERSION "\"$(BRANCH_VERSION)\""" >> $(VERSION);\ + echo "#define HV_COMMIT_DIRTY "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TAGS "\"$$COMMIT_TAGS\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TIME "\"$$COMMIT_TIME\""" >> $(VERSION);\ echo "#define HV_BUILD_TYPE "\""$$BUILD_TYPE"\""" >> $(VERSION);\ echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION);\ echo "#define HV_BUILD_SCENARIO "\"$(SCENARIO)\""" >> $(VERSION);\ echo "#define HV_BUILD_BOARD "\"$(BOARD)\""" >> $(VERSION);\ - if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ - echo "#define HV_CONFIG_TOOL \" with acrn-config\"" >> $(VERSION);\ - else \ - echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ - fi;\ echo "#endif" >> $(VERSION) -include $(C_OBJS:.o=.d) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 84782d045..4d5dbd41b 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -248,13 +248,10 @@ void init_pcpu_post(uint16_t pcpu_id) /* Calibrate TSC Frequency */ calibrate_tsc(); - pr_acrnlog("HV version %s-%s-%s %s (daily tag:%s) %s@%s build by %s%s, start time %luus", - HV_FULL_VERSION, - HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, - HV_DAILY_TAG, HV_BUILD_SCENARIO, HV_BUILD_BOARD, - HV_BUILD_USER, HV_CONFIG_TOOL, ticks_to_us(start_tick)); - - pr_acrnlog("API version %u.%u", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + pr_acrnlog("HV version %s-%s-%s %s(tag: %s) %s@%s build by %s, start time %luus", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, + HV_BUILD_TYPE, HV_COMMIT_TAGS, HV_BUILD_SCENARIO, HV_BUILD_BOARD, + HV_BUILD_USER, ticks_to_us(start_tick)); pr_acrnlog("Detect processor: %s", (get_pcpu_info())->model_name); diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 4a0451fd5..431f8ff51 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -737,10 +737,15 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) static int32_t shell_version(__unused int32_t argc, __unused char **argv) { char temp_str[MAX_STR_SIZE]; + char tag_str[TEMP_STR_SIZE] = ""; - snprintf(temp_str, MAX_STR_SIZE, "HV %s-%s-%s %s (daily tag: %s) %s@%s build by %s%s\nAPI %u.%u\r\n", - HV_FULL_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_DAILY_TAG, HV_BUILD_SCENARIO, - HV_BUILD_BOARD, HV_BUILD_USER, HV_CONFIG_TOOL, HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + if(sizeof(HV_COMMIT_TAGS) > 1){ + snprintf(tag_str, TEMP_STR_SIZE, "(tag: %s)", HV_COMMIT_TAGS); + tag_str[TEMP_STR_SIZE-1] = '\0'; + } + snprintf(temp_str, MAX_STR_SIZE, "%s-%s-%s %s%s %s@%s build by %s %s\r\n", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, tag_str, + HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, HV_BUILD_TIME); shell_puts(temp_str); return 0; -- 2.25.1
|
|
On 2022-11-15 at 14:59:33 +0800, wei6.zhang@... wrote: From: Zhang Wei <wei6.zhang@...>
hv version info is used to tell the user when and where the hv is compiled and built, this change will make it easy to read and undersatnd. It's bettert to 80 characters one line at most It follows bellow format: remote_branch-stable/unstable-acrn-commit_date-commit_id-dirty DBG(tag-current_commit_id) scenario@board build author date. An example can be as:
i.e. without tag master-unstable-2022-11-14 12:03:51-6d57f8254-dirty DBG scenario3.1@... build by zhangwei 2022-11-15 05:16:05 Another example: with tag release_3.1-stable-2022-09-27 11:15:42-7fad37e02-dirty DBG(tag: v3.1) scenario3.1@... build by zhangwei 2022-11-15 05:53:38
Tracked-On #8303 Signed-off-by: Zhang Wei wei6.zhang@... --- Makefile | 6 ++++++ hypervisor/Makefile | 19 ++++++++----------- hypervisor/arch/x86/cpu.c | 11 ++++------- hypervisor/debug/shell.c | 11 ++++++++--- 4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile index 69e322b34..0ce8e5c5c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,12 @@ ifneq ($(SCM_VERSION),) SCM_VERSION := "-"$(SCM_VERSION) endif export FULL_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(EXTRA_VERSION)$(SCM_VERSION) +ROMOTE_BRANCH := $(shell [ -d .git ] && git rev-parse --abbrev-ref HEAD) +STABLE_STR := -stable +ifeq ($(EXTRA_VERSION), -unstable) + STABLE_STR := -unstable +endif +export BRANCH_VERSION=$(ROMOTE_BRANCH)$(STABLE_STR) ifdef TARGET_DIR $(warning TARGET_DIR is obsoleted because generated configuration files are now stored in the build directory) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index cd49ae28c..4ba6a9772 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -517,15 +517,16 @@ distclean: PHONY: (VERSION) $(VERSION): $(HV_CONFIG_H) touch $(VERSION) - @if [ "$(BUILD_VERSION)"x = x -o "$(BUILD_TAG)"x = x ];then \ + @if [ "$(BUILD_VERSION)"x = x ];then \ COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\ DIRTY=`git diff-index --name-only HEAD`;\ if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\ - DAILY_TAG=`git tag --merged HEAD|grep "acrn"|tail -n 1`;\ else \ PATCH="$(BUILD_VERSION)"; \ - DAILY_TAG="$(BUILD_TAG)"; \ fi; \ + COMMIT_TAGS=$$(git tag --points-at HEAD|tr -s "\n" " "); \ + COMMIT_TAGS=$$(eval echo $$COMMIT_TAGS);\ + COMMIT_TIME=$$(git log -1 --date=format:"%Y-%m-%d %T" --format=%cd); \ TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%F %T"); \ USER="$${USER:-$$(id -u -n)}"; \ if [ x$(CONFIG_RELEASE) = "xy" ];then BUILD_TYPE="REL";else BUILD_TYPE="DBG";fi;\ @@ -535,21 +536,17 @@ $(VERSION): $(HV_CONFIG_H) echo "" >> $(VERSION); \ echo "#ifndef VERSION_H" >> $(VERSION); \ echo "#define VERSION_H" >> $(VERSION); \ - echo "#define HV_FULL_VERSION "\"$(FULL_VERSION)\""" >> $(VERSION);\ echo "#define HV_API_MAJOR_VERSION $(API_MAJOR_VERSION)U" >> $(VERSION);\ echo "#define HV_API_MINOR_VERSION $(API_MINOR_VERSION)U" >> $(VERSION);\ - echo "#define HV_DAILY_TAG "\""$$DAILY_TAG"\""" >> $(VERSION);\ - echo "#define HV_BUILD_VERSION "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_BRANCH_VERSION "\"$(BRANCH_VERSION)\""" >> $(VERSION);\ + echo "#define HV_COMMIT_DIRTY "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TAGS "\"$$COMMIT_TAGS\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TIME "\"$$COMMIT_TIME\""" >> $(VERSION);\ echo "#define HV_BUILD_TYPE "\""$$BUILD_TYPE"\""" >> $(VERSION);\ echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION);\ echo "#define HV_BUILD_SCENARIO "\"$(SCENARIO)\""" >> $(VERSION);\ echo "#define HV_BUILD_BOARD "\"$(BOARD)\""" >> $(VERSION);\ - if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ - echo "#define HV_CONFIG_TOOL \" with acrn-config\"" >> $(VERSION);\ - else \ - echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ - fi;\ echo "#endif" >> $(VERSION) -include $(C_OBJS:.o=.d) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 84782d045..4d5dbd41b 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -248,13 +248,10 @@ void init_pcpu_post(uint16_t pcpu_id) /* Calibrate TSC Frequency */ calibrate_tsc(); - pr_acrnlog("HV version %s-%s-%s %s (daily tag:%s) %s@%s build by %s%s, start time %luus", - HV_FULL_VERSION, - HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, - HV_DAILY_TAG, HV_BUILD_SCENARIO, HV_BUILD_BOARD, - HV_BUILD_USER, HV_CONFIG_TOOL, ticks_to_us(start_tick)); - - pr_acrnlog("API version %u.%u", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + pr_acrnlog("HV version %s-%s-%s %s(tag: %s) %s@%s build by %s, start time %luus", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, + HV_BUILD_TYPE, HV_COMMIT_TAGS, HV_BUILD_SCENARIO, HV_BUILD_BOARD, + HV_BUILD_USER, ticks_to_us(start_tick)); printf tag only there's one for current commit id pr_acrnlog("Detect processor: %s", (get_pcpu_info())->model_name); diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 4a0451fd5..431f8ff51 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -737,10 +737,15 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) static int32_t shell_version(__unused int32_t argc, __unused char **argv) { char temp_str[MAX_STR_SIZE]; + char tag_str[TEMP_STR_SIZE] = ""; - snprintf(temp_str, MAX_STR_SIZE, "HV %s-%s-%s %s (daily tag: %s) %s@%s build by %s%s\nAPI %u.%u\r\n", - HV_FULL_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_DAILY_TAG, HV_BUILD_SCENARIO, - HV_BUILD_BOARD, HV_BUILD_USER, HV_CONFIG_TOOL, HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + if(sizeof(HV_COMMIT_TAGS) > 1){ + snprintf(tag_str, TEMP_STR_SIZE, "(tag: %s)", HV_COMMIT_TAGS); + tag_str[TEMP_STR_SIZE-1] = '\0'; + } + snprintf(temp_str, MAX_STR_SIZE, "%s-%s-%s %s%s %s@%s build by %s %s\r\n", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, tag_str, + HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, HV_BUILD_TIME); %s%s%s (sizeof(HV_COMMIT_TAGS) > 1) ? "(tag: " : "", HV_COMMIT_TAGS, (sizeof(HV_COMMIT_TAGS) > 1) ? ")" : "" ??? shell_puts(temp_str); return 0; -- 2.25.1
|
|
From: Zhang Wei <wei6.zhang@...>
hv version info is used to tell the user when and where the hv is compiled and built, this change will make it easy to read and undersatnd. It's bettert to 80 characters one line at most
Ok, I will modify this commit to conform to this norm. It follows bellow format: remote_branch-stable/unstable-acrn-commit_date-commit_id-dirty DBG(tag-current_commit_id) scenario@board build author date. An example can be as: i.e. without tag
master-unstable-2022-11-14 12:03:51-6d57f8254-dirty DBG scenario3.1@... build by zhangwei 2022-11-15 05:16:05 Another example: with tag
release_3.1-stable-2022-09-27 11:15:42-7fad37e02-dirty DBG(tag: v3.1) scenario3.1@... build by zhangwei 2022-11-15 05:53:38
Yes, the examples will show as: i.e. without tag master-unstable-2022-11-14 12:03:51-6d57f8254-dirty DBG scenario3.1@... build by zhangwei 2022-11-15 05:16:05 with tag release_3.1-stable-2022-09-27 11:15:42-7fad37e02-dirty DBG(tag: v3.1) scenario3.1@... build by zhangwei 2022-11-15 05:53:38 Tracked-On #8303 Signed-off-by: Zhang Wei wei6.zhang@... --- Makefile | 6 ++++++ hypervisor/Makefile | 19 ++++++++----------- hypervisor/arch/x86/cpu.c | 11 ++++------- hypervisor/debug/shell.c | 11 ++++++++--- 4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile index 69e322b34..0ce8e5c5c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,12 @@ ifneq ($(SCM_VERSION),) SCM_VERSION := "-"$(SCM_VERSION) endif export FULL_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(EXTRA_VERSION)$(SCM_VE RSION) +ROMOTE_BRANCH := $(shell [ -d .git ] && git rev-parse --abbrev-ref +HEAD) STABLE_STR := -stable ifeq ($(EXTRA_VERSION), -unstable) + STABLE_STR := -unstable +endif +export BRANCH_VERSION=$(ROMOTE_BRANCH)$(STABLE_STR) ifdef TARGET_DIR $(warning TARGET_DIR is obsoleted because generated configuration files are now stored in the build directory) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index cd49ae28c..4ba6a9772 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -517,15 +517,16 @@ distclean: PHONY: (VERSION) $(VERSION): $(HV_CONFIG_H) touch $(VERSION) - @if [ "$(BUILD_VERSION)"x = x -o "$(BUILD_TAG)"x = x ];then \ + @if [ "$(BUILD_VERSION)"x = x ];then \ COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\ DIRTY=`git diff-index --name-only HEAD`;\ if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\ - DAILY_TAG=`git tag --merged HEAD|grep "acrn"|tail -n 1`;\ else \ PATCH="$(BUILD_VERSION)"; \ - DAILY_TAG="$(BUILD_TAG)"; \ fi; \ + COMMIT_TAGS=$$(git tag --points-at HEAD|tr -s "\n" " "); \ + COMMIT_TAGS=$$(eval echo $$COMMIT_TAGS);\ + COMMIT_TIME=$$(git log -1 --date=format:"%Y-%m-%d %T" --format=%cd); +\ TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%F %T"); \ USER="$${USER:-$$(id -u -n)}"; \ if [ x$(CONFIG_RELEASE) = "xy" ];then BUILD_TYPE="REL";else BUILD_TYPE="DBG";fi;\ @@ -535,21 +536,17 @@ $(VERSION): $(HV_CONFIG_H) echo "" >> $(VERSION); \ echo "#ifndef VERSION_H" >> $(VERSION); \ echo "#define VERSION_H" >> $(VERSION); \ - echo "#define HV_FULL_VERSION "\"$(FULL_VERSION)\""" >> $(VERSION);\ echo "#define HV_API_MAJOR_VERSION $(API_MAJOR_VERSION)U" >> $(VERSION);\ echo "#define HV_API_MINOR_VERSION $(API_MINOR_VERSION)U" >> $(VERSION);\ - echo "#define HV_DAILY_TAG "\""$$DAILY_TAG"\""" >> $(VERSION);\ - echo "#define HV_BUILD_VERSION "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_BRANCH_VERSION "\"$(BRANCH_VERSION)\""" >> $(VERSION);\ + echo "#define HV_COMMIT_DIRTY "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TAGS "\"$$COMMIT_TAGS\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TIME "\"$$COMMIT_TIME\""" >> $(VERSION);\ echo "#define HV_BUILD_TYPE "\""$$BUILD_TYPE"\""" >> $(VERSION);\ echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION);\ echo "#define HV_BUILD_SCENARIO "\"$(SCENARIO)\""" >> $(VERSION);\ echo "#define HV_BUILD_BOARD "\"$(BOARD)\""" >> $(VERSION);\ - if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ - echo "#define HV_CONFIG_TOOL \" with acrn-config\"" >> $(VERSION);\ - else \ - echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ - fi;\ echo "#endif" >> $(VERSION) -include $(C_OBJS:.o=.d) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 84782d045..4d5dbd41b 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -248,13 +248,10 @@ void init_pcpu_post(uint16_t pcpu_id) /* Calibrate TSC Frequency */ calibrate_tsc(); - pr_acrnlog("HV version %s-%s-%s %s (daily tag:%s) %s@%s build by %s%s, start time %luus", - HV_FULL_VERSION, - HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, - HV_DAILY_TAG, HV_BUILD_SCENARIO, HV_BUILD_BOARD, - HV_BUILD_USER, HV_CONFIG_TOOL, ticks_to_us(start_tick)); - - pr_acrnlog("API version %u.%u", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + pr_acrnlog("HV version %s-%s-%s %s(tag: %s) %s@%s build by %s, start time %luus", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, + HV_BUILD_TYPE, HV_COMMIT_TAGS, HV_BUILD_SCENARIO, HV_BUILD_BOARD, + HV_BUILD_USER, ticks_to_us(start_tick)); printf tag only there's one for current commit id
Ok, with your next suggestion, we can implement this logic as: pr_acrnlog("HV version %s-%s-%s %s%s%s%s %s@%s build by %s, start time %luus", HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, (sizeof(HV_COMMIT_TAGS) > 1) ? "(tag: " : "", HV_COMMIT_TAGS, (sizeof(HV_COMMIT_TAGS) > 1) ? ")" : "", HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, ticks_to_us(start_tick)); pr_acrnlog("Detect processor: %s", (get_pcpu_info())->model_name); diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 4a0451fd5..431f8ff51 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -737,10 +737,15 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) static int32_t shell_version(__unused int32_t argc, __unused char **argv) { char temp_str[MAX_STR_SIZE]; + char tag_str[TEMP_STR_SIZE] = ""; - snprintf(temp_str, MAX_STR_SIZE, "HV %s-%s-%s %s (daily tag: %s) %s@%s build by %s%s\nAPI %u.%u\r\n", - HV_FULL_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_DAILY_TAG, HV_BUILD_SCENARIO, - HV_BUILD_BOARD, HV_BUILD_USER, HV_CONFIG_TOOL, HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + if(sizeof(HV_COMMIT_TAGS) > 1){ + snprintf(tag_str, TEMP_STR_SIZE, "(tag: %s)", HV_COMMIT_TAGS); + tag_str[TEMP_STR_SIZE-1] = '\0'; + } + snprintf(temp_str, MAX_STR_SIZE, "%s-%s-%s %s%s %s@%s build by %s %s\r\n", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, tag_str, + HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, HV_BUILD_TIME); %s%s%s (sizeof(HV_COMMIT_TAGS) > 1) ? "(tag: " : "", HV_COMMIT_TAGS, (sizeof(HV_COMMIT_TAGS) > 1) ? ")" : "" ???
Great suggestion, it simplifies the output of version-info, it will be: snprintf(temp_str, MAX_STR_SIZE, "%s-%s-%s %s%s%s%s %s@%s build by %s %s\r\n", HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, (sizeof(HV_COMMIT_TAGS) > 1) ? "(tag: " : "", HV_COMMIT_TAGS, (sizeof(HV_COMMIT_TAGS) > 1) ? ")" : "", HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, HV_BUILD_TIME); shell_puts(temp_str); return 0; -- 2.25.1
-----Original Message----- From: Li, Fei1 <fei1.li@...> Sent: Tuesday, November 15, 2022 4:53 PM To: Zhang, Wei6 <wei6.zhang@...> Cc: acrn-dev@...; Xie, Nanlin <nanlin.xie@...>; Mao, Junjie <junjie.mao@...>; Zou, Terry <terry.zou@...> Subject: Re: [PATCH] hv: change the version format On 2022-11-15 at 14:59:33 +0800, wei6.zhang@... wrote: From: Zhang Wei <wei6.zhang@...>
hv version info is used to tell the user when and where the hv is compiled and built, this change will make it easy to read and undersatnd. It's bettert to 80 characters one line at most It follows bellow format: remote_branch-stable/unstable-acrn-commit_date-commit_id-dirty DBG(tag-current_commit_id) scenario@board build author date. An example can be as:
i.e. without tag master-unstable-2022-11-14 12:03:51-6d57f8254-dirty DBG scenario3.1@... build by zhangwei 2022-11-15 05:16:05 Another example: with tag release_3.1-stable-2022-09-27 11:15:42-7fad37e02-dirty DBG(tag: v3.1) scenario3.1@... build by zhangwei 2022-11-15 05:53:38
Tracked-On #8303 Signed-off-by: Zhang Wei wei6.zhang@... --- Makefile | 6 ++++++ hypervisor/Makefile | 19 ++++++++----------- hypervisor/arch/x86/cpu.c | 11 ++++------- hypervisor/debug/shell.c | 11 ++++++++--- 4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile index 69e322b34..0ce8e5c5c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,12 @@ ifneq ($(SCM_VERSION),) SCM_VERSION := "-"$(SCM_VERSION) endif export FULL_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(EXTRA_VERSION)$(SCM_VE RSION) +ROMOTE_BRANCH := $(shell [ -d .git ] && git rev-parse --abbrev-ref +HEAD) STABLE_STR := -stable ifeq ($(EXTRA_VERSION), -unstable) + STABLE_STR := -unstable +endif +export BRANCH_VERSION=$(ROMOTE_BRANCH)$(STABLE_STR) ifdef TARGET_DIR $(warning TARGET_DIR is obsoleted because generated configuration files are now stored in the build directory) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index cd49ae28c..4ba6a9772 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -517,15 +517,16 @@ distclean: PHONY: (VERSION) $(VERSION): $(HV_CONFIG_H) touch $(VERSION) - @if [ "$(BUILD_VERSION)"x = x -o "$(BUILD_TAG)"x = x ];then \ + @if [ "$(BUILD_VERSION)"x = x ];then \ COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\ DIRTY=`git diff-index --name-only HEAD`;\ if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\ - DAILY_TAG=`git tag --merged HEAD|grep "acrn"|tail -n 1`;\ else \ PATCH="$(BUILD_VERSION)"; \ - DAILY_TAG="$(BUILD_TAG)"; \ fi; \ + COMMIT_TAGS=$$(git tag --points-at HEAD|tr -s "\n" " "); \ + COMMIT_TAGS=$$(eval echo $$COMMIT_TAGS);\ + COMMIT_TIME=$$(git log -1 --date=format:"%Y-%m-%d %T" --format=%cd); +\ TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%F %T"); \ USER="$${USER:-$$(id -u -n)}"; \ if [ x$(CONFIG_RELEASE) = "xy" ];then BUILD_TYPE="REL";else BUILD_TYPE="DBG";fi;\ @@ -535,21 +536,17 @@ $(VERSION): $(HV_CONFIG_H) echo "" >> $(VERSION); \ echo "#ifndef VERSION_H" >> $(VERSION); \ echo "#define VERSION_H" >> $(VERSION); \ - echo "#define HV_FULL_VERSION "\"$(FULL_VERSION)\""" >> $(VERSION);\ echo "#define HV_API_MAJOR_VERSION $(API_MAJOR_VERSION)U" >> $(VERSION);\ echo "#define HV_API_MINOR_VERSION $(API_MINOR_VERSION)U" >> $(VERSION);\ - echo "#define HV_DAILY_TAG "\""$$DAILY_TAG"\""" >> $(VERSION);\ - echo "#define HV_BUILD_VERSION "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_BRANCH_VERSION "\"$(BRANCH_VERSION)\""" >> $(VERSION);\ + echo "#define HV_COMMIT_DIRTY "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TAGS "\"$$COMMIT_TAGS\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TIME "\"$$COMMIT_TIME\""" >> $(VERSION);\ echo "#define HV_BUILD_TYPE "\""$$BUILD_TYPE"\""" >> $(VERSION);\ echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION);\ echo "#define HV_BUILD_SCENARIO "\"$(SCENARIO)\""" >> $(VERSION);\ echo "#define HV_BUILD_BOARD "\"$(BOARD)\""" >> $(VERSION);\ - if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ - echo "#define HV_CONFIG_TOOL \" with acrn-config\"" >> $(VERSION);\ - else \ - echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ - fi;\ echo "#endif" >> $(VERSION) -include $(C_OBJS:.o=.d) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 84782d045..4d5dbd41b 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -248,13 +248,10 @@ void init_pcpu_post(uint16_t pcpu_id) /* Calibrate TSC Frequency */ calibrate_tsc(); - pr_acrnlog("HV version %s-%s-%s %s (daily tag:%s) %s@%s build by %s%s, start time %luus", - HV_FULL_VERSION, - HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, - HV_DAILY_TAG, HV_BUILD_SCENARIO, HV_BUILD_BOARD, - HV_BUILD_USER, HV_CONFIG_TOOL, ticks_to_us(start_tick)); - - pr_acrnlog("API version %u.%u", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + pr_acrnlog("HV version %s-%s-%s %s(tag: %s) %s@%s build by %s, start time %luus", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, + HV_BUILD_TYPE, HV_COMMIT_TAGS, HV_BUILD_SCENARIO, HV_BUILD_BOARD, + HV_BUILD_USER, ticks_to_us(start_tick)); printf tag only there's one for current commit id pr_acrnlog("Detect processor: %s", (get_pcpu_info())->model_name); diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 4a0451fd5..431f8ff51 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -737,10 +737,15 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) static int32_t shell_version(__unused int32_t argc, __unused char **argv) { char temp_str[MAX_STR_SIZE]; + char tag_str[TEMP_STR_SIZE] = ""; - snprintf(temp_str, MAX_STR_SIZE, "HV %s-%s-%s %s (daily tag: %s) %s@%s build by %s%s\nAPI %u.%u\r\n", - HV_FULL_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_DAILY_TAG, HV_BUILD_SCENARIO, - HV_BUILD_BOARD, HV_BUILD_USER, HV_CONFIG_TOOL, HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + if(sizeof(HV_COMMIT_TAGS) > 1){ + snprintf(tag_str, TEMP_STR_SIZE, "(tag: %s)", HV_COMMIT_TAGS); + tag_str[TEMP_STR_SIZE-1] = '\0'; + } + snprintf(temp_str, MAX_STR_SIZE, "%s-%s-%s %s%s %s@%s build by %s %s\r\n", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, tag_str, + HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, HV_BUILD_TIME); %s%s%s (sizeof(HV_COMMIT_TAGS) > 1) ? "(tag: " : "", HV_COMMIT_TAGS, (sizeof(HV_COMMIT_TAGS) > 1) ? ")" : "" ??? shell_puts(temp_str); return 0; -- 2.25.1
|
|
toggle quoted message
Show quoted text
-----Original Message----- From: Zhang, Wei6 <wei6.zhang@...> Sent: Tuesday, November 15, 2022 3:00 PM To: acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Mao, Junjie <junjie.mao@...>; Zou, Terry <terry.zou@...>; Zhang, Wei6 <wei6.zhang@...> Subject: [PATCH] hv: change the version format
From: Zhang Wei <wei6.zhang@...>
hv version info is used to tell the user when and where the hv is compiled and built, this change will make it easy to read and undersatnd.
It follows bellow format: remote_branch-stable/unstable-acrn-commit_date-commit_id-dirty DBG(tag-current_commit_id) scenario@board build author date. An example can be as: master-unstable-2022-11-14 12:03:51-6d57f8254-dirty DBG scenario3.1@... build by zhangwei 2022-11-15 05:16:05 Another example: release_3.1-stable-2022-09-27 11:15:42-7fad37e02-dirty DBG(tag: v3.1) scenario3.1@... build by zhangwei 2022-11-15 05:53:38
Tracked-On #8303 Signed-off-by: Zhang Wei wei6.zhang@... --- Makefile | 6 ++++++ hypervisor/Makefile | 19 ++++++++----------- hypervisor/arch/x86/cpu.c | 11 ++++------- hypervisor/debug/shell.c | 11 ++++++++--- 4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile index 69e322b34..0ce8e5c5c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,12 @@ ifneq ($(SCM_VERSION),) SCM_VERSION := "-"$(SCM_VERSION) endif export FULL_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(EXTRA_VERSION)$(SCM_VERSION) It seems you removed all uses of FULL_VERSION in the C code. Also drop this definition if that's really the case. +ROMOTE_BRANCH := $(shell [ -d .git ] && git rev-parse --abbrev-ref HEAD) Typo: ROMOTE -> REMOTE +STABLE_STR := -stable +ifeq ($(EXTRA_VERSION), -unstable) + STABLE_STR := -unstable +endif +export BRANCH_VERSION=$(ROMOTE_BRANCH)$(STABLE_STR) When `.git` is not present, will the branch version be `-stable`, i.e., starting with a hyphen? That looks quite strange. Starting with `<major>.<minor>` would be better, and even so if you no longer prints FULL_VERSION. ifdef TARGET_DIR $(warning TARGET_DIR is obsoleted because generated configuration files are now stored in the build directory) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index cd49ae28c..4ba6a9772 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -517,15 +517,16 @@ distclean: PHONY: (VERSION) $(VERSION): $(HV_CONFIG_H) touch $(VERSION) - @if [ "$(BUILD_VERSION)"x = x -o "$(BUILD_TAG)"x = x ];then \ + @if [ "$(BUILD_VERSION)"x = x ];then \ COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\ DIRTY=`git diff-index --name-only HEAD`;\ if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\ - DAILY_TAG=`git tag --merged HEAD|grep "acrn"|tail -n 1`;\ else \ PATCH="$(BUILD_VERSION)"; \ - DAILY_TAG="$(BUILD_TAG)"; \ fi; \ + COMMIT_TAGS=$$(git tag --points-at HEAD|tr -s "\n" " "); \ + COMMIT_TAGS=$$(eval echo $$COMMIT_TAGS);\
Why echoing COMMIT_TAGS here? Also when there are multiple tags attached to the same commit, is COMMIT_TAGS intended to include ALL of them? --- Best Regards Junjie Mao + COMMIT_TIME=$$(git log -1 --date=format:"%Y-%m-%d %T" --format=%cd); \ TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%F %T"); \ USER="$${USER:-$$(id -u -n)}"; \ if [ x$(CONFIG_RELEASE) = "xy" ];then BUILD_TYPE="REL";else BUILD_TYPE="DBG";fi;\ @@ -535,21 +536,17 @@ $(VERSION): $(HV_CONFIG_H) echo "" >> $(VERSION); \ echo "#ifndef VERSION_H" >> $(VERSION); \ echo "#define VERSION_H" >> $(VERSION); \ - echo "#define HV_FULL_VERSION "\"$(FULL_VERSION)\""" >> $(VERSION);\ echo "#define HV_API_MAJOR_VERSION $(API_MAJOR_VERSION)U" >> $(VERSION);\ echo "#define HV_API_MINOR_VERSION $(API_MINOR_VERSION)U" >> $(VERSION);\ - echo "#define HV_DAILY_TAG "\""$$DAILY_TAG"\""" >> $(VERSION);\ - echo "#define HV_BUILD_VERSION "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_BRANCH_VERSION "\"$(BRANCH_VERSION)\""" >> $(VERSION);\ + echo "#define HV_COMMIT_DIRTY "\""$$PATCH"\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TAGS "\"$$COMMIT_TAGS\""" >> $(VERSION);\ + echo "#define HV_COMMIT_TIME "\"$$COMMIT_TIME\""" >> $(VERSION);\ echo "#define HV_BUILD_TYPE "\""$$BUILD_TYPE"\""" >> $(VERSION);\ echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION);\ echo "#define HV_BUILD_SCENARIO "\"$(SCENARIO)\""" >> $(VERSION);\ echo "#define HV_BUILD_BOARD "\"$(BOARD)\""" >> $(VERSION);\ - if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ - echo "#define HV_CONFIG_TOOL \" with acrn-config\"" >> $(VERSION);\ - else \ - echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ - fi;\ echo "#endif" >> $(VERSION)
-include $(C_OBJS:.o=.d) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 84782d045..4d5dbd41b 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -248,13 +248,10 @@ void init_pcpu_post(uint16_t pcpu_id) /* Calibrate TSC Frequency */ calibrate_tsc();
- pr_acrnlog("HV version %s-%s-%s %s (daily tag:%s) %s@%s build by %s%s, start time %luus", - HV_FULL_VERSION, - HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, - HV_DAILY_TAG, HV_BUILD_SCENARIO, HV_BUILD_BOARD, - HV_BUILD_USER, HV_CONFIG_TOOL, ticks_to_us(start_tick)); - - pr_acrnlog("API version %u.%u", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + pr_acrnlog("HV version %s-%s-%s %s(tag: %s) %s@%s build by %s, start time %luus", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, + HV_BUILD_TYPE, HV_COMMIT_TAGS, HV_BUILD_SCENARIO, HV_BUILD_BOARD, + HV_BUILD_USER, ticks_to_us(start_tick));
pr_acrnlog("Detect processor: %s", (get_pcpu_info())->model_name);
diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 4a0451fd5..431f8ff51 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -737,10 +737,15 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) static int32_t shell_version(__unused int32_t argc, __unused char **argv) { char temp_str[MAX_STR_SIZE]; + char tag_str[TEMP_STR_SIZE] = "";
- snprintf(temp_str, MAX_STR_SIZE, "HV %s-%s-%s %s (daily tag: %s) %s@%s build by %s%s\nAPI %u.%u\r\n", - HV_FULL_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_DAILY_TAG, HV_BUILD_SCENARIO, - HV_BUILD_BOARD, HV_BUILD_USER, HV_CONFIG_TOOL, HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + if(sizeof(HV_COMMIT_TAGS) > 1){ + snprintf(tag_str, TEMP_STR_SIZE, "(tag: %s)", HV_COMMIT_TAGS); + tag_str[TEMP_STR_SIZE-1] = '\0'; + } + snprintf(temp_str, MAX_STR_SIZE, "%s-%s-%s %s%s %s@%s build by %s %s\r\n", + HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, tag_str, + HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, HV_BUILD_TIME); shell_puts(temp_str);
return 0; -- 2.25.1
|
|
toggle quoted message
Show quoted text
-----Original Message----- From: Mao, Junjie <junjie.mao@...> Sent: Wednesday, November 16, 2022 10:45 AM To: Zhang, Wei6 <wei6.zhang@...>; acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Zou, Terry <terry.zou@...> Subject: RE: [PATCH] hv: change the version format
-----Original Message----- From: Zhang, Wei6 <wei6.zhang@...> Sent: Tuesday, November 15, 2022 3:00 PM To: acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Mao, Junjie <junjie.mao@...>; Zou, Terry <terry.zou@...>; Zhang, Wei6 <wei6.zhang@...> Subject: [PATCH] hv: change the version format
From: Zhang Wei <wei6.zhang@...>
hv version info is used to tell the user when and where the hv is compiled and built, this change will make it easy to read and undersatnd.
It follows bellow format: remote_branch-stable/unstable-acrn-commit_date-commit_id-dirty DBG(tag-current_commit_id) scenario@board build author date. An example can be as: master-unstable-2022-11-14 12:03:51-6d57f8254-dirty DBG scenario3.1@... build by zhangwei 2022-11-15 05:16:05 Another example: release_3.1-stable-2022-09-27 11:15:42-7fad37e02-dirty DBG(tag: v3.1) scenario3.1@... build by zhangwei 2022-11-15 05:53:38
Tracked-On #8303 Signed-off-by: Zhang Wei wei6.zhang@... --- Makefile | 6 ++++++ hypervisor/Makefile | 19 ++++++++----------- hypervisor/arch/x86/cpu.c | 11 ++++------- hypervisor/debug/shell.c | 11 ++++++++--- 4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile index 69e322b34..0ce8e5c5c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,12 @@ ifneq ($(SCM_VERSION),) SCM_VERSION := "-"$(SCM_VERSION) endif export
FULL_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(EXTRA_VERSION )$(SCM_VE
RSION) It seems you removed all uses of FULL_VERSION in the C code. Also drop this definition if that's really the case.
The FULL_VERSION won't be used in hv. But In the acrn-dm, it is still a part of version. If necessary, I can replace FULL_VERSION with BRANCH_VERSION and also modify the acrn-dm version, after that FULL_VERSION can be deleted. +ROMOTE_BRANCH := $(shell [ -d .git ] && git rev-parse --abbrev-ref +HEAD) Typo: ROMOTE -> REMOTE
Yes, it's a Typo, I will fix it. +STABLE_STR := -stable +ifeq ($(EXTRA_VERSION), -unstable) + STABLE_STR := -unstable +endif +export BRANCH_VERSION=$(ROMOTE_BRANCH)$(STABLE_STR) When `.git` is not present, will the branch version be `-stable`, i.e., starting with a hyphen? That looks quite strange. Starting with `<major>.<minor>` would be better, and even so if you no longer prints FULL_VERSION.
Yes, without '.git', the version will start with '-', Will the follows be better? ifneq ($(REMOTE_BRANCH),) REMOTE_BRANCH := -"-"$(REMOTE_BRANCH) endif export BRANCH_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(STABLE_STR)$(REMOTE_BRANCH) ifdef TARGET_DIR $(warning TARGET_DIR is obsoleted because generated configuration files are now stored in the build directory) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index cd49ae28c..4ba6a9772 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -517,15 +517,16 @@ distclean: PHONY: (VERSION) $(VERSION): $(HV_CONFIG_H) touch $(VERSION) - @if [ "$(BUILD_VERSION)"x = x -o "$(BUILD_TAG)"x = x ];then \ + @if [ "$(BUILD_VERSION)"x = x ];then \ COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\ DIRTY=`git diff-index --name-only HEAD`;\ if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\
- DAILY_TAG=`git tag --merged HEAD|grep "acrn"|tail -n 1`;\ else \ PATCH="$(BUILD_VERSION)"; \ - DAILY_TAG="$(BUILD_TAG)"; \ fi; \ + COMMIT_TAGS=$$(git tag --points-at HEAD|tr -s "\n" " "); \ + COMMIT_TAGS=$$(eval echo $$COMMIT_TAGS);\ Why echoing COMMIT_TAGS here?
Also when there are multiple tags attached to the same commit, is COMMIT_TAGS intended to include ALL of them?
Yes, There may be more than one tag in one commit, e.g.( acrn-2022w22.1-180000p, xxx). we want to show all of them. The 'echo' is used for deleting the rear space. --- Best Regards Junjie Mao
Best Regards Zhangwei + COMMIT_TIME=$$(git log -1 --date=format:"%Y-%m-%d %T" -- format=%cd);
+\ TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%F %T"); \
USER="$${USER:-$$(id -u -n)}"; \ if [ x$(CONFIG_RELEASE) = "xy" ];then BUILD_TYPE="REL";else BUILD_TYPE="DBG";fi;\ @@ -535,21 +536,17 @@ $(VERSION): $(HV_CONFIG_H)
echo "" >> $(VERSION); \ echo "#ifndef VERSION_H" >> $(VERSION); \ echo "#define VERSION_H" >> $(VERSION); \ - echo "#define HV_FULL_VERSION "\"$(FULL_VERSION)\""" >> $(VERSION);\
echo "#define HV_API_MAJOR_VERSION $(API_MAJOR_VERSION)U" >> $(VERSION);\
echo "#define HV_API_MINOR_VERSION $(API_MINOR_VERSION)U" >> $(VERSION);\
- echo "#define HV_DAILY_TAG "\""$$DAILY_TAG"\""" >> $(VERSION);\
- echo "#define HV_BUILD_VERSION "\""$$PATCH"\""" >> $(VERSION);\
+ echo "#define HV_BRANCH_VERSION "\"$(BRANCH_VERSION)\""" >> $(VERSION);\
+ echo "#define HV_COMMIT_DIRTY "\""$$PATCH"\""" >> $(VERSION);\
+ echo "#define HV_COMMIT_TAGS "\"$$COMMIT_TAGS\""" >> $(VERSION);\
+ echo "#define HV_COMMIT_TIME "\"$$COMMIT_TIME\""" >> $(VERSION);\
echo "#define HV_BUILD_TYPE "\""$$BUILD_TYPE"\""" >> $(VERSION);\
echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION);\ echo "#define HV_BUILD_SCENARIO "\"$(SCENARIO)\""" >> $(VERSION);\
echo "#define HV_BUILD_BOARD "\"$(BOARD)\""" >> $(VERSION);\ - if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ - echo "#define HV_CONFIG_TOOL \" with acrn-config\"" >> $(VERSION);\
- else \ - echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ - fi;\ echo "#endif" >> $(VERSION)
-include $(C_OBJS:.o=.d) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 84782d045..4d5dbd41b 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -248,13 +248,10 @@ void init_pcpu_post(uint16_t pcpu_id) /* Calibrate TSC Frequency */ calibrate_tsc();
- pr_acrnlog("HV version %s-%s-%s %s (daily tag:%s) %s@%s build by %s%s, start
time %luus", - HV_FULL_VERSION, - HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE,
- HV_DAILY_TAG, HV_BUILD_SCENARIO, HV_BUILD_BOARD,
- HV_BUILD_USER, HV_CONFIG_TOOL, ticks_to_us(start_tick));
- - pr_acrnlog("API version %u.%u", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION);
+ pr_acrnlog("HV version %s-%s-%s %s(tag: %s) %s@%s build by %s, start time %luus",
+ HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY,
+ HV_BUILD_TYPE, HV_COMMIT_TAGS, HV_BUILD_SCENARIO, HV_BUILD_BOARD,
+ HV_BUILD_USER, ticks_to_us(start_tick));
pr_acrnlog("Detect processor: %s", (get_pcpu_info())- model_name);
diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 4a0451fd5..431f8ff51 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -737,10 +737,15 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) static int32_t shell_version(__unused int32_t argc, __unused char **argv) { char temp_str[MAX_STR_SIZE]; + char tag_str[TEMP_STR_SIZE] = "";
- snprintf(temp_str, MAX_STR_SIZE, "HV %s-%s-%s %s (daily tag: %s) %s@%s build
by %s%s\nAPI %u.%u\r\n", - HV_FULL_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_DAILY_TAG,
HV_BUILD_SCENARIO, - HV_BUILD_BOARD, HV_BUILD_USER, HV_CONFIG_TOOL, HV_API_MAJOR_VERSION,
HV_API_MINOR_VERSION); + if(sizeof(HV_COMMIT_TAGS) > 1){ + snprintf(tag_str, TEMP_STR_SIZE, "(tag: %s)", HV_COMMIT_TAGS);
+ tag_str[TEMP_STR_SIZE-1] = '\0'; + } + snprintf(temp_str, MAX_STR_SIZE, "%s-%s-%s %s%s %s@%s build by %s %s\r\n",
+ HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, tag_str,
+ HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, HV_BUILD_TIME);
shell_puts(temp_str);
return 0; -- 2.25.1
|
|
toggle quoted message
Show quoted text
-----Original Message----- From: Zhang, Wei6 <wei6.zhang@...> Sent: Wednesday, November 16, 2022 11:47 AM To: Mao, Junjie <junjie.mao@...>; acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Zou, Terry <terry.zou@...> Subject: RE: [PATCH] hv: change the version format
-----Original Message----- From: Mao, Junjie <junjie.mao@...> Sent: Wednesday, November 16, 2022 10:45 AM To: Zhang, Wei6 <wei6.zhang@...>; acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Zou, Terry <terry.zou@...> Subject: RE: [PATCH] hv: change the version format
-----Original Message----- From: Zhang, Wei6 <wei6.zhang@...> Sent: Tuesday, November 15, 2022 3:00 PM To: acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Mao, Junjie <junjie.mao@...>; Zou, Terry <terry.zou@...>; Zhang, Wei6 <wei6.zhang@...> Subject: [PATCH] hv: change the version format
From: Zhang Wei <wei6.zhang@...>
hv version info is used to tell the user when and where the hv is compiled and built, this change will make it easy to read and undersatnd.
It follows bellow format: remote_branch-stable/unstable-acrn-commit_date-commit_id-dirty DBG(tag-current_commit_id) scenario@board build author date. An example can be as: master-unstable-2022-11-14 12:03:51-6d57f8254-dirty DBG scenario3.1@... build by zhangwei 2022-11-15 05:16:05 Another example: release_3.1-stable-2022-09-27 11:15:42-7fad37e02-dirty DBG(tag: v3.1) scenario3.1@... build by zhangwei 2022-11-15 05:53:38
Tracked-On #8303 Signed-off-by: Zhang Wei wei6.zhang@... --- Makefile | 6 ++++++ hypervisor/Makefile | 19 ++++++++----------- hypervisor/arch/x86/cpu.c | 11 ++++------- hypervisor/debug/shell.c | 11 ++++++++--- 4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile index 69e322b34..0ce8e5c5c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,12 @@ ifneq ($(SCM_VERSION),) SCM_VERSION := "-"$(SCM_VERSION) endif export
FULL_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(EXTRA_VERSION )$(SCM_VE
RSION) It seems you removed all uses of FULL_VERSION in the C code. Also drop this definition if that's really the case.
The FULL_VERSION won't be used in hv. But In the acrn-dm, it is still a part of version. If necessary, I can replace FULL_VERSION with BRANCH_VERSION and also modify the acrn-dm version, after that FULL_VERSION can be deleted.
Let's use consistent format of versions in all ACRN components. +ROMOTE_BRANCH := $(shell [ -d .git ] && git rev-parse --abbrev-ref +HEAD) Typo: ROMOTE -> REMOTE
Yes, it's a Typo, I will fix it.
+STABLE_STR := -stable +ifeq ($(EXTRA_VERSION), -unstable) + STABLE_STR := -unstable +endif +export BRANCH_VERSION=$(ROMOTE_BRANCH)$(STABLE_STR) When `.git` is not present, will the branch version be `-stable`, i.e., starting with a hyphen? That looks quite strange. Starting with `<major>.<minor>` would be better, and even so if you no longer prints FULL_VERSION.
Yes, without '.git', the version will start with '-', Will the follows be better? ifneq ($(REMOTE_BRANCH),) REMOTE_BRANCH := -"-"$(REMOTE_BRANCH) endif export BRANCH_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(STABLE_STR)$(REMOTE_BRANCH)
That looks better to me. --- Best Regards Junjie Mao
ifdef TARGET_DIR $(warning TARGET_DIR is obsoleted because generated configuration files are now stored in the build directory) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index cd49ae28c..4ba6a9772 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -517,15 +517,16 @@ distclean: PHONY: (VERSION) $(VERSION): $(HV_CONFIG_H) touch $(VERSION) - @if [ "$(BUILD_VERSION)"x = x -o "$(BUILD_TAG)"x = x ];then \ + @if [ "$(BUILD_VERSION)"x = x ];then \ COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\ DIRTY=`git diff-index --name-only HEAD`;\ if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\
- DAILY_TAG=`git tag --merged HEAD|grep "acrn"|tail -n 1`;\ else \ PATCH="$(BUILD_VERSION)"; \ - DAILY_TAG="$(BUILD_TAG)"; \ fi; \ + COMMIT_TAGS=$$(git tag --points-at HEAD|tr -s "\n" " "); \ + COMMIT_TAGS=$$(eval echo $$COMMIT_TAGS);\ Why echoing COMMIT_TAGS here?
Also when there are multiple tags attached to the same commit, is COMMIT_TAGS intended to include ALL of them? Yes, There may be more than one tag in one commit, e.g.( acrn-2022w22.1-180000p, xxx). we want to show all of them. The 'echo' is used for deleting the rear space.
--- Best Regards Junjie Mao
Best Regards Zhangwei
+ COMMIT_TIME=$$(git log -1 --date=format:"%Y-%m-%d %T" -- format=%cd);
+\ TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%F %T"); \
USER="$${USER:-$$(id -u -n)}"; \ if [ x$(CONFIG_RELEASE) = "xy" ];then BUILD_TYPE="REL";else BUILD_TYPE="DBG";fi;\ @@ -535,21 +536,17 @@ $(VERSION): $(HV_CONFIG_H)
echo "" >> $(VERSION); \ echo "#ifndef VERSION_H" >> $(VERSION); \ echo "#define VERSION_H" >> $(VERSION); \ - echo "#define HV_FULL_VERSION "\"$(FULL_VERSION)\""" >> $(VERSION);\
echo "#define HV_API_MAJOR_VERSION $(API_MAJOR_VERSION)U" >> $(VERSION);\
echo "#define HV_API_MINOR_VERSION $(API_MINOR_VERSION)U" >> $(VERSION);\
- echo "#define HV_DAILY_TAG "\""$$DAILY_TAG"\""" >> $(VERSION);\
- echo "#define HV_BUILD_VERSION "\""$$PATCH"\""" >> $(VERSION);\
+ echo "#define HV_BRANCH_VERSION "\"$(BRANCH_VERSION)\""" >> $(VERSION);\
+ echo "#define HV_COMMIT_DIRTY "\""$$PATCH"\""" >> $(VERSION);\
+ echo "#define HV_COMMIT_TAGS "\"$$COMMIT_TAGS\""" >> $(VERSION);\
+ echo "#define HV_COMMIT_TIME "\"$$COMMIT_TIME\""" >> $(VERSION);\
echo "#define HV_BUILD_TYPE "\""$$BUILD_TYPE"\""" >> $(VERSION);\
echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION);\ echo "#define HV_BUILD_SCENARIO "\"$(SCENARIO)\""" >> $(VERSION);\
echo "#define HV_BUILD_BOARD "\"$(BOARD)\""" >> $(VERSION);\ - if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ - echo "#define HV_CONFIG_TOOL \" with acrn-config\"" >> $(VERSION);\
- else \ - echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ - fi;\ echo "#endif" >> $(VERSION)
-include $(C_OBJS:.o=.d) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 84782d045..4d5dbd41b 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -248,13 +248,10 @@ void init_pcpu_post(uint16_t pcpu_id) /* Calibrate TSC Frequency */ calibrate_tsc();
- pr_acrnlog("HV version %s-%s-%s %s (daily tag:%s) %s@%s build by %s%s, start
time %luus", - HV_FULL_VERSION, - HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE,
- HV_DAILY_TAG, HV_BUILD_SCENARIO, HV_BUILD_BOARD,
- HV_BUILD_USER, HV_CONFIG_TOOL, ticks_to_us(start_tick));
- - pr_acrnlog("API version %u.%u", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION);
+ pr_acrnlog("HV version %s-%s-%s %s(tag: %s) %s@%s build by %s, start time %luus",
+ HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY,
+ HV_BUILD_TYPE, HV_COMMIT_TAGS, HV_BUILD_SCENARIO, HV_BUILD_BOARD,
+ HV_BUILD_USER, ticks_to_us(start_tick));
pr_acrnlog("Detect processor: %s", (get_pcpu_info())- model_name);
diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 4a0451fd5..431f8ff51 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -737,10 +737,15 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) static int32_t shell_version(__unused int32_t argc, __unused char **argv) { char temp_str[MAX_STR_SIZE]; + char tag_str[TEMP_STR_SIZE] = "";
- snprintf(temp_str, MAX_STR_SIZE, "HV %s-%s-%s %s (daily tag: %s) %s@%s build
by %s%s\nAPI %u.%u\r\n", - HV_FULL_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_DAILY_TAG,
HV_BUILD_SCENARIO, - HV_BUILD_BOARD, HV_BUILD_USER, HV_CONFIG_TOOL, HV_API_MAJOR_VERSION,
HV_API_MINOR_VERSION); + if(sizeof(HV_COMMIT_TAGS) > 1){ + snprintf(tag_str, TEMP_STR_SIZE, "(tag: %s)", HV_COMMIT_TAGS);
+ tag_str[TEMP_STR_SIZE-1] = '\0'; + } + snprintf(temp_str, MAX_STR_SIZE, "%s-%s-%s %s%s %s@%s build by %s %s\r\n",
+ HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, tag_str,
+ HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, HV_BUILD_TIME);
shell_puts(temp_str);
return 0; -- 2.25.1
|
|
toggle quoted message
Show quoted text
-----Original Message----- From: Mao, Junjie <junjie.mao@...> Sent: Wednesday, November 16, 2022 11:51 AM To: Zhang, Wei6 <wei6.zhang@...>; acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Zou, Terry <terry.zou@...> Subject: RE: [PATCH] hv: change the version format
-----Original Message----- From: Zhang, Wei6 <wei6.zhang@...> Sent: Wednesday, November 16, 2022 11:47 AM To: Mao, Junjie <junjie.mao@...>; acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Zou, Terry <terry.zou@...> Subject: RE: [PATCH] hv: change the version format
-----Original Message----- From: Mao, Junjie <junjie.mao@...> Sent: Wednesday, November 16, 2022 10:45 AM To: Zhang, Wei6 <wei6.zhang@...>; acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Zou, Terry <terry.zou@...> Subject: RE: [PATCH] hv: change the version format
-----Original Message----- From: Zhang, Wei6 <wei6.zhang@...> Sent: Tuesday, November 15, 2022 3:00 PM To: acrn-dev@... Cc: Li, Fei1 <fei1.li@...>; Xie, Nanlin <nanlin.xie@...>; Mao, Junjie <junjie.mao@...>; Zou, Terry <terry.zou@...>; Zhang, Wei6 <wei6.zhang@...> Subject: [PATCH] hv: change the version format
From: Zhang Wei <wei6.zhang@...>
hv version info is used to tell the user when and where the hv is compiled and built, this change will make it easy to read and undersatnd.
It follows bellow format: remote_branch-stable/unstable-acrn-commit_date-commit_id-dirty DBG(tag-current_commit_id) scenario@board build author date. An example can be as: master-unstable-2022-11-14 12:03:51-6d57f8254-dirty DBG scenario3.1@... build by zhangwei 2022-11-15 05:16:05 Another example: release_3.1-stable-2022-09-27 11:15:42-7fad37e02-dirty DBG(tag: v3.1) scenario3.1@... build by zhangwei 2022-11-15 05:53:38
Tracked-On #8303 Signed-off-by: Zhang Wei wei6.zhang@... --- Makefile | 6 ++++++ hypervisor/Makefile | 19 ++++++++----------- hypervisor/arch/x86/cpu.c | 11 ++++------- hypervisor/debug/shell.c | 11 ++++++++--- 4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile index 69e322b34..0ce8e5c5c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,12 @@ ifneq ($(SCM_VERSION),) SCM_VERSION := "-"$(SCM_VERSION) endif export
FULL_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(EXTRA_VERSION
)$(SCM_VE
RSION) It seems you removed all uses of FULL_VERSION in the C code. Also drop this definition if that's really the case.
The FULL_VERSION won't be used in hv. But In the acrn-dm, it is still a part of version.
If necessary, I can replace FULL_VERSION with BRANCH_VERSION and also modify the acrn-dm version, after that FULL_VERSION can be deleted.
Let's use consistent format of versions in all ACRN components.
Ok, I will make acrn-dm and hv consistent in version format. +ROMOTE_BRANCH := $(shell [ -d .git ] && git rev-parse +--abbrev-ref +HEAD) Typo: ROMOTE -> REMOTE
Yes, it's a Typo, I will fix it.
+STABLE_STR := -stable +ifeq ($(EXTRA_VERSION), -unstable) + STABLE_STR := -unstable +endif +export BRANCH_VERSION=$(ROMOTE_BRANCH)$(STABLE_STR) When `.git` is not present, will the branch version be `-stable`, i.e., starting with a hyphen? That looks quite strange. Starting with `<major>.<minor>` would be better, and even so if you no longer
prints FULL_VERSION.
Yes, without '.git', the version will start with '-', Will the follows be better? ifneq ($(REMOTE_BRANCH),) REMOTE_BRANCH := -"-"$(REMOTE_BRANCH) endif export
BRANCH_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(STABLE_STR) $(REMOTE_
BRANCH) That looks better to me.
Yes, a little improvement. --- Best Regards Junjie Mao
Best Regards Zhangwei
ifdef TARGET_DIR $(warning TARGET_DIR is obsoleted because generated configuration files are now stored in the build directory) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index cd49ae28c..4ba6a9772 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -517,15 +517,16 @@ distclean: PHONY: (VERSION) $(VERSION): $(HV_CONFIG_H) touch $(VERSION) - @if [ "$(BUILD_VERSION)"x = x -o "$(BUILD_TAG)"x = x ];then \ + @if [ "$(BUILD_VERSION)"x = x ];then \ COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\ DIRTY=`git diff-index --name-only HEAD`;\ if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\
- DAILY_TAG=`git tag --merged HEAD|grep "acrn"|tail -n 1`;\ else \ PATCH="$(BUILD_VERSION)"; \ - DAILY_TAG="$(BUILD_TAG)"; \ fi; \ + COMMIT_TAGS=$$(git tag --points-at HEAD|tr -s "\n" " "); \ + COMMIT_TAGS=$$(eval echo $$COMMIT_TAGS);\ Why echoing COMMIT_TAGS here?
Also when there are multiple tags attached to the same commit, is COMMIT_TAGS intended to include ALL of them? Yes, There may be more than one tag in one commit, e.g.( acrn-2022w22.1- 180000p, xxx).
we want to show all of them. The 'echo' is used for deleting the rear space.
--- Best Regards Junjie Mao
Best Regards Zhangwei
+ COMMIT_TIME=$$(git log -1 --date=format:"%Y-%m-%d %T" -- format=%cd);
+\ TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%F %T"); \
USER="$${USER:-$$(id -u -n)}"; \ if [ x$(CONFIG_RELEASE) = "xy" ];then BUILD_TYPE="REL";else BUILD_TYPE="DBG";fi;\ @@ -535,21 +536,17 @@ $(VERSION): $(HV_CONFIG_H)
echo "" >> $(VERSION); \ echo "#ifndef VERSION_H" >> $(VERSION); \ echo "#define VERSION_H" >> $(VERSION); \ - echo "#define HV_FULL_VERSION "\"$(FULL_VERSION)\""" >> $(VERSION);\
echo "#define HV_API_MAJOR_VERSION $(API_MAJOR_VERSION)U" >> $(VERSION);\
echo "#define HV_API_MINOR_VERSION $(API_MINOR_VERSION)U" >> $(VERSION);\
- echo "#define HV_DAILY_TAG "\""$$DAILY_TAG"\""" >> $(VERSION);\
- echo "#define HV_BUILD_VERSION "\""$$PATCH"\""" >> $(VERSION);\
+ echo "#define HV_BRANCH_VERSION "\"$(BRANCH_VERSION)\""" >> $(VERSION);\
+ echo "#define HV_COMMIT_DIRTY "\""$$PATCH"\""" >> $(VERSION);\
+ echo "#define HV_COMMIT_TAGS "\"$$COMMIT_TAGS\""" >> $(VERSION);\
+ echo "#define HV_COMMIT_TIME "\"$$COMMIT_TIME\""" >> $(VERSION);\
echo "#define HV_BUILD_TYPE "\""$$BUILD_TYPE"\""" >> $(VERSION);\
echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION);\ echo "#define HV_BUILD_SCENARIO "\"$(SCENARIO)\""" >> $(VERSION);\
echo "#define HV_BUILD_BOARD "\"$(BOARD)\""" >> $(VERSION);\ - if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ - echo "#define HV_CONFIG_TOOL \" with acrn-config\"" >> $(VERSION);\
- else \ - echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ - fi;\ echo "#endif" >> $(VERSION)
-include $(C_OBJS:.o=.d) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 84782d045..4d5dbd41b 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -248,13 +248,10 @@ void init_pcpu_post(uint16_t pcpu_id) /* Calibrate TSC Frequency */ calibrate_tsc();
- pr_acrnlog("HV version %s-%s-%s %s (daily tag:%s) %s@%s build by %s%s, start
time %luus", - HV_FULL_VERSION, - HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE,
- HV_DAILY_TAG, HV_BUILD_SCENARIO, HV_BUILD_BOARD,
- HV_BUILD_USER, HV_CONFIG_TOOL, ticks_to_us(start_tick));
- - pr_acrnlog("API version %u.%u", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION);
+ pr_acrnlog("HV version %s-%s-%s %s(tag: %s) %s@%s build by %s, start time %luus",
+ HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY,
+ HV_BUILD_TYPE, HV_COMMIT_TAGS, HV_BUILD_SCENARIO, HV_BUILD_BOARD,
+ HV_BUILD_USER, ticks_to_us(start_tick));
pr_acrnlog("Detect processor: %s", (get_pcpu_info())- model_name);
diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 4a0451fd5..431f8ff51 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -737,10 +737,15 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) static int32_t shell_version(__unused int32_t argc, __unused char **argv) { char temp_str[MAX_STR_SIZE]; + char tag_str[TEMP_STR_SIZE] = "";
- snprintf(temp_str, MAX_STR_SIZE, "HV %s-%s-%s %s (daily tag: %s) %s@%s build
by %s%s\nAPI %u.%u\r\n", - HV_FULL_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_DAILY_TAG,
HV_BUILD_SCENARIO, - HV_BUILD_BOARD, HV_BUILD_USER, HV_CONFIG_TOOL, HV_API_MAJOR_VERSION,
HV_API_MINOR_VERSION); + if(sizeof(HV_COMMIT_TAGS) > 1){ + snprintf(tag_str, TEMP_STR_SIZE, "(tag: %s)", HV_COMMIT_TAGS);
+ tag_str[TEMP_STR_SIZE-1] = '\0'; + } + snprintf(temp_str, MAX_STR_SIZE, "%s-%s-%s %s%s %s@%s build by %s %s\r\n",
+ HV_BRANCH_VERSION, HV_COMMIT_TIME, HV_COMMIT_DIRTY, HV_BUILD_TYPE, tag_str,
+ HV_BUILD_SCENARIO, HV_BUILD_BOARD, HV_BUILD_USER, HV_BUILD_TIME);
shell_puts(temp_str);
return 0; -- 2.25.1
|
|