1@echo off 2::# default builds static library. 3::# you can pass the following arguments (case insensitive): 4::# - "DLL" to build a DLL instead of a static library 5::# - "/MT" to build a static library compatible with MSVC's /MT option (LIBCMT vs MSVCRT) 6::# - "USBDK" to build with UsbDk backend 7 8if Test%BUILD_ALT_DIR%==Test goto usage 9 10::# process commandline parameters 11set TARGET=LIBRARY 12set STATIC_LIBC= 13set WITH_USBDK= 14set version=1.0 15set PWD=%~dp0 16set BUILD_CMD=build -bcwgZ -M2 17 18:more_args 19 20if "%1" == "" goto no_more_args 21::# /I for case insensitive 22if /I Test%1==TestDLL set TARGET=DYNLINK 23if /I Test%1==Test/MT set STATIC_LIBC=1 24if /I Test%1==TestUSBDK set WITH_USBDK=1 25 26shift 27goto more_args 28 29:no_more_args 30 31cd ..\libusb\os 32echo TARGETTYPE=%TARGET% > target 33copy target+..\..\msvc\libusb_sources sources >NUL 2>&1 34del target 35@echo on 36%BUILD_CMD% 37@echo off 38if errorlevel 1 goto builderror 39cd ..\.. 40 41set cpudir=i386 42set destType=Win32 43if %_BUILDARCH%==x86 goto isI386 44set cpudir=amd64 45set destType=x64 46:isI386 47 48set srcPath=libusb\os\obj%BUILD_ALT_DIR%\%cpudir% 49 50set dstPath=%destType%\Debug 51if %DDKBUILDENV%==chk goto isDebug 52set dstPath=%destType%\Release 53:isDebug 54 55if exist %destType% goto md2 56mkdir %destType% 57:md2 58if exist %dstPath% goto md3 59mkdir %dstPath% 60:md3 61if exist %dstPath%\dll goto md4 62mkdir %dstPath%\dll 63:md4 64if exist %dstPath%\lib goto md5 65md %dstPath%\lib 66:md5 67if exist %dstPath%\examples goto md6 68md %dstPath%\examples 69:md6 70@echo on 71 72@if /I NOT Test%1==TestDLL goto copylib 73copy %srcPath%\libusb-%version%.dll %dstPath%\dll 74copy %srcPath%\libusb-%version%.pdb %dstPath%\dll 75:copylib 76copy %srcPath%\libusb-%version%.lib %dstPath%\lib 77 78@echo off 79 80if exist examples\listdevs_ddkbuild goto md7 81md examples\listdevs_ddkbuild 82:md7 83 84cd examples\listdevs_ddkbuild 85copy ..\..\msvc\listdevs_sources sources >NUL 2>&1 86@echo on 87%BUILD_CMD% 88@echo off 89if errorlevel 1 goto builderror 90cd ..\.. 91 92set srcPath=examples\listdevs_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% 93@echo on 94 95copy %srcPath%\listdevs.exe %dstPath%\examples 96copy %srcPath%\listdevs.pdb %dstPath%\examples 97 98@echo off 99 100if exist examples\xusb_ddkbuild goto md8 101md examples\xusb_ddkbuild 102:md8 103 104cd examples\xusb_ddkbuild 105copy ..\..\msvc\xusb_sources sources >NUL 2>&1 106@echo on 107%BUILD_CMD% 108@echo off 109if errorlevel 1 goto builderror 110cd ..\.. 111 112set srcPath=examples\xusb_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% 113@echo on 114 115copy %srcPath%\xusb.exe %dstPath%\examples 116copy %srcPath%\xusb.pdb %dstPath%\examples 117 118@echo off 119 120if exist examples\getopt\getopt_ddkbuild goto md9 121md examples\getopt\getopt_ddkbuild 122:md9 123 124cd examples\getopt\getopt_ddkbuild 125copy ..\..\..\msvc\getopt_sources sources >NUL 2>&1 126@echo on 127%BUILD_CMD% 128@echo off 129if errorlevel 1 goto builderror 130cd ..\..\.. 131 132if exist examples\fxload_ddkbuild goto md10 133md examples\fxload_ddkbuild 134:md10 135 136cd examples\fxload_ddkbuild 137copy ..\..\msvc\fxload_sources sources >NUL 2>&1 138@echo on 139%BUILD_CMD% 140@echo off 141if errorlevel 1 goto builderror 142cd ..\.. 143 144set srcPath=examples\fxload_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% 145@echo on 146 147copy %srcPath%\fxload.exe %dstPath%\examples 148copy %srcPath%\fxload.pdb %dstPath%\examples 149 150@echo off 151 152if exist examples\hotplugtest_ddkbuild goto md11 153md examples\hotplugtest_ddkbuild 154:md11 155 156cd examples\hotplugtest_ddkbuild 157copy ..\..\msvc\hotplugtest_sources sources >NUL 2>&1 158@echo on 159%BUILD_CMD% 160@echo off 161if errorlevel 1 goto builderror 162cd ..\.. 163 164set srcPath=examples\hotplugtest_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% 165@echo on 166 167copy %srcPath%\hotplugtest.exe %dstPath%\examples 168copy %srcPath%\hotplugtest.pdb %dstPath%\examples 169 170@echo off 171 172cd msvc 173goto done 174 175:usage 176echo ddk_build must be run in a WDK build environment 177pause 178goto done 179 180:builderror 181echo Build failed 182 183:done 184cd %PWD% 185