mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
Fix build when px4 is a submodule (#7006)
* Fix build when px4 is a submodule * Check if submodule directory exists. * Fix submodule directory reading
This commit is contained in:
@@ -986,10 +986,34 @@ function(px4_create_git_hash_header)
|
||||
|
||||
set(px4_git_ver_header ${PX4_BINARY_DIR}/build_git_version.h)
|
||||
|
||||
# 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(deps
|
||||
${PX4_SOURCE_DIR}/Tools/px_update_git_header.py
|
||||
${git_dir_path}/index
|
||||
${git_dir_path}/HEAD)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${px4_git_ver_header}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_update_git_header.py ${px4_git_ver_header} > ${PX4_BINARY_DIR}/git_header.log
|
||||
DEPENDS ${PX4_SOURCE_DIR}/Tools/px_update_git_header.py ${PX4_SOURCE_DIR}/.git/index ${PX4_SOURCE_DIR}/.git/HEAD
|
||||
DEPENDS ${deps}
|
||||
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
||||
COMMENT "Generating git hash header"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user