Skip to content

Commit 5fdd679

Browse files
committed
Add support for target compile features in evaluator and pipeline
- Updated the evaluator to recognize and handle the EV_TARGET_COMPILE_FEATURES event, including visibility and item properties. - Enhanced the test suite to include cases for compile features, ensuring proper evaluation and visibility checks. - Modified the pipeline to account for compile features in the model snapshot, including updates to the output format to reflect the new data. - Added a new test case to validate the usage of compile features in a project setup.
1 parent da70c40 commit 5fdd679

31 files changed

Lines changed: 1100 additions & 603 deletions

docs/build_model/build_model_builder.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ The release-1 supported build-semantic set is:
6161
- `EVENT_TARGET_INCLUDE_DIRECTORIES`
6262
- `EVENT_TARGET_COMPILE_DEFINITIONS`
6363
- `EVENT_TARGET_COMPILE_OPTIONS`
64+
- `EVENT_TARGET_COMPILE_FEATURES`
6465
- `EVENT_TEST_ENABLE`
6566
- `EVENT_TEST_ADD`
6667
- `EVENT_INSTALL_RULE_ADD`
@@ -110,6 +111,7 @@ Release-1 typed directory/global properties are:
110111
- `COMPILE_DEFINITIONS`
111112
- `COMPILE_OPTIONS`
112113
- `LINK_OPTIONS`
114+
- `LINK_LIBRARIES`
113115
114116
Other directory/global properties are stored in a raw future-facing property
115117
bag. They are not dropped silently.
@@ -123,11 +125,18 @@ bag. They are not dropped silently.
123125
- `EVENT_TARGET_ADD_SOURCE` appends a raw source path without hidden path
124126
normalization.
125127
- `EVENT_TARGET_ADD_DEPENDENCY` appends an explicit dependency name reference.
126-
- `EVENT_TARGET_PROP_SET` updates typed scalar properties when the property name
127-
is one of the promoted release-1 keys; otherwise it is recorded in the raw
128-
property bag.
129-
130-
Release-1 promoted target property keys are:
128+
- visibility-aware target events and `EVENT_TARGET_COMPILE_FEATURES` are stored
129+
as typed raw item entries without flattening transitive semantics
130+
- `EVENT_TARGET_PROP_SET` updates typed scalar properties for the promoted
131+
scalar keys below and also promotes supported usage-requirement setters into
132+
the same typed item families used by the direct target events
133+
- promoted `SET` operations replace only the matching logical subfamily inside a
134+
shared typed array; for example `INTERFACE_INCLUDE_DIRECTORIES` does not wipe
135+
`INTERFACE_SYSTEM_INCLUDE_DIRECTORIES`
136+
- unsupported target properties, custom metadata, and `APPEND_STRING` payloads
137+
remain in the raw property bag
138+
139+
Release-1 promoted scalar target property keys are:
131140
- `OUTPUT_NAME`
132141
- `PREFIX`
133142
- `SUFFIX`
@@ -136,6 +145,23 @@ Release-1 promoted target property keys are:
136145
- `RUNTIME_OUTPUT_DIRECTORY`
137146
- `FOLDER`
138147
148+
Release-1 promoted usage-requirement target property keys are:
149+
- `INCLUDE_DIRECTORIES`
150+
- `INTERFACE_INCLUDE_DIRECTORIES`
151+
- `INTERFACE_SYSTEM_INCLUDE_DIRECTORIES`
152+
- `COMPILE_DEFINITIONS`
153+
- `INTERFACE_COMPILE_DEFINITIONS`
154+
- `COMPILE_OPTIONS`
155+
- `INTERFACE_COMPILE_OPTIONS`
156+
- `COMPILE_FEATURES`
157+
- `INTERFACE_COMPILE_FEATURES`
158+
- `LINK_LIBRARIES`
159+
- `INTERFACE_LINK_LIBRARIES`
160+
- `LINK_OPTIONS`
161+
- `INTERFACE_LINK_OPTIONS`
162+
- `LINK_DIRECTORIES`
163+
- `INTERFACE_LINK_DIRECTORIES`
164+
139165
Visibility-aware target events are stored as typed raw entries. The builder does
140166
not flatten visibility or transitive effects during ingest.
141167

