Extend MSBuild project to build all supported platforms at once

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2019-04-23 13:19:27 +02:00
parent daba4f4c7d
commit 56424d52f7
2 changed files with 45 additions and 52 deletions

View File

@ -37,24 +37,24 @@ If you already have `wintun.vcxproj.user` file, just add the `<PropertyGroup>` s
Open _Developer Command Prompt for VS 2017_ and use the `msbuild` command:
```
msbuild wintun.proj [/t:<target>] [/p:Configuration=<configuration>] [/p:Platform=<platform>]
msbuild wintun.proj [/t:<target>]
```
### Targets
- `Build`: Builds the driver. This is the default target.
- `Build`: Builds the driver release configurations of all supported platforms. This is the default target.
- `Clean`: Deletes all intermediate and output files.
- `Rebuild`: Alias for `Clean` followed by `Build`.
- `SDV`: Runs Static Driver Verifier, which includes a clean driver build, only for release configurations.
- `SDV`: Runs Static Driver Verifier, which includes a clean driver build, only for AMD64 release configuration.
- `DVL`: Runs the `SDV`, and creates a Driver Verification Log, only for release configurations.
- `DVL`: Runs the `SDV`, and creates a Driver Verification Log, only for AMD64 release configurations.
- `MSM`: Builds Microsoft Installer Merge Module in `<output folder>\wintun-<platform>-<version>.msm`.
- `MSM`: Builds Microsoft Installer Merge Modules in `<output folder>\wintun-<platform>-<version>.msm`.
The driver output folder is:
The driver output folders are:
Platform and Configuration | Folder
-------------------------- | --------------------
@ -65,14 +65,6 @@ AMD64 Release | `amd64\Release\wintun`
ARM64 Debug | `arm64\Debug\wintun`
ARM64 Release | `arm64\Release\wintun`
### Properties
Properties may be defined as environment variables, or specified on the `msbuild` command line.
- `Configuration`: Specifies configuration to build or clean. May be `Debug` or `Release` (default).
- `Platform`: Specifies driver platform to build. May be `x86` or `amd64` (default), or `arm64`.
## Usage

View File

