diff --git a/cmake/common.cmake b/cmake/common.cmake index 1cf6980..ef8a9d2 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -116,6 +116,10 @@ macro(spl_create_component) list(APPEND COMPONENT_NAMES ${component_name}) set(COMPONENT_NAMES ${COMPONENT_NAMES} PARENT_SCOPE) + # Collect all component paths for later usage (e.g., in an extension) + list(APPEND COMPONENT_PATHS ${component_path}) + set(COMPONENT_PATHS ${COMPONENT_PATHS} PARENT_SCOPE) + list(APPEND target_include_directories__INCLUDES ${CMAKE_CURRENT_LIST_DIR}/src) list(APPEND target_include_directories__INCLUDES ${CMAKE_CURRENT_BINARY_DIR}) @@ -172,6 +176,41 @@ macro(spl_create_component) # create the config.json file. This is exported as SPHINX_BUILD_CONFIGURATION_FILE env variable set(_reports_config_json ${SPHINX_OUTPUT_DIR}/config.json) + # create the test specification rst file + set(_unit_test_spec_rst ${SPHINX_OUTPUT_DIR}/unit_test_spec.rst) + file(WRITE ${_unit_test_spec_rst} " +Unit Test Specification +======================= + +.. needtable:: + :filter: type == 'test' + :columns: id, title, tests, results + :style: table + +") + + # create the test results rst file + set(_unit_test_results_rst ${SPHINX_OUTPUT_DIR}/unit_test_results.rst) + file(WRITE ${_unit_test_results_rst} " +Unit Test Results +================= + +.. test-report:: Unit Test Results + :id: TEST_RESULT + :file: ${_component_test_junit_xml} + +") + + # create the code coverage rst file + set(_coverage_rst ${SPHINX_OUTPUT_DIR}/coverage.rst) + file(WRITE ${_coverage_rst} " +Code Coverage +============= + +`Report `_ + +") + # generate Doxyfile from template set(_component_doxyfile ${SPHINX_OUTPUT_DIR}/Doxyfile) set(DOXYGEN_PROJECT_NAME "Doxygen Documentation") @@ -187,11 +226,10 @@ macro(spl_create_component) file(RELATIVE_PATH _rel_component_doxysphinx_index_rst ${SPHINX_SOURCE_DIR} ${DOXYGEN_OUTPUT_DIRECTORY}/html/index) file(WRITE ${_reports_config_json} "{ - \"component_doc_dir\": \"${_rel_component_doc_dir}\", - \"component_reports_dir\": \"${SPHINX_OUTPUT_DIR}\", - \"component_test_junit_xml\": \"${_component_test_junit_xml}\", - \"include_patterns\": [\"${_rel_component_doc_dir}/**\",\"${_rel_sphinx_output_dir}/**\"] - }") + \"component_doc_dir\": \"${_rel_component_doc_dir}\", + \"component_reports_dir\": \"${_rel_sphinx_output_dir}\", + \"include_patterns\": [\"${_rel_component_doc_dir}/**\",\"${_rel_sphinx_output_dir}/**\"] +}") # add the generated files as dependency to cmake configure step set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_reports_config_json} ${_unit_test_spec_rst} ${_unit_test_results_rst} ${_component_doxyfile}) @@ -205,6 +243,10 @@ macro(spl_create_component) COMMAND ${CMAKE_COMMAND} -E remove_directory ${SPHINX_OUTPUT_DIR}/html COMMAND ${CMAKE_COMMAND} -E remove_directory ${SPHINX_OUTPUT_DIR}/doxygen COMMAND ${CMAKE_COMMAND} -E make_directory ${SPHINX_OUTPUT_DIR}/doxygen + + # now comes the tricky part: we need to copy the coverage html output directory + # to the sub directory inside html output directory where the coverage.html file is located. + COMMAND ${CMAKE_COMMAND} -E copy_directory ${SPHINX_OUTPUT_DIR}/coverage ${SPHINX_OUTPUT_DIR}/html/${_rel_sphinx_output_dir}/coverage COMMAND doxygen ${_rel_component_doxyfile} COMMAND doxysphinx build ${SPHINX_SOURCE_DIR} ${SPHINX_OUTPUT_HTML_DIR} ${_rel_component_doxyfile} COMMAND ${CMAKE_COMMAND} -E env SPHINX_BUILD_CONFIGURATION_FILE=${_reports_config_json} AUTOCONF_JSON_FILE=${AUTOCONF_JSON} VARIANT=${VARIANT} -- sphinx-build -b html ${SPHINX_SOURCE_DIR} ${SPHINX_OUTPUT_HTML_DIR} @@ -227,10 +269,13 @@ macro(_spl_create_docs_target) # create the config.json file. This is exported as SPHINX_BUILD_CONFIGURATION_FILE env variable set(_docs_config_json ${SPHINX_OUTPUT_DIR}/config.json) + list(JOIN COMPONENT_PATHS "\", \"" _component_paths_json) + set(_component_paths_json "[\"${_component_paths_json}\"]") file(RELATIVE_PATH _rel_sphinx_output_dir ${SPHINX_SOURCE_DIR} ${SPHINX_OUTPUT_DIR}) file(WRITE ${_docs_config_json} "{ - \"include_patterns\": [\"${_rel_sphinx_output_dir}/**\"] - }") + \"include_patterns\": [\"${_rel_sphinx_output_dir}/**\", \"src/**\"], + \"component_paths\": ${_component_paths_json} +}") # add the generated files as dependency to cmake configure step set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_docs_config_json}) diff --git a/cmake/spl.cmake b/cmake/spl.cmake index 8bb4ba5..80dce43 100644 --- a/cmake/spl.cmake +++ b/cmake/spl.cmake @@ -72,7 +72,6 @@ elseif(BUILD_KIT STREQUAL test) add_custom_target(coverage) add_custom_target(reports) - _spl_create_docs_target() else() message(FATAL_ERROR "Invalid BUILD_KIT selected!") endif(BUILD_KIT STREQUAL prod) @@ -81,10 +80,10 @@ endif(BUILD_KIT STREQUAL prod) cmake_language(DEFER DIRECTORY ${CMAKE_SOURCE_DIR} CALL _spl_hook_end_of_configure()) function(_spl_hook_end_of_configure) - _spl_coverage_create_overall_report() - - if(CONAN__REQUIRES OR CONAN__BUILD_REQUIRES) - endif() # CONAN__REQUIRES + if(BUILD_KIT STREQUAL test) + _spl_coverage_create_overall_report() + _spl_create_docs_target() + endif(BUILD_KIT STREQUAL test) endfunction(_spl_hook_end_of_configure) # # This is one possibility to open guiconfig of kconfiglib. VSCode task is the preferred solution diff --git a/src/project_creator/templates/project/{{cookiecutter.name}}/conf.py b/src/project_creator/templates/project/{{cookiecutter.name}}/conf.py index 6e1c765..50ebd2e 100644 --- a/src/project_creator/templates/project/{{cookiecutter.name}}/conf.py +++ b/src/project_creator/templates/project/{{cookiecutter.name}}/conf.py @@ -29,7 +29,7 @@ "**/test_results.rst", # We renamed this file, but nobody deletes it. ] -include_patterns = ["index.rst", "coverage.rst", "definitions.rst", "doc/**"] +include_patterns = ["index.rst", "doc/**"] # configuration of built-in stuff ########################################### # @see https://www.sphinx-doc.org/en/master/usage/configuration.html diff --git a/src/project_creator/templates/project/{{cookiecutter.name}}/coverage.rst b/src/project_creator/templates/project/{{cookiecutter.name}}/coverage.rst deleted file mode 100644 index 8b02570..0000000 --- a/src/project_creator/templates/project/{{cookiecutter.name}}/coverage.rst +++ /dev/null @@ -1,4 +0,0 @@ -Code Coverage -============= - -`Report <../coverage/index.html>`_ diff --git a/src/project_creator/templates/project/{{cookiecutter.name}}/doc/unit_test_results.rst b/src/project_creator/templates/project/{{cookiecutter.name}}/doc/unit_test_results.rst deleted file mode 100644 index ad73038..0000000 --- a/src/project_creator/templates/project/{{cookiecutter.name}}/doc/unit_test_results.rst +++ /dev/null @@ -1,8 +0,0 @@ - -Unit Test Results -================= - -.. test-report:: Unit Test Results - :id: TEST_RESULT - :file: {{ build_config.component_test_junit_xml }} - diff --git a/src/project_creator/templates/project/{{cookiecutter.name}}/doc/unit_test_spec.rst b/src/project_creator/templates/project/{{cookiecutter.name}}/doc/unit_test_spec.rst deleted file mode 100644 index 99d02fd..0000000 --- a/src/project_creator/templates/project/{{cookiecutter.name}}/doc/unit_test_spec.rst +++ /dev/null @@ -1,9 +0,0 @@ - -Unit Test Specification -======================= - -.. needtable:: - :filter: type == 'test' - :columns: id, title, tests, results - :style: table - diff --git a/src/project_creator/templates/project/{{cookiecutter.name}}/index.rst b/src/project_creator/templates/project/{{cookiecutter.name}}/index.rst index 87251e7..a20c8fa 100644 --- a/src/project_creator/templates/project/{{cookiecutter.name}}/index.rst +++ b/src/project_creator/templates/project/{{cookiecutter.name}}/index.rst @@ -10,10 +10,10 @@ Software Component Report {{ build_config.component_doc_dir }}/index {% if build_config.component_reports_dir %} - /doc/unit_test_spec - /doc/unit_test_results + {{ build_config.component_reports_dir }}/unit_test_spec + {{ build_config.component_reports_dir }}/unit_test_results {{ build_config.component_reports_dir }}/doxygen/html/index - coverage + {{ build_config.component_reports_dir }}/coverage {% endif %} {% else %}