Commit 967ceba5 authored by stijn's avatar stijn Committed by Paul Sokolovsky
Browse files

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)
parent c1481bb0
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="">
<ImportGroup Label="PropertySheets">
<Import Project="env.props" />
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
<PropertyGroup Label="UserMacros" />
......@@ -22,5 +22,24 @@
<ItemGroup />
<PyOutputFiles Include="$(TargetPath)">
<PyCookieFiles Include="$(PyBuildDir)copycookie*" Exclude="$(PyFileCopyCookie)"/>
<!-- Copy PyOutputFiles to their target destination.
To force this when switching between platforms/configurations which are already up-to-date (and as such,
for which a build wouldn't even start because all outputs are effectively newer than the inputs)
an empty file $(PyFileCopyCookie) is created serving as a record to indicate what was last copied,
and any previous records are deleted. So when switching between builds which are otherwise up-to-date
the tracker will notice a missing file and a build is started anyway (and it will just copy our files). -->
<Target Name="CopyFilesToWinDir" AfterTargets="Build"
Inputs="$(TargetPath)" Outputs="$(PyFileCopyCookie);@(PyOutputFiles->'%(Destination)')">
<Delete Files="@(PyCookieFiles)"/>
<Touch Files="$(PyFileCopyCookie)" AlwaysCreate="true"/>
<Copy SourceFiles="%(PyOutputFiles.Identity)" DestinationFiles="%(PyOutputFiles.Destination)"/>
<WriteLinesToFile File="$(TLogLocation)$(ProjectName).write.u.tlog" Lines="$(PyFileCopyCookie);@(PyOutputFiles->'%(Destination)')" Overwrite="True"/>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="">
<PyBuildDir Condition="'$(PyBuildDir)'==''">$(MSBuildThisFileDirectory)build\</PyBuildDir>
<PyOutDir Condition="'$(PyOutDir)'==''">$(PyBaseDir)windows\</PyOutDir>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="" DefaultTargets="GenerateHeaders">
<Import Project="env.props" Condition="$(PyEnvIncluded)!=True"/>
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
<!--Generate qstrdefs.h and mpversion.h similar to what is done in py/>
<Target Name="GenerateHeaders" DependsOnTargets="MakeQstrData;MakeVersionHdr">
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="">
<!-- The properties below specify the output directory structure.
This defaults to, for example for Configuration = Debug and Platform = x64:
micropython [PyBaseDir]
|- ...
|- windows [PyWinDir]
|- ...
|- micropython.exe
|- build [PyBuildDir]
|- Debugx64 [PyOutDir]
| |- ...
| |- micropython.exe
| |-
| |- obj [PyIntDir]
|- genhdr
Note that the micropython executable will be copied from PyOutDir
to PyWinDir after each build. -->
<!-- Start from project root -->
<PyBuildDir Condition="'$(PyBuildDir)' == ''">$(PyWinDir)build\</PyBuildDir>
<!-- All include directories needed for uPy -->
<!-- Within PyBuildDir different subdirectories are used based on configuration and platform.
By default these are chosen based on the Configuration and Platform properties, but
this file might be imported by other projects (to figure out where the artifacts go
or what the include files are) and those projects might already contain conflicting
Configuration/Platform properties, so allow to override these -->
<PyPlatform Condition="'$(PyPlatform)' == ''">$(Platform)</PyPlatform>
<PyConfiguration Condition="'$(PyConfiguration)' == ''">$(Configuration)</PyConfiguration>
<!-- The final destination directories -->
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="">
<Import Project="env.props" Condition="$(PyEnvIncluded)!=True"/>
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
<ClCompile Include="$(PyBaseDir)py\*.c" />
<ClCompile Include="$(PyBaseDir)windows\*.c" />
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment