8000 msvc: Use different output directories depending on build type · micropython/micropython@967ceba · GitHub
[go: up one dir, main page]

Skip to content

Commit 967ceba

Browse files
stinosPaul Sokolovsky
authored and
Paul Sokolovsky
committed
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)
1 parent c1481bb commit 967ceba

File tree

5 files changed

+70
-15
lines changed

5 files changed

+70
-15
lines changed

windows/msvc/common.props

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ImportGroup Label="PropertySheets">
4-
<Import Project="env.props" />
4+
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
55
</ImportGroup>
66
<PropertyGroup Label="UserMacros" />
77
<PropertyGroup>
88
<OutDir>$(PyOutDir)</OutDir>
9-
<IntDir>$(PyBuildDir)$(Configuration)$(Platform)\</IntDir>
10-
<PyIncDirs>$(PyBaseDir);$(PyBaseDir)windows;$(PyBaseDir)windows\msvc;$(PyBuildDir)</PyIncDirs>
9+
<IntDir>$(PyIntDir)</IntDir>
10+
<PyFileCopyCookie>$(PyBuildDir)copycookie$(Configuration)$(Platform)</PyFileCopyCookie>
1111
</PropertyGroup>
1212
<ItemDefinitionGroup>
1313
<ClCompile>
@@ -22,5 +22,24 @@
2222
<GenerateMapFile>true</GenerateMapFile>
2323
</Link>
2424
</ItemDefinitionGroup>
25-
<ItemGroup />
25+
<ItemGroup>
26+
<PyOutputFiles Include="$(TargetPath)">
27+
<Destination>$(PyWinDir)%(FileName)%(Extension)</Destination>
28+
</PyOutputFiles>
29+
<PyCookieFiles Include="$(PyBuildDir)copycookie*" Exclude="$(PyFileCopyCookie)"/>
30+
</ItemGroup>
31+
32+
<!-- Copy PyOutputFiles to their target destination.
33+
To force this when switching between platforms/configurations which are already up-to-date (and as such,
34+
for which a build wouldn't even start because all outputs are effectively newer than the inputs)
35+
an empty file $(PyFileCopyCookie) is created serving as a record to indicate what was last copied,
36+
and any previous records are deleted. So when switching between builds which are otherwise up-to-date
37+
the tracker will notice a missing file and a build is started anyway (and it will just copy our files). -->
38+
<Target Name="CopyFilesToWinDir" AfterTargets="Build"
39+
Inputs="$(TargetPath)" Outputs="$(PyFileCopyCookie);@(PyOutputFiles->'%(Destination)')">
40+
<Delete Files="@(PyCookieFiles)"/>
41+
<Touch Files="$(PyFileCopyCookie)" AlwaysCreate="true"/>
42+
<Copy SourceFiles="%(PyOutputFiles.Identity)" DestinationFiles="%(PyOutputFiles.Destination)"/>
43+
<WriteLinesToFile File="$(TLogLocation)$(ProjectName).write.u.tlog" Lines="$(PyFileCopyCookie);@(PyOutputFiles->'%(Destination)')" Overwrite="True"/>
44+
</Target>
2645
</Project>

windows/msvc/env.props

Lines changed: 0 additions & 9 deletions
This file was deleted.

windows/msvc/genhdr.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="GenerateHeaders">
33

4-
<Import Project="env.props" Condition="$(PyEnvIncluded)!=True"/>
4+
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
55

66
<!--Generate qstrdefs.h and mpversion.h similar to what is done in py/py.mk-->
77
<Target Name="GenerateHeaders" DependsOnTargets="MakeQstrData;MakeVersionHdr">

windows/msvc/paths.props

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<PyPathsIncluded>True</PyPathsIncluded>
5+
6+
<!-- The properties below specify the output directory structure.
7+
This defaults to, for example for Configuration = Debug and Platform = x64:
8+
9+
micropython [PyBaseDir]
10+
|- ...
11+
|- windows [PyWinDir]
12+
|- ...
13+
|- micropython.exe
14+
|- build [PyBuildDir]
15+
|- Debugx64 [PyOutDir]
16+
| |- ...
17+
| |- micropython.exe
18+
| |- micropython.map
19+
| |- obj [PyIntDir]
20+
|- genhdr
21+
22+
Note that the micropython executable will be copied from PyOutDir
23+
to PyWinDir after each build. -->
24+
25+
<!-- Start from project root -->
26+
<PyBaseDir>$([System.IO.Path]::GetFullPath(`$(MSBuildThisFileDirectory)..\..`))\</PyBaseDir>
27+
<PyWinDir>$(PyBaseDir)windows\</PyWinDir>
28+
<PyBuildDir Condition="'$(PyBuildDir)' == ''">$(PyWinDir)build\</PyBuildDir>
29+
30+
<!-- All include directories needed for uPy -->
31+
<PyIncDirs>$(PyBaseDir);$(PyWinDir);$(PyBuildDir);$(PyWinDir)msvc</PyIncDirs>
32+
33+
<!-- Within PyBuildDir different subdirectories are used based on configuration and platform.
34+
By default these are chosen based on the Configuration and Platform properties, but
35+
this file might be imported by other projects (to figure out where the artifacts go
36+
or what the include files are) and those projects might already contain conflicting
37+
Configuration/Platform properties, so allow to override these -->
38+
<PyPlatform Condition="'$(PyPlatform)' == ''">$(Platform)</PyPlatform>
39+
<PyConfiguration Condition="'$(PyConfiguration)' == ''">$(Configuration)</PyConfiguration>
40+
41+
<!-- The final destination directories -->
42+
<PyOutDir>$(PyBuildDir)$(PyConfiguration)$(PyPlatform)\</PyOutDir>
43+
<PyIntDir>$(PyOutDir)obj\</PyIntDir>
44+
</PropertyGroup>
45+
</Project>

windows/msvc/sources.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="env.props" Condition="$(PyEnvIncluded)!=True"/>
3+
<Import Project="paths.props" Condition="'$(PyPathsIncluded)' != 'True'"/>
44
<ItemGroup>
55
<ClCompile Include="$(PyBaseDir)py\*.c" />
66
<ClCompile Include="$(PyBaseDir)windows\*.c" />

0 commit comments

Comments
 (0)
0