Skip to content

Commit 90606a5

Browse files
committed
Reintroduce project-scoped Zig global cache.
7489516 reverted the workaround we had in place for random Zig failures when building in parallel. While we don't want a global cache for every inner build, we *do* want a global cache for the project as a whole in order to isolate the build from the rest of the machine as much as we can.
1 parent fa94626 commit 90606a5

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

src/sdk/build/Vezel.Zig.Sdk.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
DocumentationAnalysis="$(DocumentationAnalysis)"
6464
DynamicImageBase="$(DynamicImageBase)"
6565
EagerBinding="$(EagerBinding)"
66-
EnvironmentVariables="ZIG_LOCAL_CACHE_DIR=$(CachePath)"
66+
EnvironmentVariables="ZIG_GLOBAL_CACHE_DIR=$(GlobalCachePath); ZIG_LOCAL_CACHE_DIR=$(LocalCachePath)"
6767
FastMath="$(FastMath)"
6868
ImageBase="$(ImageBase)"
6969
IncludeDirectories="@(IncludeDirectory)"

src/sdk/build/Vezel.Zig.Sdk.Clean.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<!-- SPDX-License-Identifier: 0BSD -->
22

33
<Project>
4-
<ItemGroup>
5-
<Clean Include="$(CachePath)/**" />
4+
<ItemGroup Condition="'$(IsOuterBuild)' != 'true'">
5+
<Clean Include="$(GlobalCachePath)/**" />
6+
<Clean Include="$(LocalCachePath)/**" />
67
<Clean Include="$(_CommandFragmentsPath)/**" />
78
</ItemGroup>
89

src/sdk/build/Vezel.Zig.Sdk.Defaults.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
-->
88

99
<PropertyGroup>
10-
<CachePath Condition="'$(CachePath)' == ''">$(IntermediateOutputPath)zig-cache</CachePath>
10+
<GlobalCachePath Condition="'$(CachePath)' == ''">$(BaseIntermediateOutputPath)zig-cache</GlobalCachePath>
11+
<LocalCachePath Condition="'$(CachePath)' == ''">$(IntermediateOutputPath)zig-cache</LocalCachePath>
1112
<CommandsPath Condition="'$(CommandsPath)' == ''">$(IntermediateOutputPath)compile_commands.json</CommandsPath>
1213
<DefaultSources Condition="'$(DefaultSources)' == ''">true</DefaultSources>
1314
<EditorSupport Condition="'$(EditorSupport)' == ''">true</EditorSupport>

src/sdk/build/Vezel.Zig.Sdk.Editor.targets

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
<!--
3838
The Zig compiler will not emit a new compilation database fragment for a
3939
given source file if it has not actually changed. This unfortunately
40-
means that we have to clean the entire Zig cache when we need to refresh
41-
compile_commands.json. Fun.
40+
means that we have to clean the entire local Zig cache when we need to
41+
refresh compile_commands.json. Fun.
4242
-->
43-
<RemoveDir Directories="$(CachePath)"
44-
Condition="Exists('$(CachePath)')" />
43+
<RemoveDir Directories="$(LocalCachePath)"
44+
Condition="Exists('$(LocalCachePath)')" />
4545
</Target>
4646

4747
<!--

src/sdk/build/Vezel.Zig.Sdk.Test.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
DocumentationAnalysis="$(DocumentationAnalysis)"
3636
DynamicImageBase="$(DynamicImageBase)"
3737
EagerBinding="$(EagerBinding)"
38-
EnvironmentVariables="ZIG_LOCAL_CACHE_DIR=$(CachePath)"
38+
EnvironmentVariables="ZIG_GLOBAL_CACHE_DIR=$(GlobalCachePath); ZIG_LOCAL_CACHE_DIR=$(LocalCachePath)"
3939
FastMath="$(FastMath)"
4040
ImageBase="$(ImageBase)"
4141
IncludeDirectories="@(IncludeDirectory)"

0 commit comments

Comments
 (0)