diff --git a/.editorconfig b/.editorconfig index ddceb3c..3ca70e6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,2 +1,6 @@ -[*.{c,h,inf}] +[*.{c,h,inf,rc,wxs}] indent_style = tab + +[*.{proj,props,vcxproj,wixproj}] +indent_style = space +indent_size = 2 diff --git a/Makefile b/Makefile deleted file mode 100644 index e0c8318..0000000 --- a/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -# -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright (C) 2018-2019 WireGuard LLC. All Rights Reserved. -# - -# TODO: Unify version definition with wintun.vcxproj. Migrate from NMAKE to MSBuild? -WINTUN_VERSION=0.1 - -DIST_DIR=dist -MSBUILD_FLAGS=/m /v:minimal /nologo -WIX_CANDLE_FLAGS=-nologo -ext WixDifxAppExtension -ext WixIIsExtension -dWINTUN_VERSION="$(WINTUN_VERSION)" -WIX_LIGHT_FLAGS=-nologo -ext WixDifxAppExtension -ext WixIIsExtension -sw1103 - -build :: \ - build_x86_Release \ - build_amd64_Release \ - build_arm64_Release - -dvl :: "wintun.DVL.XML" - -msm :: \ - "$(DIST_DIR)" \ - "$(DIST_DIR)\wintun-x86-$(WINTUN_VERSION).msm" \ - "$(DIST_DIR)\wintun-amd64-$(WINTUN_VERSION).msm" - -"sdv\SDV.DVL.xml" "amd64\Release\vc.nativecodeanalysis.all.xml" : - msbuild.exe "wintun.vcxproj" /t:sdv /p:Inputs="/check:*" /p:Configuration="Release" /p:Platform="x64" $(MSBUILD_FLAGS) - -"wintun.DVL.XML" : "sdv\SDV.DVL.xml" "amd64\Release\vc.nativecodeanalysis.all.xml" - msbuild.exe "wintun.vcxproj" /t:dvl /p:Configuration="Release" /p:Platform="x64" $(MSBUILD_FLAGS) - -"$(DIST_DIR)" : - md $@ > NUL 2>&1 - -clean :: - -rd /s /q "sdv" > NUL 2>&1 - -del /f /q "wintun.DVL.XML" > NUL 2>&1 - -del /f /q "smvbuild.log" > NUL 2>&1 - -del /f /q "smvstats.txt" > NUL 2>&1 - -rd /s /q "$(DIST_DIR)" > NUL 2>&1 - -CFG=Release -PLAT=x86 -!INCLUDE "Makefile.PlatCfg.mak" -PLAT=amd64 -!INCLUDE "Makefile.PlatCfg.mak" -PLAT=arm64 -!INCLUDE "Makefile.PlatCfg.mak" - -CFG=Debug -PLAT=x86 -!INCLUDE "Makefile.PlatCfg.mak" -PLAT=amd64 -!INCLUDE "Makefile.PlatCfg.mak" -PLAT=arm64 -!INCLUDE "Makefile.PlatCfg.mak" diff --git a/Makefile.PlatCfg.mak b/Makefile.PlatCfg.mak deleted file mode 100644 index 60a472a..0000000 --- a/Makefile.PlatCfg.mak +++ /dev/null @@ -1,43 +0,0 @@ -# -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright (C) 2018-2019 WireGuard LLC. All Rights Reserved. -# - -!IF "$(PLAT)" == "x86" -PLAT_MSBUILD=Win32 -PLAT_WIX=x86 -!ELSEIF "$(PLAT)" == "amd64" -PLAT_MSBUILD=x64 -PLAT_WIX=x64 -!ELSEIF "$(PLAT)" == "arm64" -PLAT_MSBUILD=ARM64 -PLAT_WIX=arm64 # TODO: Follow WiX ARM64 support. -!ELSE -!ERROR Invalid platform "$(PLAT)". PLAT must be "x86", "amd64", or "arm64". -!ENDIF - -OUTPUT_DIR=$(PLAT)\$(CFG) - -build_$(PLAT)_$(CFG) :: - msbuild.exe "wintun.vcxproj" /t:Build /p:Configuration="$(CFG)" /p:Platform="$(PLAT_MSBUILD)" $(MSBUILD_FLAGS) - -clean :: - -rd /s /q "$(OUTPUT_DIR)" > NUL 2>&1 - -!IF "$(CFG)" == "Release" - -"$(OUTPUT_DIR)\wintun.wixobj" : "wintun.wxs" - "$(WIX)bin\candle.exe" $(WIX_CANDLE_FLAGS) -arch "$(PLAT_WIX)" -out $@ $** - -"$(DIST_DIR)\wintun-$(PLAT)-$(WINTUN_VERSION).msm" : \ - "$(DIST_DIR)" \ - "$(OUTPUT_DIR)\wintun.cer" \ - "$(OUTPUT_DIR)\wintun\wintun.cat" \ - "$(OUTPUT_DIR)\wintun\wintun.inf" \ - "$(OUTPUT_DIR)\wintun\wintun.sys" \ - "$(OUTPUT_DIR)\wintun.wixobj" \ - "$(WIX)bin\difxapp_$(PLAT_WIX).wixlib" - "$(WIX)bin\light.exe" $(WIX_LIGHT_FLAGS) -b output_dir="$(OUTPUT_DIR)" -out $@ -spdb "$(OUTPUT_DIR)\wintun.wixobj" "$(WIX)bin\difxapp_$(PLAT_WIX).wixlib" - -!ENDIF diff --git a/README.md b/README.md index 2db1beb..34ef9ab 100644 --- a/README.md +++ b/README.md @@ -37,18 +37,22 @@ If you already have `wintun.vcxproj.user` file, just add the `` s Open _Developer Command Prompt for VS 2017_ and use the `nmake` command: ``` -nmake [] +msbuild wintun.proj [/t:] [/p:Configuration=] [/p:Platform=] ``` ### Targets - - `build`: Builds the driver. This is the default target. + - `Build`: Builds the driver. This is the default target. - - `clean`: Deletes all intermediate and output files. + - `Clean`: Deletes all intermediate and output files. - - `dvl`: Runs Static Driver Verifier, which includes a clean driver build, and creates a Driver Verification Log in `wintun.DVL.XML` file. When you are ready to test your driver using the Windows Hardware Certification Kit (HCK), you need to copy the `wintun.DVL.XML` file to the `%SystemDrive%\DVL` directory on the test computer. + - `Rebuild`: Alias for `Clean` followed by `Build`. - - `msm`: Builds Microsoft Installer Merge Module in `\wintun.msm`. This target requires the driver to be built first (e.g. `nmake build msm` or `nmake dvl msm`). + - `SDV`: Runs Static Driver Verifier, which includes a clean driver build. Release configurations only. + + - `DVL`: Runs the `SDV`, and creates a Driver Verification Log in `wintun.DVL.XML` file. Release configurations only. When you are ready to test your driver using the Windows Hardware Certification Kit (HCK), you need to copy the `wintun.DVL.XML` file to the `%SystemDrive%\DVL` directory on the test computer. + + - `MSM`: Builds Microsoft Installer Merge Module in `\wintun--.msm`. The driver output folder is: @@ -61,6 +65,14 @@ 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 diff --git a/wintun.proj b/wintun.proj new file mode 100644 index 0000000..344fa73 --- /dev/null +++ b/wintun.proj @@ -0,0 +1,100 @@ + + + + + + + Release + amd64 + $(Platform)\$(Configuration)\ + + + + + + + Win32 + x86 + + + x64 + x64 + + + ARM64 + arm64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(DistributionDir) + wintun-$(WintunPlatform)-$(WintunVersionStr) + .msm + $(MSMName)$(MSMExt) + $(MSMDir)$(MSMFileName) + + + + + diff --git a/wintun.props b/wintun.props new file mode 100644 index 0000000..4ad435c --- /dev/null +++ b/wintun.props @@ -0,0 +1,23 @@ + + + + + 0 + 1 + 0.1 + $(WintunVersionMaj).$(WintunVersionMin) + + + x86 + x86 + amd64 + arm64 + + dist\ + sdv\ + + \ No newline at end of file diff --git a/wintun.vcxproj b/wintun.vcxproj index 592a05d..f4f31ed 100644 --- a/wintun.vcxproj +++ b/wintun.vcxproj @@ -102,50 +102,26 @@ - - 0 - 1 - 0.1 - + + <_ProjectFileVersion>15.0.28127.55 - - + $(WintunPlatform)\$(ConfigurationName)\ + $(WintunPlatform)\$(ConfigurationName)\ true + + $(WDKContentRoot)CodeAnalysis\DriverMustFixRules.ruleset - x86\$(ConfigurationName)\ - x86\$(ConfigurationName)\ - - true + AllRules.ruleset - x86\$(ConfigurationName)\ - x86\$(ConfigurationName)\ - - - true - $(WDKContentRoot)CodeAnalysis\DriverMustFixRules.ruleset - amd64\$(ConfigurationName)\ - amd64\$(ConfigurationName)\ - - - true - $(WDKContentRoot)CodeAnalysis\DriverMustFixRules.ruleset - arm64\$(ConfigurationName)\ - arm64\$(ConfigurationName)\ - - - true - AllRules.ruleset - amd64\$(ConfigurationName)\ - amd64\$(ConfigurationName)\ - - - true - AllRules.ruleset - arm64\$(ConfigurationName)\ - arm64\$(ConfigurationName)\ + + + + + + WINTUN_VERSION_MAJ=$(WintunVersionMaj);WINTUN_VERSION_MIN=$(WintunVersionMin);WINTUN_VERSION_STR="$(WintunVersionStr)";NDIS_MINIPORT_DRIVER=1;NDIS620_MINIPORT=1;NDIS630_MINIPORT=1;NDIS_WDM=1;%(PreprocessorDefinitions) @@ -164,7 +140,7 @@ - $(WintunVersionMaj).$(WintunVersionMin) + $(WintunVersion) diff --git a/wintun.wixproj b/wintun.wixproj new file mode 100644 index 0000000..7ee76d9 --- /dev/null +++ b/wintun.wixproj @@ -0,0 +1,70 @@ + + + + + Release + x64 + {F95A1EBF-1E19-47D4-9D8C-4F0C41B9E3B8} + wintun + Module + false + + + + + + $(WintunPlatform)\$(Configuration)\ + $(WintunPlatform)\$(Configuration)\ + $(ProjectName) + WINTUN_VERSION=$(WintunVersion);$(DefineConstants) + -ext WixDifxAppExtension -ext WixIIsExtension $(CompilerAdditionalOptions) + 1103;$(LinkerSuppressSpecificWarnings) + -ext WixDifxAppExtension -ext WixIIsExtension -b output_dir="$(IntermediateOutputPath.TrimEnd('\'))" $(LinkerAdditionalOptions) + + + true + $(DistributionDir) + $(ProjectName)-$(WintunPlatform)-$(WintunVersionStr) + + + + + + + + + + + + + + + + + + + $(TestCertificate) + $(ProductionCertificate) + SignTarget + $(BuildDependsOn);SignTarget + CleanSignTarget;$(CleanDependsOn) + + + + + + + + +