vezel-dev / zig-sdk

An MSBuild SDK for building Zig, C, and C++ projects using the Zig compiler.

Home Page:https://docs.vezel.dev/zig-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generated `compile_commands.json` is invalid on Unix systems

alexrp opened this issue · comments

\ characters are replaced with / because MSBuild thinks they're path separators, resulting in invalid JSON...

<Target Name="_GatherCompileCommands"
Condition="'$(_RefreshCompileCommands)' == 'true'">
<ItemGroup>
<_CdbFragments Include="$(_CommandFragmentsPath)/*.json" />
<_CdbFragments Update="@(_CdbFragments)"
Json="$([System.IO.File]::ReadAllText('%(FullPath)').Trim().TrimEnd(','))" />
</ItemGroup>
<PropertyGroup>
<_CompileCommands>
<![CDATA[
[ @(_CdbFragments->'%(Json)', ', ') ]
]]>
</_CompileCommands>
</PropertyGroup>
<WriteLinesToFile File="$(CommandsPath)"
Lines="$(_CompileCommands)"
Overwrite="true" />
</Target>

Seems like we might have to use an inline task for this.