mavlink: cmake generate mavlink headers at build time

- mavlink/mavlink is now directly included as a submodule instead of the generated mavlink/c_library_v2
 - this also switches to mavlink development.xml by default
This commit is contained in:
Jacob Crabill 2021-11-05 20:01:38 -07:00 committed by GitHub
parent 88489ae8bd
commit 5969508fa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 71 additions and 32 deletions

8
.gitmodules vendored
View File

@ -1,6 +1,6 @@
[submodule "mavlink/include/mavlink/v2.0"]
path = mavlink/include/mavlink/v2.0
url = https://github.com/mavlink/c_library_v2.git
[submodule "src/modules/mavlink/mavlink"]
path = src/modules/mavlink/mavlink
url = https://github.com/mavlink/mavlink.git
branch = master
[submodule "src/drivers/uavcan/libuavcan"]
path = src/drivers/uavcan/libuavcan
@ -65,7 +65,7 @@
url = https://github.com/mavlink/libevents.git
[submodule "Tools/simulation-ignition"]
path = Tools/simulation-ignition
url = https://github.com/Auterion/px4-simulation-ignition.git
url = https://github.com/PX4/px4-simulation-ignition.git
[submodule "src/lib/crypto/libtomcrypt"]
path = src/lib/crypto/libtomcrypt
url = https://github.com/PX4/libtomcrypt.git

View File

@ -21,6 +21,7 @@ exec find boards msg src platforms test \
-path src/lib/parameters/uthash -prune -o \
-path src/modules/ekf2/EKF -prune -o \
-path src/modules/gyro_fft/CMSIS_5 -prune -o \
-path src/modules/mavlink/mavlink -prune -o \
-path src/modules/micrortps_bridge/micro-CDR -prune -o \
-path src/modules/micrortps_bridge/microRTPS_client -prune -o \
-path test/mavsdk_tests/catch2 -prune -o \

@ -1 +1 @@
Subproject commit 7c2c623da9f5dcb3f01d32830af1a2ed958de363
Subproject commit ea9b6cb5b93365928190864a6592c0a280e101ea

@ -1 +1 @@
Subproject commit e070c50d591541d440510b65c9da5cad1db5aa9a
Subproject commit 68de2cc63ded9a0d6641d45e9eb3ed2b43454cba

View File

@ -6,6 +6,7 @@ empy>=3.3
jinja2>=2.8
jsonschema
kconfiglib
lxml
matplotlib>=3.0.*
numpy>=1.13
nunavut>=1.1.0

View File

@ -86,6 +86,8 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i
gdb \
git \
lcov \
libxml2-dev \
libxml2-utils \
make \
ninja-build \
python3 \

@ -1 +1 @@
Subproject commit e78ad94a4f41bbc202fd7fc1acb728b09cb1dbaf
Subproject commit 0ea4dbe2c3dac84f5927a59b1caf5e5561cf942e

@ -1 +1 @@
Subproject commit d8366bf2389eae6106d1dbfaac72ebfdf23a5d2d
Subproject commit 1c8c9197103e746a21f2d2d2c844dd2f7e2b036b

View File

@ -125,7 +125,7 @@ function(px4_add_module)
# as well as interface include and libraries
foreach(dep ${DEPENDS})
get_target_property(dep_type ${dep} TYPE)
if (${dep_type} STREQUAL "STATIC_LIBRARY")
if((${dep_type} STREQUAL "STATIC_LIBRARY") OR (${dep_type} STREQUAL "INTERFACE_LIBRARY"))
target_link_libraries(${MODULE}_original PRIVATE ${dep})
else()
add_dependencies(${MODULE}_original ${dep})
@ -205,7 +205,7 @@ function(px4_add_module)
# as well as interface include and libraries
foreach(dep ${DEPENDS})
get_target_property(dep_type ${dep} TYPE)
if (${dep_type} STREQUAL "STATIC_LIBRARY")
if((${dep_type} STREQUAL "STATIC_LIBRARY") OR (${dep_type} STREQUAL "INTERFACE_LIBRARY"))
target_link_libraries(${MODULE} PRIVATE ${dep})
else()
add_dependencies(${MODULE} ${dep})

@ -1 +0,0 @@
Subproject commit 5571ffbcd67e19ee6c6301fe13712856906525c2

View File

