mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
version library add ECL
This commit is contained in:
parent
2a3d66cf45
commit
d21cf7123e
@ -113,7 +113,7 @@ include(common/px4_git)
|
||||
|
||||
execute_process(
|
||||
COMMAND git describe --always --tags
|
||||
OUTPUT_VARIABLE git_tag
|
||||
OUTPUT_VARIABLE PX4_GIT_TAG
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
||||
)
|
||||
@ -166,7 +166,7 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebIn
|
||||
|
||||
#=============================================================================
|
||||
|
||||
message(STATUS "PX4 VERSION: ${git_tag}")
|
||||
message(STATUS "PX4 VERSION: ${PX4_GIT_TAG}")
|
||||
message(STATUS "CONFIG: ${CONFIG}")
|
||||
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
@ -448,14 +448,14 @@ endif()
|
||||
# Important to having packaging at end of cmake file.
|
||||
#
|
||||
set(CPACK_PACKAGE_NAME ${PROJECT_NAME}-${CONFIG})
|
||||
set(CPACK_PACKAGE_VERSION ${git_version})
|
||||
set(CPACK_PACKAGE_VERSION ${PX4_GIT_TAG})
|
||||
set(CPACK_PACKAGE_CONTACT ${package-contact})
|
||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
|
||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "The PX4 Pro autopilot.")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CONFIG}-${git_tag}")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${git_version}")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CONFIG}-${PX4_GIT_TAG}")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PX4_GIT_TAG}")
|
||||
set(CPACK_SOURCE_GENERATOR "ZIP;TBZ2")
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "")
|
||||
set(CPACK_SET_DESTDIR "OFF")
|
||||
|
||||
@ -51,19 +51,23 @@ if(NOT IS_DIRECTORY "${git_dir_path}")
|
||||
message(FATAL_ERROR "${git_dir_path} is not a directory")
|
||||
endif()
|
||||
|
||||
set(px4_git_ver_header ${PX4_BINARY_DIR}/build_git_version.h)
|
||||
set(px4_git_ver_header ${CMAKE_CURRENT_BINARY_DIR}/build_git_version.h)
|
||||
add_custom_command(OUTPUT ${px4_git_ver_header}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/px_update_git_header.py ${px4_git_ver_header} > ${PX4_BINARY_DIR}/git_header.log
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/px_update_git_header.py ${px4_git_ver_header} > ${CMAKE_CURRENT_BINARY_DIR}/git_header.log
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/px_update_git_header.py
|
||||
${git_dir_path}/HEAD
|
||||
${git_dir_path}/index
|
||||
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
||||
COMMENT "Generating git hash header"
|
||||
COMMENT "Generating git version header"
|
||||
)
|
||||
set_source_files_properties(${px4_git_ver_header} PROPERTIES GENERATED TRUE)
|
||||
add_custom_target(ver_gen ALL DEPENDS ${px4_git_ver_header})
|
||||
|
||||
add_library(git_ver INTERFACE)
|
||||
target_include_directories(git_ver INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_dependencies(git_ver ver_gen)
|
||||
|
||||
# The URL for the elf file for crash logging
|
||||
if (DEFINED ENV{BUILD_URI})
|
||||
set(BUILD_URI $ENV{BUILD_URI})
|
||||
@ -71,6 +75,7 @@ else()
|
||||
set(BUILD_URI "localhost")
|
||||
endif()
|
||||
|
||||
add_definitions(-DBUILD_URI=${BUILD_URI})
|
||||
|
||||
px4_add_library(version version.c ${px4_git_ver_header})
|
||||
add_library(version version.c)
|
||||
target_compile_definitions(version PRIVATE BUILD_URI=${BUILD_URI})
|
||||
target_link_libraries(version PRIVATE git_ver)
|
||||
add_dependencies(version prebuild_targets)
|
||||
|
||||
@ -14,6 +14,16 @@ try:
|
||||
except:
|
||||
old_header = ''
|
||||
|
||||
|
||||
# Generate the header file content
|
||||
header = """
|
||||
/* Auto Magically Generated file */
|
||||
/* Do not edit! */
|
||||
#pragma once
|
||||
"""
|
||||
|
||||
|
||||
# PX4
|
||||
git_tag = subprocess.check_output('git describe --always --tags --dirty'.split(),
|
||||
stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||
git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(),
|
||||
@ -25,48 +35,64 @@ except:
|
||||
git_branch_name = ''
|
||||
git_version_short = git_version[0:16]
|
||||
|
||||
if (os.path.exists('platforms/nuttx/NuttX/nuttx')):
|
||||
nuttx_git_tag = subprocess.check_output('git describe --always --tags --match nuttx-* --dirty'.split(),
|
||||
cwd='platforms/nuttx/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='platforms/nuttx/NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||
nuttx_git_version_short = nuttx_git_version[0:16]
|
||||
else:
|
||||
nuttx_git_version = "0000000"
|
||||
nuttx_git_version_short = "0000000"
|
||||
nuttx_git_tag = "v0.0.0"
|
||||
|
||||
mavlink_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(),
|
||||
cwd='mavlink/include/mavlink/v2.0', stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||
mavlink_git_version_short = mavlink_git_version[0:16]
|
||||
|
||||
# Generate the header file content
|
||||
header = """
|
||||
/* Auto Magically Generated file */
|
||||
/* Do not edit! */
|
||||
#pragma once
|
||||
header += """
|
||||
#define PX4_GIT_VERSION_STR "{git_version}"
|
||||
#define PX4_GIT_VERSION_BINARY 0x{git_version_short}
|
||||
#define PX4_GIT_TAG_STR "{git_tag}"
|
||||
#define PX4_GIT_BRANCH_NAME "{git_branch_name}"
|
||||
|
||||
#define NUTTX_GIT_VERSION_STR "{nuttx_git_version}"
|
||||
#define NUTTX_GIT_VERSION_BINARY 0x{nuttx_git_version_short}
|
||||
#define NUTTX_GIT_TAG_STR "{nuttx_git_tag}"
|
||||
|
||||
#define MAVLINK_LIB_GIT_VERSION_STR "{mavlink_git_version}"
|
||||
#define MAVLINK_LIB_GIT_VERSION_BINARY 0x{mavlink_git_version_short}
|
||||
""".format(git_tag=git_tag,
|
||||
git_version=git_version,
|
||||
git_version_short=git_version_short,
|
||||
git_branch_name=git_branch_name,
|
||||
nuttx_git_version=nuttx_git_version,
|
||||
nuttx_git_version_short=nuttx_git_version_short,
|
||||
nuttx_git_tag=nuttx_git_tag,
|
||||
mavlink_git_version=mavlink_git_version,
|
||||
git_branch_name=git_branch_name)
|
||||
|
||||
|
||||
# ECL
|
||||
if (os.path.exists('src/lib/ecl/.git')):
|
||||
ecl_git_tag = subprocess.check_output('git describe --always --tags --dirty'.split(),
|
||||
cwd='src/lib/ecl', stderr=subprocess.STDOUT).decode('utf-8')
|
||||
|
||||
ecl_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(),
|
||||
cwd='src/lib/ecl', stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||
ecl_git_version_short = ecl_git_version[0:16]
|
||||
|
||||
header += """
|
||||
#define ECL_LIB_GIT_VERSION_STR "{ecl_git_version}"
|
||||
#define ECL_LIB_GIT_VERSION_BINARY 0x{ecl_git_version_short}
|
||||
""".format(ecl_git_version=ecl_git_version,
|
||||
ecl_git_version_short=ecl_git_version_short)
|
||||
|
||||
|
||||
# Mavlink
|
||||
if (os.path.exists('mavlink/include/mavlink/v2.0/.git')):
|
||||
mavlink_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(),
|
||||
cwd='mavlink/include/mavlink/v2.0', stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||
mavlink_git_version_short = mavlink_git_version[0:16]
|
||||
|
||||
header += """
|
||||
#define MAVLINK_LIB_GIT_VERSION_STR "{mavlink_git_version}"
|
||||
#define MAVLINK_LIB_GIT_VERSION_BINARY 0x{mavlink_git_version_short}
|
||||
""".format(mavlink_git_version=mavlink_git_version,
|
||||
mavlink_git_version_short=mavlink_git_version_short)
|
||||
|
||||
|
||||
# NuttX
|
||||
if (os.path.exists('platforms/nuttx/NuttX/nuttx/.git')):
|
||||
nuttx_git_tag = subprocess.check_output('git describe --always --tags --match nuttx-* --dirty'.split(),
|
||||
cwd='platforms/nuttx/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='platforms/nuttx/NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||
nuttx_git_version_short = nuttx_git_version[0:16]
|
||||
|
||||
header += """
|
||||
#define NUTTX_GIT_VERSION_STR "{nuttx_git_version}"
|
||||
#define NUTTX_GIT_VERSION_BINARY 0x{nuttx_git_version_short}
|
||||
#define NUTTX_GIT_TAG_STR "{nuttx_git_tag}"
|
||||
""".format(nuttx_git_version=nuttx_git_version,
|
||||
nuttx_git_version_short=nuttx_git_version_short,
|
||||
nuttx_git_tag=nuttx_git_tag)
|
||||
|
||||
|
||||
if old_header != header:
|
||||
print('Updating header {}'.format(sys.argv[1]))
|
||||
fp_header = open(filename, 'w')
|
||||
|
||||
@ -340,14 +340,28 @@ uint64_t px4_firmware_version_binary(void)
|
||||
return PX4_GIT_VERSION_BINARY;
|
||||
}
|
||||
|
||||
const char *px4_ecl_lib_version_string(void)
|
||||
{
|
||||
#ifdef ECL_LIB_GIT_VERSION_STRING
|
||||
return ECL_LIB_GIT_VERSION_STRING;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MAVLINK_LIB_GIT_VERSION_BINARY
|
||||
uint64_t px4_mavlink_lib_version_binary(void)
|
||||
{
|
||||
return MAVLINK_LIB_GIT_VERSION_BINARY;
|
||||
}
|
||||
#endif /* MAVLINK_LIB_GIT_VERSION_BINARY */
|
||||
|
||||
uint64_t px4_os_version_binary(void)
|
||||
{
|
||||
//TODO: get NuttX version via git tag
|
||||
#ifdef NUTTX_GIT_VERSION_BINARY
|
||||
return NUTTX_GIT_VERSION_BINARY;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -177,12 +177,16 @@ __EXPORT const char *px4_firmware_version_string(void);
|
||||
*/
|
||||
__EXPORT const char *px4_firmware_git_branch(void);
|
||||
|
||||
|
||||
/**
|
||||
* Firmware version in binary form (first part of the git tag)
|
||||
*/
|
||||
__EXPORT uint64_t px4_firmware_version_binary(void);
|
||||
|
||||
/**
|
||||
* ECL lib version as human readable string (git tag)
|
||||
*/
|
||||
__EXPORT const char *px4_ecl_lib_version_string(void);
|
||||
|
||||
/**
|
||||
* MAVLink lib version in binary form (first part of the git tag)
|
||||
*/
|
||||
|
||||
@ -1866,6 +1866,12 @@ void Logger::write_version()
|
||||
write_info("sys_toolchain", px4_toolchain_name());
|
||||
write_info("sys_toolchain_ver", px4_toolchain_version());
|
||||
|
||||
const char* ecl_version = px4_ecl_lib_version_string();
|
||||
|
||||
if (ecl_version && ecl_version[0]) {
|
||||
write_info("sys_lib_ecl_ver", ecl_version);
|
||||
}
|
||||
|
||||
char revision = 'U';
|
||||
const char *chip_name = nullptr;
|
||||
|
||||
|
||||
@ -66,4 +66,5 @@ px4_add_module(
|
||||
conversion
|
||||
git_ecl
|
||||
ecl_geo
|
||||
version
|
||||
)
|
||||
|
||||
@ -38,4 +38,5 @@ px4_add_module(
|
||||
SRCS
|
||||
hardfault_log.c
|
||||
DEPENDS
|
||||
version
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user