Skip to content

Commit c27d314

Browse files
committed
sdk: converge slnf-direct and transitive cache keys in single-API mode
Parallel MSBuild was racing on obj/ outputs because Stride.Games (and other API-dep projects) ended up with two cache entries per TF: one from the slnf's direct Build (AdditionalProperties included StrideGraphicsApi) and one from transitive dispatches (where the singular never made it through). Two cache entries → two real compiles → same obj path → race. In single-API builds the singular StrideGraphicsApi is redundant information — the plural already pins the API. Strip it at ProjectReference evaluation time via ItemDefinitionGroup, and drop it from the inner-build AdditionalProperties too. Both paths now converge on one cache key per (project, TF); the inner reads the singular locally from StrideGraphicsApis when it needs it. Multi-API mode (StrideGraphicsApiDependentBuildAll=true) keeps the singular as a cache-key differentiator, with the strip disabled and the SetTargetFramework augmentation preserved for transitive dispatches. The target uses Update (not Remove+Include) so existing metadata — SetTargetFramework from _GetProjectReferenceTargetFrameworkProperties, GlobalPropertiesToRemove from the ItemDefinitionGroup — survives.
1 parent 41eca7d commit c27d314

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

sources/sdk/Stride.Build.Sdk/Sdk/Stride.GraphicsApi.InnerBuild.targets

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,36 @@
6969
<Output ItemName="_StrideGraphicsApisItems" TaskParameter="TargetOutputs" />
7070
</MSBuild>
7171

