summaryrefslogtreecommitdiff
path: root/windows/msvc
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2016-03-15 10:22:34 +0100
committerDamien George <damien.p.george@gmail.com>2016-04-16 13:19:15 +0100
commit9a627e8881c1b5d8fad9f1a563b5af23716e1b55 (patch)
tree1dbf954104d780a4fee08ead7a8544ba6ec69cf1 /windows/msvc
parent61b560f63f9f5f84fffb4a1a0e2cb3d8f98fb291 (diff)
windows/msvc: Implement automatic qstr generation using makeqstrdefs.
Note this still needs some work: currently all source files are always preprocessed no matter which one actually changed, moreover that happens file by file without any parallellism so builds are painstakingly slow.
Diffstat (limited to 'windows/msvc')
-rw-r--r--windows/msvc/genhdr.targets63
1 files changed, 52 insertions, 11 deletions
diff --git a/windows/msvc/genhdr.targets b/windows/msvc/genhdr.targets
index 3d9a148be..a2b4c8096 100644
--- a/windows/msvc/genhdr.targets
+++ b/windows/msvc/genhdr.targets
@@ -3,33 +3,74 @@
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
- <!--Generate qstrdefs.h and mpversion.h similar to what is done in py/py.mk-->
- <Target Name="GenerateHeaders" DependsOnTargets="MakeQstrData;MakeVersionHdr">
+ <!--Generate qstrdefs.h and mpversion.h similar to what is done in py/mkrules.mk-->
+ <Target Name="GenerateHeaders" DependsOnTargets="MakeVersionHdr;MakeQstrData">
</Target>
<PropertyGroup>
<DestDir>$(PyBuildDir)genhdr\</DestDir>
<PySrcDir>$(PyBaseDir)py\</PySrcDir>
+ <QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs>
+ <QstrDefsCollected>$(DestDir)qstrdefscollected.h</QstrDefsCollected>
+ <QstrGen>$(DestDir)qstrdefs.generated.h</QstrGen>
<PyPython Condition="'$(PyPython)' == ''">python</PyPython>
</PropertyGroup>
+ <ItemGroup>
+ <PyQstrSourceFiles Include="@(ClCompile);$(PySrcDir)qstrdefs.h"/>
+ </ItemGroup>
+
<Target Name="MakeDestDir">
<MakeDir Directories="$(DestDir)"/>
</Target>
- <Target Name="MakeQstrData" DependsOnTargets="MakeDestDir">
+ <Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(PyQstrSourceFiles)" Outputs="$(QstrDefsCollected)">
+ <ItemGroup>
+ <PyIncDirs Include="$(PyIncDirs)"/>
+ <PreProcDefs Include=" %(ClCompile.PreProcessorDefinitions)"/>
+ <PyQstrSourceFiles>
+ <Qstr>$([System.String]::new('%(FullPath)').Replace('$(PyBaseDir)', '$(DestDir)'))</Qstr>
+ </PyQstrSourceFiles>
+ <PyQstrSourceFiles>
+ <Qstr>$([System.IO.Path]::ChangeExtension('%(Qstr)', '.qstr'))</Qstr>
+ <PreProc>$([System.IO.Path]::ChangeExtension('%(Qstr)', '.pp'))</PreProc>
+ <QstrDir>$([System.IO.Path]::GetDirectoryName('%(Qstr)'))</QstrDir>
+ <PreProcOnly>$([System.String]::new('%(FileName)').Contains('qstrdefs'))</PreProcOnly>
+ </PyQstrSourceFiles>
+ </ItemGroup>
<PropertyGroup>
- <PreProc>$(DestDir)qstrdefs.preprocessed.h</PreProc>
- <QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs>
- <DestFile>$(DestDir)qstrdefs.generated.h</DestFile>
- <TmpFile>$(DestFile).tmp</TmpFile>
+
</PropertyGroup>
+
+ <!-- Preprocess and pass to makeqstrdefs if needed, else just copy -->
+ <MakeDir Directories="@(PyQstrSourceFiles->'%(QstrDir)')"/>
+ <Touch Files="$(QstrGen)" AlwaysCreate="true"/>
+
+ <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /Fi%(PyQstrSourceFiles.PreProc) /P %(PyQstrSourceFiles.Identity)"/>
+ <Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py -s -o %(PyQstrSourceFiles.Qstr) %(PyQstrSourceFiles.PreProc)" Condition="'%(PyQstrSourceFiles.PreProcOnly)' != 'True'"/>
+ <Copy SourceFiles="%(PyQstrSourceFiles.PreProc)" DestinationFiles="%(PyQstrSourceFiles.Qstr)" Condition="'%(PyQstrSourceFiles.PreProcOnly)' == 'True'"/>
+
+ <!-- Collect all output (where qstrdefs file(s) have priority over autogenerated ones), then
+ filter out lines which definitely aren't qstr definitions so we don't end up with a huge (> 10mb) filesize -->
+ <ReadLinesFromFile File="%(PyQstrSourceFiles.Qstr)" Condition="'%(PyQstrSourceFiles.PreProcOnly)' == 'True'">
+ <Output TaskParameter="Lines" ItemName="PreProcLines"/>
+ </ReadLinesFromFile>
+ <ReadLinesFromFile File="%(PyQstrSourceFiles.Qstr)">
+ <Output TaskParameter="Lines" ItemName="PreProcLines"/>
+ </ReadLinesFromFile>
<ItemGroup>
- <PyIncDirs Include="$(PyIncDirs)"/>
+ <QStrLines Include="@(PreProcLines)" Condition="$([System.String]::new('%(Identity)').Contains('Q'))"/>
</ItemGroup>
- <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /Fi$(PreProc) /P $(PySrcDir)qstrdefs.h"/>
- <Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(PreProc) $(QstrDefs) > $(TmpFile)"/>
- <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
+
+ <WriteLinesToFile Lines="@(QStrLines)" File="$(QstrDefsCollected)" Overwrite="true"/>
+ </Target>
+
+ <Target Name="MakeQstrData" DependsOnTargets="MakeQstrDefs">
+ <PropertyGroup>
+ <TmpFile>$(DestFile).tmp</TmpFile>
+ </PropertyGroup>
+ <Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(QstrDefs) $(QstrDefsCollected) > $(TmpFile)"/>
+ <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(QstrGen)"/>
</Target>
<Target Name="MakeVersionHdr" DependsOnTargets="MakeDestDir">