NMake2MSBuild

— UPDATE 2016/03/09 —

Nmake2MsBuild は WDK 10 Version 1511 にて削除されました。理由といたしましては、本ツールが、ドライバ開発環境がコマンドラインから Visual Studio に移行した WDK 8 環境への移行を想定した一時的なツールであるためです。

Nmake2MsBuild

The Nmake2MsBuild tool was removed from the WDK starting in Windows 10, Version 1511.

今後は、Visual Studio を用いてドライバのテンプレートプロジェクトにファイルを追加する方法をご利用ください。こちらの方法も驚くほど簡単ですので、一度お試しいただければ幸いです!

Creating a Driver From Existing Source Files

To convert a driver that was created with a previous version of the WDK, create a new Windows driver solution in Visual Studio using one of the provided Windows driver templates. If you start with a template for your driver model, the structure of the project will be in place and the correct platform tool set will be selected. You can then add your source files to the solution.

——————————–

 

皆様、雨の多い今日この頃ですが、いかがお過ごしでしょうか。

WDK サポートチームのI沢(アイザワ)です。

 

今回は、ドライバのビルド環境に関するお話です。

WDK 8 からドライバのビルドが Visual Studio 上で行うことができるようになり、非常に便利になったことは既にみなさんご存知かと思います。

しかしながら、それ以前のドライバを Visual Studio でビルドできるようにするためには当然ながら移行作業が必要となります。

実は上記移行作業を簡単にしてくれる便利なツールとして Nmake2MsBuild が用意されております。意外と知られていなかったりしますので、今回はこちらのツールをご紹介いたします。

 

■ インストール

Nmake2MsBuild の威力を確認するために、今回は Windows 8.1 x64 環境に以下をインストールいたします。

 

· Visual Studio 2013

· Windows Driver Kit 8.1 Update 1

https://www.microsoft.com/en-us/download/details.aspx?id=42273

· Windows Driver Kit Version 7.1.0

https://www.microsoft.com/en-us/download/details.aspx?id=11800

 

Visual Studio 2013 および Windows Driver Kit 8.1 Update 1 は、Nmake2MsBuild のインストールおよびNmake2MsBuild で生成されたプロジェクトファイルを用いてドライバをビルドするためにインストールいたします。

Windows Driver Kit Version 7.1.0 は、含まれているサンプルコードを Nmake2MsBuild の変換元として使用いたします。

 

■ ソリューション & プロジェクトファイルの生成

NMake2MSBuild.exe はデフォルトで以下のパスに格納されております。

C:\Program Files (x86)\Windows Kits\8.1\bin\x86\NMake2MSBuild.exe

 

今回、プロジェクトファイルを生成するドライバは toaster の bus ドライバサンプルを使用いたします。

デフォルトでは以下のフォルダにソースコードが格納されております。

C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic

 

コマンドプロンプトを起動し、NMake2MSBuild.exe が格納されているフォルダへ移動して、以下のコマンドを実行いたします。

ポイントとしては、引数に指定するのはフォルダではなく sources ファイルとなる点です。

C:\Program Files (x86)\Windows Kits\8.1\bin\x86>NMake2MSBuild.exe C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\sources

 

以下が実行した結果です。

ソリューションファイルとプロジェクトファイルの生成に成功したことがわかります!

C:\Program Files (x86)\Windows Kits\8.1\bin\x86>NMake2MSBuild.exe C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\sources

ConvertFile : Information :

    Converting "C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\sources"

GenerateMsBuildFile : Information :

    Generated file "C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\sources.props"

ConvertFile : Information :

    Converting "C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\makefile.inc"

GenerateMsBuildFile : Information :

    Generated file "C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\makefile.inc.props"

PostProcessing : Information :

    Generated Project File dynambus.vcxproj

GetDependencyInformation : Information :

    Checking for external project dependencies

GetDependencyInformation : Information :

    The primary project collection does not contain any projects that depend on others.

CreatePackage : Information :

    Generated Package Project file 'C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\dynambus-Package\dynambus-Package.vcxproj'

InitializeProjectsForSolution : Information :

    Generating solution C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\dynambus.sln from:

        C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\dynambus-Package\dynambus-Package.vcxproj

        C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\dynambus.vcxproj

CreateSolutionIncludingDependencies : Information :

    Solution C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\bus\dynamic\dynambus.sln was created successfully

Convert : Information :

    ========== Project Conversion Finished: 1 Solution created with 2 Projects ==========

 

■ Visual Studio でのビルド

それでは sources ファイルが格納されているフォルダにソリューションファイル (dynambus.sln) が格納されておりますので、こちらを実行いたしましょう。

実行後、ソリューションエクスプローラーの表示を確認すると、ドライバビルド用のプロジェクトとパッケージング用のプロジェクトが作成されていることが確認できます。

 

clip_image002

 

このままビルドしてみましょう…メニューの [ビルド] から [ソリューションのビルド] を選択すると…。

 

clip_image004

 

ビルドに成功しました!簡単ですね。

これで Visual Studio のパワフルな機能を存分に活用しながらドライバの開発を行うことができます!

新バージョンの OS リリースに備えて過去のドライバを Visual Studio 環境に移行する場合は是非ご活用ください。

 

ではでは。