libusbK 
3.0
Library Documentation
© 2011-2021 Travis Lee Robinson. All rights reserved.
Building with make.cmd

Building and packaging with the automated MSDOS script make.cmd.

On this page:


About

make.cmd is a MSDOS (extended mode) batch file which fully automates several tasks.

Note
make.cmd is non-specific to libusbK. It is fully configurable from its make.cfg configuration.

Features

  • Generates WDK "sources" from custom ".sources" file templates
    • By design, WDK allows only one project (or sources file) per directory. The make.cmd custom ".sources" file templates eliminate this restriction.
    • Provides pre-tagging functionality for WDK "sources" files.
  • Code signing
  • INNO setup installer creation
  • Version control
  • Binary package creation
  • Source package creation
  • Regular expression based cleaning
  • Source code re/formatting

Requirements


Initial Setup and Configuration

After installing the required software, make.cfg must be configured to use it. Generally this only requires modifying the WDK SETUP section so make.cmd can locate your WDK installation. See the comments in make.cfg for more information.

Automatically configuring make.cmd with a WDK installation

  1. From the start menu, locate the WDK installation programs folder
  2. Open a build window for the build environment that will be used as the default.
  3. Execute make.cmd build
  4. Close the build window and open a normal command prompt
  5. Verify propper operation by repeating step #3

make.cmd Command Line Usage

Syntax

make.cmd command[=value] <command-specific-arguments> 

Commands

Command[=value] command-specific-arguments
BUILD
Builds all projects defined in WDK_SOURCES_LIST for a single environment/architecture combination. See the WDK SETUP and BUILD sections in make.cfg.

If no setenv.bat command-specific arguments are specified, make.cmd will use the defaults defined by WDK_DEF_ENV_OPTIONS. See the WDK SETUP section in make.cfg.

For more information, see Using the SetEnv.bat
[fre|chk]
For release builds use the fre, for debug builds use chk.
NOTE: Debug builds include log messages.
[64|x64]:
Build architecture:
  • x64 = AMD64
  • 64 = IA64 (rare)
[WIN7|WLH|WXP|WNET|W2K]
Specifies the Build environment:
  • WIN7 = Windows 7
  • WLH = Windows Vista
  • WXP = Windows XP
  • WNET = Windows Server 2003
  • W2K = Windows 2000 W2K is Only supported with WDK version 6001.18002
[no_oacr]
Disables OACR (Microsoft Auto Code Review)

[sign]
Sign dll, sys, and exe files with a code signing certificate after compiling.
See the SIGN section in make.cfg.
DIST
Build all projects for all environment/architecture combinations defined in DIST_BUILD_LIST. See the DIST section in make.cfg.
dist=finalize
Used for official release builds.
Build additional components and installers. Requires additional configuration. See post_build_libusbK_dll.cfg
[fre|chk]
For release builds use the fre, for debug builds use chk.
NOTE: chk builds include debug log messages.
[sign]
Sign dll, sys, and exe files with a code signing certificate after compiling.
See the SIGN section in make.cfg.
CLEAN
Cleans the source and output directories. See the CLEAN section in make.cfg
clean=bin
Removes temporary files and directories from the output directory. See CLEAN_BIN_EXP in make.cfg.
clean=src
Removes temporary files and directories from the source directory. See CLEAN_SRC_EXP in make.cfg.
clean=full
Cleans the source directory. Removes the output directory entirely.
 
version=package;inc
Increment the package nano version number.
version=package;dec
Decrement the package nano version number.
version=[package|project name]; [inc|dec|set]; [major|macro|minor|nano]; [set value];
Full package/project version control
 
ZIP
Create a combined binary and source package.
zip=bin
Create a binary zip package from the output directory.
zip=src
Create a source zip package from the source directory.
 
FORMATCODE
Format source code. (Uses Astyle by default) See the FORMATCODE section in make.cfg
 

Usage Examples

