summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorstijn <stinos@zoho.com>2015-01-02 16:31:49 +0100
committerstijn <stinos@zoho.com>2015-01-02 16:55:02 +0100
commitffc96a901a13f6f114368ad50a1d7189c0826822 (patch)
treea366a6dcc6085e34ca32eb3a2d6b3da074fe6129
parentfbfd3554fac29c886ccfed1b8796ed8852d32442 (diff)
downloadmicropython-ffc96a901a13f6f114368ad50a1d7189c0826822.tar.gz
micropython-ffc96a901a13f6f114368ad50a1d7189c0826822.zip
msvc: Use single build target for dealing with generated files
Remove some duplication in the code for generating qstrdefs.generated.h and py-version.h
-rw-r--r--windows/msvc/genhdr.targets27
1 files changed, 17 insertions, 10 deletions
diff --git a/windows/msvc/genhdr.targets b/windows/msvc/genhdr.targets
index fe0abbe093..8001985b77 100644
--- a/windows/msvc/genhdr.targets
+++ b/windows/msvc/genhdr.targets
@@ -7,7 +7,6 @@
</Target>
<PropertyGroup>
- <SrcDir>$(PyBaseDir)py\</SrcDir>
<DestDir>$(PyBuildDir)genhdr\</DestDir>
</PropertyGroup>
@@ -18,19 +17,18 @@
<!--see py/py.mk under #qstr data-->
<Target Name="MakeQstrData" DependsOnTargets="MakeDestDir">
<PropertyGroup>
+ <PySrcDir>$(PyBaseDir)py\</PySrcDir>
<PreProc>$(DestDir)qstrdefs.preprocessed.h</PreProc>
<QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs>
<DestFile>$(DestDir)qstrdefs.generated.h</DestFile>
+ <TmpFile>$(DestFile).tmp</TmpFile>
</PropertyGroup>
<ItemGroup>
<PyIncDirs Include="$(PyIncDirs)"/>
</ItemGroup>
- <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /Fi$(PreProc) /P $(SrcDir)qstrdefs.h"/>
- <Exec Command="python $(SrcDir)makeqstrdata.py $(PreProc) $(QstrDefs) > $(DestFile).tmp"/>
- <Exec Command="fc /B $(DestFile).tmp $(DestFile) > NUL 2>&amp;1" IgnoreExitCode="true">
- <Output TaskParameter="ExitCode" PropertyName="FilesDiffer" />
- </Exec>
- <Copy SourceFiles="$(DestFile).tmp" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/>
+ <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)"/>
</Target>
<!--see py/py-version.sh-->
@@ -55,6 +53,7 @@
</PropertyGroup>
<PropertyGroup>
<DestFile>$(DestDir)py-version.h</DestFile>
+ <TmpFile>$(DestFile).tmp</TmpFile>
</PropertyGroup>
<ItemGroup>
<Lines Include="// This file was generated by $([System.IO.Path]::GetFileName(`$(MsBuildThisFile)`))"/>
@@ -62,11 +61,19 @@
<Lines Include="#define MICROPY_GIT_HASH &quot;$(GitHash)&quot;"/>
<Lines Include="#define MICROPY_BUILD_DATE &quot;$([System.DateTime]::Now.ToString(`yyyy-MM-dd`))&quot;"/>
</ItemGroup>
- <WriteLinesToFile Lines="@(Lines)" File="$(DestFile).tmp" Overwrite="true"/>
- <Exec Command="fc /B $(DestFile).tmp $(DestFile) > NUL 2>&amp;1" IgnoreExitCode="true">
+ <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>&amp;1" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="FilesDiffer" />
</Exec>
- <Copy SourceFiles="$(DestFile).tmp" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/>
+ <Copy SourceFiles="$(SourceFile)" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/>
</Target>
</Project>