micropython/windows/msvc/genhdr.targets
stijn 967ceba5b7 msvc: Use different output directories depending on build type
This allows multiple versions (e.g. Debug/Release, x86/x64) of micropython.exe
to co-exist instead and also solves potential problems where msbuild does not
completely rebuild the output and/or pdb files when switching between builds,
which in turn can cause linker errors in dependent projects.

By default exe/map/... files go in windows/build/$(Configuration)$(Platform)

After each build micropython.exe is still copied from the above directory to
the windows directory though, as that is consistent with the other ports and
the test runner by default uses that location as well.

Also rename env.props -> path.props which is a clearer name,
and add ample documentation in the affected build files.

(also see discussion in #1538)
2015-12-11 23:42:30 +02:00

56 lines
2.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="GenerateHeaders">
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
<!--Generate qstrdefs.h and mpversion.h similar to what is done in py/py.mk-->
<Target Name="GenerateHeaders" DependsOnTargets="MakeQstrData;MakeVersionHdr">
</Target>
<PropertyGroup>
<DestDir>$(PyBuildDir)genhdr\</DestDir>
<PySrcDir>$(PyBaseDir)py\</PySrcDir>
<PyPython Condition="'$(PyPython)' == ''">python</PyPython>
</PropertyGroup>
<Target Name="MakeDestDir">
<MakeDir Directories="$(DestDir)"/>
</Target>
<Target Name="MakeQstrData" DependsOnTargets="MakeDestDir">
<PropertyGroup>
<PreProc>$(DestDir)qstrdefs.preprocessed.h</PreProc>
<QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs>
<DestFile>$(DestDir)qstrdefs.generated.h</DestFile>
<TmpFile>$(DestFile).tmp</TmpFile>
</PropertyGroup>
<ItemGroup>
<PyIncDirs Include="$(PyIncDirs)"/>
</ItemGroup>
<Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /Fi$(PreProc) /P $(PySrcDir)qstrdefs.h"/>
<Exec Command="$(PyPython) $(PySrcDir)makeqstrdata.py $(PreProc) $(QstrDefs) > $(TmpFile)"/>
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
</Target>
<Target Name="MakeVersionHdr" DependsOnTargets="MakeDestDir">
<PropertyGroup>
<DestFile>$(DestDir)mpversion.h</DestFile>
<TmpFile>$(DestFile).tmp</TmpFile>
</PropertyGroup>
<Exec Command="$(PyPython) $(PySrcDir)makeversionhdr.py $(TmpFile)"/>
<MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/>
</Target>
<!--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>&amp;1" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="FilesDiffer" />
</Exec>
<Copy SourceFiles="$(SourceFile)" DestinationFiles="$(DestFile)" Condition="'$(FilesDiffer)'!='0'"/>
</Target>
</Project>