BUILD examples

make.cmd build
make.cmd build chk
make.cmd build sign
make.cmd build wxp chk sign

DIST examples

make.cmd dist
make.cmd dist chk
make.cmd dist=finalize chk sign

CLEAN examples

make.cmd clean
make.cmd clean=full

Configuration Examples

make.cfg example

; BUILD CONFIGURATION FILE
; 
; NOTES:
;	* Type 'make.cmd help' for more information.
;   * It is not required to execute make.cmd from within a WDK build environment.
;	* When make.cmd is executed from within a WDK build environment, it updates
;     WDK_DIR and WDK_DEF_ENV_OPTIONS in this cfg file; use this to quickly
;     configure make.cfg automatically.
;   * If make.cmd cannot locate a required build component it may prompt the user
;     with options to locate them.
;

; WDK SETUP -----------------------------------------------------------
; To download a Microsoft WDK release see:
; http://www.microsoft.com/whdc/devtools/wdk/wdkpkg.mspx 
; The build process cannot continue unless some version of WDK is located.
;
WDK_DIR=Z:\WinDDK\7600.16385.1
WDK_DEF_ENV_OPTIONS=chk x86 WIN7
WDK_BUILD_OPTIONS=/cegZ
WDK_SOURCES_LIST=libusbK.sys; libusbK.lib; kList.exe; kBench.exe; dpscat.exe; libusbK.dll;
;WDK_SOURCES_LIST=libusbK.lib; kList.exe; kBench.exe; dpscat.exe; libusbK.dll;
NO_OACR=no_oacr

; BUILD ---------------------------------------------------------------
;
BUILD_QUIET=1
BUILD_OUTPUT_BASE_DIR=bin

; TARGET_OUTPUT_ABS_DIR is what the TARGETPATH must be set to in the
; sources file. This is a special (more dynamic) setting value that is
; loaded before each target.  The .sources file TARGETPATH must be set
; to this. 
; ie: TARGETNAME = $(G_TARGET_OUTPUT_NAME) 
; and TARGETPATH = $(G_TARGET_OUTPUT_ABS_DIR)
;
TARGET_OUTPUT_ABS_DIR=!G_BUILD_OUTPUT_BASE_ABS_DIR!\!G_TARGET_OUTPUT_FILENAME_EXT!

