spl-core 9.2.1__tar.gz → 9.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. {spl_core-9.2.1 → spl_core-9.3.0}/PKG-INFO +1 -1
  2. {spl_core-9.2.1 → spl_core-9.3.0}/pyproject.toml +1 -1
  3. spl_core-9.3.0/src/spl_core/__init__.py +1 -0
  4. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/common.cmake +217 -42
  5. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kconfig/kconfig.py +36 -9
  6. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kconfig.cmake +4 -0
  7. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/report_generation/ubproject.toml +4 -1
  8. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/spl.cmake +1 -0
  9. spl_core-9.2.1/src/spl_core/__init__.py +0 -1
  10. {spl_core-9.2.1 → spl_core-9.3.0}/LICENSE +0 -0
  11. {spl_core-9.2.1 → spl_core-9.3.0}/README.md +0 -0
  12. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/__run.py +0 -0
  13. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/common/__init__.py +0 -0
  14. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/common/path.py +0 -0
  15. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/conan.cmake +0 -0
  16. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/config/KConfig +0 -0
  17. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/gcov_maid/__init__.py +0 -0
  18. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/gcov_maid/gcov_maid.py +0 -0
  19. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kconfig/__init__.py +0 -0
  20. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/__init__.py +0 -0
  21. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/create.py +0 -0
  22. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/.vscode/cmake-variants.json +0 -0
  23. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/KConfig +0 -0
  24. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/src/greeter/CMakeLists.txt +0 -0
  25. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/src/greeter/doc/_images/screenshot.png +0 -0
  26. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/src/greeter/doc/index.md +0 -0
  27. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/src/greeter/src/greeter.c +0 -0
  28. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/src/greeter/src/greeter.h +0 -0
  29. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/src/greeter/test/test_greeter.cc +0 -0
  30. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/src/main/CMakeLists.txt +0 -0
  31. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/src/main/doc/index.md +0 -0
  32. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/src/main/src/main.c +0 -0
  33. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/test/EnglishVariant/test__EnglishVariant.py +0 -0
  34. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/test/German/test__GermanVariant.py +0 -0
  35. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/variants/EnglishVariant/config.cmake +0 -0
  36. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/variants/EnglishVariant/parts.cmake +0 -0
  37. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/variants/GermanVariant/config.cmake +0 -0
  38. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/variants/GermanVariant/config.txt +0 -0
  39. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/application/variants/GermanVariant/parts.cmake +0 -0
  40. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/.gitignore +0 -0
  41. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/.vscode/cmake-kits.json +0 -0
  42. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/.vscode/extensions.json +0 -0
  43. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/.vscode/launch.json +0 -0
  44. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/.vscode/settings.json +0 -0
  45. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/.vscode/tasks.json +0 -0
  46. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/CMakeLists.txt +0 -0
  47. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/README.md +0 -0
  48. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/bootstrap.json +0 -0
  49. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/build.bat +0 -0
  50. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/build.ps1 +0 -0
  51. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/conf.py +0 -0
  52. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/doc/common/index.md +0 -0
  53. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/doc/common/sphinx_configuration.md +0 -0
  54. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/doc/components/index.md +0 -0
  55. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/doc/software_architecture/index.md +0 -0
  56. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/doc/software_requirements/index.md +0 -0
  57. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/doc/test_report_template.txt +0 -0
  58. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/index.md +0 -0
  59. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/pypeline.yaml +0 -0
  60. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/pyproject.toml +0 -0
  61. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/pytest.ini +0 -0
  62. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/scoopfile.json +0 -0
  63. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/tools/toolchains/clang/toolchain.cmake +0 -0
  64. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/kickstart/templates/project/tools/toolchains/gcc/toolchain.cmake +0 -0
  65. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/main.py +0 -0
  66. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/report_generation/__init__.py +0 -0
  67. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/report_generation/spl_html_settings.py +0 -0
  68. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/report_generation/spl_sphinx.py +0 -0
  69. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/report_generation/spl_theme_extension.py +0 -0
  70. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/report_generation/static/spl_core_logo.png +0 -0
  71. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/report_generation/static/spl_custom.css +0 -0
  72. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/steps/collect_pr_changes.py +0 -0
  73. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/test_utils/archive_artifacts_collection.py +0 -0
  74. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/test_utils/artifacts_archiver.py +0 -0
  75. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/test_utils/base_variant_test_runner.py +0 -0
  76. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/test_utils/junit_merger.py +0 -0
  77. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/test_utils/pytest_plugin.py +0 -0
  78. {spl_core-9.2.1 → spl_core-9.3.0}/src/spl_core/test_utils/spl_build.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spl-core
