|
3 | 3 |
|
4 | 4 | <Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/> |
5 | 5 |
|
6 | | - <!--Generate qstrdefs.h and mpversion.h similar to what is done in py/py.mk--> |
7 | | - <Target Name="GenerateHeaders" DependsOnTargets="MakeQstrData;MakeVersionHdr"> |
| 6 | + <!--Generate qstrdefs.h and mpversion.h similar to what is done in py/mkrules.mk--> |
| 7 | + <Target Name="GenerateHeaders" DependsOnTargets="MakeVersionHdr;MakeQstrData"> |
8 | 8 | </Target> |
9 | 9 |
|
10 | 10 | <PropertyGroup> |
11 | 11 | <DestDir>$(PyBuildDir)genhdr\</DestDir> |
12 | 12 | <PySrcDir>$(PyBaseDir)py\</PySrcDir> |
| 13 | + <QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs> |
| 14 | + <QstrDefsCollected>$(DestDir)qstrdefscollected.h</QstrDefsCollected> |
| 15 | + <QstrGen>$(DestDir)qstrdefs.generated.h</QstrGen> |
13 | 16 | <PyPython Condition="'$(PyPython)' == ''">python</PyPython> |
14 | 17 | </PropertyGroup> |
15 | 18 |
|
| 19 | + <ItemGroup> |
| 20 | + <PyQstrSourceFiles Include="@(ClCompile);$(PySrcDir)qstrdefs.h"/> |
| 21 | + </ItemGroup> |
| 22 | + |
16 | 23 | <Target Name="MakeDestDir"> |
17 | 24 | <MakeDir Directories="$(DestDir)"/> |
18 | 25 | </Target> |
19 | 26 |
|
20 | | - <Target Name="MakeQstrData" DependsOnTargets="MakeDestDir"> |
| 27 | + <Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(PyQstrSourceFiles)" Outputs="$(QstrDefsCollected)"> |
| 28 | + <ItemGroup> |
| 29 | + <PyIncDirs Include="$(PyIncDirs)"/> |
| 30 | + <PreProcDefs Include=" %(ClCompile.PreProcessorDefinitions)"/> |
| 31 | + <PyQstrSourceFiles> |
| 32 | + <Qstr>$([System.String]::new('%(FullPath)').Replace('$(PyBaseDir)', '$(DestDir)'))</Qstr> |
| 33 | + </PyQstrSourceFiles> |
| 34 | + <PyQstrSourceFiles> |
| 35 | + <Qstr>$([System.IO.Path]::ChangeExtension('%(Qstr)', '.qstr'))</Qstr> |
| 36 | + <PreProc>$([System.IO.Path]::ChangeExtension('%(Qstr)', '.pp'))</PreProc> |
| 37 | + <QstrDir>$([System.IO.Path]::GetDirectoryName('%(Qstr)'))</QstrDir> |
| 38 | + <PreProcOnly>$([System.String]::new('%(FileName)').Contains('qstrdefs'))</PreProcOnly> |
| 39 | + </PyQstrSourceFiles> |
| 40 | + </ItemGroup> |
21 | 41 | <PropertyGroup> |
22 | | - <PreProc>$(DestDir)qstrdefs.preprocessed.h</PreProc> |
23 | | - <QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs> |
24 | | - <DestFile>$(DestDir)qstrdefs.generated.h</DestFile> |
25 | | - <TmpFile>$(DestFile).tmp</TmpFile> |
| 42 | + |
26 | 43 | </PropertyGroup> |
| 44 | + |
| 45 | + <!-- Preprocess and pass to makeqstrdefs if needed, else just copy --> |
| 46 | + <MakeDir Directories="@(PyQstrSourceFiles->'%(QstrDir)')"/> |
| 47 | + <Touch Files="$(QstrGen)" AlwaysCreate="true"/> |
| 48 | + |
| 49 | + <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /Fi%(PyQstrSourceFiles.PreProc) /P %(PyQstrSourceFiles.Identity)"/> |
| 50 | + <Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py -s -o %(PyQstrSourceFiles.Qstr) %(PyQstrSourceFiles.PreProc)" Condition="'%(PyQstrSourceFiles.PreProcOnly)' != 'True'"/> |
| 51 | + <Copy SourceFiles="%(PyQstrSourceFiles.PreProc)" DestinationFiles="%(PyQstrSourceFiles.Qstr)" Condition="'%(PyQstrSourceFiles.PreProcOnly)' == 'True'"/> |
| 52 | + |
| 53 | + <!-- Collect all output (where qstrdefs file(s) have priority over autogenerated ones), then |
| 54 | + filter out lines which definitely aren't qstr definitions so we don't end up with a huge (> 10mb) filesize --> |
| 55 | + <ReadLinesFromFile File="%(PyQstrSourceFiles.Qstr)" Condition="'%(PyQstrSourceFiles.PreProcOnly)' == 'True'"> |
| 56 | + <Output TaskParameter="Lines" ItemName="PreProcLines"/> |
| 57 | + </ReadLinesFromFile> |
| 58 | + <ReadLinesFromFile File="%(PyQstrSourceFiles.Qstr)"> |
| 59 | + <Output TaskParameter="Lines" ItemName="PreProcLines"/> |
| 60 | + </ReadLinesFromFile> |
27 | 61 | <ItemGroup> |
28 | | - <PyIncDirs Include="$(PyIncDirs)"/> |
| 62 | + <QStrLines Include="@(PreProcLines)" Condition="$([System.String]::new('%(Identity)').Contains('Q'))"/> |
29 | 63 | </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)"/> |
| 64 | + |
| 65 | + <WriteLinesToFile Lines="@(QStrLines)" File="$(QstrDefsCollected)" Overwrite="true"/> |
| 66 | + </Target> |
| 67 | + |
| 68 | + <Target Name="MakeQstrData" DependsOnTargets="MakeQstrDefs"> |
| 69 | + <PropertyGroup> |
| 70 | + <TmpFile>$(DestFile).tmp</TmpFile> |
| 71 | + </PropertyGroup> |
| 72 | + <Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(QstrDefs) $(QstrDefsCollected) > $(TmpFile)"/> |
| 73 | + <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(QstrGen)"/> |
33 | 74 | </Target> |
34 | 75 |
|
35 | 76 | <Target Name="MakeVersionHdr" DependsOnTargets="MakeDestDir"> |
|
0 commit comments