genhdr.targets 2.45 KB
Newer Older
stijn's avatar
stijn committed
1
2
3
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="GenerateHeaders">

4
  <Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
5

6
7
  <!--Generate qstrdefs.h and mpversion.h similar to what is done in py/py.mk-->
  <Target Name="GenerateHeaders" DependsOnTargets="MakeQstrData;MakeVersionHdr">
stijn's avatar
stijn committed
8
9
10
  </Target>

  <PropertyGroup>
11
    <DestDir>$(PyBuildDir)genhdr\</DestDir>
12
    <PySrcDir>$(PyBaseDir)py\</PySrcDir>
13
    <PyPython Condition="'$(PyPython)' == ''">python</PyPython>
stijn's avatar
stijn committed
14
15
16
17
18
19
20
21
22
  </PropertyGroup>

  <Target Name="MakeDestDir">
    <MakeDir Directories="$(DestDir)"/>
  </Target>

  <Target Name="MakeQstrData" DependsOnTargets="MakeDestDir">
    <PropertyGroup>
      <PreProc>$(DestDir)qstrdefs.preprocessed.h</PreProc>
23
      <QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs>
stijn's avatar
stijn committed
24
      <DestFile>$(DestDir)qstrdefs.generated.h</DestFile>
25
      <TmpFile>$(DestFile).tmp</TmpFile>
stijn's avatar
stijn committed
26
    </PropertyGroup>
27
28
29
    <ItemGroup>
      <PyIncDirs Include="$(PyIncDirs)"/>
    </ItemGroup>
30
    <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /Fi$(PreProc) /P $(PySrcDir)qstrdefs.h"/>
31
    <Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(PreProc) $(QstrDefs) > $(TmpFile)"/>
32
    <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
stijn's avatar
stijn committed
33
34
  </Target>

35
  <Target Name="MakeVersionHdr" DependsOnTargets="MakeDestDir">
stijn's avatar
stijn committed
36
    <PropertyGroup>
37
      <DestFile>$(DestDir)mpversion.h</DestFile>
38
      <TmpFile>$(DestFile).tmp</TmpFile>
stijn's avatar
stijn committed
39
    </PropertyGroup>
40
    <Exec Command="$(PyPython) $(PySrcDir)makeversionhdr.py $(TmpFile)"/>
41
42
43
44
45
46
47
48
49
    <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">
50
51
      <Output TaskParameter="ExitCode" PropertyName="FilesDiffer" />
    </Exec>
52
    <Copy SourceFiles="$(SourceFile)" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/>
stijn's avatar
stijn committed
53
54
55
  </Target>

</Project>