docs/build_model/build_model_closure_matrix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Interpretation rule:
5858
| Directory graph, nesting, and owner capture | `project`, `directory` | `closed` | Mostly tightening and bug work remain, not new architecture. | Nested directory ownership, parentage, and inherited context no longer require new storage design. | `strong` |
5959
| Target declaration, kind identity, alias/imported identity | `target` | `closed` | Target identity is now canonical: `UNKNOWN_LIBRARY` is distinct from utility targets, imported/alias globality is first-class, and alias kind queries resolve to the effective target family. | New target-family work fits into the existing target record shape without structural redesign. | `strong` |
6060
| Source membership, file sets, and source-file properties | `target`, `build_step` | `closed` | Source membership is now modeled canonically: regular sources, `INTERFACE_SOURCES`, typed file sets, generated status, producer linkage, and source-local compile metadata no longer depend on raw property carry-through. | New source/file-set parity work fits the existing typed source and file-set query surface without new core model shapes. | `strong` |
61-
| Usage-requirement raw item model | `directory`, `target` | `partial` | Raw storage exists, but wider combinations still create downstream pressure. | Include dirs, defs, opts, link libs, link dirs, features, flags, and provenance fit the stable item model without new families. | `moderate` |
61+
| Usage-requirement raw item model | `directory`, `target` | `closed` | Usage requirements are now canonical across direct events and supported property setters: directory/global `LINK_LIBRARIES`, target include/define/option/feature/link families, and `SYSTEM` provenance no longer depend on the raw property bag as their primary downstream source. | Include dirs, defs, opts, link libs, link dirs, link opts, compile features, flags, and provenance fit the stable item model without new families; remaining work is limited to transitive semantics and intentional raw-property boundaries such as custom keys and `APPEND_STRING`. | `strong` |
6262
| Effective propagation and transitive query semantics | `target`, `directory`, `query` | `partial` | Transitive closure is implemented for important families, but more combinations can still force query/model expansion. | Effective queries cover common real-project propagation cases without needing new semantics or side channels. | `moderate` |
6363
| Generator-expression-carrying downstream preservation | `target`, `directory`, `install`, `export`, `replay` | `open` | This is one of the biggest sources of "looks implemented row-by-row, still fails on real projects." | Artifact-relevant genex context is preserved or resolved downstream strongly enough that codegen does not need evaluator-private escape hatches. | `weak` |
6464
| Config, language, and platform split | `target`, `query`, `replay` | `partial` | Some context-sensitive querying exists, but broad multi-config/platform closure is still a common major-work source. | Per-config, per-language, and per-platform artifact decisions stop forcing new model/query design. | `moderate` |

docs/build_model/build_model_coverage_matrix.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Control rules:
142142
| `include_directories` | native | `yes` | `directory` | `canonical` | `yes` | `indirect` |
143143
| `include_guard` | native | `no` | `none` | `none` | `n/a` | `none` |
144144
| `link_directories` | native | `yes` | `directory` | `canonical` | `yes` | `indirect` |
145-
| `link_libraries` | native | `yes` | `target/directory` | `subset` | `subset` | `indirect` |
145+
| `link_libraries` | native | `yes` | `target/directory` | `subset` | `subset` | `direct` |
146146
| `macro` | structural | `no` | `none` | `none` | `n/a` | `none` |
147147
| `mark_as_advanced` | native | `no` | `none` | `none` | `n/a` | `none` |
148148
| `math` | native | `no` | `none` | `none` | `n/a` | `none` |
@@ -151,8 +151,8 @@ Control rules:
151151
| `project` | native | `yes` | `project` | `canonical` | `yes` | `indirect` |
152152
| `return` | native | `no` | `none` | `none` | `n/a` | `none` |
153153
| `set` | native | `no` | `none` | `none` | `n/a` | `none` |
154-
| `set_property` | native | `yes` | `target/directory/test` | `subset` | `subset` | `indirect` |
155-
| `set_target_properties` | native | `yes` | `target` | `subset` | `subset` | `indirect` |
154+
| `set_property` | native | `yes` | `target/directory/test` | `subset` | `subset` | `direct` |
155+
| `set_target_properties` | native | `yes` | `target` | `subset` | `subset` | `direct` |
156156
| `source_group` | native | `no` | `none` | `none` | `n/a` | `none` |
157157
| `target_compile_definitions` | native | `yes` | `target` | `canonical` | `yes` | `direct` |
158158
| `target_compile_options` | native | `yes` | `target` | `canonical` | `yes` | `direct` |
@@ -214,7 +214,7 @@ Control rules:
214214
| `site_name` | native | `no` | `none` | `none` | `n/a` | `none` |
215215
| `subdir_depends` | native | `yes` | `none` | `none` | `boundary` | `none` |
216216
| `subdirs` | native | `yes` | `none` | `none` | `boundary` | `none` |
217-
| `target_compile_features` | native | `yes` | `target` | `canonical` | `yes` | `indirect` |
217+
| `target_compile_features` | native | `yes` | `target` | `canonical` | `yes` | `direct` |
218218
| `target_precompile_headers` | native | `yes` | `target` | `ownership_only` | `boundary` | `indirect` |
219219
| `target_sources` | native | `yes` | `target` | `canonical` | `yes` | `direct` |
220220
| `try_run` | native | `yes` | `replay` | `ownership_only` | `boundary` | `indirect` |

