Skip to content

Commit 8dec62a

Browse files
committed
msvc: Define main build/include directories in a single location
- Use a single file env.props for defining the main directories used when building. env.props resolves the base directory and defines overridable output directories, and is used by all other build files. - Fix the build currently failing, basically because the preprocessing command for generating qstrdefs uses different include directories than the build itself does. (specifically, qstrdefs.h uses #include "py/mpconfig.h" since the fixes for adafruit#1022 in 51dfcb4, so we need to use the base directory as include directory, not the py dir itself). So define a single variable containing the include directories instead and use it where needed.
1 parent fd40a9c commit 8dec62a

4 files changed

Lines changed: 26 additions & 11 deletions

File tree

windows/msvc/common.props

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<ImportGroup Label="PropertySheets" />
3+
<ImportGroup Label="PropertySheets">
4+
<Import Project="env.props" />
5+
</ImportGroup>
46
<PropertyGroup Label="UserMacros" />
57
<PropertyGroup>
6-
<OutDir>$(ProjectDir)</OutDir>
7-
<IntDir>$(ProjectDir)build\$(Configuration)$(Platform)\</IntDir>
8+
<OutDir>$(PyOutDir)</OutDir>
9+
<IntDir>$(PyBuildDir)$(Configuration)$(Platform)\</IntDir>
10+
<PyIncDirs>$(PyBaseDir);$(PyBaseDir)windows;$(PyBaseDir)windows\msvc;$(PyBuildDir)</PyIncDirs>
811
</PropertyGroup>
912
<ItemDefinitionGroup>
1013
<ClCompile>
11-
<AdditionalIncludeDirectories>.\;..\;.\build;.\msvc</AdditionalIncludeDirectories>
14+
<AdditionalIncludeDirectories>$(PyIncDirs);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
1215
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1316
<SDLCheck>false</SDLCheck>
1417
<WarningLevel>Level1</WarningLevel>

windows/msvc/env.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<PyBaseDir>$([System.IO.Path]::GetFullPath(`$(MSBuildThisFileDirectory)..\..`))\</PyBaseDir>
5+
<PyBuildDir Condition="'$(PyBuildDir)'==''">$(MSBuildThisFileDirectory)build\</PyBuildDir>
6+
<PyOutDir Condition="'$(PyOutDir)'==''">$(PyBaseDir)windows\</PyOutDir>
7+
<PyEnvIncluded>True</PyEnvIncluded>
8+
</PropertyGroup>
9+
</Project>

windows/msvc/genhdr.targets

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
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"/>
5+
46
<Target Name="GenerateHeaders" DependsOnTargets="MakeQstrData;MakeVersionHeader">
57
</Target>
68

79
<PropertyGroup>
8-
<SrcDir>$(MsBuildThisFileDirectory)..\..\py\</SrcDir>
9-
<DestDir>$(MsBuildThisFileDirectory)..\build\genhdr\</DestDir>
10+
<SrcDir>$(PyBaseDir)py\</SrcDir>
11+
<DestDir>$(PyBuildDir)genhdr\</DestDir>
1012
</PropertyGroup>
1113

1214
<Target Name="MakeDestDir">
@@ -17,10 +19,13 @@
1719
<Target Name="MakeQstrData" DependsOnTargets="MakeDestDir">
1820
<PropertyGroup>
1921
<PreProc>$(DestDir)qstrdefs.preprocessed.h</PreProc>
20-
<QstrDefs>$(MsBuildThisFileDirectory)..\..\unix\qstrdefsport.h</QstrDefs>
22+
<QstrDefs>$(PyBaseDir)unix\qstrdefsport.h</QstrDefs>
2123
<DestFile>$(DestDir)qstrdefs.generated.h</DestFile>
2224
</PropertyGroup>
23-
<Exec Command="cl /nologo /I$(SrcDir) /I$(MsBuildThisFileDirectory).. /Fi$(PreProc) /P $(SrcDir)qstrdefs.h"/>
25+
<ItemGroup>
26+
<PyIncDirs Include="$(PyIncDirs)"/>
27+
</ItemGroup>
28+
<Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /Fi$(PreProc) /P $(SrcDir)qstrdefs.h"/>
2429
<Exec Command="python $(SrcDir)makeqstrdata.py $(PreProc) $(QstrDefs) > $(DestFile).tmp"/>
2530
<Exec Command="fc /B $(DestFile).tmp $(DestFile) > NUL 2>&amp;1" IgnoreExitCode="true">
2631
<Output TaskParameter="ExitCode" PropertyName="FilesDiffer" />

windows/msvc/sources.props

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +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-
<PropertyGroup>
4-
<PyBaseDir>$(MsbuildThisFileDirectory)..\..\</PyBaseDir>
5-
</PropertyGroup>
3+
<Import Project="env.props" Condition="$(PyEnvIncluded)!=True"/>
64
<ItemGroup>
75
<ClCompile Include="$(PyBaseDir)py\*.c" />
86
<ClCompile Include="$(PyBaseDir)extmod\*.c" />

0 commit comments

Comments
 (0)