|
| 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" DependsOnTargets="_TouchRegenSources;_RegenPegen;_RegenAST_H;_RegenOpcodes;_RegenTokens;_RegenKeywords"> |
| 82 | + <Message Text="Generated sources are up to date" Importance="high" /> |
| 83 | + </Target> |
| 84 | +</Project> |
0 commit comments