|
7 | 7 | </Target> |
8 | 8 |
|
9 | 9 | <PropertyGroup> |
10 | | - <SrcDir>$(PyBaseDir)py\</SrcDir> |
11 | 10 | <DestDir>$(PyBuildDir)genhdr\</DestDir> |
12 | 11 | </PropertyGroup> |
13 | 12 |
|
|
18 | 17 | <!--see py/py.mk under #qstr data--> |
19 | 18 | <Target Name="MakeQstrData" DependsOnTargets="MakeDestDir"> |
20 | 19 | <PropertyGroup> |
| 20 | + <PySrcDir>$(PyBaseDir)py\</PySrcDir> |
21 | 21 | <PreProc>$(DestDir)qstrdefs.preprocessed.h</PreProc> |
22 | 22 | <QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs> |
23 | 23 | <DestFile>$(DestDir)qstrdefs.generated.h</DestFile> |
| 24 | + <TmpFile>$(DestFile).tmp</TmpFile> |
24 | 25 | </PropertyGroup> |
25 | 26 | <ItemGroup> |
26 | 27 | <PyIncDirs Include="$(PyIncDirs)"/> |
27 | 28 | </ItemGroup> |
28 | | - <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /Fi$(PreProc) /P $(SrcDir)qstrdefs.h"/> |
29 | | - <Exec Command="python $(SrcDir)makeqstrdata.py $(PreProc) $(QstrDefs) > $(DestFile).tmp"/> |
30 | | - <Exec Command="fc /B $(DestFile).tmp $(DestFile) > NUL 2>&1" IgnoreExitCode="true"> |
31 | | - <Output TaskParameter="ExitCode" PropertyName="FilesDiffer" /> |
32 | | - </Exec> |
33 | | - <Copy SourceFiles="$(DestFile).tmp" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/> |
| 29 | + <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /Fi$(PreProc) /P $(PySrcDir)qstrdefs.h"/> |
| 30 | + <Exec Command="python $(PySrcDir)makeqstrdata.py $(PreProc) $(QstrDefs) > $(TmpFile)"/> |
| 31 | + <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/> |
34 | 32 | </Target> |
35 | 33 |
|
36 | 34 | <!--see py/py-version.sh--> |
|
55 | 53 | </PropertyGroup> |
56 | 54 | <PropertyGroup> |
57 | 55 | <DestFile>$(DestDir)py-version.h</DestFile> |
| 56 | + <TmpFile>$(DestFile).tmp</TmpFile> |
58 | 57 | </PropertyGroup> |
59 | 58 | <ItemGroup> |
60 | 59 | <Lines Include="// This file was generated by $([System.IO.Path]::GetFileName(`$(MsBuildThisFile)`))"/> |
61 | 60 | <Lines Include="#define MICROPY_GIT_TAG "$(GitTag)""/> |
62 | 61 | <Lines Include="#define MICROPY_GIT_HASH "$(GitHash)""/> |
63 | 62 | <Lines Include="#define MICROPY_BUILD_DATE "$([System.DateTime]::Now.ToString(`yyyy-MM-dd`))""/> |
64 | 63 | </ItemGroup> |
65 | | - <WriteLinesToFile Lines="@(Lines)" File="$(DestFile).tmp" Overwrite="true"/> |
66 | | - <Exec Command="fc /B $(DestFile).tmp $(DestFile) > NUL 2>&1" IgnoreExitCode="true"> |
| 64 | + <WriteLinesToFile Lines="@(Lines)" File="$(TmpFile)" Overwrite="true"/> |
| 65 | + <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/> |
| 66 | + </Target> |
| 67 | + |
| 68 | + <!--Copies SourceFile to DestFile only if SourceFile's content differs from DestFile's. |
| 69 | + We use this to 'touch' the generated files only when they are really newer |
| 70 | + so a build is only triggered if the generated content actually changed, |
| 71 | + and not just because the file date changed since the last build--> |
| 72 | + <Target Name="CopyFileIfDifferent"> |
| 73 | + <Exec Command="fc /B $(SourceFile) $(DestFile) > NUL 2>&1" IgnoreExitCode="true"> |
67 | 74 | <Output TaskParameter="ExitCode" PropertyName="FilesDiffer" /> |
68 | 75 | </Exec> |
69 | | - <Copy SourceFiles="$(DestFile).tmp" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/> |
| 76 | + <Copy SourceFiles="$(SourceFile)" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/> |
70 | 77 | </Target> |
71 | 78 |
|
72 | 79 | </Project> |
0 commit comments