Skip to content

Commit 77316f7

Browse files
committed
fix(config): require JSON feature propagation in consumers
Make installed-package and pkg-config consumers fail at compile time when the optional JSON feature macro is not exported. Clarify that JSON conversion diagnostics are distinct from backend semantic validation performed during materialization.
1 parent 18ae558 commit 77316f7

7 files changed

Lines changed: 35 additions & 8 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
run: >-
5252
cmake -S tests/install_consumer -B build-json-consumer
5353
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/install-json-config
54+
-DLOGIT_CONSUMER_REQUIRE_JSON_CONFIG=ON
5455
-DCMAKE_CXX_STANDARD=11
5556
- name: Build and run optional JSON installed-package consumer
5657
if: matrix.std == 11
@@ -61,7 +62,9 @@ jobs:
6162
if: matrix.std == 11
6263
env:
6364
PKG_CONFIG_PATH: ${{ github.workspace }}/install-json-config/share/pkgconfig:${{ github.workspace }}/install-json-config/lib/pkgconfig
64-
run: cmake -S tests/pkgconfig_consumer -B build-json-pkgconfig
65+
run: >-
66+
cmake -S tests/pkgconfig_consumer -B build-json-pkgconfig
67+
-DLOGIT_CONSUMER_REQUIRE_JSON_CONFIG=ON
6568
- name: Build and run optional JSON pkg-config consumer
6669
if: matrix.std == 11
6770
run: |

‎docs/configuration-loading-RU.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ if (!logit::parse_configuration_json(text, document, diagnostics)) {
6060
```
6161

6262
Разбор не создаёт logger'ы и заменяет `document` только после полного успеха.
63-
Синтаксические ошибки используют категорию `configuration_parse_failed`;
64-
структурные ошибки, неверные типы, named values и неизвестные поля получают
65-
path-aware diagnostics. Floating-point значения JSON отклоняются, поскольку в
63+
Frontend возвращает path-aware diagnostics для JSON syntax и shape/conversion
64+
ошибок; синтаксические ошибки используют категорию
65+
`configuration_parse_failed`. Backend schema validation выполняется отдельной
66+
core-фазой: unknown fields, backend types, enum/named values, defaults и
67+
feature availability могут быть диагностированы `materialize_configuration()`,
68+
а не JSON conversion. Floating-point значения JSON отклоняются, поскольку в
6669
schema v1 предусмотрены только signed и unsigned integer значения.
6770

6871
Следующие этапы вызываются явно через `materialize_configuration()` и

‎docs/configuration-loading.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ if (!logit::parse_configuration_json(text, document, diagnostics)) {
6464
```
6565

6666
Parsing has no logger side effects and replaces `document` only after a
67-
complete successful conversion. Syntax errors use
68-
`configuration_parse_failed`; structural, type, named-value, and unknown-field
69-
errors retain path-aware diagnostics. JSON floating-point values are rejected
70-
because schema v1 has only signed and unsigned integer numeric values.
67+
complete successful conversion. The frontend reports JSON syntax and
68+
shape/conversion errors with path-aware diagnostics and uses
69+
`configuration_parse_failed` for syntax errors. Backend schema validation is a
70+
later core phase: backend unknown fields, backend types, enum/named values,
71+
defaults, and feature availability may be diagnosed by
72+
`materialize_configuration()` rather than by the JSON conversion itself. JSON
73+
floating-point values are rejected because schema v1 has only signed and
74+
unsigned integer numeric values.
7175

7276
Call `materialize_configuration()` and `instantiate_configuration()` explicitly
7377
for the later phases. The frontend does not read files, apply frontend-specific

‎tests/install_consumer/CMakeLists.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.18)
22
project(install_consumer LANGUAGES CXX)
33

44
option(LOGIT_CONSUMER_REQUIRE_FMT "Exercise the installed fmt-enabled package" OFF)
5+
option(LOGIT_CONSUMER_REQUIRE_JSON_CONFIG "Exercise the installed JSON-enabled package" OFF)
56

67
find_package(log-it-cpp CONFIG REQUIRED)
78

@@ -10,3 +11,6 @@ target_link_libraries(install_consumer PRIVATE log-it-cpp::log-it-cpp)
1011
if(LOGIT_CONSUMER_REQUIRE_FMT)
1112
target_compile_definitions(install_consumer PRIVATE LOGIT_CONSUMER_REQUIRE_FMT=1)
1213
endif()
14+
if(LOGIT_CONSUMER_REQUIRE_JSON_CONFIG)
15+
target_compile_definitions(install_consumer PRIVATE LOGIT_CONSUMER_REQUIRE_JSON_CONFIG=1)
16+
endif()

‎tests/install_consumer/main.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <logit.hpp>
22

3+
#if defined(LOGIT_CONSUMER_REQUIRE_JSON_CONFIG) && !defined(LOGIT_WITH_JSON_CONFIG)
4+
# error "The installed package did not propagate LOGIT_WITH_JSON_CONFIG"
5+
#endif
6+
37
int main() {
48
#if defined(LOGIT_WITH_JSON_CONFIG)
59
logit::ConfigurationDocument document;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
cmake_minimum_required(VERSION 3.18)
22
project(pkgconfig_consumer LANGUAGES CXX)
33

4+
option(LOGIT_CONSUMER_REQUIRE_JSON_CONFIG "Exercise the JSON-enabled package" OFF)
5+
46
find_package(PkgConfig REQUIRED)
57
pkg_check_modules(LOGIT REQUIRED IMPORTED_TARGET log-it-cpp)
68

79
add_executable(pkgconfig_consumer main.cpp)
810
target_compile_features(pkgconfig_consumer PRIVATE cxx_std_11)
911
target_link_libraries(pkgconfig_consumer PRIVATE PkgConfig::LOGIT)
12+
if(LOGIT_CONSUMER_REQUIRE_JSON_CONFIG)
13+
target_compile_definitions(pkgconfig_consumer PRIVATE LOGIT_CONSUMER_REQUIRE_JSON_CONFIG=1)
14+
endif()

‎tests/pkgconfig_consumer/main.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <logit.hpp>
22

3+
#if defined(LOGIT_CONSUMER_REQUIRE_JSON_CONFIG) && !defined(LOGIT_WITH_JSON_CONFIG)
4+
# error "The pkg-config package did not propagate LOGIT_WITH_JSON_CONFIG"
5+
#endif
6+
37
int main() {
48
#if defined(LOGIT_WITH_JSON_CONFIG)
59
logit::ConfigurationDocument document;

0 commit comments

Comments
 (0)