2014-05-05 06:18:27 -04:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="GenerateHeaders">
|
|
|
|
|
2015-11-12 03:42:12 -05:00
|
|
|
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
|
2015-01-02 05:49:23 -05:00
|
|
|
|
2016-04-23 12:55:14 -04:00
|
|
|
<!--Generate qstrdefs.generated.h and mpversion.h similar to what is done in py/mkrules.mk and py/py.mk-->
|
2019-02-17 22:58:44 -05:00
|
|
|
<Target Name="GenerateHeaders" DependsOnTargets="MakeVersionHdr;MakeModuleDefs;MakeQstrData">
|
2014-05-05 06:18:27 -04:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
<PropertyGroup>
|
2015-01-02 05:49:23 -05:00
|
|
|
<DestDir>$(PyBuildDir)genhdr\</DestDir>
|
2015-04-22 12:38:05 -04:00
|
|
|
<PySrcDir>$(PyBaseDir)py\</PySrcDir>
|
2017-09-06 00:09:13 -04:00
|
|
|
<QstrDefs>$(PyBaseDir)ports\unix\qstrdefsport.h</QstrDefs>
|
2016-04-23 12:55:14 -04:00
|
|
|
<PyQstrDefs>$(PySrcDir)qstrdefs.h</PyQstrDefs>
|
2016-03-15 05:22:34 -04:00
|
|
|
<QstrDefsCollected>$(DestDir)qstrdefscollected.h</QstrDefsCollected>
|
|
|
|
<QstrGen>$(DestDir)qstrdefs.generated.h</QstrGen>
|
2015-11-07 14:00:26 -05:00
|
|
|
<PyPython Condition="'$(PyPython)' == ''">python</PyPython>
|
2018-07-24 07:29:03 -04:00
|
|
|
<CLToolExe Condition="'$(CLToolExe)' == ''">cl.exe</CLToolExe>
|
|
|
|
<PyClTool>$([System.IO.Path]::Combine(`$(CLToolPath)`, `$(CLToolExe)`))</PyClTool>
|
2014-05-05 06:18:27 -04:00
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
<Target Name="MakeDestDir">
|
|
|
|
<MakeDir Directories="$(DestDir)"/>
|
|
|
|
</Target>
|
|
|
|
|
2016-04-23 12:55:14 -04:00
|
|
|
<!-- 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>
|
|
|
|
|
2017-04-03 07:16:12 -04:00
|
|
|
<!-- If any of these changed we'll force all qstrs to be generated again-->
|
|
|
|
<ItemGroup>
|
|
|
|
<QstrDependencies Include="$(PyWinDir)mpconfigport.h;$(PySrcDir)mpconfig.h;$(PySrcDir)makeqstrdata.py"/>
|
|
|
|
</ItemGroup>
|
|
|
|
|
2016-04-23 12:55:14 -04:00
|
|
|
<!-- Preprocess changed files, concatenate and feed into makeqstrdefs.py split/cat-->
|
2017-04-03 07:16:12 -04:00
|
|
|
<Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(ClCompile);@(QstrDependencies)" Outputs="$(QstrDefsCollected)">
|
2016-03-15 05:22:34 -04:00
|
|
|
<ItemGroup>
|
|
|
|
<PyIncDirs Include="$(PyIncDirs)"/>
|
2016-06-15 18:40:31 -04:00
|
|
|
<PreProcDefs Include="%(ClCompile.PreProcessorDefinitions);NO_QSTR;N_X64;N_X86;N_THUMB;N_ARM"/>
|
2016-04-23 12:55:14 -04:00
|
|
|
<PyQstrSourceFiles Include="@(ClCompile)">
|
|
|
|
<OutFile>$([System.String]::new('%(FullPath)').Replace('$(PyBaseDir)', '$(DestDir)qstr\'))</OutFile>
|
|
|
|
</PyQstrSourceFiles>
|
2016-03-15 05:22:34 -04:00
|
|
|
<PyQstrSourceFiles>
|
2016-04-23 12:55:14 -04:00
|
|
|
<OutFile>$([System.IO.Path]::ChangeExtension('%(OutFile)', '.pp'))</OutFile>
|
|
|
|
<OutDir>$([System.IO.Path]::GetDirectoryName('%(OutFile)'))</OutDir>
|
2016-03-15 05:22:34 -04:00
|
|
|
</PyQstrSourceFiles>
|
|
|
|
<PyQstrSourceFiles>
|
2017-04-03 07:16:12 -04:00
|
|
|
<Changed Condition="$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('%(OutFile)')))) > 0">True</Changed>
|
2016-03-15 05:22:34 -04:00
|
|
|
</PyQstrSourceFiles>
|
2017-04-03 07:16:12 -04:00
|
|
|
<QstrDependencies>
|
|
|
|
<Changed Condition="$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('$(DestDir)qstr.i.last')))) > 0">True</Changed>
|
|
|
|
</QstrDependencies>
|
2016-03-15 05:22:34 -04:00
|
|
|
</ItemGroup>
|
2017-04-03 07:16:12 -04:00
|
|
|
<PropertyGroup>
|
|
|
|
<ForceQstrRebuild>@(QstrDependencies->AnyHaveMetadataValue('Changed', 'True'))</ForceQstrRebuild>
|
2017-05-01 04:50:58 -04:00
|
|
|
<RunPreProcConcat>@(PyQstrSourceFiles->AnyHaveMetadataValue('Changed', 'True'))</RunPreProcConcat>
|
2017-04-03 07:16:12 -04:00
|
|
|
</PropertyGroup>
|
2016-03-15 05:22:34 -04:00
|
|
|
|
2016-04-23 12:55:14 -04:00
|
|
|
<MakeDir Directories="@(PyQstrSourceFiles->'%(OutDir)')"/>
|
2018-07-24 07:29:03 -04:00
|
|
|
<Exec Command="$(PyClTool) /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /Fi%(PyQstrSourceFiles.OutFile) /P %(PyQstrSourceFiles.Identity)"
|
2017-04-03 07:16:12 -04:00
|
|
|
Condition="'%(PyQstrSourceFiles.Changed)' == 'True' Or '$(ForceQstrRebuild)' == 'True'"/>
|
2016-04-23 12:55:14 -04:00
|
|
|
<ConcatPreProcFiles InputFiles="@(PyQstrSourceFiles->'%(OutFile)')" OutputFile="$(DestDir)qstr.i.last"
|
2017-05-01 04:50:58 -04:00
|
|
|
Condition="'$(RunPreProcConcat)' == 'True' Or '$(ForceQstrRebuild)' == 'True'"/>
|
2016-04-23 12:55:14 -04:00
|
|
|
<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)"/>
|
2016-03-15 05:22:34 -04:00
|
|
|
</Target>
|
|
|
|
|
2019-02-17 22:58:44 -05:00
|
|
|
<Target Name="MakeModuleDefs" DependsOnTargets="MakeDestDir">
|
|
|
|
<PropertyGroup>
|
|
|
|
<DestFile>$(DestDir)moduledefs.h</DestFile>
|
|
|
|
<TmpFile>$(DestFile).tmp</TmpFile>
|
|
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
|
|
<PyUserModuleFiles Include="@(ClCompile)">
|
|
|
|
<Path>$([System.String]::new('%(FullPath)').Replace('$(PyBaseDir)', ''))</Path>
|
|
|
|
</PyUserModuleFiles>
|
|
|
|
</ItemGroup>
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makemoduledefs.py --vpath="., $(PyBaseDir), $(PyUserCModules)" @(PyUserModuleFiles->'%(Path)', ' ') > $(TmpFile)"/>
|
|
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
|
|
|
|
</Target>
|
|
|
|
|
2016-04-23 12:55:14 -04:00
|
|
|
<Target Name="MakeQstrData" DependsOnTargets="MakeQstrDefs" Inputs="$(QstrDefsCollected);$(PyQstrDefs);$(QstrDefs)" Outputs="$(QstrGen)">
|
2016-03-15 05:22:34 -04:00
|
|
|
<PropertyGroup>
|
2016-04-23 12:55:14 -04:00
|
|
|
<TmpFile>$(QstrGen).tmp</TmpFile>
|
2016-03-15 05:22:34 -04:00
|
|
|
</PropertyGroup>
|
2018-07-24 07:29:03 -04:00
|
|
|
<Exec Command="$(PyClTool) /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /E $(PyQstrDefs) $(QstrDefs) > $(DestDir)qstrdefspreprocessed.h"/>
|
2016-04-23 12:55:14 -04:00
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(DestDir)qstrdefspreprocessed.h $(QstrDefsCollected) > $(TmpFile)"/>
|
2016-03-15 05:22:34 -04:00
|
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(QstrGen)"/>
|
2014-05-05 06:18:27 -04:00
|
|
|
</Target>
|
|
|
|
|
2015-04-22 12:38:05 -04:00
|
|
|
<Target Name="MakeVersionHdr" DependsOnTargets="MakeDestDir">
|
2014-05-05 06:18:27 -04:00
|
|
|
<PropertyGroup>
|
2015-04-22 12:38:05 -04:00
|
|
|
<DestFile>$(DestDir)mpversion.h</DestFile>
|
2015-01-02 10:31:49 -05:00
|
|
|
<TmpFile>$(DestFile).tmp</TmpFile>
|
2014-05-05 06:18:27 -04:00
|
|
|
</PropertyGroup>
|
2015-11-07 14:00:26 -05:00
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeversionhdr.py $(TmpFile)"/>
|
2015-01-02 10:31:49 -05:00
|
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
|
|
|
|
</Target>
|
|
|
|
|
2017-03-22 05:54:40 -04:00
|
|
|
<Target Name="RemoveGeneratedFiles" AfterTargets="Clean">
|
|
|
|
<RemoveDir Directories="$(DestDir)"/>
|
|
|
|
</Target>
|
|
|
|
|
2015-01-02 10:31:49 -05:00
|
|
|
<!--Copies SourceFile to DestFile only if SourceFile's content differs from DestFile's.
|
|
|
|
We use this to 'touch' the generated files only when they are really newer
|
|
|
|
so a build is only triggered if the generated content actually changed,
|
|
|
|
and not just because the file date changed since the last build-->
|
|
|
|
<Target Name="CopyFileIfDifferent">
|
|
|
|
<Exec Command="fc /B $(SourceFile) $(DestFile) > NUL 2>&1" IgnoreExitCode="true">
|
2014-05-28 10:03:38 -04:00
|
|
|
<Output TaskParameter="ExitCode" PropertyName="FilesDiffer" />
|
|
|
|
</Exec>
|
2015-01-02 10:31:49 -05:00
|
|
|
<Copy SourceFiles="$(SourceFile)" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/>
|
2014-05-05 06:18:27 -04:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
</Project>
|