@ -135,9 +135,9 @@ if (os.path.exists('src/lib/ecl/.git')):
# Mavlink
if (os.path.exists('mavlink/include/mavlink/v2.0/.git')):
if (os.path.exists('src/modules/mavlink/mavlink/.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()
cwd='src/modules/mavlink/mavlink', stderr=subprocess.STDOUT).decode('utf-8').strip()
mavlink_git_version_short = mavlink_git_version[0:16]
header += f"""

View File

@ -1,6 +1,6 @@
############################################################################
#
# Copyright (c) 2015-2017 PX4 Development Team. All rights reserved.
# Copyright (c) 2015-2021 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@ -31,18 +31,51 @@
#
############################################################################
px4_add_git_submodule(TARGET git_mavlink_v2 PATH "${PX4_SOURCE_DIR}/mavlink/include/mavlink/v2.0")
set(MAVLINK_DIALECT "development") # standard, development, etc
# force mavlink dialect to standard if flash constrained
if(px4_constrained_flash_build)
set(MAVLINK_DIALECT "standard")
endif()
set(MAVLINK_GIT_DIR "${CMAKE_CURRENT_LIST_DIR}/mavlink")
set(MAVLINK_LIBRARY_DIR "${CMAKE_BINARY_DIR}/mavlink")
file(RELATIVE_PATH MAVLINK_GIT_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${MAVLINK_GIT_DIR})
px4_add_git_submodule(TARGET git_mavlink_v2 PATH "${MAVLINK_GIT_DIR}")
add_custom_command(
OUTPUT ${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT}/${MAVLINK_DIALECT}.h
COMMAND
${PYTHON_EXECUTABLE} ${MAVLINK_GIT_DIR}/pymavlink/tools/mavgen.py
--lang C --wire-protocol 2.0
#--no-validate
#--strict-units
--output ${MAVLINK_LIBRARY_DIR}
${MAVLINK_GIT_DIR}/message_definitions/v1.0/${MAVLINK_DIALECT}.xml
DEPENDS
git_mavlink_v2
${MAVLINK_GIT_DIR}/pymavlink/tools/mavgen.py
${MAVLINK_GIT_DIR}/message_definitions/v1.0/${MAVLINK_DIALECT}.xml
COMMENT "Generating Mavlink ${MAVLINK_DIALECT}: ${MAVLINK_GIT_DIR_RELATIVE}/message_definitions/v1.0/${MAVLINK_DIALECT}.xml"
USES_TERMINAL
)
add_custom_target(mavlink_c_generate DEPENDS ${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT}/${MAVLINK_DIALECT}.h)
# mavlink header only library
add_library(mavlink_c INTERFACE)
target_sources(mavlink_c INTERFACE ${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT}/${MAVLINK_DIALECT}.h)
set_source_files_properties(${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT}/${MAVLINK_DIALECT}.h PROPERTIES GENERATED true)
target_include_directories(mavlink_c INTERFACE ${MAVLINK_LIBRARY_DIR} ${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT})
target_compile_options(mavlink_c INTERFACE -Wno-address-of-packed-member -Wno-cast-align)
px4_add_module(
MODULE modules__mavlink
MAIN mavlink
COMPILE_FLAGS
-Wno-cast-align # TODO: fix and enable
-Wno-address-of-packed-member # TODO: fix in c_library_v2
-Wno-enum-compare # ROTATION <-> MAV_SENSOR_ROTATION
#-DDEBUG_BUILD
INCLUDES
${PX4_SOURCE_DIR}/mavlink/include/mavlink
SRCS
mavlink.c
mavlink_command_sender.cpp
@ -70,9 +103,9 @@ px4_add_module(
drivers_barometer
drivers_gyroscope
drivers_magnetometer
git_mavlink_v2
conversion
geo
mavlink_c
version
UNITY_BUILD
)

@ -0,0 +1 @@
Subproject commit 3718ee300bef7a8e7a25314e25e03c11d9f0b180

View File

@ -61,7 +61,7 @@
# define MAVLINK_COMM_5 static_cast<mavlink_channel_t>(5)
#endif
#include <v2.0/mavlink_types.h>
#include <mavlink_types.h>
#include <unistd.h>
__BEGIN_DECLS
@ -92,7 +92,7 @@ void mavlink_end_uart_send(mavlink_channel_t chan, int length);
extern mavlink_status_t *mavlink_get_channel_status(uint8_t chan);
extern mavlink_message_t *mavlink_get_channel_buffer(uint8_t chan);
#include <v2.0/standard/mavlink.h>
#include <mavlink.h>
__END_DECLS

View File

@ -48,7 +48,7 @@
#ifndef MAVLINK_FTP_UNIT_TEST
#include "mavlink_main.h"
#else
#include <v2.0/standard/mavlink.h>
#include <mavlink.h>
#endif
using namespace time_literals;

View File

@ -46,7 +46,7 @@
#ifndef MAVLINK_FTP_UNIT_TEST
#include "mavlink_bridge_header.h"
#else
#include <v2.0/standard/mavlink.h>
#include <mavlink.h>
#endif
class MavlinkFtpTest;

View File

@ -31,12 +31,13 @@
#
############################################################################
include_directories(${PX4_SOURCE_DIR}/mavlink/include/mavlink)
px4_add_module(
MODULE modules__mavlink__mavlink_tests
MAIN mavlink_tests
STACK_MAIN 8192
INCLUDES
${CMAKE_BINARY_DIR}/mavlink
${CMAKE_BINARY_DIR}/mavlink/common
COMPILE_FLAGS
-DMAVLINK_FTP_UNIT_TEST
#-DMAVLINK_FTP_DEBUG

View File

@ -40,7 +40,7 @@
#ifndef MAVLINK_FTP_UNIT_TEST
#include "../mavlink_bridge_header.h"
#else
#include <v2.0/standard/mavlink.h>
#include <mavlink.h>
#endif
#include "../mavlink_ftp.h"

View File

@ -55,12 +55,13 @@ px4_add_module(
-Wno-cast-align
-Wno-address-of-packed-member # TODO: fix in c_library_v2
INCLUDES
${PX4_SOURCE_DIR}/mavlink/include/mavlink
${CMAKE_BINARY_DIR}/mavlink
${CMAKE_BINARY_DIR}/mavlink/development
SRCS
simulator.cpp
simulator_mavlink.cpp
DEPENDS
git_mavlink_v2
mavlink_c_generate
conversion
geo
drivers_accelerometer
@ -68,6 +69,6 @@ px4_add_module(
drivers_gyroscope
drivers_magnetometer
)
target_include_directories(modules__simulator INTERFACE ${PX4_SOURCE_DIR}/mavlink/include/mavlink)
target_include_directories(modules__simulator INTERFACE ${CMAKE_BINARY_DIR}/mavlink)
add_subdirectory(battery_simulator)

View File

@ -76,8 +76,8 @@
#include <random>
#include <v2.0/common/mavlink.h>
#include <v2.0/mavlink_types.h>
#include <mavlink.h>
#include <mavlink_types.h>
using namespace time_literals;