3
- Version: 9.2.1
3
+ Version: 9.3.0
4
4
  Summary: Software Product Line Support for CMake
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "spl-core"
3
- version = "9.2.1"
3
+ version = "9.3.0"
4
4
  description = "Software Product Line Support for CMake"
5
5
  authors = ["Avengineers <karsten.guenther@kamg.de>"]
6
6
  license = "MIT"
@@ -0,0 +1 @@
1
+ __version__ = "9.3.0"
@@ -323,9 +323,24 @@ macro(spl_create_component)
323
323
  # create the config.json file. This is exported as SPHINX_BUILD_CONFIGURATION_FILE env variable
324
324
  set(_docs_config_json ${_component_docs_out_dir}/config.json)
325
325
  file(RELATIVE_PATH _rel_component_doc_dir ${_sphinx_source_dir} ${_component_doc_dir})
326
+ set(_docs_include_patterns "\"${_rel_component_doc_dir}/**\",\"${_rel_component_docs_out_dir}/**\"")
327
+ set(_component_docs_root_html ${_component_docs_html_out_dir}/index.html)
328
+
329
+ # A component run opted in to ubCode is rooted in a generated page, not in the project's index (ADR 0005).
330
+ # The root pages sit in the component's binary dir, outside the run output dirs that the variant runs read.
331
+ file(RELATIVE_PATH _rel_component_binary_dir ${_sphinx_source_dir} ${CMAKE_CURRENT_BINARY_DIR})
332
+ if(SPL_UBCODE_SELECTION_FILE)
333
+ _spl_write_component_root_page(docs "${_component_info}")
334
+ string(APPEND _docs_include_patterns ",\"${_rel_component_binary_dir}/root_docs.md\"")
335
+ set(_component_docs_root_html ${_component_docs_html_out_dir}/${_rel_component_binary_dir}/root_docs.html)
336
+ else()
337
+ # Root pages of an earlier configure with the opt-in
338
+ file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/root_docs.md ${CMAKE_CURRENT_BINARY_DIR}/root_reports.md)
339
+ endif()
340
+
326
341
  file(WRITE ${_docs_config_json} "{
327
342
  \"component_info\": ${_component_info},
328
- \"include_patterns\": [\"${_rel_component_doc_dir}/**\",\"${_rel_component_docs_out_dir}/**\"]
343
+ \"include_patterns\": [${_docs_include_patterns}]
329
344
  }")
330
345
 
331
346
  # add the generated files as dependency to cmake configure step
@@ -334,12 +349,13 @@ macro(spl_create_component)
334
349
  # We do not know all dependencies for generating the docs (apart from the rst files).
335
350
  # This might cause incremental builds to not update parts of the documentation.
336
351
  # To avoid this the command passes -E to make sphinx-build write all files new.
337
- _spl_sphinx_build_command(_spl_sphinx_build SHAPE docs CONFIG ${_docs_config_json} OUTPUT_DIR ${_component_docs_html_out_dir} COMPONENT ${component_path})
352
+ _spl_sphinx_build_command(_spl_sphinx_build SHAPE docs CONFIG ${_docs_config_json} OUTPUT_DIR ${_component_docs_html_out_dir} COMPONENT ${component_path}
353
+ VARIANT_DATA ${_component_docs_out_dir}/variant_data.json ROOT_DOC ${_rel_component_binary_dir}/root_docs)
338
354
  add_custom_target(
339
355
  ${component_name}_docs
340
356
  COMMAND ${CMAKE_COMMAND} -E make_directory ${_component_docs_out_dir}
341
357
  COMMAND ${_spl_sphinx_build}
342
- BYPRODUCTS ${_component_docs_html_out_dir}/index.html
358
+ BYPRODUCTS ${_component_docs_root_html}
343
359
  )
344
360
 
345
361
  # Generate source documentation using clanguru
@@ -409,6 +425,12 @@ Code Coverage
409
425
  if(_COMPONENT_SOURCE_DOCS_INCLUDE_PATTERN)
410
426
  string(APPEND _reports_include_patterns ",\"${_COMPONENT_SOURCE_DOCS_INCLUDE_PATTERN}\"")
411
427
  endif()
