Closed kkukshtel closed 6 months ago
and as such need different packages to support different RIDs
You almost certainly don't need this. The reason Zig is so great as a cross-compilation toolkit is that you just need to install a Zig distribution compiled for your build machine and it can cross-compile to any other target supported by Zig.
This is why Vezel.Zig.Sdk works this way (HostRuntimeIdentifier
being the RID for the build machine, derived from NETCoreSdkPortableRuntimeIdentifier
): https://github.com/vezel-dev/zig-sdk/blob/220b025d679a22359f882852cb26e7ab58d5860d/src/sdk/build/Vezel.Zig.Sdk.Core.targets#L7-L12
It's to support different RIDs of development machines. I build work on both windows/osx so I need the correct zig exe on those platforms in order to invoke zig. The downstream comp stuff yeah it doesn't matter.
My recommendation for that would then be to do exactly what that code I linked above is doing (but substitute HostRuntimeIdentifier
for NETCoreSdkPortableRuntimeIdentifier
), i.e.:
<Project Sdk="Microsoft.NET.Sdk">
...
<ItemGroup>
<PackageReference Include="Vezel.Zig.Toolsets.$(NETCoreSdkPortableRuntimeIdentifier)"
Version="0.12.0.*"
PrivateAssets="all" />
</ItemGroup>
...
</Project>
(You can optionally replace that trailing asterisk with a specific number if you want the build to be fully predictable. I use that last number to indicate the 'packaging version', e.g. in case a bug in the packaging needs to be fixed for a particular Zig version.)
Ah this seems to have worked great - thank you!!
As the title says - I'm working in a single project that can be compiled to different platforms, and as such need different packages to support different RIDs. So I have
osx-x64
,osx-arm64
,andwin-x64
. Running build on the project seems to just choose whichever package was installed last as the path, so even if I'm running onwin-x64
it may chooseosx-x64
.To get around this I parse out the RID from the generated path with RegEX and replace it with the dev machine RID (and assume that the dev machine has the correct pacakge added), but I'd love a way if somehow the MSBuild props could be automatically intuited. Maybe one option could be to expose props that give you paths that represent the dev machine as well? So like
ZigToolsetPath_DEV
. Or just add in "static" props that put the onus on the dev to ensure the correct package is installed, likeZigToolsetPath_win-x64
.