diff --git a/.github/workflows/deploy_all.yml b/.github/workflows/deploy_all.yml index 9fdbc81482..18480ac036 100644 --- a/.github/workflows/deploy_all.yml +++ b/.github/workflows/deploy_all.yml @@ -35,11 +35,11 @@ jobs: - name: parameter & events metadata run: | - make ${{matrix.target}} ver_gen events_json + make ${{matrix.target}} ver_gen events_json actuators_json ./src/lib/version/get_git_tag_or_branch_version.sh build/${{ matrix.target }} >> $GITHUB_ENV cd build/${{ matrix.target }} mkdir _metadata || true - cp parameters.* events/*.xz _metadata + cp parameters.* events/*.xz actuators.json* _metadata - uses: jakejarvis/s3-sync-action@master with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a6c30cd56..bca9b38eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -423,6 +423,8 @@ endforeach() # add events lib after modules and libs as it needs to know all source files (PX4_SRC_FILES) add_subdirectory(src/lib/events EXCLUDE_FROM_ALL) +# metadata needs PX4_MODULE_CONFIG_FILES +add_subdirectory(src/lib/metadata EXCLUDE_FROM_ALL) # must be the last module before firmware add_subdirectory(src/lib/parameters EXCLUDE_FROM_ALL) diff --git a/cmake/kconfig.cmake b/cmake/kconfig.cmake index 0918c6e84e..ef555a5fd5 100644 --- a/cmake/kconfig.cmake +++ b/cmake/kconfig.cmake @@ -194,10 +194,12 @@ if(EXISTS ${BOARD_DEFCONFIG}) if (NOT CONSTRAINED_FLASH AND NOT EXTERNAL_METADATA AND NOT ${PX4_BOARD_LABEL} STREQUAL "test") list(APPEND romfs_extra_files ${PX4_BINARY_DIR}/parameters.json.xz - ${PX4_BINARY_DIR}/events/all_events.json.xz) + ${PX4_BINARY_DIR}/events/all_events.json.xz + ${PX4_BINARY_DIR}/actuators.json.xz) list(APPEND romfs_extra_dependencies parameters_xml - events_json) + events_json + actuators_json) endif() list(APPEND romfs_extra_files ${PX4_BINARY_DIR}/component_general.json.xz) list(APPEND romfs_extra_dependencies component_general_json) diff --git a/src/lib/component_information/CMakeLists.txt b/src/lib/component_information/CMakeLists.txt index 9e40d72909..6d0b62be3d 100644 --- a/src/lib/component_information/CMakeLists.txt +++ b/src/lib/component_information/CMakeLists.txt @@ -37,6 +37,7 @@ # 2: COMP_METADATA_TYPE_COMMANDS # 3: COMP_METADATA_TYPE_PERIPHERALS # 4: COMP_METADATA_TYPE_EVENTS +# 5: COMP_METADATA_TYPE_ACTUATORS set(comp_metadata_types) set(comp_metadata_board "${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}") set(s3_url "https://px4-travis.s3.amazonaws.com") @@ -67,6 +68,18 @@ else() endif() list(APPEND comp_metadata_types "--type" "4,${PX4_BINARY_DIR}/events/all_events.json.xz,${comp_metadata_events_uri},${comp_metadata_events_uri_fallback},") +set(comp_metadata_actuators_uri_board "${s3_url}/Firmware/{version}/${comp_metadata_board}/actuators.json.xz") +list(FIND config_romfs_extra_dependencies "actuators_json" index) +if (${index} EQUAL -1) + set(comp_metadata_actuators_uri ${comp_metadata_actuators_uri_board}) + set(comp_metadata_actuators_uri_fallback "") +else() + set(comp_metadata_actuators_uri "mftp://etc/extras/actuators.json.xz") + set(comp_metadata_actuators_uri_fallback ${comp_metadata_actuators_uri_board}) +endif() +list(APPEND comp_metadata_types "--type" "5,${PX4_BINARY_DIR}/actuators.json.xz,${comp_metadata_actuators_uri},${comp_metadata_actuators_uri_fallback},") + + set(component_general_json ${PX4_BINARY_DIR}/component_general.json) set(component_information_header ${CMAKE_CURRENT_BINARY_DIR}/checksums.h) add_custom_command(OUTPUT ${component_general_json} ${component_general_json}.xz ${component_information_header} @@ -84,6 +97,8 @@ add_custom_command(OUTPUT ${component_general_json} ${component_general_json}.xz parameters_xml ${PX4_BINARY_DIR}/events/all_events.json.xz events_json + ${PX4_BINARY_DIR}/actuators.json.xz + actuators_json ver_gen generate_crc.py COMMENT "Generating component_general.json and checksums.h" diff --git a/src/lib/component_information/generate_component_general.py b/src/lib/component_information/generate_component_general.py index 6b8f605913..964302f355 100755 --- a/src/lib/component_information/generate_component_general.py +++ b/src/lib/component_information/generate_component_general.py @@ -65,8 +65,9 @@ for metadata_type_tuple in args.type: 'type': int(type_id), 'uri': uri.replace('{version}', version_dir), 'fileCrc': file_crc, - 'uriFallback': fallback_uri.replace('{version}', version_dir), } + if len(fallback_uri) > 0: + json_type['uriFallback'] = fallback_uri.replace('{version}', version_dir) if len(translation_uri) > 0: json_type['translationUri'] = translation_uri metadata_types.append(json_type) diff --git a/src/lib/metadata/CMakeLists.txt b/src/lib/metadata/CMakeLists.txt new file mode 100644 index 0000000000..719c1483ca --- /dev/null +++ b/src/lib/metadata/CMakeLists.txt @@ -0,0 +1,56 @@ +############################################################################ +# +# Copyright (c) 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 +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# actuator metadata generation +get_property(module_config_files GLOBAL PROPERTY PX4_MODULE_CONFIG_FILES) +if(config_io_board) + set(board_with_io_arg --board-with-io) +endif() +set(generated_actuators_metadata_file ${PX4_BINARY_DIR}/actuators.json) +add_custom_command(OUTPUT ${generated_actuators_metadata_file} + ${generated_actuators_metadata_file}.xz + COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/module_config/generate_actuators_metadata.py + ${board_with_io_arg} + --timer-config ${PX4_BOARD_DIR}/src/timer_config.cpp + --config-files ${module_config_files} #--verbose + --compress + --board ${PX4_BOARD} + --output-file ${generated_actuators_metadata_file} + DEPENDS + ${module_config_files} + ${PX4_SOURCE_DIR}/Tools/module_config/generate_actuators_metadata.py + ${PX4_SOURCE_DIR}/src/lib/mixer_module/output_functions.yaml + COMMENT "Generating actuators.json" +) +add_custom_target(actuators_json DEPENDS ${generated_actuators_metadata_file}) +