Skip to content

Commit

Permalink
Merge branch 'main_wjx' into 'main'
Browse files Browse the repository at this point in the history
fix MX3SDK-1577 ver display

Closes MX3SDK-1577

See merge request canmv/k230/superproject_k230_rtsmart!2
  • Loading branch information
kendryte747 committed Oct 21, 2024
2 parents 7a99316 + 34a1b82 commit c7adb89
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rtsmart/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ endif
mpp: .mpp_built

kernel: .parse_config
@$(SDK_SRC_ROOT_DIR)/tools/gen_verinfo_h.sh $(SDK_RTSMART_SRC_DIR)/rtsmart/kernel/bsp/maix3/applications/sdk_version.h
@export RTT_CC=gcc; \
export RTT_CC_PREFIX=$(CROSS_COMPILE_PREFIX); \
export RTT_EXEC_PATH=$(CROSS_COMPILE_DIR); \
Expand Down
48 changes: 48 additions & 0 deletions tools/gen_verinfo_h.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

source ${SDK_SRC_ROOT_DIR}/.config


parse_nncase_version()
{
# Extract the version from the header file
VERSION=$(grep -oP '(?<=#define NNCASE_VERSION ")[^"]*' ${SDK_RTSMART_SRC_DIR}/libs/nncase/riscv64/nncase/include/nncase/version.h)

echo "$VERSION"
}
gen_version_file()
{
local version_file="$1"

local nncase_version=$(parse_nncase_version)
local sdk_ver="unknown"
local canmv_ver="unknown"

pushd "${SDK_SRC_ROOT_DIR}" > /dev/null
local commitid="unknown"
local last_tag="unknown"
git rev-parse --short HEAD && commitid=$(git rev-parse --short HEAD)
git describe --tags `git rev-list --tags --max-count=1` && last_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
git describe --tags --exact-match && last_tag=$(git describe --tags --exact-match)
sdk_ver="${last_tag}-$(date "+%Y%m%d-%H%M%S")-$(whoami)-$(hostname)-${commitid}"
popd > /dev/null


if [ "$CONFIG_SDK_ENABLE_CANMV" = "y" ]; then
pushd "${SDK_CANMV_SRC_DIR}" > /dev/null
local commitid="unknown"
local last_tag="unknown"
git rev-parse --short HEAD && commitid=$(git rev-parse --short HEAD)
git describe --tags `git rev-list --tags --max-count=1` && last_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
git describe --tags --exact-match && last_tag=$(git describe --tags --exact-match)
canmv_ver="${last_tag}-$(date "+%Y%m%d-%H%M%S")-$(whoami)-$(hostname)-${commitid}"
popd > /dev/null
fi
echo -e "#ifndef __VER___INFO___H__\n#define __VER___INFO___H__\n" >${version_file}
echo "#define SDK_VERSION_ \"${sdk_ver}\"" >> ${version_file}
echo "#define NNCASE_VERSION_ \"${nncase_version}\"" >> ${version_file}
[ "$CONFIG_SDK_ENABLE_CANMV" = "y" ] && echo "#define CANMV_VERSION_ \"${canmv_ver}\"" >> ${version_file}
echo -e "#endif \n" >>${version_file}
#cat $repo_info_file >> ${version_file}
}
gen_version_file $1

0 comments on commit c7adb89

Please sign in to comment.