2014-05-05 11:18:27 +01: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 08:42:12 +00:00
|
|
|
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
|
2015-01-02 10:49:23 +00:00
|
|
|
|
2016-04-23 17:55:14 +01:00
|
|
|
<!--Generate qstrdefs.generated.h and mpversion.h similar to what is done in py/mkrules.mk and py/py.mk-->
|
2019-02-18 03:58:44 +00:00
|
|
|
<Target Name="GenerateHeaders" DependsOnTargets="MakeVersionHdr;MakeModuleDefs;MakeQstrData">
|
2014-05-05 11:18:27 +01:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
<PropertyGroup>
|
2015-01-02 10:49:23 +00:00
|
|
|
<DestDir>$(PyBuildDir)genhdr\</DestDir>
|
2015-04-22 17:38:05 +01:00
|
|
|
<PySrcDir>$(PyBaseDir)py\</PySrcDir>
|
2017-09-06 05:09:13 +01:00
|
|
|
<QstrDefs>$(PyBaseDir)ports\unix\qstrdefsport.h</QstrDefs>
|
2016-04-23 17:55:14 +01:00
|
|
|
<PyQstrDefs>$(PySrcDir)qstrdefs.h</PyQstrDefs>
|
2016-03-15 09:22:34 +00:00
|
|
|
<QstrDefsCollected>$(DestDir)qstrdefscollected.h</QstrDefsCollected>
|
|
|
|
<QstrGen>$(DestDir)qstrdefs.generated.h</QstrGen>
|
2015-11-07 19:00:26 +00:00
|
|
|
<PyPython Condition="'$(PyPython)' == ''">python</PyPython>
|
2018-07-24 12:29:03 +01:00
|
|
|
<CLToolExe Condition="'$(CLToolExe)' == ''">cl.exe</CLToolExe>
|
|
|
|
<PyClTool>$([System.IO.Path]::Combine(`$(CLToolPath)`, `$(CLToolExe)`))</PyClTool>
|
2014-05-05 11:18:27 +01:00
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
<Target Name="MakeDestDir">
|
|
|
|
<MakeDir Directories="$(DestDir)"/>
|
|
|
|
</Target>
|
|
|
|
|
2016-04-23 17:55:14 +01: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 12:16:12 +01: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 17:55:14 +01:00
|
|
|
<!-- Preprocess changed files, concatenate and feed into makeqstrdefs.py split/cat-->
|
2017-04-03 12:16:12 +01:00
|
|
|
<Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(ClCompile);@(QstrDependencies)" Outputs="$(QstrDefsCollected)">
|
2016-03-15 09:22:34 +00:00
|
|
|
<ItemGroup>
|
|
|
|
<PyIncDirs Include="$(PyIncDirs)"/>
|
2019-05-29 16:14:45 +01:00
|
|
|
<PreProcDefs Include="%(ClCompile.PreProcessorDefinitions);NO_QSTR"/>
|
2016-04-23 17:55:14 +01:00
|
|
|
<PyQstrSourceFiles Include="@(ClCompile)">
|
|
|
|
<OutFile>$([System.String]::new('%(FullPath)').Replace('$(PyBaseDir)', '$(DestDir)qstr\'))</OutFile>
|
|
|
|
</PyQstrSourceFiles>
|
2016-03-15 09:22:34 +00:00
|
|
|
<PyQstrSourceFiles>
|
2016-04-23 17:55:14 +01:00
|
|
|
<OutFile>$([System.IO.Path]::ChangeExtension('%(OutFile)', '.pp'))</OutFile>
|
|
|
|
<OutDir>$([System.IO.Path]::GetDirectoryName('%(OutFile)'))</OutDir>
|
2016-03-15 09:22:34 +00:00
|
|
|
</PyQstrSourceFiles>
|
|
|
|
<PyQstrSourceFiles>
|
2017-04-03 12:16:12 +01:00
|
|
|
<Changed Condition="$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('%(OutFile)')))) > 0">True</Changed>
|
2016-03-15 09:22:34 +00:00
|
|
|
</PyQstrSourceFiles>
|
2017-04-03 12:16:12 +01: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 09:22:34 +00:00
|
|
|
</ItemGroup>
|
2017-04-03 12:16:12 +01:00
|
|
|
<PropertyGroup>
|
|
|
|
<ForceQstrRebuild>@(QstrDependencies->AnyHaveMetadataValue('Changed', 'True'))</ForceQstrRebuild>
|
2017-05-01 09:50:58 +01:00
|
|
|
<RunPreProcConcat>@(PyQstrSourceFiles->AnyHaveMetadataValue('Changed', 'True'))</RunPreProcConcat>
|
2017-04-03 12:16:12 +01:00
|
|
|
</PropertyGroup>
|
2016-03-15 09:22:34 +00:00
|
|
|
|
2016-04-23 17:55:14 +01:00
|
|
|
<MakeDir Directories="@(PyQstrSourceFiles->'%(OutDir)')"/>
|
2018-07-24 12:29:03 +01:00
|
|
|
<Exec Command="$(PyClTool) /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /Fi%(PyQstrSourceFiles.OutFile) /P %(PyQstrSourceFiles.Identity)"
|
2017-04-03 12:16:12 +01:00
|
|
|
Condition="'%(PyQstrSourceFiles.Changed)' == 'True' Or '$(ForceQstrRebuild)' == 'True'"/>
|
2016-04-23 17:55:14 +01:00
|
|
|
<ConcatPreProcFiles InputFiles="@(PyQstrSourceFiles->'%(OutFile)')" OutputFile="$(DestDir)qstr.i.last"
|
2017-05-01 09:50:58 +01:00
|
|
|
Condition="'$(RunPreProcConcat)' == 'True' Or '$(ForceQstrRebuild)' == 'True'"/>
|
2016-04-23 17:55:14 +01: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 09:22:34 +00:00
|
|
|
</Target>
|
|
|
|
|
2019-02-18 03:58:44 +00: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 17:55:14 +01:00
|
|
|
<Target Name="MakeQstrData" DependsOnTargets="MakeQstrDefs" Inputs="$(QstrDefsCollected);$(PyQstrDefs);$(QstrDefs)" Outputs="$(QstrGen)">
|
2016-03-15 09:22:34 +00:00
|
|
|
<PropertyGroup>
|
2016-04-23 17:55:14 +01:00
|
|
|
<TmpFile>$(QstrGen).tmp</TmpFile>
|
2016-03-15 09:22:34 +00:00
|
|
|
</PropertyGroup>
|
2018-07-24 12:29:03 +01:00
|
|
|
<Exec Command="$(PyClTool) /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /E $(PyQstrDefs) $(QstrDefs) > $(DestDir)qstrdefspreprocessed.h"/>
|
2016-04-23 17:55:14 +01:00
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(DestDir)qstrdefspreprocessed.h $(QstrDefsCollected) > $(TmpFile)"/>
|
2016-03-15 09:22:34 +00:00
|
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(QstrGen)"/>
|
2014-05-05 11:18:27 +01:00
|
|
|
</Target>
|
|
|
|
|
2015-04-22 17:38:05 +01:00
|
|
|
<Target Name="MakeVersionHdr" DependsOnTargets="MakeDestDir">
|
2014-05-05 11:18:27 +01:00
|
|
|
<PropertyGroup>
|
2015-04-22 17:38:05 +01:00
|
|
|
<DestFile>$(DestDir)mpversion.h</DestFile>
|
2015-01-02 15:31:49 +00:00
|
|
|
<TmpFile>$(DestFile).tmp</TmpFile>
|
2014-05-05 11:18:27 +01:00
|
|
|
</PropertyGroup>
|
2015-11-07 19:00:26 +00:00
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeversionhdr.py $(TmpFile)"/>
|
2015-01-02 15:31:49 +00:00
|
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
|
|
|
|
</Target>
|
|
|
|
|
2017-03-22 09:54:40 +00:00
|
|
|
<Target Name="RemoveGeneratedFiles" AfterTargets="Clean">
|
|
|
|
<RemoveDir Directories="$(DestDir)"/>
|
|
|
|
</Target>
|
|
|
|
|
2015-01-02 15:31:49 +00: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 15:03:38 +01:00
|
|
|
<Output TaskParameter="ExitCode" PropertyName="FilesDiffer" />
|
|
|
|
</Exec>
|
2015-01-02 15:31:49 +00:00
|
|
|
<Copy SourceFiles="$(SourceFile)" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/>
|
2014-05-05 11:18:27 +01:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
</Project>
|