Skip to content

Commit db9c2e3

Browse files
stinospfalcon
authored andcommitted
msvc: Rebuild all qstrs when mpconfig headers are modified
Make qstr generation depend on modifications in mpconfigport.h, mpconfig.h and makeqstrdata.py and if any of those change scan all source files for qstrs again since they might have changed (for example typcially when enabling new features in mpconfig.h). This fixes adafruit#2982 for msvc builds.
1 parent 8d865fa commit db9c2e3

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

windows/msvc/genhdr.targets

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ using(var outFile = System.IO.File.CreateText(OutputFile)) {
4343
</Task>
4444
</UsingTask>
4545

46+
<!-- If any of these changed we'll force all qstrs to be generated again-->
47+
<ItemGroup>
48+
<QstrDependencies Include="$(PyWinDir)mpconfigport.h;$(PySrcDir)mpconfig.h;$(PySrcDir)makeqstrdata.py"/>
49+
</ItemGroup>
50+
4651
<!-- Preprocess changed files, concatenate and feed into makeqstrdefs.py split/cat-->
47-
<Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(ClCompile)" Outputs="$(QstrDefsCollected)">
52+
<Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(ClCompile);@(QstrDependencies)" Outputs="$(QstrDefsCollected)">
4853
<ItemGroup>
4954
<PyIncDirs Include="$(PyIncDirs)"/>
5055
<PreProcDefs Include="%(ClCompile.PreProcessorDefinitions);NO_QSTR;N_X64;N_X86;N_THUMB;N_ARM"/>
@@ -56,15 +61,21 @@ using(var outFile = System.IO.File.CreateText(OutputFile)) {
5661
<OutDir>$([System.IO.Path]::GetDirectoryName('%(OutFile)'))</OutDir>
5762
</PyQstrSourceFiles>
5863
<PyQstrSourceFiles>
59-
<Changed>$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('%(OutFile)'))))</Changed>
64+
<Changed Condition="$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('%(OutFile)')))) &gt; 0">True</Changed>
6065
</PyQstrSourceFiles>
66+
<QstrDependencies>
67+
<Changed Condition="$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('$(DestDir)qstr.i.last')))) &gt; 0">True</Changed>
68+
</QstrDependencies>
6169
</ItemGroup>
70+
<PropertyGroup>
71+
<ForceQstrRebuild>@(QstrDependencies->AnyHaveMetadataValue('Changed', 'True'))</ForceQstrRebuild>
72+
</PropertyGroup>
6273

6374
<MakeDir Directories="@(PyQstrSourceFiles->'%(OutDir)')"/>
6475
<Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /Fi%(PyQstrSourceFiles.OutFile) /P %(PyQstrSourceFiles.Identity)"
65-
Condition="%(PyQstrSourceFiles.Changed) &gt; 0"/>
76+
Condition="'%(PyQstrSourceFiles.Changed)' == 'True' Or '$(ForceQstrRebuild)' == 'True'"/>
6677
<ConcatPreProcFiles InputFiles="@(PyQstrSourceFiles->'%(OutFile)')" OutputFile="$(DestDir)qstr.i.last"
67-
Condition="%(PyQstrSourceFiles.Changed) &gt; 0"/>
78+
Condition="@(PyQstrSourceFiles->AnyHaveMetadataValue('Changed', 'True')) Or '$(ForceQstrRebuild)' == 'True'"/>
6879
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py split $(DestDir)qstr.i.last $(DestDir)qstr $(QstrDefsCollected)"/>
6980
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py cat $(DestDir)qstr.i.last $(DestDir)qstr $(QstrDefsCollected)"/>
7081
</Target>

0 commit comments

Comments
 (0)