; CLEAN ---------------------------------------------------------------
;
; If make.cmd is executed with the 'clean' argument, these directories 
; and files will be recursively cleaned from the dir and subdirs this 
; config file resides in.
;
CLEAN_BIN_EXP=\\Debug\\ \\Release\\ \.pdb$ \.exp$ \\libusbK-[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*-setup- \.bmp$
CLEAN_SRC_EXP=resharper \\obj \\bin\\ \\buildfre \\buildchk \.suo$ \.sln\.DotSettings$ \.user$ \.ncb$ \.orig$ \\Debug \\Release \\x64 \\x86 \\testing\\libusbK.lib \.\\build_env_vars\.lst \\doc\\output \\inf-wizard2\\lib\\libwdi\.lib$ \\libwdi\\embedded\.h$ \\libwdi\\embedder\.ilk$ \\libwdi\\embedder\.pdb$ \\libwdi\\embedder\.exe$ \\InfWizard.aps$ \\\.vs
CLEAN_PACKAGE_TEMP_EXP=\.remove-me\.

; DIST ----------------------------------------------------------------
;
; This is the list of env build settings to build for a distribution set.
; Each comma delimited item represents a distinct set of target binaries
; that will be built for every source file in WDK_SOURCES_LIST when 'dist'
; is used on the commandline.
;
DIST_BUILD_LIST=x64 WNET; 64 WNET; WXP;

; PACKAGE -------------------------------------------------------------
;
PACKAGE_ROOT_NAME=libusbK
PACKAGE_DIR=package
PACKAGE_ALL_NAME=all
PACKAGE_SRC_NAME=src
PACKAGE_BIN_NAME=bin
PACKAGE_ZIP_EXT=7z
PACKAGE_TEMP_DIR=!G_PACKAGE_DIR!\output

; F_PACKAGE_NAME will evaluate to all, src, or bin (see above) depending on
; the operation. F_PACKAGE_VERSION will evaluate to the 'PACKAGE' version
; defined in make.versions.
;
PACKAGE_NAME_FORMAT=!G_PACKAGE_ROOT_NAME!-!F_PACKAGE_VERSION!-!F_PACKAGE_NAME!
PACKAGE_ALL_SUBDIR_FORMAT=!G_PACKAGE_ROOT_NAME!-!F_PACKAGE_VERSION!

; SIGN ----------------------------------------------------------------
;
;SIGN_CERT_FILE=!CD!\cert\DigiCert.crt
SIGN_CERT_NAME=Travis Lee Robinson
SIGN_CERT_TIMESTAMP=/t http://timestamp.digicert.com

SIGN_CERT_ARGS=sign /v /ac "!G_SIGN_CERT_FILE!" /s my /n "!G_SIGN_CERT_NAME!" !G_SIGN_CERT_TIMESTAMP!
SIGN_CERT_VERIFY_ARGS=verify /kp /v

; GCC -----------------------------------------------------------------
;
MINGW_W64_DIR=C:\MinGW64
MINGW_W32_DIR=C:\MinGW

; FORMATCODE ----------------------------------------------------------
; If make.cmd is executed with the 'formatcode' argument, FORMATCODE_EXE 
; will be executed and FORMATCODE_ARGS will be passed in as an argument. 
; Download astyle at astyle.sourceforge.net.
;
FORMATCODE_EXE=C:\Windows\AStyle.exe
FORMATCODE_STA_OPS=--pad-oper --indent=tab --lineend=windows --align-pointer=type --style=allman
FORMATCODE_ARGS=!G_FORMATCODE_STA_OPS! --recursive *.c *.cpp *.h;

; MISC ----------------------------------------------------------------
; This will enable log messages for make.cmd.
SCRIPT_DEBUGGING=0

; Month, day and year used in the version header template
_MM_=!DATE:~4,2!
_DD_=!DATE:~7,2!
_YYYY_=!DATE:~10,4!

; Only used to generate a test inf file.
; NOTE: the '^' is only there to escape the '&' for make.cmd.
;
BENCHMARK_DEVICE_HWID=USB\VID_04D8^&PID_FA2E

; Only used to generate a test inf file.
; {6C696275-7362-2D77-696E-33322D574446} is the GUID libusbK will assign
; if the 'DeviceInterfaceGUIDs' key is not found/invalid.
; To set this key from the inf file, update the line: 
; HKR,,DeviceInterfaceGUIDs, 0x10000,"{your-guid}"
; in the 'UsbK_Device_HW_AddReg' section.
;
BENCHMARK_DEVICE_GUID={00006275-7362-2D77-696E-33322D574446}

; Full path to Visual studio devenv.com
; Used for building libwdi & InfWizard2
;
DEVENV_EXE="%VS90COMNTOOLS%..\IDE\devenv"

make.versions example

PACKAGE = 3.1.0.0; NUL; NUL;
libusbK.sys = PACKAGE; .\common_version_h.in; .\src\sys\lusbk_version.h;
libusbK.lib = PACKAGE; .\common_version_h.in; .\src\lib\lusbk_version.h;
libusbK.dll = PACKAGE; .\common_version_h.in; .\src\dll\lusbk_version.h;
kBench.exe = PACKAGE; .\common_version_h.in; .\src\kBench\lusbk_version.h;
kList.exe = PACKAGE; .\common_version_h.in; .\src\kList\lusbk_version.h;
dpscat.exe = PACKAGE; .\common_version_h.in; .\src\dpscat\lusbk_version.h;