aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/km/build/wdk7.1
diff options
context:
space:
mode:
Diffstat (limited to 'km/build/wdk7.1')
-rw-r--r--km/build/wdk7.1/.gitignore2
-rw-r--r--km/build/wdk7.1/add_cert.bat26
-rw-r--r--km/build/wdk7.1/build_driver.bat122
-rw-r--r--km/build/wdk7.1/build_drivers.bat13
-rw-r--r--km/build/wdk7.1/check_ddk.bat38
-rw-r--r--km/build/wdk7.1/check_env.bat18
-rw-r--r--km/build/wdk7.1/clean_driver.bat96
-rw-r--r--km/build/wdk7.1/clean_drivers.bat13
-rw-r--r--km/build/wdk7.1/setenv.bat35
-rw-r--r--km/build/wdk7.1/sign.bat33
10 files changed, 396 insertions, 0 deletions
diff --git a/km/build/wdk7.1/.gitignore b/km/build/wdk7.1/.gitignore
new file mode 100644
index 0000000..e6416c5
--- /dev/null
+++ b/km/build/wdk7.1/.gitignore
@@ -0,0 +1,2 @@
+/bin/
+/lib/
diff --git a/km/build/wdk7.1/add_cert.bat b/km/build/wdk7.1/add_cert.bat
new file mode 100644
index 0000000..7223a2a
--- /dev/null
+++ b/km/build/wdk7.1/add_cert.bat
@@ -0,0 +1,26 @@
+@rem Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com>
+@rem This file is part of the "Windows 7 drivers" project.
+@rem For details, see https://github.com/egor-tensin/windows7-drivers.
+@rem Distributed under the MIT License.
+
+@setlocal enabledelayedexpansion
+@echo off
+
+set cert_name=windows7_drivers
+
+echo ============================ CERT INFO ============================
+echo Certificate name: %cert_name%
+echo ========================== END CERT INFO ==========================
+echo.
+echo ======================= ADDING CERTIFICATE ========================
+call check_ddk.bat || goto :add_cert_failure
+echo makecert.exe -r -pe -ss root -n CN="%cert_name%" "%cert_name%.cer"
+ makecert.exe -r -pe -ss root -n CN="%cert_name%" "%cert_name%.cer" >nul || goto :add_cert_failure
+echo del "%cert_name%.cer"
+ del "%cert_name%.cer" >nul || goto :add_cert_failure
+echo =================== ADDING CERTIFICATE SUCCESS ====================
+exit /b 0
+
+:add_cert_failure
+echo =================== ADDING CERTIFICATE FAILURE ====================
+exit /b %errorlevel%
diff --git a/km/build/wdk7.1/build_driver.bat b/km/build/wdk7.1/build_driver.bat
new file mode 100644
index 0000000..1cf2a9a
--- /dev/null
+++ b/km/build/wdk7.1/build_driver.bat
@@ -0,0 +1,122 @@
+@rem Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com>
+@rem This file is part of the "Windows 7 drivers" project.
+@rem For details, see https://github.com/egor-tensin/windows7-drivers.
+@rem Distributed under the MIT License.
+
+@setlocal enabledelayedexpansion
+@echo off
+
+if "%~1" == "" (
+ echo Usage: %~nx0 DRIVER_SRC_ROOT >&2
+ exit /b 1
+)
+
+call check_env.bat || exit /b !errorlevel!
+call check_ddk.bat || exit /b !errorlevel!
+
+set "driver_src_root=%~f1"
+
+for /f %%i in ("%driver_src_root%") do (
+ set "driver_name=%%~ni"
+ set "driver_dist_subdir=%%~dpi"
+)
+
+call :make_relative driver_dist_subdir "%src_root%"
+
+set "sys_dist_dir=%bin_root%\%target_platform%\%target_configuration%\%driver_dist_subdir%"
+set "pdb_dist_dir=%bin_root%\%target_platform%\%target_configuration%\%driver_dist_subdir%"
+set "lib_dist_dir=%lib_root%\%target_platform%\%target_configuration%\%driver_dist_subdir%"
+
+echo =========================== DRIVER INFO ===========================
+echo Driver source directory: %driver_src_root%
+echo Driver name: %driver_name%
+echo ========================= END DRIVER INFO =========================
+echo.
+echo ============================== BUILD ==============================
+set "LIBDISTDIR=%lib_dist_dir%"
+pushd "%driver_src_root%" && (
+ build.exe /cegwZ
+ popd
+)
+if errorlevel 0 (
+ echo ========================== BUILD SUCCESS ==========================
+) else (
+ echo ========================== BUILD FAILURE ==========================
+ exit /b %errorlevel%
+)
+
+if "%_BUILDARCH%" == "x86" (
+ set buildarch_directory=i386
+) else (
+ set "buildarch_directory=%_BUILDARCH%"
+)
+
+set "sys_path=%driver_src_root%\obj%BUILD_ALT_DIR%\%buildarch_directory%\%driver_name%.sys"
+set "pdb_path=%driver_src_root%\obj%BUILD_ALT_DIR%\%buildarch_directory%\%driver_name%.pdb"
+set "lib_path=%driver_src_root%\obj%BUILD_ALT_DIR%\%buildarch_directory%\%driver_name%.lib"
+
+if exist "%sys_path%" (
+ echo.
+ call "%build_root%\sign.bat" "%sys_path%" || exit /b !errorlevel!
+)
+
+echo.
+echo ============================== DISTR ==============================
+if exist "%sys_path%" (
+ call :distr_copy "%sys_path%" "%sys_dist_dir%" || goto :distr_failure
+ call :distr_copy "%pdb_path%" "%pdb_dist_dir%" || goto :distr_failure
+)
+if exist "%lib_path%" (
+ call :distr_copy "%lib_path%" "%lib_dist_dir%" || goto :distr_failure
+)
+echo ========================== DISTR SUCCESS ==========================
+exit /b
+
+:distr_mkdir
+if not exist "%~1\" (
+ echo mkdir "%~1"
+ mkdir "%~1" >nul
+ exit /b !errorlevel!
+)
+exit /b 0
+
+:distr_copy
+call :distr_mkdir "%~2" || exit /b !errorlevel!
+echo copy "%~1" "%~2"
+ copy "%~1" "%~2" >nul
+exit /b %errorlevel%
+
+:distr_failure
+echo ========================== DISTR FAILURE ==========================
+exit /b %errorlevel%
+
+:make_relative
+@setlocal enabledelayedexpansion
+
+set "abs=%~1"
+if defined %~1 set "abs=!%~1!"
+
+set "base=%~2"
+if not defined base set "base=%CD%"
+
+for /f "tokens=*" %%i in ("%abs%") do set "abs=%%~fi"
+for /f "tokens=*" %%i in ("%base%") do set "base=%%~fi"
+
+set match=
+set upper=
+
+for /f "tokens=*" %%i in ('echo.%base:\=^&echo.%') do (
+ set "sub=!sub!%%i\"
+ call set "tmp=%%abs:!sub!=%%"
+ if "!tmp!" == "!abs!" (
+ set "upper=!upper!..\"
+ ) else (
+ set "match=!sub!"
+ )
+)
+
+set "rel=%upper%!abs:%match%=!"
+
+(endlocal & if defined %~1 (set "%~1=%rel%") else (echo.%rel%))
+
+exit /b 0
diff --git a/km/build/wdk7.1/build_drivers.bat b/km/build/wdk7.1/build_drivers.bat
new file mode 100644
index 0000000..35b2867
--- /dev/null
+++ b/km/build/wdk7.1/build_drivers.bat
@@ -0,0 +1,13 @@
+@rem Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com>
+@rem This file is part of the "Windows 7 drivers" project.
+@rem For details, see https://github.com/egor-tensin/windows7-drivers.
+@rem Distributed under the MIT License.
+
+@setlocal enabledelayedexpansion
+@echo off
+
+for /f "delims=" %%i in ('dir "%src_root%\sources" /b /s') do (
+ set "driver_src_root=%%~dpi"
+ echo.
+ call build_driver.bat "!driver_src_root:~0,-1!" || exit /b !errorlevel!
+)
diff --git a/km/build/wdk7.1/check_ddk.bat b/km/build/wdk7.1/check_ddk.bat
new file mode 100644
index 0000000..aaabd76
--- /dev/null
+++ b/km/build/wdk7.1/check_ddk.bat
@@ -0,0 +1,38 @@
+@rem Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com>
+@rem This file is part of the "Windows 7 drivers" project.
+@rem For details, see https://github.com/egor-tensin/windows7-drivers.
+@rem Distributed under the MIT License.
+
+@setlocal enabledelayedexpansion
+@echo off
+
+call check_env.bat || exit /b !errorlevel!
+
+if not defined BUILD_ALT_DIR goto :ddk_not_set
+if not defined _BUILDARCH goto :ddk_not_set
+
+if not exist "%build_root%\sign.bat" (
+ echo Error: %build_root%\sign.bat was not found ^(don^'t know how to sign drivers otherwise^) >&2
+ exit /b 1
+)
+
+where build.exe >nul 2>&1 || goto :build_not_found
+where signtool.exe >nul 2>&1 || goto :signtool_not_found
+where makecert.exe >nul 2>&1 || goto :makecert_not_found
+exit /b 0
+
+:ddk_not_set
+echo Error: either %%BUILD_ALT_DIR%% or %%_BUILDARCH%% are not set ^(have you set up the WinDDK environment?^) >&2
+exit /b 1
+
+:build_not_found
+echo Error: build.exe was not found ^(have you set up the WinDDK environment?^) >&2
+exit /b 1
+
+:signtool_not_found
+echo Error: signtool.exe was not found ^(have you set up the WinDDK environment?^) >&2
+exit /b 1
+
+:makecert_not_found
+echo Error: makecert.exe was not found ^(have you set up the WinDDK environment?^) >&2
+exit /b 1
diff --git a/km/build/wdk7.1/check_env.bat b/km/build/wdk7.1/check_env.bat
new file mode 100644
index 0000000..f3cb382
--- /dev/null
+++ b/km/build/wdk7.1/check_env.bat
@@ -0,0 +1,18 @@
+@rem Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com>
+@rem This file is part of the "Windows 7 drivers" project.
+@rem For details, see https://github.com/egor-tensin/windows7-drivers.
+@rem Distributed under the MIT License.
+
+@setlocal enabledelayedexpansion
+@echo off
+
+if not defined root goto :env_not_set
+if not defined bin_root goto :env_not_set
+if not defined lib_root goto :env_not_set
+if not defined src_root goto :env_not_set
+
+exit /b 0
+
+:env_not_set
+echo Error: either %%root%%, %%bin_root%%, %%lib_root%% or %%src_root%% are not set ^(have you set up the build environment using setenv.bat?^) >&2
+exit /b 1
diff --git a/km/build/wdk7.1/clean_driver.bat b/km/build/wdk7.1/clean_driver.bat
new file mode 100644
index 0000000..2a98624
--- /dev/null
+++ b/km/build/wdk7.1/clean_driver.bat
@@ -0,0 +1,96 @@
+@rem Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com>
+@rem This file is part of the "Windows 7 drivers" project.
+@rem For details, see https://github.com/egor-tensin/windows7-drivers.
+@rem Distributed under the MIT License.
+
+@setlocal enabledelayedexpansion
+@echo off
+
+if "%~1" == "" (
+ echo Usage: %~nx0 DRIVER_SRC_ROOT >&2
+ exit /b 1
+)
+
+call check_ddk.bat || exit /b !errorlevel!
+call check_env.bat || exit /b !errorlevel!
+
+set "driver_src_root=%~f1"
+cd "%driver_src_root%" || exit /b !errorlevel!
+
+for /f %%i in ("%driver_src_root%") do (
+ set "driver_name=%%~ni"
+ set "driver_dist_root=%%~dpi"
+)
+
+call :make_relative driver_dist_root "%src_root%"
+
+set "sys_dist_dir=%bin_root%\%target_platform%\%target_configuration%\%driver_dist_root%"
+set "pdb_dist_dir=%bin_root%\%target_platform%\%target_configuration%\%driver_dist_root%"
+set "lib_dist_dir=%lib_root%\%target_platform%\%target_configuration%\%driver_dist_root%"
+
+echo =========================== DRIVER INFO ===========================
+echo Driver source directory: %driver_src_root%
+echo Driver name: %driver_name%
+echo ========================= END DRIVER INFO =========================
+echo.
+echo ============================== CLEAN ==============================
+call :clean_rmdir "obj%BUILD_ALT_DIR%" || goto :clean_failure
+call :clean_del "build%BUILD_ALT_DIR%.err" || goto :clean_failure
+call :clean_del "build%BUILD_ALT_DIR%.log" || goto :clean_failure
+call :clean_del "build%BUILD_ALT_DIR%.wrn" || goto :clean_failure
+call :clean_del "%sys_dist_dir%%driver_name%.sys" || goto :clean_failure
+call :clean_del "%pdb_dist_dir%%driver_name%.pdb" || goto :clean_failure
+call :clean_del "%lib_dist_dir%%driver_name%.lib" || goto :clean_failure
+echo ========================== CLEAN SUCCESS ==========================
+exit /b 0
+
+:clean_rmdir
+if exist "%~1\" (
+ echo rmdir /s /q "%~1"
+ rmdir /s /q "%~1" >nul
+ exit /b !errorlevel!
+)
+exit /b 0
+
+:clean_del
+if exist "%~1" (
+ echo del "%~1"
+ del "%~1" >nul
+ exit /b !errorlevel!
+)
+exit /b 0
+
+:clean_failure
+echo ========================== CLEAN FAILURE ==========================
+exit /b %errorlevel%
+
+:make_relative
+@setlocal enabledelayedexpansion
+
+set "abs=%~1"
+if defined %~1 set "abs=!%~1!"
+
+set "base=%~2"
+if not defined base set "base=%CD%"
+
+for /f "tokens=*" %%i in ("%abs%") do set "abs=%%~fi"
+for /f "tokens=*" %%i in ("%base%") do set "base=%%~fi"
+
+set match=
+set upper=
+
+for /f "tokens=*" %%i in ('echo.%base:\=^&echo.%') do (
+ set "sub=!sub!%%i\"
+ call set "tmp=%%abs:!sub!=%%"
+ if "!tmp!" == "!abs!" (
+ set "upper=!upper!..\"
+ ) else (
+ set "match=!sub!"
+ )
+)
+
+set "rel=%upper%!abs:%match%=!"
+
+(endlocal & if defined %~1 (set "%~1=%rel%") else (echo.%rel%))
+
+exit /b 0
diff --git a/km/build/wdk7.1/clean_drivers.bat b/km/build/wdk7.1/clean_drivers.bat
new file mode 100644
index 0000000..8442c90
--- /dev/null
+++ b/km/build/wdk7.1/clean_drivers.bat
@@ -0,0 +1,13 @@
+@rem Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com>
+@rem This file is part of the "Windows 7 drivers" project.
+@rem For details, see https://github.com/egor-tensin/windows7-drivers.
+@rem Distributed under the MIT License.
+
+@setlocal enabledelayedexpansion
+@echo off
+
+for /f "delims=" %%i in ('dir "%src_root%\sources" /b /s') do (
+ set "driver_src_root=%%~dpi"
+ echo.
+ call clean_driver.bat "!driver_src_root:~0,-1!" || exit /b !errorlevel!
+)
diff --git a/km/build/wdk7.1/setenv.bat b/km/build/wdk7.1/setenv.bat
new file mode 100644
index 0000000..c77bb92
--- /dev/null
+++ b/km/build/wdk7.1/setenv.bat
@@ -0,0 +1,35 @@
+@rem Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com>
+@rem This file is part of the "Windows 7 drivers" project.
+@rem For details, see https://github.com/egor-tensin/windows7-drivers.
+@rem Distributed under the MIT License.
+
+@echo off
+
+set "build_root=%~dp0%"
+
+set "root=%build_root%\..\..\.."
+for /f "delims=" %%i in ("%root%") do set "root=%%~fi"
+
+set "src_root=%root%\km\src"
+set "bin_root=%root%\km\build\wdk7.1\bin"
+set "lib_root=%root%\km\build\wdk7.1\lib"
+
+set target_configuration=Release
+
+if not defined _BUILDARCH (
+ echo Error: %%_BUILDARCH%% is not defined ^(have you set up the WinDDK environment?^) >&2
+ exit /b 1
+)
+
+if "%_BUILDARCH%" == "AMD64" (
+ set target_platform=x64
+ exit /b 0
+)
+
+if "%_BUILDARCH%" == "x86" (
+ set target_platform=x86
+ exit /b 0
+)
+
+echo Error: invalid %%_BUILDARCH%% value "%_BUILDARCH%" ^(the only supported architecture is x86^(-64^)^) >&2
+exit /b 1
diff --git a/km/build/wdk7.1/sign.bat b/km/build/wdk7.1/sign.bat
new file mode 100644
index 0000000..9955ac2
--- /dev/null
+++ b/km/build/wdk7.1/sign.bat
@@ -0,0 +1,33 @@
+@rem Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com>
+@rem This file is part of the "Windows 7 drivers" project.
+@rem For details, see https://github.com/egor-tensin/windows7-drivers.
+@rem Distributed under the MIT License.
+
+@setlocal enabledelayedexpansion
+@echo off
+
+set cert_name=windows7_drivers
+
+if "%~1" == "" (
+ echo Usage: %~nx0 SYS_PATH >&2
+ exit /b 1
+)
+
+set "sys_path=%~f1"
+
+echo ============================ CERT INFO ============================
+echo Certificate name: %cert_name%
+echo ========================== END CERT INFO ==========================
+echo.
+echo ============================= SIGNING =============================
+call check_ddk.bat || goto :signing_failure
+echo signtool.exe sign /s root /n "%cert_name%" "%sys_path%"
+ signtool.exe sign /s root /n "%cert_name%" "%sys_path%" >nul || goto :signing_failure
+echo signtool.exe verify /pa "%sys_path%"
+ signtool.exe verify /pa "%sys_path%" >nul || goto :signing_failure
+echo ========================= SIGNING SUCCESS =========================
+exit /b 0
+
+:signing_failure
+echo ========================= SIGNING FAILURE =========================
+exit /b %errorlevel%