<分区>
我使用 msbuild
编译 C++ 代码,并在 ClCompile
项中指定了 cl
选项。像...
<ItemGroup>
<ClCompile Include="something.cpp">
<FloatingPointModel>Precise</FloatingPointModel>
<WarningLevel>Level2</WarningLevel>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" />
以上只是一个例子。现在我想打印用于 cl
调用的所有选项。问题是:我该怎么做?我的第一次尝试是使用如下内容:
<Target Name="WriteToFile" AfterTargets="ClCompile" >
<WriteLinesToFile File="$(OutDir)\log.txt" Lines="@(ClCompile)" Overwrite="true" />
</Target>
遗憾的是,这只记录文件名 (something.cpp
) 而不是选项。
请注意,我知道编译器选项由 Tracker.exe
存储在 CL.command.*.tlog
文件中,但首先,我不知道我想依靠它,因为它可能会发生变化,其次,我很可能需要稍后进行一些转换。我也知道我可以访问各个选项(如 %(ClCompile.FloatingPointModel)
),但我也不想单独处理每个选项。
有更好的方法吗?