Skip to content

Commit f3289a5

Browse files
authored
bpo-44479: Regenerate test_frozenmain.h and frozen_hello.h during build on Windows (GH-26984)
1 parent d17cc1f commit f3289a5

File tree

3 files changed

+42
-29
lines changed

3 files changed

+42
-29
lines changed

PCbuild/_freeze_importlib.vcxproj

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,18 @@
123123
<IntFile>$(IntDir)importlib_zipimport.g.h</IntFile>
124124
<OutFile>$(PySourcePath)Python\importlib_zipimport.h</OutFile>
125125
</None>
126+
<None Include="..\Tools\freeze\flag.py">
127+
<ModName>hello</ModName>
128+
<IntFile>$(IntDir)frozen_hello.g.h</IntFile>
129+
<OutFile>$(PySourcePath)Python\frozen_hello.h</OutFile>
130+
</None>
126131
</ItemGroup>
127132
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
128133
<ImportGroup Label="ExtensionTargets">
129134
</ImportGroup>
130135
<Target Name="_RebuildImportLib">
131136
<Exec Command='"$(TargetPath)" "%(None.ModName)" "%(None.FullPath)" "%(None.IntFile)"' />
132137

133-
<PropertyGroup>
134-
<_OldContent Condition="Exists($(OutTargetPath))"></_OldContent>
135-
<_NewContent Condition="Exists($(IntTargetPath))">$([System.IO.File]::ReadAllText($(IntTargetPath)).Replace(`&#x0D;&#x0A;`, `&#x0A;`))</_NewContent>
136-
</PropertyGroup>
137-
138138
<Copy SourceFiles="%(None.IntFile)"
139139
DestinationFiles="%(None.OutFile)"
140140
Condition="!Exists(%(None.OutFile)) or (Exists(%(None.IntFile)) and '$([System.IO.File]::ReadAllText(%(None.OutFile)).Replace(`&#x0D;&#x0A;`, `&#x0A;`))' != '$([System.IO.File]::ReadAllText(%(None.IntFile)).Replace(`&#x0D;&#x0A;`, `&#x0A;`))')">
@@ -153,9 +153,7 @@
153153
</Target>
154154
<Target Name="_CleanImportLib" BeforeTargets="CoreClean">
155155
<ItemGroup>
156-
<Clean Include="$(IntDir)importlib.g.h" />
157-
<Clean Include="$(IntDir)importlib_external.g.h" />
158-
<Clean Include="$(IntDir)importlib_zipimport.g.h" />
156+
<Clean Include="%(None.IntFile)" />
159157
</ItemGroup>
160158
</Target>
161159
</Project>

PCbuild/python.vcxproj

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@
114114
</ItemGroup>
115115
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
116116
<ImportGroup Label="ExtensionTargets">
117+
<Import Project="regen.targets" />
117118
</ImportGroup>
119+
<Target Name="_TriggerPostRegen" AfterTargets="Build" DependsOnTargets="PostBuildRegen" />
118120
<Target Name="ValidateUcrtbase" AfterTargets="AfterBuild" Condition="$(Configuration) != 'PGInstrument' and $(Platform) != 'ARM' and $(Platform) != 'ARM64'">
119121
<PropertyGroup>
120122
<UcrtName>ucrtbase</UcrtName>
@@ -145,23 +147,4 @@ $(_PGOPath)
145147
</PropertyGroup>
146148
<WriteLinesToFile File="$(PySourcePath)python.bat" Lines="$(_Content)" Overwrite="true" Condition="'$(_Content)' != '$(_ExistingContent)'" />
147149
</Target>
148-
<Target Name="GenerateLicense" AfterTargets="AfterBuild">
149-
<ItemGroup>
150-
<LicenseFiles Include="$(PySourcePath)LICENSE;
151-
$(PySourcePath)PC\crtlicense.txt;
152-
$(bz2Dir)LICENSE;
153-
$(opensslOutDir)LICENSE;
154-
$(libffiDir)LICENSE;" />
155-
<LicenseFiles Include="$(tcltkDir)tcllicense.terms;
156-
$(tcltkDir)tklicense.terms;
157-
$(tcltkDir)tixlicense.terms" Condition="$(IncludeTkinter)" />
158-
<_LicenseFiles Include="@(LicenseFiles)">
159-
<Content Condition="Exists(%(FullPath))">$([System.IO.File]::ReadAllText(%(FullPath)))</Content>
160-
</_LicenseFiles>
161-
</ItemGroup>
162-
163-
<WriteLinesToFile File="$(OutDir)LICENSE.txt"
164-
Overwrite="true"
165-
Lines="@(_LicenseFiles->'%(Content)')" />
166-
</Target>
167150
</Project>

