2014-05-05 11:18:27 +01:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2022-02-22 14:42:50 +00:00
|
|
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0" DefaultTargets="GenerateHeaders">
|
2014-05-05 11:18:27 +01:00
|
|
|
|
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-->
|
2022-06-23 15:05:08 +01:00
|
|
|
<Target Name="GenerateHeaders" DependsOnTargets="MakeVersionHdr;MakeModuleDefs;MakeRootPointers;MakeCompressedData;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>
|
2022-05-31 08:10:14 +01:00
|
|
|
<ModuleDefsCollected>$(DestDir)/moduledefs.collected</ModuleDefsCollected>
|
2022-07-01 18:29:08 +01:00
|
|
|
<RootPointersCollected>$(DestDir)/root_pointers.collected</RootPointersCollected>
|
2022-06-23 15:05:08 +01:00
|
|
|
<CompressedCollected>$(DestDir)/compressed.collected</CompressedCollected>
|
2021-01-16 08:01:17 +00:00
|
|
|
<PyPython Condition="'$(PyPython)' == ''">$(MICROPY_CPYTHON3)</PyPython>
|
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>
|
2022-01-12 12:57:41 +00:00
|
|
|
<PyPlatformToolsetNum>120</PyPlatformToolsetNum> <!--Minimum we support is VS2013.-->
|
|
|
|
<PyPlatformToolsetNum Condition="$(PlatformToolset.StartsWith('v'))">$(PlatformToolset.Replace('v', ''))</PyPlatformToolsetNum>
|
|
|
|
<PyParallelPreProc Condition="'$(PyPlatformToolsetNum)' > '140'">True</PyParallelPreProc> <!--VS2017 and up.-->
|
2014-05-05 11:18:27 +01:00
|
|
|
</PropertyGroup>
|
|
|
|
|
2022-01-12 12:57:41 +00:00
|
|
|
<UsingTask Condition="'$(PyParallelPreProc)' == 'True'"
|
|
|
|
TaskName="ParallelCustomBuild" AssemblyFile="$(VCTargetsPath)\Microsoft.Build.CppTasks.Common.dll"/>
|
|
|
|
|
2014-05-05 11:18:27 +01:00
|
|
|
<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))
|
2022-06-23 15:05:08 +01:00
|
|
|
if((line.Contains(".c") && line.StartsWith("#line")) || line.Contains("MP_QSTR") ||
|
|
|
|
line.Contains("MP_REGISTER") || line.Contains("MP_COMPRESSED_ROM_TEXT"))
|
2016-04-23 17:55:14 +01:00
|
|
|
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-->
|
2023-01-24 10:03:59 +00:00
|
|
|
<Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir;MakeVersionHdr" 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"/>
|
2020-09-10 11:11:58 +01:00
|
|
|
<PyQstrSourceFiles Include="@(ClCompile)" Exclude="$(PyBuildDir)\frozen_content.c">
|
2022-01-12 12:57:41 +00:00
|
|
|
<Changed>False</Changed>
|
2016-04-23 17:55:14 +01:00
|
|
|
<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>
|
2022-01-12 12:57:41 +00:00
|
|
|
<PyPreProcCommand>$(PyClTool) /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D')</PyPreProcCommand>
|
2017-04-03 12:16:12 +01:00
|
|
|
<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>
|
2022-01-12 12:57:41 +00:00
|
|
|
<ItemGroup>
|
|
|
|
<PyQstrSourceFilesToPreProc Include="@(PyQstrSourceFiles)" Condition="'%(Changed)' == 'True' Or '$(ForceQstrRebuild)' == 'True'">
|
|
|
|
<Command>$(PyPreProcCommand) /Fi%(OutFile) /P %(Identity)</Command>
|
|
|
|
<Outputs>%(OutFile)</Outputs>
|
|
|
|
</PyQstrSourceFilesToPreProc>
|
|
|
|
</ItemGroup>
|
|
|
|
|
|
|
|
<MakeDir Directories="@(PyQstrSourceFilesToPreProc->'%(OutDir)')"/>
|
|
|
|
<Exec Condition="'$(PyParallelPreProc)' != 'True'" Command="%(PyQstrSourceFilesToPreProc.Command)" />
|
|
|
|
<ParallelCustomBuild Condition="'$(PyParallelPreProc)' == 'True' And '@(PyQstrSourceFilesToPreProc)' != ''" Sources="@(PyQstrSourceFilesToPreProc)" />
|
2016-03-15 09:22:34 +00:00
|
|
|
|
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'"/>
|
2020-03-04 11:11:39 +00:00
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py split qstr $(DestDir)qstr.i.last $(DestDir)qstr _"/>
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py cat qstr _ $(DestDir)qstr $(QstrDefsCollected)"/>
|
2016-03-15 09:22:34 +00:00
|
|
|
</Target>
|
|
|
|
|
2022-06-23 15:05:08 +01:00
|
|
|
<Target Name="CollectCompressedData" DependsOnTargets="MakeQstrDefs" Inputs="$(DestDir)qstr.i.last" Outputs="$(CompressedCollected)">
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py split compress $(DestDir)qstr.i.last $(DestDir)compress _"/>
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py cat compress _ $(DestDir)compress $(CompressedCollected)"/>
|
|
|
|
</Target>
|
|
|
|
|
2022-05-31 08:10:14 +01:00
|
|
|
<Target Name="CollectModuleDefs" DependsOnTargets="MakeQstrDefs" Inputs="$(DestDir)qstr.i.last" Outputs="$(ModuleDefsCollected)">
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py split module $(DestDir)qstr.i.last $(DestDir)module _"/>
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py cat module _ $(DestDir)module $(ModuleDefsCollected)"/>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<Target Name="MakeModuleDefs" DependsOnTargets="CollectModuleDefs" Inputs="$(ModuleDefsCollected)" Outputs="$(DestDir)moduledefs.h">
|
2019-02-18 03:58:44 +00:00
|
|
|
<PropertyGroup>
|
|
|
|
<DestFile>$(DestDir)moduledefs.h</DestFile>
|
|
|
|
<TmpFile>$(DestFile).tmp</TmpFile>
|
|
|
|
</PropertyGroup>
|
2022-05-31 08:10:14 +01:00
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makemoduledefs.py $(ModuleDefsCollected) > $(TmpFile)"/>
|
2019-02-18 03:58:44 +00:00
|
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
|
|
|
|
</Target>
|
|
|
|
|
2022-07-01 18:29:08 +01:00
|
|
|
<Target Name="CollectRootPointers" DependsOnTargets="MakeQstrDefs" Inputs="$(DestDir)qstr.i.last" Outputs="$(RootPointersCollected)">
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py split root_pointer $(DestDir)qstr.i.last $(DestDir)root_pointer _"/>
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py cat root_pointer _ $(DestDir)root_pointer $(RootPointersCollected)"/>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<Target Name="MakeRootPointers" DependsOnTargets="CollectRootPointers" Inputs="$(PySrcDir)make_root_pointers.py;$(RootPointersCollected)" Outputs="$(DestDir)root_pointers.h">
|
|
|
|
<PropertyGroup>
|
|
|
|
<DestFile>$(DestDir)root_pointers.h</DestFile>
|
|
|
|
<TmpFile>$(DestFile).tmp</TmpFile>
|
|
|
|
</PropertyGroup>
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)make_root_pointers.py $(RootPointersCollected) > $(TmpFile)"/>
|
|
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
|
|
|
|
</Target>
|
|
|
|
|
2022-06-23 15:05:08 +01:00
|
|
|
<Target Name="MakeCompressedData" DependsOnTargets="CollectCompressedData" Inputs="$(CompressedCollected)" Outputs="$(DestDir)compressed.data.h">
|
|
|
|
<PropertyGroup>
|
|
|
|
<DestFile>$(DestDir)compressed.data.h</DestFile>
|
|
|
|
<TmpFile>$(DestFile).tmp</TmpFile>
|
|
|
|
</PropertyGroup>
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makecompresseddata.py $(CompressedCollected) > $(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>
|
2020-09-10 11:11:58 +01:00
|
|
|
<Exec Command="$(PyClTool) /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /E $(PyQstrDefs) $(QstrDefs) > $(DestDir)qstrdefs.preprocessed.h"/>
|
|
|
|
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(DestDir)qstrdefs.preprocessed.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>
|
|
|
|
|
2022-07-01 18:29:08 +01:00
|
|
|
<Target Name="FreezeModules" Condition="'$(FrozenManifest)' != ''" DependsOnTargets="MakeQstrData;MakeRootPointers" Inputs="$(FrozenManifest)" Outputs="$(PyBuildDir)frozen_content.c">
|
2020-09-10 11:11:58 +01:00
|
|
|
<ItemGroup>
|
|
|
|
<ClCompile Include="$(PyBuildDir)frozen_content.c"/>
|
|
|
|
<ClCompile>
|
|
|
|
<PreprocessorDefinitions>MICROPY_MODULE_FROZEN_MPY=1;MICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
|
|
</ClCompile>
|
|
|
|
</ItemGroup>
|
2022-07-08 06:00:33 +01:00
|
|
|
<Exec Command="$(PyPython) $(PyBaseDir)tools\makemanifest.py -v MPY_DIR=$(PyBaseDir) -v MPY_LIB_DIR=$(PyBaseDir)/lib/micropython-lib -v PORT_DIR=$(PyWinDir) -o $(PyBuildDir)frozen_content.c -b $(PyBuildDir) $(FrozenManifest)"/>
|
2020-09-10 11:11:58 +01:00
|
|
|
<WriteLinesToFile File="$(TLogLocation)frozen.read.1.tlog" Lines="$(FrozenManifest)" Overwrite="True"/>
|
|
|
|
</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>
|