Windows: Fix VS2010 project files
[libusbx.git] / msvc / ddk_build.cmd
blobaadab502e4598989dde1d5e80fc9610c3691791f
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)
7 if Test%BUILD_ALT_DIR%==Test goto usage
9 ::# process commandline parameters
10 set TARGET=LIBRARY
11 set STATIC_LIBC=
12 set version=1.0
13 set PWD=%~dp0
14 set BUILD_CMD=build -bcwgZ -M2
16 if "%1" == "" goto no_more_args
17 ::# /I for case insensitive
18 if /I Test%1==TestDLL set TARGET=DYNLINK
19 if /I Test%1==Test/MT set STATIC_LIBC=1
20 :no_more_args
22 cd ..\libusb\os
23 echo TARGETTYPE=%TARGET% > target
24 copy target+..\..\msvc\libusb_sources sources >NUL 2>&1
25 del target
26 @echo on
27 %BUILD_CMD%
28 @echo off
29 if errorlevel 1 goto builderror
30 cd ..\..
32 set cpudir=i386
33 set destType=Win32
34 if %_BUILDARCH%==x86 goto isI386
35 set cpudir=amd64
36 set destType=x64
37 :isI386
39 set srcPath=libusb\os\obj%BUILD_ALT_DIR%\%cpudir%
41 set dstPath=%destType%\Debug
42 if %DDKBUILDENV%==chk goto isDebug
43 set dstPath=%destType%\Release
44 :isDebug
46 if exist %destType% goto md2
47 mkdir %destType%
48 :md2
49 if exist %dstPath% goto md3
50 mkdir %dstPath%
51 :md3
52 if exist %dstPath%\dll goto md4
53 mkdir %dstPath%\dll
54 :md4
55 if exist %dstPath%\lib goto md5
56 md %dstPath%\lib
57 :md5
58 if exist %dstPath%\examples goto md6
59 md %dstPath%\examples
60 :md6
61 @echo on
63 @if /I NOT Test%1==TestDLL goto copylib
64 copy %srcPath%\libusb-%version%.dll %dstPath%\dll
65 copy %srcPath%\libusb-%version%.pdb %dstPath%\dll
66 :copylib
67 copy %srcPath%\libusb-%version%.lib %dstPath%\lib
69 @echo off
71 if exist examples\listdevs_ddkbuild goto md7
72 md examples\listdevs_ddkbuild
73 :md7
75 cd examples\listdevs_ddkbuild
76 copy ..\..\msvc\listdevs_sources sources >NUL 2>&1
77 @echo on
78 %BUILD_CMD%
79 @echo off
80 if errorlevel 1 goto builderror
81 cd ..\..
83 set srcPath=examples\listdevs_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
84 @echo on
86 copy %srcPath%\listdevs.exe %dstPath%\examples
87 copy %srcPath%\listdevs.pdb %dstPath%\examples
89 @echo off
91 if exist examples\xusb_ddkbuild goto md8
92 md examples\xusb_ddkbuild
93 :md8
95 cd examples\xusb_ddkbuild
96 copy ..\..\msvc\xusb_sources sources >NUL 2>&1
97 @echo on
98 %BUILD_CMD%
99 @echo off
100 if errorlevel 1 goto builderror
101 cd ..\..
103 set srcPath=examples\xusb_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
104 @echo on
106 copy %srcPath%\xusb.exe %dstPath%\examples
107 copy %srcPath%\xusb.pdb %dstPath%\examples
109 @echo off
111 if exist examples\getopt\getopt_ddkbuild goto md9
112 md examples\getopt\getopt_ddkbuild
113 :md9
115 cd examples\getopt\getopt_ddkbuild
116 copy ..\..\..\msvc\getopt_sources sources >NUL 2>&1
117 @echo on
118 %BUILD_CMD%
119 @echo off
120 if errorlevel 1 goto builderror
121 cd ..\..\..
123 if exist examples\fxload_ddkbuild goto md10
124 md examples\fxload_ddkbuild
125 :md10
127 cd examples\fxload_ddkbuild
128 copy ..\..\msvc\fxload_sources sources >NUL 2>&1
129 @echo on
130 %BUILD_CMD%
131 @echo off
132 if errorlevel 1 goto builderror
133 cd ..\..
135 set srcPath=examples\fxload_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
136 @echo on
138 copy %srcPath%\fxload.exe %dstPath%\examples
139 copy %srcPath%\fxload.pdb %dstPath%\examples
141 @echo off
143 if exist examples\hotplugtest_ddkbuild goto md11
144 md examples\hotplugtest_ddkbuild
145 :md11
147 cd examples\hotplugtest_ddkbuild
148 copy ..\..\msvc\hotplugtest_sources sources >NUL 2>&1
149 @echo on
150 %BUILD_CMD%
151 @echo off
152 if errorlevel 1 goto builderror
153 cd ..\..
155 set srcPath=examples\hotplugtest_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
156 @echo on
158 copy %srcPath%\hotplugtest.exe %dstPath%\examples
159 copy %srcPath%\hotplugtest.pdb %dstPath%\examples
161 @echo off
163 cd msvc
164 goto done
166 :usage
167 echo ddk_build must be run in a WDK build environment
168 pause
169 goto done
171 :builderror
172 echo Build failed
174 :done
175 cd %PWD%