summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--windows/msvc/genhdr.targets83
1 files changed, 44 insertions, 39 deletions
diff --git a/windows/msvc/genhdr.targets b/windows/msvc/genhdr.targets
index a2b4c80964..ba0681f554 100644
--- a/windows/msvc/genhdr.targets
+++ b/windows/msvc/genhdr.targets
@@ -3,7 +3,7 @@
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
- <!--Generate qstrdefs.h and mpversion.h similar to what is done in py/mkrules.mk-->
+ <!--Generate qstrdefs.generated.h and mpversion.h similar to what is done in py/mkrules.mk and py/py.mk-->
<Target Name="GenerateHeaders" DependsOnTargets="MakeVersionHdr;MakeQstrData">
</Target>
@@ -11,65 +11,70 @@
<DestDir>$(PyBuildDir)genhdr\</DestDir>
<PySrcDir>$(PyBaseDir)py\</PySrcDir>
<QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs>
+ <PyQstrDefs>$(PySrcDir)qstrdefs.h</PyQstrDefs>
<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="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(PyQstrSourceFiles)" Outputs="$(QstrDefsCollected)">
+ <!-- Concatenate preprocessed files for use with makeqstrdefs.py.
+ Filters out any lines which aren't used by makeqstrdefs.py so the resulting file is
+ hundreds of times smaller and processing in python takes substantially less time-->
+ <UsingTask TaskName="ConcatPreProcFiles" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
+ <ParameterGroup>
+ <OutputFile Required="true" ParameterType="System.String"/>
+ <InputFiles Required="true" ParameterType="System.String[]"/>
+ </ParameterGroup>
+ <Task>
+ <Code Type="Fragment" Language="cs">
+ <![CDATA[
+using(var outFile = System.IO.File.CreateText(OutputFile)) {
+ foreach(var inFile in InputFiles)
+ foreach(var line in System.IO.File.ReadAllLines(inFile))
+ if((line.Contains(".c") && line.StartsWith("#line")) || line.Contains("MP_QSTR"))
+ outFile.WriteLine( line );
+}
+ ]]>
+ </Code>
+ </Task>
+ </UsingTask>
+
+ <!-- Preprocess changed files, concatenate and feed into makeqstrdefs.py split/cat-->
+ <Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(ClCompile)" Outputs="$(QstrDefsCollected)">
<ItemGroup>
<PyIncDirs Include="$(PyIncDirs)"/>
- <PreProcDefs Include=" %(ClCompile.PreProcessorDefinitions)"/>
+ <PreProcDefs Include="%(ClCompile.PreProcessorDefinitions);__QSTR_EXTRACT;N_X64;N_X86;N_THUMB;N_ARM"/>
+ <PyQstrSourceFiles Include="@(ClCompile)">
+ <OutFile>$([System.String]::new('%(FullPath)').Replace('$(PyBaseDir)', '$(DestDir)qstr\'))</OutFile>
+ </PyQstrSourceFiles>
<PyQstrSourceFiles>
- <Qstr>$([System.String]::new('%(FullPath)').Replace('$(PyBaseDir)', '$(DestDir)'))</Qstr>
+ <OutFile>$([System.IO.Path]::ChangeExtension('%(OutFile)', '.pp'))</OutFile>
+ <OutDir>$([System.IO.Path]::GetDirectoryName('%(OutFile)'))</OutDir>
</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>
+ <Changed>$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('%(OutFile)'))))</Changed>
</PyQstrSourceFiles>
</ItemGroup>
- <PropertyGroup>
-
- </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>
- <QStrLines Include="@(PreProcLines)" Condition="$([System.String]::new('%(Identity)').Contains('Q'))"/>
- </ItemGroup>
- <WriteLinesToFile Lines="@(QStrLines)" File="$(QstrDefsCollected)" Overwrite="true"/>
+ <MakeDir Directories="@(PyQstrSourceFiles->'%(OutDir)')"/>
+ <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /Fi%(PyQstrSourceFiles.OutFile) /P %(PyQstrSourceFiles.Identity)"
+ Condition="%(PyQstrSourceFiles.Changed) &gt; 0"/>
+ <ConcatPreProcFiles InputFiles="@(PyQstrSourceFiles->'%(OutFile)')" OutputFile="$(DestDir)qstr.i.last"
+ Condition="%(PyQstrSourceFiles.Changed) &gt; 0"/>
+ <Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py split $(DestDir)qstr.i.last $(DestDir)qstr $(QstrDefsCollected)"/>
+ <Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py cat $(DestDir)qstr.i.last $(DestDir)qstr $(QstrDefsCollected)"/>
</Target>
- <Target Name="MakeQstrData" DependsOnTargets="MakeQstrDefs">
+ <Target Name="MakeQstrData" DependsOnTargets="MakeQstrDefs" Inputs="$(QstrDefsCollected);$(PyQstrDefs);$(QstrDefs)" Outputs="$(QstrGen)">
<PropertyGroup>
- <TmpFile>$(DestFile).tmp</TmpFile>
+ <TmpFile>$(QstrGen).tmp</TmpFile>
</PropertyGroup>
- <Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(QstrDefs) $(QstrDefsCollected) > $(TmpFile)"/>
+ <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /E $(PyQstrDefs) $(QstrDefs) > $(DestDir)qstrdefspreprocessed.h"/>
+ <Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(DestDir)qstrdefspreprocessed.h $(QstrDefsCollected) > $(TmpFile)"/>
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(QstrGen)"/>
</Target>