mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 04:03:34 +08:00
NuttX upgrade cmake wrapper (#7873)
* NuttX cmake * px4_macros:Pass the stringified predicate as second arg to static assert CC_ASSERT mapes to the c++ static_assert or provides the same funtionality for c via the other macros. The c++ static assert takes 2 argumants the prdicate and a message. This fixes the lacking second argument. * Updated nuttx and apps submodule to upstream nuttx 7.21+==master This is the latest uptake of upstream nuttx and apps. * ROMFS generate with xxd instead of objcopy * delete nuttx-patches * NuttX update submodules to latest px4_nuttx-master * fix nuttx apps and board dependency * docker_run update to latest container 2017-08-29 * cmake ROMFS portable sed usage * NuttX update submodules to latest px4_nuttx-master
This commit is contained in:
@@ -30,6 +30,38 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# check if px4 source is a git repo
|
||||
if (EXISTS ${PX4_SOURCE_DIR}/.git)
|
||||
if (IS_DIRECTORY ${PX4_SOURCE_DIR}/.git)
|
||||
# standard git repo
|
||||
set(git_dir_path ${PX4_SOURCE_DIR}/.git)
|
||||
else()
|
||||
# git submodule
|
||||
file(READ ${PX4_SOURCE_DIR}/.git git_dir_path)
|
||||
string(STRIP ${git_dir_path} git_dir_path)
|
||||
string(REPLACE "gitdir: " "" git_dir_path ${git_dir_path})
|
||||
get_filename_component(git_dir_path ${git_dir_path} ABSOLUTE)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "is not a git repository")
|
||||
endif()
|
||||
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)
|
||||
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
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/px_update_git_header.py
|
||||
${git_dir_path}/HEAD
|
||||
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
||||
COMMENT "Generating git hash header"
|
||||
)
|
||||
set_source_files_properties(${px4_git_ver_header} PROPERTIES GENERATED TRUE)
|
||||
add_custom_target(ver_gen ALL DEPENDS ${px4_git_ver_header})
|
||||
|
||||
px4_add_module(
|
||||
MODULE lib__version
|
||||
COMPILE_FLAGS
|
||||
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
filename = sys.argv[1]
|
||||
|
||||
try:
|
||||
fp_header = open(filename, 'r')
|
||||
old_header = fp_header.read()
|
||||
except:
|
||||
old_header = ''
|
||||
|
||||
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(),
|
||||
stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||
try:
|
||||
git_branch_name = subprocess.check_output('git symbolic-ref -q --short HEAD'.split(),
|
||||
stderr=subprocess.STDOUT).decode('utf-8').strip()
|
||||
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
|
||||
#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,
|
||||
mavlink_git_version_short=mavlink_git_version_short)
|
||||
|
||||
if old_header != header:
|
||||
print('Updating header {}'.format(sys.argv[1]))
|
||||
fp_header = open(filename, 'w')
|
||||
fp_header.write(header)
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#include "build_git_version.h" //generated from build_git_version.h.in
|
||||
#include "build_git_version.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user