428
+ set(_component_reports_root_html ${_component_reports_html_out_dir}/index.html)
429
+ if(SPL_UBCODE_SELECTION_FILE)
430
+ _spl_write_component_root_page(reports "${_component_info}")
431
+ string(APPEND _reports_include_patterns ",\"${_rel_component_binary_dir}/root_reports.md\"")
432
+ set(_component_reports_root_html ${_component_reports_html_out_dir}/${_rel_component_binary_dir}/root_reports.html)
433
+ endif()
412
434
  file(WRITE ${_reports_config_json} "{
413
435
  \"component_info\": ${_component_info},
414
436
  \"include_patterns\": [${_reports_include_patterns}]
@@ -431,12 +453,13 @@ Code Coverage
431
453
 
432
454
  # No OUTPUT is defined to force execution of this target every time
433
455
  # TODO: list of dependencies is not complete
434
- _spl_sphinx_build_command(_spl_sphinx_build SHAPE reports CONFIG ${_reports_config_json} OUTPUT_DIR ${_component_reports_html_out_dir} COMPONENT ${component_path})
456
+ _spl_sphinx_build_command(_spl_sphinx_build SHAPE reports CONFIG ${_reports_config_json} OUTPUT_DIR ${_component_reports_html_out_dir} COMPONENT ${component_path}
457
+ VARIANT_DATA ${_component_reports_out_dir}/variant_data.json ROOT_DOC ${_rel_component_binary_dir}/root_reports)
435
458
  add_custom_target(
436
459
  ${component_name}_report
437
460
  COMMAND ${CMAKE_COMMAND} -E make_directory ${_component_reports_out_dir}
438
461
  COMMAND ${_spl_sphinx_build}
439
- BYPRODUCTS ${_component_reports_html_out_dir}/index.html
462
+ BYPRODUCTS ${_component_reports_root_html}
440
463
  DEPENDS ${TEST_OUT_JUNIT} ${_cov_out_html}
441
464
  )
442
465
  if(_COMPONENT_SOURCE_DOCS_INCLUDE_PATTERN)
@@ -507,7 +530,9 @@ macro(_spl_create_docs_target)
507
530
  # create the config.json file. This is exported as SPHINX_BUILD_CONFIGURATION_FILE env variable
508
531
  list(JOIN COMPONENTS_INFO "," _components_info_json)
509
532
  set(_components_info_json "[${_components_info_json}]")
510
- list(JOIN COMPONENTS_SPHINX_INCLUDE_PATTERNS "\",\"" _components_sphinx_include_patterns_json)
533
+ # The SPL's own documents (SPL_PROJECT_DOCS_INCLUDE_PATTERNS) come first
534
+ set(_docs_include_patterns ${SPL_PROJECT_DOCS_INCLUDE_PATTERNS} ${COMPONENTS_SPHINX_INCLUDE_PATTERNS})
535
+ list(JOIN _docs_include_patterns "\",\"" _components_sphinx_include_patterns_json)
511
536
  set(_components_sphinx_include_patterns_json "[\"${_components_sphinx_include_patterns_json}\"]")
512
537
  file(WRITE ${_docs_config_json} "{
513
538
  \"target\": \"docs\",
@@ -517,7 +542,17 @@ macro(_spl_create_docs_target)
517
542
 
518
543
  # add the generated files as dependency to cmake configure step
519
544
  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_docs_config_json})