docs/build_model/build_model_query.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,25 @@ BM_String_Item_Span bm_query_directory_system_include_directories_raw(const Buil
5555
BM_Directory_Id id);
5656
BM_String_Item_Span bm_query_directory_link_directories_raw(const Build_Model *model,
5757
BM_Directory_Id id);
58+
BM_String_Item_Span bm_query_directory_link_libraries_raw(const Build_Model *model,
59+
BM_Directory_Id id);
5860

5961
BM_String_Item_Span bm_query_global_include_directories_raw(const Build_Model *model);
6062
BM_String_Item_Span bm_query_global_system_include_directories_raw(const Build_Model *model);
6163
BM_String_Item_Span bm_query_global_link_directories_raw(const Build_Model *model);
6264
BM_String_Item_Span bm_query_global_compile_definitions_raw(const Build_Model *model);
6365
BM_String_Item_Span bm_query_global_compile_options_raw(const Build_Model *model);
6466
BM_String_Item_Span bm_query_global_link_options_raw(const Build_Model *model);
67+
BM_String_Item_Span bm_query_global_link_libraries_raw(const Build_Model *model);
6568
BM_String_Span bm_query_global_raw_property_items(const Build_Model *model,
6669
String_View property_name);
6770
```
6871
6972
`bm_query_global_raw_property_items(...)` is the canonical escape hatch for
7073
global raw properties that are reconstructed but not yet promoted to dedicated
71-
named accessors. Codegen and tests may use it for keys such as
72-
`LINK_LIBRARIES`, while the model remains fully opaque.
74+
named accessors. Usage-requirement families such as `LINK_LIBRARIES` now have
75+
typed named accessors; the raw-property query remains for custom and
76+
unsupported global keys while the model stays opaque.
7377
7478
### Target Raw Accessors
7579
@@ -157,6 +161,8 @@ BM_String_Item_Span bm_query_target_compile_definitions_raw(const Build_Model *m
157161
BM_Target_Id id);
158162
BM_String_Item_Span bm_query_target_compile_options_raw(const Build_Model *model,
159163
BM_Target_Id id);
164+
BM_String_Item_Span bm_query_target_compile_features_raw(const Build_Model *model,
165+
BM_Target_Id id);
160166
BM_String_Item_Span bm_query_target_link_options_raw(const Build_Model *model,
161167
BM_Target_Id id);
162168
BM_String_Item_Span bm_query_target_link_directories_raw(const Build_Model *model,
@@ -208,6 +214,12 @@ bool bm_query_target_effective_compile_options_items(const Build_Model *model,
208214
Arena *scratch,
209215
BM_String_Item_Span *out);
210216

217+
bool bm_query_target_effective_compile_features_items(const Build_Model *model,
218+
BM_Target_Id id,
219+
const BM_Query_Eval_Context *ctx,
220+
Arena *scratch,
221+
BM_String_Item_Span *out);
222+
211223
bool bm_query_target_effective_link_libraries_items(const Build_Model *model,
212224
BM_Target_Id id,
213225
Arena *scratch,
@@ -238,6 +250,12 @@ bool bm_query_target_effective_compile_options(const Build_Model *model,
238250
Arena *scratch,
239251
BM_String_Span *out);
240252

253+
bool bm_query_target_effective_compile_features(const Build_Model *model,
254+
BM_Target_Id id,
255+
const BM_Query_Eval_Context *ctx,
256+
Arena *scratch,
257+
BM_String_Span *out);
258+
241259
bool bm_query_target_effective_link_libraries(const Build_Model *model,
242260
BM_Target_Id id,
243261
Arena *scratch,
@@ -292,7 +310,7 @@ The canonical memoized surface covers:
292310

293311
- effective include directories, compile definitions, compile options, link
294312
libraries, link options, and link directories in both item and value form
295-
- effective compile features
313+
- effective compile features in both item and value form
296314
- effective imported/local target file and linker file resolution
297315
- imported link-language lookup
298316

@@ -405,7 +423,10 @@ evaluator carry-through:
405423
- `CXX_MODULE_DIRS[_<name>]`
406424

407425
Effective link-library reconstruction also includes raw `LINK_LIBRARIES`
408-
properties from global and directory scopes when they exist in the model.
426+
item spans from global and directory scopes through
427+
`bm_query_global_link_libraries_raw(...)` and
428+
`bm_query_directory_link_libraries_raw(...)`; codegen no longer depends on the
429+
raw property bag for this family.
409430

410431
Effective queries must never mutate the model.
411432
They also must not persist inferred edges back into `Build_Model`; all such

docs/build_model/build_model_types.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Every directory record contains:
240240
- `binary_dir`
241241
- `provenance`
242242
- typed raw property families for include dirs, system include dirs, link dirs,
243-
compile definitions, compile options, and link options
243+
compile definitions, compile options, link options, and link libraries
244244
- a future-facing raw property bag for additional promoted directory/global
245245
properties
246246

@@ -267,12 +267,15 @@ Every target record contains:
267267
- raw explicit dependency references
268268
- raw typed property entries for:
269269
`link_libraries`, `link_options`, `link_directories`,
270-
`include_directories`, `compile_definitions`, `compile_options`
270+
`include_directories`, `compile_definitions`, `compile_options`,
271+
`compile_features`
271272
- typed scalar properties promoted from `EVENT_TARGET_PROP_SET`:
272273
`OUTPUT_NAME`, `PREFIX`, `SUFFIX`,
273274
`ARCHIVE_OUTPUT_DIRECTORY`, `LIBRARY_OUTPUT_DIRECTORY`,
274275
`RUNTIME_OUTPUT_DIRECTORY`, `FOLDER`
275-
- a future-facing raw property bag for unsupported target properties
276+
- a future-facing raw property bag for unsupported target properties,
277+
custom metadata, imported-config scalars, and `APPEND_STRING` setter
278+
payloads that intentionally remain outside the canonical item model
276279

277280
Alias targets preserve their own identity flags, but their frozen `kind`
278281
matches the aliased target family. Local custom targets remain

src_v2/build_model/build_model_builder.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static bool bm_is_supported_build_event(Event_Kind kind) {
7777
case EVENT_TARGET_INCLUDE_DIRECTORIES:
7878
case EVENT_TARGET_COMPILE_DEFINITIONS:
7979
case EVENT_TARGET_COMPILE_OPTIONS:
80+
case EVENT_TARGET_COMPILE_FEATURES:
8081
case EVENT_TEST_ENABLE:
8182
case EVENT_TEST_ADD:
8283
case EVENT_INSTALL_RULE_ADD:
@@ -661,6 +662,7 @@ bool bm_builder_apply_event(BM_Builder *builder, const Event *ev) {
661662
case EVENT_TARGET_INCLUDE_DIRECTORIES:
662663
case EVENT_TARGET_COMPILE_DEFINITIONS:
663664
case EVENT_TARGET_COMPILE_OPTIONS:
665+
case EVENT_TARGET_COMPILE_FEATURES:
664666
if (ev->h.kind == EVENT_SOURCE_MARK_GENERATED ||
665667
ev->h.kind == EVENT_SOURCE_PROPERTY_MUTATE ||
666668
ev->h.kind == EVENT_BUILD_STEP_DECLARE ||

src_v2/build_model/build_model_builder_directory.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ static bool bm_directory_apply_mutation(Arena *arena,
2424
static bool bm_apply_property_event(Arena *arena,
2525
BM_String_Item_View **include_directories,
2626
BM_String_Item_View **system_include_directories,
27+
BM_String_Item_View **link_libraries,
2728
BM_String_Item_View **link_directories,
2829
BM_String_Item_View **compile_definitions,
2930
BM_String_Item_View **compile_options,
@@ -42,6 +43,18 @@ static bool bm_apply_property_event(Arena *arena,
4243
return bm_directory_apply_mutation(arena, link_directories, mut, provenance);
4344
}
4445

46+
if (bm_sv_eq_ci_lit(mut->property_name, "LINK_LIBRARIES")) {
47+
return bm_directory_apply_mutation(arena, link_libraries, mut, provenance) &&
48+
bm_record_raw_property(arena,
49+
raw_properties,
50+
mut->property_name,
51+
mut->op,
52+
mut->modifier_flags,
53+
mut->items,
54+
mut->item_count,
55+
provenance);
56+
}
57+
4558
if (bm_sv_eq_ci_lit(mut->property_name, "COMPILE_DEFINITIONS")) {
4659
return bm_directory_apply_mutation(arena, compile_definitions, mut, provenance);
4760
}
@@ -110,6 +123,7 @@ bool bm_builder_handle_directory_event(BM_Builder *builder, const Event *ev) {
110123
if (!bm_apply_property_event(builder->arena,
111124
&directory->include_directories,
112125
&directory->system_include_directories,
126+
&directory->link_libraries,
113127
&directory->link_directories,
114128
&directory->compile_definitions,
115129
&directory->compile_options,
@@ -126,6 +140,7 @@ bool bm_builder_handle_directory_event(BM_Builder *builder, const Event *ev) {
126140
if (!bm_apply_property_event(builder->arena,
127141
&draft->global_properties.include_directories,
128142
&draft->global_properties.system_include_directories,
143+
&draft->global_properties.link_libraries,
129144
&draft->global_properties.link_directories,
130145
&draft->global_properties.compile_definitions,
131146
&draft->global_properties.compile_options,

0 commit comments

Comments
 (0)