PCbuild/regen.targets

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,44 @@
7373
</Target>
7474

7575
<Target Name="_RegenKeywords" Inputs="@(_KeywordSources)" Outputs="@(_KeywordOutputs)">
76-
<Message Text="Regenerate @(KeywordOutputs->'%(Filename)%(Extension)',' ')" Importance="high" />
76+
<Message Text="Regenerate @(_KeywordOutputs->'%(Filename)%(Extension)',' ')" Importance="high" />
7777
<Exec Command="set PYTHONPATH=Tools\peg_generator%0D%0A$(PythonForBuild) -m pegen.keywordgen Grammar\python.gram Grammar\Tokens Lib\keyword.py"
7878
WorkingDirectory="$(PySourcePath)" />
7979
</Target>
80-
80+
8181
<Target Name="Regen" DependsOnTargets="_TouchRegenSources;_RegenPegen;_RegenAST_H;_RegenOpcodes;_RegenTokens;_RegenKeywords">
8282
<Message Text="Generated sources are up to date" Importance="high" />
8383
</Target>
84+
85+
86+
<ItemGroup>
87+
<_TestFrozenSources Include="$(PySourcePath)Programs\freeze_test_frozenmain.py;
88+
$(PySourcePath)Programs\test_frozenmain.py;
89+
@(_OpcodeOutputs)" />
90+
<_TestFrozenOutputs Include="$(PySourcePath)Programs\test_frozenmain.h" />
91+
<_LicenseSources Include="$(PySourcePath)LICENSE;
92+
$(PySourcePath)PC\crtlicense.txt;
93+
$(bz2Dir)LICENSE;
94+
$(opensslOutDir)LICENSE;
95+
$(libffiDir)LICENSE;" />
96+
<_LicenseSources Include="$(tcltkDir)tcllicense.terms;
97+
$(tcltkDir)tklicense.terms;
98+
$(tcltkDir)tixlicense.terms" Condition="$(IncludeTkinter)" />
99+
<_LicenseOutputs Include="$(OutDir)LICENSE.txt" />
100+
</ItemGroup>
101+
102+
<Target Name="_RegenLicense" Inputs="@(_LicenseSources)" Outputs="@(_LicenseOutputs)">
103+
<Message Text="Regenerate @(_LicenseOutputs->'%(Filename)%(Extension)', ' ')" Importance="high" />
104+
<ItemGroup>
105+
<_Text Include="@(_LicenseFiles)">
106+
<Content Condition="Exists(%(FullPath))">$([System.IO.File]::ReadAllText(%(FullPath)))</Content>
107+
</_Text>
108+
</ItemGroup>
109+
110+
<WriteLinesToFile File="@(_LicenseOutputs)" Overwrite="true" Lines="@(_Text->'%(Content)')" />
111+
</Target>
112+
113+
<Target Name="PostBuildRegen" DependsOnTargets="_RegenLicense">
114+
<Message Text="Other generated files are up to date" Importance="high" />
115+
</Target>
84116
</Project>

0 commit comments

Comments
 (0)