Windows: MS project files part 2 - WDK project files
authorPete Batard <pbatard@gmail.com>
Mon, 9 May 2011 23:38:49 +0000 (00:38 +0100)
committerPeter Stuge <peter@stuge.se>
Mon, 13 Jun 2011 20:06:30 +0000 (22:06 +0200)
References #57.

msvc/ddk_build.cmd [new file with mode: 0644]
msvc/libusb_sources [new file with mode: 0644]
msvc/lsusb_sources [new file with mode: 0644]

diff --git a/msvc/ddk_build.cmd b/msvc/ddk_build.cmd
new file mode 100644 (file)
index 0000000..5d7d6b3
--- /dev/null
@@ -0,0 +1,106 @@
+@rem default builds static library.
+@rem you can pass the following arguments (case insensitive):
+@rem - "DLL" to build a DLL instead of a static library
+@rem - "/MT" to build a static library compatible with MSVC's /MT option (LIBCMT vs MSVCRT)
+@echo off
+
+if Test%BUILD_ALT_DIR%==Test goto usage
+
+rem process commandline parameters
+set TARGET=LIBRARY
+set STATIC_LIBC=
+set version=1.0
+
+if "%1" == "" goto no_more_args
+rem /I for case insensitive
+if /I Test%1==TestDLL set TARGET=DYNLINK
+if /I Test%1==Test/MT set STATIC_LIBC=1
+:no_more_args
+
+cd ..\libusb\os
+echo TARGETTYPE=%TARGET% > target
+copy target+..\..\msvc\libusb_sources sources >NUL 2>&1
+del target
+@echo on
+build -cwgZ
+@echo off
+if errorlevel 1 goto builderror
+cd ..\..
+
+set cpudir=i386
+set destType=Win32
+if %_BUILDARCH%==x86 goto isI386
+set cpudir=amd64
+set destType=x64
+:isI386
+
+set srcPath=libusb\os\obj%BUILD_ALT_DIR%\%cpudir%
+
+set dstPath=%destType%\Debug
+if %DDKBUILDENV%==chk goto isDebug
+set dstPath=%destType%\Release
+:isDebug
+
+if exist %destType% goto md2
+mkdir %destType%
+:md2
+if exist %dstPath% goto md3
+mkdir %dstPath%
+:md3
+if exist %dstPath%\dll goto md4
+mkdir %dstPath%\dll
+:md4
+if exist %dstPath%\lib goto md5
+md %dstPath%\lib
+:md5
+if exist %dstPath%\examples goto md6
+md %dstPath%\examples
+:md6
+@echo on
+
+@if NOT Test%1==TestDLL goto copylib
+copy %srcPath%\libusb-%version%.dll %dstPath%\dll
+copy %srcPath%\libusb-%version%.pdb %dstPath%\dll
+:copylib
+copy %srcPath%\libusb-%version%.lib %dstPath%\lib
+
+@echo off
+
+if exist examples\lsusb_ddkbuild goto md7
+md examples\lsusb_ddkbuild
+:md7
+
+cd examples\lsusb_ddkbuild
+copy ..\..\msvc\lsusb_sources sources >NUL 2>&1
+@echo on
+build -cwgZ
+@echo off
+if errorlevel 1 goto buildlsusberror
+cd ..\..
+
+set srcPath=examples\lsusb_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
+@echo on
+
+copy %srcPath%\lsusb.exe %dstPath%\examples
+copy %srcPath%\lsusb.pdb %dstPath%\examples
+
+cd msvc
+goto done
+
+
+:builderror
+cd ..\..\msvc
+echo Build failed
+goto done
+
+:buildlsusberror
+cd ..\..\msvc
+echo lsusb build failed
+goto done
+
+:usage
+echo ddk_build must be run in a WDK build environment
+pause
+goto done
+
+:done
diff --git a/msvc/libusb_sources b/msvc/libusb_sources
new file mode 100644 (file)
index 0000000..8e8e65c
--- /dev/null
@@ -0,0 +1,36 @@
+#TARGETTYPE is not defined, to allow selection between static lib or DLL with ddk_build
+TARGETNAME=libusb-1.0
+DLLDEF=..\libusb-1.0.def
+
+!IFNDEF MSC_WARNING_LEVEL
+MSC_WARNING_LEVEL=/W3
+!ENDIF
+
+!IFDEF STATIC_LIBC
+USE_LIBCMT=1
+!ELSE
+USE_MSVCRT=1
+!ENDIF
+
+INCLUDES=..;..\..\msvc;$(DDK_INC_PATH)
+C_DEFINES= $(C_DEFINES) $(LIBUSB_DEFINES) /DDDKBUILD
+
+# http://jpassing.com/2009/10/21/ltcg-issues-with-the-win7amd64-environment-of-wdk-7600/
+# prevents the following error when using the 64 bit static lib with Visual Studio 2010:
+# "fatal error C1001: An internal error has occurred in the compiler.
+# (compiler file 'f:\dd\vctools\compiler\utc\src\p2\p2symtab.c', line 1823)"
+# and the following with Visual Studio 2010:
+# "fatal error C1047: The object or library file 'libusb-1.0.lib' was created with
+#  an older compiler than other objects; rebuild old objects and libraries"
+USER_C_FLAGS=/GL-
+
+TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib
+
+SOURCES=..\core.c \
+       ..\descriptor.c \
+       ..\io.c \
+       ..\sync.c \
+       threads_windows.c \
+       poll_windows.c \
+       windows_usb.c \
+       ..\libusb-1.0.rc
diff --git a/msvc/lsusb_sources b/msvc/lsusb_sources
new file mode 100644 (file)
index 0000000..dbfefbb
--- /dev/null
@@ -0,0 +1,19 @@
+TARGETNAME=lsusb
+TARGETTYPE=PROGRAM
+386_STDCALL=0
+
+_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP)
+!IFNDEF MSC_WARNING_LEVEL
+MSC_WARNING_LEVEL=/W3
+!ENDIF
+
+!IFDEF STATIC_LIBC
+USE_LIBCMT=1
+!ELSE
+USE_MSVCRT=1
+!ENDIF
+
+UMTYPE=console
+INCLUDES=..\..\libusb;$(DDK_INC_PATH)
+UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
+SOURCES=..\lsusb.c