520
- _spl_sphinx_build_command(_spl_sphinx_build SHAPE docs CONFIG ${_docs_config_json} OUTPUT_DIR ${_docs_html_out_dir})
545
+ _spl_write_variant_data(${_docs_out_dir}/variant_data.json docs)
546
+
547
+ # The component runs get their files here, once every component is known
548
+ foreach(_variant_data_component_info ${COMPONENTS_INFO})
549
+ string(JSON _variant_data_docs_output_dir GET ${_variant_data_component_info} docs_output_dir)
550
+ if(_variant_data_docs_output_dir)
551
+ _spl_write_variant_data(${PROJECT_SOURCE_DIR}/${_variant_data_docs_output_dir}/variant_data.json docs)
552
+ endif()
553
+ endforeach()
554
+
555
+ _spl_sphinx_build_command(_spl_sphinx_build SHAPE docs CONFIG ${_docs_config_json} OUTPUT_DIR ${_docs_html_out_dir} VARIANT_DATA ${_docs_out_dir}/variant_data.json)
521
556
  add_custom_target(
522
557
  docs
523
558
  COMMAND ${CMAKE_COMMAND} -E make_directory ${_docs_out_dir}
@@ -535,10 +570,14 @@ endmacro()
535
570
  # them becomes the shape and `@COMPONENT_PATH@` the component's path, so each run
536
571
  # can name a file or directory of its own, e.g. `-d;<dir>/doctrees/@COMPONENT_PATH@/@SHAPE@`.
537
572
  #
573
+ # VARIANT_DATA is the run's variant data file and ROOT_DOC the docname of a component
574
+ # run's generated root page. Both reach Sphinx only when the SPL sets
575
+ # SPL_UBCODE_SELECTION_FILE (ADR 0005); without it the command is unchanged.
576
+ #
538
577
  # Sphinx runs through SPL_PYTHON, like hammocking and gcov_maid, so a build uses the
539
578
  # Sphinx of the environment it was configured with, whatever comes first in PATH.
540
579
  function(_spl_sphinx_build_command out_var)
541
- cmake_parse_arguments(ARG "" "SHAPE;CONFIG;OUTPUT_DIR;COMPONENT" "" ${ARGN})
580
+ cmake_parse_arguments(ARG "" "SHAPE;CONFIG;OUTPUT_DIR;COMPONENT;VARIANT_DATA;ROOT_DOC" "" ${ARGN})
542
581
  if(NOT ARG_SHAPE MATCHES "^(docs|reports)$")
543
582
  message(FATAL_ERROR "_spl_sphinx_build_command: SHAPE must be 'docs' or 'reports', not '${ARG_SHAPE}'.")
544
583
  endif()
@@ -554,6 +593,14 @@ function(_spl_sphinx_build_command out_var)
554
593
  string(REPLACE "@COMPONENT_PATH@" "${ARG_COMPONENT}" _option "${_option}")
555
594
  list(APPEND _options "${_option}")
556
595
  endforeach()
596
+ if(SPL_UBCODE_SELECTION_FILE)
597
+ if(ARG_VARIANT_DATA)
598
+ list(APPEND _options -D needs_variant_data_file=${ARG_VARIANT_DATA})
599
+ endif()
600
+ if(ARG_ROOT_DOC)
601
+ list(APPEND _options -D root_doc=${ARG_ROOT_DOC})
602
+ endif()
603
+ endif()
557
604
 
558
605
  set(${out_var}
559
606
  ${CMAKE_COMMAND} -E env
@@ -565,6 +612,159 @@ function(_spl_sphinx_build_command out_var)
565
612
  )
566
613
  endfunction()
567
614
 
615
+ # Writes the variant data file of one Sphinx run: the features of the KConfig model
616
+ # ({} without one) and build_config with the variant and the run's target (`docs` or
617
+ # `reports`), which documents read as var.build_config.* in {if} conditions.
618
+ # build_config is added to the parsed features document with string(JSON ... SET)
619
+ # instead of being concatenated as text, so a value with quotes or backslashes keeps
620
+ # the file valid JSON.
621
+ function(_spl_write_variant_data out_file target)
622
+ if(SPL_FEATURES_JSON AND EXISTS ${SPL_FEATURES_JSON})
623
+ file(READ ${SPL_FEATURES_JSON} _variant_data)
624
+ else()
625
+ set(_variant_data "{\"features\": {}}")
626
+ endif()
627
+
628
+ set(_build_config "{}")
629
+ string(JSON _build_config SET "${_build_config}" variant "\"${VARIANT}\"")
630
+ string(JSON _build_config SET "${_build_config}" target "\"${target}\"")
631
+ string(JSON _variant_data SET "${_variant_data}" build_config "${_build_config}")
632
+
633
+ file(WRITE ${out_file} "${_variant_data}")
634
+ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${out_file})
635
+ endfunction()
636
+
637
+ # The content of a component's page: its title and a toctree of its documents. The
638
+ # variant report's wrapper pages and the root pages of the component's own runs use it.
639
+ # SHAPE `docs` lists only the component's doc index; SHAPE `reports` adds the report
640
+ # pages and the source docs index the component has.
641
+ function(_spl_component_page_content out_var component_info shape)
642
+ string(JSON _name GET ${component_info} name)
643
+ string(JSON _long_name GET ${component_info} long_name)
644
+ string(JSON _path GET ${component_info} path)
645
+ string(JSON _has_reports GET ${component_info} has_reports)
646
+ string(JSON _reports_output_dir GET ${component_info} reports_output_dir)
647
+ string(JSON _source_docs_dir GET ${component_info} source_docs_dir)
648
+
649
+ if(NOT _long_name STREQUAL "")
650
+ set(_title "${_long_name}")
651
+ else()
652
+ set(_title "${_name}")
653
+ endif()
654
+
655
+ set(_content "# ${_title}
656
+
657
+ ```{toctree}
658
+ :maxdepth: 2
659
+
660
+ /${_path}/doc/index
661
+ ")
662
+ if(shape STREQUAL reports)
663
+ if(_has_reports)
664
+ string(APPEND _content "/${_reports_output_dir}/unit_test_spec
665
+ /${_reports_output_dir}/unit_test_results
666
+ /${_reports_output_dir}/coverage
667
+ ")
668
+ endif()
669
+ if(_source_docs_dir)
670
+ string(APPEND _content "/${_source_docs_dir}/index
671
+ ")
672
+ endif()
673
+ endif()
674
+ string(APPEND _content "```
675
+ ")
676
+ set(${out_var} "${_content}" PARENT_SCOPE)
677
+ endfunction()
678
+
679
+ # Writes the root page of a component's own run (ADR 0005) into the component's binary
680
+ # dir: root_docs.md for the docs run, root_reports.md for the reports run. It lies outside
681
+ # the run output dirs, so the variant runs do not read it.
682
+ function(_spl_write_component_root_page shape component_info)
683
+ _spl_component_page_content(_content "${component_info}" ${shape})
684
+ set(_root_page ${CMAKE_CURRENT_BINARY_DIR}/root_${shape}.md)
685
+ file(WRITE ${_root_page} "${_content}")
686
+ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_root_page})
687
+ endfunction()
688
+
689
+ # A TOML basic string, with backslashes and double quotes escaped.
690
+ function(_spl_toml_string out_var value)
691
+ string(REPLACE "\\" "\\\\" value "${value}")
692
+ string(REPLACE "\"" "\\\"" value "${value}")
693
+ set(${out_var} "\"${value}\"" PARENT_SCOPE)
694
+ endfunction()
695
+
696
+ # A TOML array of basic strings, one per line.
697
+ function(_spl_toml_string_array out_var)
698
+ set(_array "[")
699
+ foreach(_value IN LISTS ARGN)
700
+ _spl_toml_string(_value "${_value}")
701
+ string(APPEND _array "\n ${_value},")
702
+ endforeach()
703
+ string(APPEND _array "\n]")
704
+ set(${out_var} "${_array}" PARENT_SCOPE)
705
+ endfunction()
706
+
707
+ # Writes the ubCode selection of the configured build (ADR 0005) to
708
+ # ${PROJECT_SOURCE_DIR}/${SPL_UBCODE_SELECTION_FILE}, when the SPL sets the variable.
709
+ # It reads _SPL_VARIANT_REPORTS_INCLUDE_PATTERNS and _SPL_VARIANT_REPORTS_VARIANT_DATA_FILE,
710
+ # which the macro _spl_create_reports_target sets in the caller's scope, so it is called
711
+ # after that macro in the same scope (_spl_hook_end_of_configure). The document patterns are split by parser: a pattern
712
+ # that names a directory (`<p>/**`) reaches the md parser as `<p>/**/*.md` and the rst
713
+ # parser as `<p>/**/*.rst`; any other pattern reaches the parser its suffix names.
714
+ # The md parser gets the MyST extensions Sphinx gets (SplSphinx myst_enable_extensions), so
715
+ # that ubCode reads :::{if} blocks; html_admonition is left out, ubCode does not implement it.
716
+ # It appends spl-core's report_generation/ubproject.toml: its [source] table, which lets
717
+ # ubCode read the gitignored build/ dir, and spl-core's needs model.
718
+ function(_spl_write_ubcode_selection)
719
+ if(NOT SPL_UBCODE_SELECTION_FILE)
720
+ return()
721
+ endif()
722
+
723
+ set(_md_include "")
724
+ set(_rst_include "")
725
+ foreach(_pattern IN LISTS _SPL_VARIANT_REPORTS_INCLUDE_PATTERNS)
726
+ # ubCode matches a pattern without a slash in every directory; anchor it at the project root.
727
+ if(NOT _pattern MATCHES "/")
728
+ set(_pattern "./${_pattern}")
729
+ endif()
730
+ if(_pattern MATCHES "/\\*\\*$")
731
+ list(APPEND _md_include "${_pattern}/*.md")
732
+ list(APPEND _rst_include "${_pattern}/*.rst")
733
+ elseif(_pattern MATCHES "\\.md$")
734
+ list(APPEND _md_include "${_pattern}")
735
+ elseif(_pattern MATCHES "\\.rst$")
736
+ list(APPEND _rst_include "${_pattern}")
737
+ else()
738
+ message(WARNING "The include pattern '${_pattern}' names neither a directory (`/**`) nor a .md or .rst file; ubCode does not read it.")
739
+ endif()
740
+ endforeach()
741
+ _spl_toml_string_array(_md_include_toml ${_md_include})
742
+ _spl_toml_string_array(_rst_include_toml ${_rst_include})
743
+
744
+ file(RELATIVE_PATH _variant_data_file ${PROJECT_SOURCE_DIR} ${_SPL_VARIANT_REPORTS_VARIANT_DATA_FILE})
745
+ _spl_toml_string(_variant_data_file_toml "${_variant_data_file}")
746
+
747
+ file(READ ${SPL_CORE_PYTHON_DIRECTORY}/report_generation/ubproject.toml _spl_core_ubproject)
748
+
749
+ file(WRITE ${PROJECT_SOURCE_DIR}/${SPL_UBCODE_SELECTION_FILE} "# Generated by spl-core at CMake configure. Do not edit it; keep it out of git.
750
+ # It selects the documents and the variant data of the configured build for ubCode.
751
+
752
+ [variants]
753
+ data_file = ${_variant_data_file_toml}
754
+
755
+ [parse.parsers.md]
756
+ flavour = \"myst\"
757
+ extensions = [\"colon_fence\", \"deflist\", \"html_image\", \"dollarmath\"]
758
+ include = ${_md_include_toml}
759
+
760
+ [parse.parsers.rst]
761
+ include = ${_rst_include_toml}
762
+
763
+ # Copied from spl-core's report_generation/ubproject.toml: [source], which lets ubCode read
764
+ # the gitignored build/ dir, and spl-core's needs model.
765
+ ${_spl_core_ubproject}")
766
+ endfunction()
767
+
568
768
  macro(_spl_create_reports_target)
569
769
  set(_reports_output_dir ${CMAKE_CURRENT_BINARY_DIR}/reports)
570
770
  file(RELATIVE_PATH _rel_reports_output_dir ${PROJECT_SOURCE_DIR} ${_reports_output_dir})
@@ -576,9 +776,12 @@ macro(_spl_create_reports_target)
576
776
  set(_components_info_json "[${_components_info_json}]")
577
777
 
578
778
  # Add the variant specific rst files (e.g, coverage.rst) and the component source
579
- # docs (report content only) to the include patterns
779
+ # docs (report content only) to the include patterns. The SPL's own documents
780
+ # (SPL_PROJECT_DOCS_INCLUDE_PATTERNS) come first. _spl_write_ubcode_selection reads the same list.
580
781
  list(APPEND COMPONENTS_SPHINX_INCLUDE_PATTERNS "${_rel_reports_output_dir}/**" ${COMPONENTS_SOURCE_DOCS_INCLUDE_PATTERNS})
581
- list(JOIN COMPONENTS_SPHINX_INCLUDE_PATTERNS "\",\"" _components_sphinx_include_patterns_json)
782
+ set(_SPL_VARIANT_REPORTS_INCLUDE_PATTERNS ${SPL_PROJECT_DOCS_INCLUDE_PATTERNS} ${COMPONENTS_SPHINX_INCLUDE_PATTERNS})
783
+ set(_SPL_VARIANT_REPORTS_VARIANT_DATA_FILE ${_reports_output_dir}/variant_data.json)
784
+ list(JOIN _SPL_VARIANT_REPORTS_INCLUDE_PATTERNS "\",\"" _components_sphinx_include_patterns_json)
582
785
  set(_components_sphinx_include_patterns_json "[\"${_components_sphinx_include_patterns_json}\"]")
583
786
  file(WRITE ${_reports_config_json} "{
584
787
  \"target\": \"reports\",
@@ -608,37 +811,7 @@ macro(_spl_create_reports_target)
608
811
  endif()
609
812
 
610
813
  string(JSON _wrapper_name GET ${component_info} name)
611
- string(JSON _wrapper_long_name GET ${component_info} long_name)
612
- string(JSON _wrapper_path GET ${component_info} path)
613
- string(JSON _wrapper_has_reports GET ${component_info} has_reports)
614
- string(JSON _wrapper_reports_output_dir GET ${component_info} reports_output_dir)
615
- string(JSON _wrapper_source_docs_dir GET ${component_info} source_docs_dir)
616
-
617
- if(NOT _wrapper_long_name STREQUAL "")
618
- set(_wrapper_title "${_wrapper_long_name}")
619
- else()
620
- set(_wrapper_title "${_wrapper_name}")
621
- endif()
622
-
623
- set(_wrapper_content "# ${_wrapper_title}
624
-
625
- ```{toctree}
626
- :maxdepth: 2
627
-
628
- /${_wrapper_path}/doc/index
629
- ")
630
- if(_wrapper_has_reports)
631
- string(APPEND _wrapper_content "/${_wrapper_reports_output_dir}/unit_test_spec
632
- /${_wrapper_reports_output_dir}/unit_test_results
633
- /${_wrapper_reports_output_dir}/coverage
634
- ")
635
- endif()
636
- if(_wrapper_source_docs_dir)
637
- string(APPEND _wrapper_content "/${_wrapper_source_docs_dir}/index
638
- ")
639
- endif()
640
- string(APPEND _wrapper_content "```
641
- ")
814
+ _spl_component_page_content(_wrapper_content "${component_info}" reports)
642
815
 
643
816
  set(_wrapper_file ${_reports_output_dir}/${_wrapper_name}_index.md)
644
817
  file(WRITE ${_wrapper_file} "${_wrapper_content}")
@@ -663,6 +836,7 @@ Code Coverage
663
836
  string(JSON component_reports_output_dir GET ${component_info} reports_output_dir)
664
837
 
665
838
  if(component_reports_output_dir)
839
+ _spl_write_variant_data(${PROJECT_SOURCE_DIR}/${component_reports_output_dir}/variant_data.json reports)
666
840
  set(_variant_component_reports_out_dir reports/html/${component_reports_output_dir})
667
841
  set(_cov_out_html ${_variant_component_reports_out_dir}/coverage/index.html)
668
842
  set(_cov_out_json ${component_path}/coverage.json)
@@ -691,13 +865,14 @@ Code Coverage
691
865
 
692
866
  # add the generated files as dependency to cmake configure step
693
867
  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_reports_config_json})
868
+ _spl_write_variant_data(${_reports_output_dir}/variant_data.json reports)
694
869
 
695
870
  # These files are generated by custom commands in _spl_coverage_create_overall_report()
696
871
  set(COV_OUT_VARIANT_JSON variant-coverage.json)
697
872
  set(JUNIT_OUT_VARIANT_XML variant-junit.xml)
698
873
 
699
874
  # The command passes -E to sphinx-build to make sure all files are regenerated.
700
- _spl_sphinx_build_command(_spl_sphinx_build SHAPE reports CONFIG ${_reports_config_json} OUTPUT_DIR ${_reports_html_output_dir})
875
+ _spl_sphinx_build_command(_spl_sphinx_build SHAPE reports CONFIG ${_reports_config_json} OUTPUT_DIR ${_reports_html_output_dir} VARIANT_DATA ${_reports_output_dir}/variant_data.json)
701
876
  add_custom_target(
702
877
  reports
703
878
  ALL
@@ -3,7 +3,7 @@ import json
3
3
  import os
4
4
  import re
5
5
  from abc import ABC, abstractmethod
6
- from collections.abc import Generator
6
+ from collections.abc import Generator, Sequence
7
7
  from contextlib import contextmanager
8
8
  from dataclasses import dataclass
9
9
  from enum import Enum, auto
@@ -142,17 +142,40 @@ class HeaderWriter(FileWriter):
142
142
  return "\n".join(result)
143
143
 
144
144
 
145
+ def _feature_values(configuration_data: ConfigurationData) -> dict[str, Any]:
146
+ """Maps every configured element to its json value: booleans as true/false, everything else as is."""
147
+ result: dict[str, Any] = {}
148
+ for element in configuration_data.elements:
149
+ if element.type is ConfigElementType.BOOL:
150
+ result[element.name] = True if element.value == TriState.Y else False
151
+ else:
152
+ result[element.name] = element.value
153
+ return result
154
+
155
+
145
156
  class JsonWriter(FileWriter):
146
157
  """Writes the ConfigurationData in json format"""
147
158
 
148
159
  def generate_content(self, configuration_data: ConfigurationData) -> str:
149
- result = {}
150
- for element in configuration_data.elements:
151
- if element.type is ConfigElementType.BOOL:
152
- result[element.name] = True if element.value == TriState.Y else False
153
- else:
154
- result[element.name] = element.value
155
- return json.dumps({"features": result}, indent=4)
160
+ return json.dumps({"features": _feature_values(configuration_data)}, indent=4)
161
+
162
+
163
+ class FeaturesWriter(FileWriter):
164
+ """Writes the complete feature list: every declared boolean defaults to false, the configured elements override it.
165
+
166
+ ``write()`` sets the declared booleans that ``generate_content()`` reads.
167
+ """
168
+
169
+ _declared_booleans: Sequence[str] = ()
170
+
171
+ def write(self, configuration_data: ConfigurationData, declared_booleans: Sequence[str] = ()) -> None:
172
+ self._declared_booleans = declared_booleans
173
+ super().write(configuration_data)
174
+
175
+ def generate_content(self, configuration_data: ConfigurationData) -> str:
176
+ features: dict[str, Any] = dict.fromkeys(self._declared_booleans, False)
177
+ features.update(_feature_values(configuration_data))
178
+ return json.dumps({"features": features}, indent=4)
156
179
 
157
180
 
158
181
  class CMakeWriter(FileWriter):
@@ -270,14 +293,18 @@ def main() -> None:
270
293
  parser.add_argument("--out_header_file", required=True, type=non_existing_path)
271
294
  parser.add_argument("--out_json_file", required=False, type=non_existing_path)
272
295
  parser.add_argument("--out_cmake_file", required=False, type=non_existing_path)
296
+ parser.add_argument("--out_features_file", required=False, type=non_existing_path)
273
297
  arguments = parser.parse_args()
274
- config = KConfig(arguments.kconfig_model_file, arguments.kconfig_config_file).config
298
+ k_config = KConfig(arguments.kconfig_model_file, arguments.kconfig_config_file)
299
+ config = k_config.config
275
300
 
276
301
  HeaderWriter(arguments.out_header_file).write(config)
277
302
  if arguments.out_json_file:
278
303
  JsonWriter(arguments.out_json_file).write(config)
279
304
  if arguments.out_cmake_file:
280
305
  CMakeWriter(arguments.out_cmake_file).write(config)
306
+ if arguments.out_features_file:
307
+ FeaturesWriter(arguments.out_features_file).write(config, k_config.declared_boolean_symbols())
281
308
 
282
309
 
283
310
  if __name__ == "__main__":
@@ -9,6 +9,9 @@ set(KCONFIG_CONFIG_FILE ${PROJECT_SOURCE_DIR}/variants/${VARIANT}/config.txt)
9
9
  if(EXISTS ${KCONFIG_MODEL_FILE})
10
10
  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${KCONFIG_MODEL_FILE})
11
11
 
12
+ # Every feature of the model, read by the variant data file of each Sphinx run
13
+ set(SPL_FEATURES_JSON ${KCONFIG_OUT_DIR}/features.json)
14
+
12
15
  if(EXISTS ${KCONFIG_CONFIG_FILE})
13
16
  set(_KCONFIG_CONFIG_FILE_option --kconfig_config_file ${KCONFIG_CONFIG_FILE})
14
17
  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${KCONFIG_CONFIG_FILE})
@@ -26,6 +29,7 @@ if(EXISTS ${KCONFIG_MODEL_FILE})
26
29
  --out_header_file ${AUTOCONF_H}
27
30
  --out_json_file ${AUTOCONF_JSON}
28
31
  --out_cmake_file ${AUTOCONF_CMAKE}
32
+ --out_features_file ${SPL_FEATURES_JSON}
29
33
  COMMAND_ECHO STDOUT
30
34
  RESULT_VARIABLE ret
31
35
  )
@@ -1,7 +1,10 @@
1
1
  [source]
2
2
  exclude = [".bzr", ".direnv", ".eggs", ".git", ".git-rewrite", ".hg", ".svn", ".venv", ".vscode", "_build", "dist", "node_modules", "site-packages"]
3
3
  respect_gitignore = false
4
- extend_include = ["build/**/__source_docs/**"]
4
+
5
+ # Present, even empty, so that ubCode reads the test-report directive and adds the test-case
6
+ # need type that the results predicate links.
7
+ [test_reports]
5
8
 
6
9
  [needs.links.realizes]
7
10
  incoming = "is realized by"
@@ -111,6 +111,7 @@ function(_spl_hook_end_of_configure)
111
111
  _spl_coverage_create_overall_report()
112
112
  _spl_create_docs_target()
113
113
  _spl_create_reports_target()
114
+ _spl_write_ubcode_selection()
114
115
  endif(BUILD_KIT STREQUAL test)
115
116
  _spl_create_build_info_file()
116
117
  endfunction(_spl_hook_end_of_configure)
@@ -1 +0,0 @@
1
- __version__ = "9.2.1"
File without changes
File without changes
File without changes
File without changes