mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 04:41:36 +08:00
Create NuttX git hash and tag
This commit is contained in:
committed by
Lorenz Meier
parent
f66f024e3a
commit
95fd2cd184
@@ -3,6 +3,7 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import re
|
||||||
|
|
||||||
filename = sys.argv[1]
|
filename = sys.argv[1]
|
||||||
|
|
||||||
@@ -16,6 +17,11 @@ git_tag = subprocess.check_output('git describe --always --tags'.split(),
|
|||||||
stderr=subprocess.STDOUT).decode('utf-8').strip()
|
stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||||
git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(),
|
git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(),
|
||||||
stderr=subprocess.STDOUT).decode('utf-8').strip()
|
stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||||
|
nuttx_git_tag = subprocess.check_output('git describe --always --tags'.split(),
|
||||||
|
cwd='NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip().replace("nuttx-","v")
|
||||||
|
nuttx_git_tag = re.sub('-.*','.0',nuttx_git_tag)
|
||||||
|
nuttx_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(),
|
||||||
|
cwd='NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||||
git_version_short = git_version[0:16]
|
git_version_short = git_version[0:16]
|
||||||
|
|
||||||
# Generate the header file content
|
# Generate the header file content
|
||||||
@@ -26,9 +32,13 @@ header = """
|
|||||||
#define PX4_GIT_VERSION_STR "{git_version}"
|
#define PX4_GIT_VERSION_STR "{git_version}"
|
||||||
#define PX4_GIT_VERSION_BINARY 0x{git_version_short}
|
#define PX4_GIT_VERSION_BINARY 0x{git_version_short}
|
||||||
#define PX4_GIT_TAG_STR "{git_tag}"
|
#define PX4_GIT_TAG_STR "{git_tag}"
|
||||||
|
#define NUTTX_GIT_VERSION_STR "{nuttx_git_version}"
|
||||||
|
#define NUTTX_GIT_TAG_STR "{nuttx_git_tag}"
|
||||||
""".format(git_tag=git_tag,
|
""".format(git_tag=git_tag,
|
||||||
git_version=git_version,
|
git_version=git_version,
|
||||||
git_version_short=git_version_short)
|
git_version_short=git_version_short,
|
||||||
|
nuttx_git_version=nuttx_git_version,
|
||||||
|
nuttx_git_tag=nuttx_git_tag)
|
||||||
|
|
||||||
if old_header != header:
|
if old_header != header:
|
||||||
print('Updating header {}'.format(sys.argv[1]))
|
print('Updating header {}'.format(sys.argv[1]))
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ uint32_t px4_os_version(void)
|
|||||||
#elif defined(__PX4_QURT)
|
#elif defined(__PX4_QURT)
|
||||||
return 0; //TODO: implement version for QuRT
|
return 0; //TODO: implement version for QuRT
|
||||||
#elif defined(__PX4_NUTTX)
|
#elif defined(__PX4_NUTTX)
|
||||||
return version_tag_to_number("v7.18.0"); //TODO: get correct version
|
return version_tag_to_number(NUTTX_GIT_TAG_STR);
|
||||||
#else
|
#else
|
||||||
# error "px4_os_version not implemented for current OS"
|
# error "px4_os_version not implemented for current OS"
|
||||||
#endif
|
#endif
|
||||||
@@ -199,7 +199,7 @@ uint32_t px4_os_version(void)
|
|||||||
const char *px4_os_version_string(void)
|
const char *px4_os_version_string(void)
|
||||||
{
|
{
|
||||||
#if defined(__PX4_NUTTX)
|
#if defined(__PX4_NUTTX)
|
||||||
return NULL; //TODO: get NuttX git tag as string
|
return NUTTX_GIT_VERSION_STR;
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user