1<?xml version="1.0" encoding="utf-8"?> 2<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 3 <Target Name="_SetPythonForBuild"> 4 <PropertyGroup> 5 <PythonForBuild>$(PYTHON)</PythonForBuild> 6 </PropertyGroup> 7 </Target> 8 9 <ItemGroup> 10 <_PegenSources Include="$(PySourcePath)Grammar\python.gram;$(PySourcePath)Grammar\Tokens" /> 11 <_PegenOutputs Include="$(PySourcePath)Parser\parser.c" /> 12 <_ASTSources Include="$(PySourcePath)Parser\Python.asdl" /> 13 <_ASTOutputs Include="$(PySourcePath)Include\internal\pycore_ast.h"> 14 <Argument>-H</Argument> 15 </_ASTOutputs> 16 <_ASTOutputs Include="$(PySourcePath)Include\internal\pycore_ast_state.h"> 17 <Argument>-I</Argument> 18 </_ASTOutputs> 19 <_ASTOutputs Include="$(PySourcePath)Python\Python-ast.c"> 20 <Argument>-C</Argument> 21 </_ASTOutputs> 22 <_OpcodeSources Include="$(PySourcePath)Tools\scripts\generate_opcode_h.py;$(PySourcePath)Lib\opcode.py" /> 23 <_OpcodeOutputs Include="$(PySourcePath)Include\opcode.h;$(PySourcePath)Python\opcode_targets.h" /> 24 <_TokenSources Include="$(PySourcePath)Grammar\Tokens" /> 25 <_TokenOutputs Include="$(PySourcePath)Doc\library\token-list.inc"> 26 <Format>rst</Format> 27 </_TokenOutputs> 28 <_TokenOutputs Include="$(PySourcePath)Include\token.h"> 29 <Format>h</Format> 30 </_TokenOutputs> 31 <_TokenOutputs Include="$(PySourcePath)Parser\token.c"> 32 <Format>c</Format> 33 </_TokenOutputs> 34 <_TokenOutputs Include="$(PySourcePath)Lib\token.py"> 35 <Format>py</Format> 36 </_TokenOutputs> 37 <_KeywordSources Include="$(PySourcePath)Grammar\python.gram;$(PySourcePath)Grammar\Tokens" /> 38 <_KeywordOutputs Include="$(PySourcePath)Lib\keyword.py" /> 39 </ItemGroup> 40 41 <Target Name="_TouchRegenSources" Condition="$(ForceRegen) == 'true'"> 42 <Message Text="Touching source files to force regeneration" Importance="high" /> 43 <Touch Files="@(_PegenSources);@(_ASTSources);@(_OpcodeSources);@(_TokenSources);@(_KeywordOutputs)" 44 AlwaysCreate="False" /> 45 </Target> 46 47 <Target Name="_RegenPegen" Inputs="@(_PegenSources)" Outputs="@(_PegenOutputs)"> 48 <Message Text="Regenerate @(_PegenOutputs->'%(Filename)%(Extension)',' ')" Importance="high" /> 49 <!-- Specify python.gram with POSIX-like path because the argument gets written into the file verbatim --> 50 <Exec Command="set PYTHONPATH=Tools\peg_generator%0D%0A$(PythonForBuild) -m pegen -q c ./Grammar/python.gram Grammar\Tokens -o Parser\parser.c" 51 WorkingDirectory="$(PySourcePath)" /> 52 </Target> 53 54 <Target Name="_RegenAST_H" Inputs="@(_ASTSources)" Outputs="@(_ASTOutputs)"> 55 <Message Text="Regenerate @(_ASTOutputs->'%(Filename)%(Extension)',' ')" Importance="high" /> 56 <Exec Command="$(PythonForBuild) Parser\asdl_c.py Parser\Python.asdl @(_ASTOutputs->'%(Argument) "%(Identity)"',' ')" 57 WorkingDirectory="$(PySourcePath)" /> 58 </Target> 59 60 <Target Name="_RegenOpcodes" Inputs="@(_OpcodeSources)" Outputs="@(_OpcodeOutputs)"> 61 <Message Text="Regenerate @(_OpcodeOutputs->'%(Filename)%(Extension)',' ')" Importance="high" /> 62 <Exec Command="$(PythonForBuild) Tools\scripts\generate_opcode_h.py Lib\opcode.py Include\opcode.h" 63 WorkingDirectory="$(PySourcePath)" /> 64 <Exec Command="$(PythonForBuild) Python\makeopcodetargets.py Python\opcode_targets.h" 65 WorkingDirectory="$(PySourcePath)" /> 66 </Target> 67 68 <Target Name="_RegenTokens" Inputs="@(_TokenSources)" Outputs="@(_TokenOutputs)"> 69 <Message Text="Regenerate @(_TokenOutputs->'%(Filename)%(Extension)',' ')" Importance="high" /> 70 <Exec Command="$(PythonForBuild) Tools\scripts\generate_token.py %(_TokenOutputs.Format) Grammar\Tokens "%(_TokenOutputs.Identity)"" 71 WorkingDirectory="$(PySourcePath)" /> 72 <Touch Files="@(_TokenOutputs)" /> 73 </Target> 74 75 <Target Name="_RegenKeywords" Inputs="@(_KeywordSources)" Outputs="@(_KeywordOutputs)"> 76 <Message Text="Regenerate @(_KeywordOutputs->'%(Filename)%(Extension)',' ')" Importance="high" /> 77 <Exec Command="set PYTHONPATH=Tools\peg_generator%0D%0A$(PythonForBuild) -m pegen.keywordgen Grammar\python.gram Grammar\Tokens Lib\keyword.py" 78 WorkingDirectory="$(PySourcePath)" /> 79 </Target> 80 81 <Target Name="Regen" 82 Condition="$(Configuration) != 'PGUpdate'" 83 DependsOnTargets="_TouchRegenSources;_RegenPegen;_RegenAST_H;_RegenOpcodes;_RegenTokens;_RegenKeywords"> 84 <Message Text="Generated sources are up to date" Importance="high" /> 85 </Target> 86 87 88 <ItemGroup> 89 <_LicenseSources Include="$(PySourcePath)LICENSE; 90 $(PySourcePath)PC\crtlicense.txt; 91 $(bz2Dir)LICENSE; 92 $(opensslOutDir)LICENSE; 93 $(libffiDir)LICENSE;" /> 94 <_LicenseSources Include="$(tcltkDir)tcllicense.terms; 95 $(tcltkDir)tklicense.terms; 96 $(tcltkDir)tixlicense.terms" Condition="$(IncludeTkinter)" /> 97 </ItemGroup> 98 99 <Target Name="_RegenLicense"> 100 <ItemGroup> 101 <_Text1 Include="@(_LicenseSources)"> 102 <Content Condition="Exists(%(FullPath))">$([System.IO.File]::ReadAllText(%(FullPath)))</Content> 103 </_Text1> 104 <_Text Include="@(_Text1->'%(Content)')" /> 105 </ItemGroup> 106 107 <WriteLinesToFile File="$(OutDir)LICENSE.txt" Overwrite="true" Lines="@(_Text)" /> 108 <Warning Text="License file %(_LicenseSources.FullPath) is missing" 109 Condition="!Exists(@(_LicenseSources))" /> 110 <Message Text="Wrote $(OutDir)LICENSE.txt" Importance="high" /> 111 </Target> 112 113 <Target Name="PostBuildRegen" DependsOnTargets="_RegenLicense" /> 114</Project> 115