72-
<!-- Create one inner build per TFM x API combination -->
72+
<!-- Create one inner build per TFM (single-API) or per TFMxAPI (multi-API).
73+
StrideGraphicsApi is only added to AdditionalProperties in multi-API mode; in single-API
74+
mode the inner evaluates it from StrideGraphicsApis locally, keeping the cache key
75+
identical to transitive dispatches (which can't reliably propagate it via SetTargetFramework). -->
7376
<ItemGroup Condition="'$(StrideGraphicsApiDependent)' == 'true'">
7477
<_TargetFrameworkWithStrideGraphicsApi Include="@(_StrideGraphicsApisItems->'%(OriginalItemSpec)')" StrideGraphicsApi="%(_StrideGraphicsApisItems.Identity)" />
7578
<_InnerBuildProjects Include="$(MSBuildProjectFile)">
7679
<AdditionalProperties Condition="'%(_TargetFrameworkWithStrideGraphicsApi.StrideGraphicsApiDependent)' != 'true'">TargetFramework=%(_TargetFrameworkWithStrideGraphicsApi.TargetFramework)</AdditionalProperties>
77-
<AdditionalProperties Condition="'%(_TargetFrameworkWithStrideGraphicsApi.StrideGraphicsApiDependent)' == 'true'">TargetFramework=%(_TargetFrameworkWithStrideGraphicsApi.TargetFramework);StrideGraphicsApi=%(_TargetFrameworkWithStrideGraphicsApi.StrideGraphicsApi)</AdditionalProperties>
80+
<AdditionalProperties Condition="'%(_TargetFrameworkWithStrideGraphicsApi.StrideGraphicsApiDependent)' == 'true' And '$(StrideGraphicsApiDependentBuildAll)' != 'true'">TargetFramework=%(_TargetFrameworkWithStrideGraphicsApi.TargetFramework)</AdditionalProperties>
81+
<AdditionalProperties Condition="'%(_TargetFrameworkWithStrideGraphicsApi.StrideGraphicsApiDependent)' == 'true' And '$(StrideGraphicsApiDependentBuildAll)' == 'true'">TargetFramework=%(_TargetFrameworkWithStrideGraphicsApi.TargetFramework);StrideGraphicsApi=%(_TargetFrameworkWithStrideGraphicsApi.StrideGraphicsApi)</AdditionalProperties>
7882
</_InnerBuildProjects>
7983
</ItemGroup>
8084
</Target>
8185

8286
<!-- ================================================================ -->
8387
<!-- Project reference Graphics API propagation -->
8488
<!-- ================================================================ -->
85-
<!-- Detects if referenced projects are StrideGraphicsApiDependent
86-
and injects StrideGraphicsApi into their SetTargetFramework.
87-
For non-dependent references, removes StrideGraphicsApi to
88-
prevent unnecessary rebuilds. -->
89+
<!-- Detects which referenced projects are StrideGraphicsApiDependent and stamps that
90+
metadata. Also strips StrideGraphicsApi from all ProjectReferences at evaluation time
91+
so the singular property never flows through as a global, keeping slnf-direct and
92+
transitive dispatches on the same project-instance cache key. -->
8993
<Target Name="_StrideQueryGraphicsApiDependent" Returns="@(_StrideGraphicsApiDependentItemsInternal)" Condition="'$(StrideProjectType)' != 'Cpp'">
9094
<ItemGroup>
9195
<_StrideGraphicsApiDependentItemsInternal Include="stride_fake_graphics_api" StrideGraphicsApiDependent="$(StrideGraphicsApiDependent)" />
9296
</ItemGroup>
9397
</Target>
9498

95-
<!-- Evaluation-time strip so both _GetProjectReferenceTargetFrameworkProperties (the TFM
96-
query) and the main Build dispatch honour it — target-time metadata set in
97-
_StrideProjectReferenceGraphicsApiDependent runs too late for the TFM query. Stripped
98-
unconditionally; API-dependent references re-add StrideGraphicsApi via SetTargetFramework
99-
at target time (see lines below), which is applied as Properties by the dispatcher. -->
100-
<ItemDefinitionGroup>
99+
<ItemDefinitionGroup Condition="'$(StrideGraphicsApiDependentBuildAll)' != 'true'">
101100
<ProjectReference>
102-
<GlobalPropertiesToRemove>%(ProjectReference.GlobalPropertiesToRemove);StrideGraphicsApi;StrideGraphicsApis;StrideGraphicsApiDependent;StrideGraphicsApiDependentBuildAll;StridePlatform;StridePlatforms;StrideNativeBuildMode;StrideTestRuntimeIdentifier;StrideSkipAutoPack</GlobalPropertiesToRemove>
101+
<GlobalPropertiesToRemove>%(ProjectReference.GlobalPropertiesToRemove);StrideGraphicsApi</GlobalPropertiesToRemove>
103102
</ProjectReference>
104103
</ItemDefinitionGroup>
105104

@@ -123,12 +122,17 @@
123122
<_StrideGraphicsApiCurrent Condition="'$(_StrideGraphicsApiCurrent)' == ''">Direct3D11</_StrideGraphicsApiCurrent>
124123
</PropertyGroup>
125124
<ItemGroup>
126-
<_MSBuildProjectReferenceExistent Remove="@(_StrideGraphicsApiDependentItems->'%(OriginalItemSpec)')" />
127-
<_MSBuildProjectReferenceExistent Include="@(_StrideGraphicsApiDependentItems->'%(OriginalItemSpec)')" Condition="'%(_StrideGraphicsApiDependentItems.StrideGraphicsApiDependent)' != 'true'" />
128-
<_MSBuildProjectReferenceExistent Include="@(_StrideGraphicsApiDependentItems->'%(OriginalItemSpec)')" Condition="'%(_StrideGraphicsApiDependentItems.StrideGraphicsApiDependent)' == 'true'">
125+
<!-- Stamp StrideGraphicsApiDependent per ref, then (in multi-API mode only) augment
126+
API-dep refs so inner-build dispatches match the slnf-direct cache key. In single-API
127+
mode the singular StrideGraphicsApi is computed locally by the inner from the plural. -->
128+
<_MSBuildProjectReferenceExistent Update="@(_StrideGraphicsApiDependentItems->'%(OriginalItemSpec)')">
129129
<StrideGraphicsApiDependent>%(_StrideGraphicsApiDependentItems.StrideGraphicsApiDependent)</StrideGraphicsApiDependent>
130+
</_MSBuildProjectReferenceExistent>
131+
</ItemGroup>
132+
<ItemGroup Condition="'$(StrideGraphicsApiDependentBuildAll)' == 'true'">
133+
<_MSBuildProjectReferenceExistent Update="@(_MSBuildProjectReferenceExistent)" Condition="'%(_MSBuildProjectReferenceExistent.StrideGraphicsApiDependent)' == 'true'">
130134
<StrideGraphicsApi>$(_StrideGraphicsApiCurrent)</StrideGraphicsApi>
131-
<SetTargetFramework>%(_StrideGraphicsApiDependentItems.SetTargetFramework);StrideGraphicsApi=$(_StrideGraphicsApiCurrent)</SetTargetFramework>
135+
<SetTargetFramework>%(_MSBuildProjectReferenceExistent.SetTargetFramework);StrideGraphicsApi=$(_StrideGraphicsApiCurrent)</SetTargetFramework>
132136
</_MSBuildProjectReferenceExistent>
133137
</ItemGroup>
134138
</Target>

0 commit comments

Comments
 (0)