@ -11,31 +11,15 @@
<!--
General Properties
-->
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<Platform Condition="'$(Platform)' == ''">amd64</Platform>
<OutputDir>$(Platform)\$(Configuration)\</OutputDir>
</PropertyGroup>
<Import Project="wintun.props"/>
<Import Project="wintun.vcxproj.user" Condition="exists('wintun.vcxproj.user')"/>
<PropertyGroup Condition="'$(Platform)' == 'x86'">
<MSBuildPlatform>Win32</MSBuildPlatform>
<WiXPlatform>x86</WiXPlatform>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'amd64'">
<MSBuildPlatform>x64</MSBuildPlatform>
<WiXPlatform>x64</WiXPlatform>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'arm64'">
<MSBuildPlatform>ARM64</MSBuildPlatform>
<WiXPlatform>arm64</WiXPlatform> <!-- TODO: Follow WiX ARM64 support. -->
</PropertyGroup>
<Target Name="Build" DependsOnTargets="Driver"/>
<Target Name="Build" DependsOnTargets="Driver-x86;Driver-amd64;Driver-arm64"/>
<Target Name="MSM" DependsOnTargets="MSM-x86;MSM-amd64"/>
<Target Name="Clean">
<RemoveDir Directories="$(OutputDir)"/>
<RemoveDir Directories="x86\Release\"/>
<RemoveDir Directories="amd64\Release\"/>
<RemoveDir Directories="arm64\Release\"/>
<RemoveDir Directories="$(SDVDir)"/>
<RemoveDir Directories="$(DistributionDir)"/>
<Delete Files="smvbuild.log;smvstats.txt;wintun.DVL.XML"/>
@ -46,24 +30,40 @@
Driver Building
Note: Use explicit Inputs/Outputs as WindowsDriver.Common.targets triggers driver re-packaging and signing on every invocation.
-->
<Target Name="Driver"
Outputs="$(OutputDir)wintun\wintun.sys;$(OutputDir)wintun\wintun.inf;$(OutputDir)wintun\wintun.cat"
<Target Name="Driver-x86"
Outputs="x86\Release\wintun\wintun.sys;x86\Release\wintun\wintun.inf;x86\Release\wintun\wintun.cat"
Inputs="wintun.c;wintun.inf;wintun.props;wintun.rc;wintun.vcxproj">
<MSBuild
Projects="wintun.vcxproj"
Targets="Build"
Properties="Configuration=$(Configuration);Platform=$(MSBuildPlatform)"/>
Properties="Configuration=Release;Platform=Win32"/>
</Target>
<Target Name="Driver-amd64"
Outputs="amd64\Release\wintun\wintun.sys;amd64\Release\wintun\wintun.inf;amd64\Release\wintun\wintun.cat"
Inputs="wintun.c;wintun.inf;wintun.props;wintun.rc;wintun.vcxproj">
<MSBuild
Projects="wintun.vcxproj"
Targets="Build"
Properties="Configuration=Release;Platform=x64"/>
</Target>
<Target Name="Driver-arm64"
Outputs="arm64\Release\wintun\wintun.sys;arm64\Release\wintun\wintun.inf;arm64\Release\wintun\wintun.cat"
Inputs="wintun.c;wintun.inf;wintun.props;wintun.rc;wintun.vcxproj">
<MSBuild
Projects="wintun.vcxproj"
Targets="Build"
Properties="Configuration=Release;Platform=ARM64"/>
</Target>
<!--
Static Driver Verifier
-->
<Target Name="SDV"
Outputs="$(SDVDir)SDV.DVL.xml;$(OutputDir)vc.nativecodeanalysis.all.xml">
Outputs="$(SDVDir)SDV.DVL.xml;amd64\Release\vc.nativecodeanalysis.all.xml">
<MSBuild
Projects="wintun.vcxproj"
Targets="sdv"
Properties="Inputs=/check:*;Configuration=$(Configuration);Platform=$(MSBuildPlatform)"/>
Properties="Inputs=/check:*;Configuration=Release;Platform=x64"/>
</Target>
<!--
@ -72,29 +72,30 @@
<Target Name="DVL"
DependsOnTargets="SDV"
Outputs="wintun.DVL.XML"
Inputs="$(SDVDir)SDV.DVL.xml;$(OutputDir)vc.nativecodeanalysis.all.xml">
Inputs="$(SDVDir)SDV.DVL.xml;amd64\Release\vc.nativecodeanalysis.all.xml">
<MSBuild
Projects="wintun.vcxproj"
Targets="dvl"
Properties="Configuration=$(Configuration);Platform=$(MSBuildPlatform)"/>
Properties="Configuration=Release;Platform=x64"/>
</Target>
<!--
MSM Building
-->
<PropertyGroup>
<MSMDir>$(DistributionDir)</MSMDir>
<MSMName>wintun-$(WintunPlatform)-$(WintunVersionStr)</MSMName>
<MSMExt>.msm</MSMExt>
<MSMFileName>$(MSMName)$(MSMExt)</MSMFileName>
<MSMPath>$(MSMDir)$(MSMFileName)</MSMPath>
</PropertyGroup>
<Target Name="MSM"
<Target Name="MSM-x86"
DependsOnTargets="Build"
Outputs="$(MSMPath)">
Outputs="$(DistributionDir)wintun-x86-$(WintunVersionStr).msm">
<MSBuild
Projects="wintun.wixproj"
Targets="Build"
Properties="Configuration=$(Configuration);Platform=$(WiXPlatform)"/>
Properties="Configuration=Release;Platform=x86"/>
</Target>
<Target Name="MSM-amd64"
DependsOnTargets="Build"
Outputs="$(DistributionDir)wintun-amd64-$(WintunVersionStr).msm">
<MSBuild
Projects="wintun.wixproj"
Targets="Build"
Properties="Configuration=Release;Platform=x64"/>
</Target>
</Project>