Skip to content

Commit c52f125

Browse files
committed
msvc: Update genhdr script to emit MicroPython version numbers
1 parent dea853d commit c52f125

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

windows/msvc/genhdr.targets

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,23 @@
5555
<DestFile>$(DestDir)py-version.h</DestFile>
5656
<TmpFile>$(DestFile).tmp</TmpFile>
5757
</PropertyGroup>
58+
<PropertyGroup>
59+
<Ver>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), `^v[0-9\.]{5}`))</Ver>
60+
<Ver Condition="'$(Ver)'==''">v0.0.1</Ver>
61+
<Ver>$(Ver.Remove(0, 1))</Ver>
62+
<VerMajor>$(Ver.Split(`.`)[0])</VerMajor>
63+
<VerMinor>$(Ver.Split(`.`)[1])</VerMinor>
64+
<VerMicro>$(Ver.Split(`.`)[2])</VerMicro>
65+
</PropertyGroup>
5866
<ItemGroup>
5967
<Lines Include="// This file was generated by $([System.IO.Path]::GetFileName(`$(MsBuildThisFile)`))"/>
6068
<Lines Include="#define MICROPY_GIT_TAG &quot;$(GitTag)&quot;"/>
6169
<Lines Include="#define MICROPY_GIT_HASH &quot;$(GitHash)&quot;"/>
6270
<Lines Include="#define MICROPY_BUILD_DATE &quot;$([System.DateTime]::Now.ToString(`yyyy-MM-dd`))&quot;"/>
71+
<Lines Include="#define MICROPY_VERSION_MAJOR ($(VerMajor))"/>
72+
<Lines Include="#define MICROPY_VERSION_MINOR ($(VerMinor))"/>
73+
<Lines Include="#define MICROPY_VERSION_MICRO ($(VerMicro))"/>
74+
<Lines Include="#define MICROPY_VERSION_STRING &quot;$(Ver)&quot;"/>
6375
</ItemGroup>
6476
<WriteLinesToFile Lines="@(Lines)" File="$(TmpFile)" Overwrite="true"/>
6577
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>

0 commit comments

Comments
 (0)