Windows MSVC 编译期写入 编译器版本 Git Commit ID 到源代码中
这是一个半成品,只输出了相关信息。动手能力强的同学可以改造一下,毕竟每个人环境不同。
set cl=$(ClCompilerPath)
set file=config.h
echo %cl%
for /f "skip=1 tokens=2 delims==" %%i in ('wmic datafile where "name='%cl:\=\\%'" get version /format:list') do for /f "delims=*" %%v in ("%%i") do set "version=%%v"
echo %version%
set cmd=git rev-parse --short head
for /f "delims=*" %%i in ('%cmd%') do set commit=%%i
echo %commit%
评论已关闭