2014-05-05 06:18:27 -04:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="GenerateHeaders">
|
|
|
|
|
2015-01-02 05:49:23 -05:00
|
|
|
<Import Project="env.props" Condition="$(PyEnvIncluded)!=True"/>
|
|
|
|
|
2014-05-05 06:18:27 -04:00
|
|
|
<Target Name="GenerateHeaders" DependsOnTargets="MakeQstrData;MakeVersionHeader">
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<PropertyGroup>
|
2015-01-02 05:49:23 -05:00
|
|
|
<DestDir>$(PyBuildDir)genhdr\</DestDir>
|
2014-05-05 06:18:27 -04:00
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
<Target Name="MakeDestDir">
|
|
|
|
<MakeDir Directories="$(DestDir)"/>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<!--see py/py.mk under #qstr data-->
|
|
|
|
<Target Name="MakeQstrData" DependsOnTargets="MakeDestDir">
|
|
|
|
<PropertyGroup>
|
2015-01-02 10:31:49 -05:00
|
|
|
<PySrcDir>$(PyBaseDir)py\</PySrcDir>
|
2014-05-05 06:18:27 -04:00
|
|
|
<PreProc>$(DestDir)qstrdefs.preprocessed.h</PreProc>
|
2015-01-02 05:49:23 -05:00
|
|
|
<QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs>
|
2014-05-05 06:18:27 -04:00
|
|
|
<DestFile>$(DestDir)qstrdefs.generated.h</DestFile>
|
2015-01-02 10:31:49 -05:00
|
|
|
<TmpFile>$(DestFile).tmp</TmpFile>
|
2014-05-05 06:18:27 -04:00
|
|
|
</PropertyGroup>
|
2015-01-02 05:49:23 -05:00
|
|
|
<ItemGroup>
|
|
|
|
<PyIncDirs Include="$(PyIncDirs)"/>
|
|
|
|
</ItemGroup>
|
2015-01-02 10:31:49 -05:00
|
|
|
<Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /Fi$(PreProc) /P $(PySrcDir)qstrdefs.h"/>
|
|
|
|
<Exec Command="python $(PySrcDir)makeqstrdata.py $(PreProc) $(QstrDefs) > $(TmpFile)"/>
|
|
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
|
2014-05-05 06:18:27 -04:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
<!--see py/py-version.sh-->
|
|
|
|
<Target Name="GetGitState">
|
|
|
|
<Exec Command="git describe --dirty --always" ConsoleToMSBuild="true" IgnoreExitCode="true">
|
|
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitTag" />
|
|
|
|
</Exec>
|
|
|
|
<Exec Command="git rev-parse --short HEAD 2>NUL || echo unknown" ConsoleToMSBuild="true" IgnoreExitCode="true">
|
|
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitHash" />
|
|
|
|
</Exec>
|
|
|
|
<Exec Command="git diff --no-ext-diff --quiet --exit-code 2>NUL || echo 0" ConsoleToMSBuild="true" IgnoreExitCode="true">
|
|
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitFilesAreClean" />
|
|
|
|
</Exec>
|
|
|
|
<Exec Command="git diff-index --cached --quiet HEAD -- 2>NUL || echo 0" ConsoleToMSBuild="true" IgnoreExitCode="true" Condition="'$(GitFilesAreClean)'==''">
|
|
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitFilesAreClean" />
|
|
|
|
</Exec>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<Target Name="MakeVersionHeader" DependsOnTargets="MakeDestDir;GetGitState">
|
|
|
|
<PropertyGroup Condition="'$(GitFilesAreClean)'=='0'">
|
|
|
|
<GitHash>$(GitHash)-dirty</GitHash>
|
|
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
|
|
<DestFile>$(DestDir)py-version.h</DestFile>
|
2015-01-02 10:31:49 -05:00
|
|
|
<TmpFile>$(DestFile).tmp</TmpFile>
|
2014-05-05 06:18:27 -04:00
|
|
|
</PropertyGroup>
|
2015-04-22 06:03:52 -04:00
|
|
|
<PropertyGroup>
|
|
|
|
<Ver>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), `^v[0-9\.]{5}`))</Ver>
|
|
|
|
<Ver Condition="'$(Ver)'==''">v0.0.1</Ver>
|
|
|
|
<Ver>$(Ver.Remove(0, 1))</Ver>
|
|
|
|
<VerMajor>$(Ver.Split(`.`)[0])</VerMajor>
|
|
|
|
<VerMinor>$(Ver.Split(`.`)[1])</VerMinor>
|
|
|
|
<VerMicro>$(Ver.Split(`.`)[2])</VerMicro>
|
|
|
|
</PropertyGroup>
|
2014-05-05 06:18:27 -04:00
|
|
|
<ItemGroup>
|
|
|
|
<Lines Include="// This file was generated by $([System.IO.Path]::GetFileName(`$(MsBuildThisFile)`))"/>
|
|
|
|
<Lines Include="#define MICROPY_GIT_TAG "$(GitTag)""/>
|
|
|
|
<Lines Include="#define MICROPY_GIT_HASH "$(GitHash)""/>
|
|
|
|
<Lines Include="#define MICROPY_BUILD_DATE "$([System.DateTime]::Now.ToString(`yyyy-MM-dd`))""/>
|
2015-04-22 06:03:52 -04:00
|
|
|
<Lines Include="#define MICROPY_VERSION_MAJOR ($(VerMajor))"/>
|
|
|
|
<Lines Include="#define MICROPY_VERSION_MINOR ($(VerMinor))"/>
|
|
|
|
<Lines Include="#define MICROPY_VERSION_MICRO ($(VerMicro))"/>
|
|
|
|
<Lines Include="#define MICROPY_VERSION_STRING "$(Ver)""/>
|
2014-05-05 06:18:27 -04:00
|
|
|
</ItemGroup>
|
2015-01-02 10:31:49 -05:00
|
|
|
<WriteLinesToFile Lines="@(Lines)" File="$(TmpFile)" Overwrite="true"/>
|
|
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<!--Copies SourceFile to DestFile only if SourceFile's content differs from DestFile's.
|
|
|
|
We use this to 'touch' the generated files only when they are really newer
|
|
|
|
so a build is only triggered if the generated content actually changed,
|
|
|
|
and not just because the file date changed since the last build-->
|
|
|
|
<Target Name="CopyFileIfDifferent">
|
|
|
|
<Exec Command="fc /B $(SourceFile) $(DestFile) > NUL 2>&1" IgnoreExitCode="true">
|
2014-05-28 10:03:38 -04:00
|
|
|
<Output TaskParameter="ExitCode" PropertyName="FilesDiffer" />
|
|
|
|
</Exec>
|
2015-01-02 10:31:49 -05:00
|
|
|
<Copy SourceFiles="$(SourceFile)" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/>
|
2014-05-05 06:18:27 -04:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
</Project>
|