download SDL dlls if not present
authorkoda
Wed, 24 Oct 2012 10:18:42 +0100
changeset 7810 da60e6b6baa3
parent 7809 7d4fb2f35f4f
child 7811 49ab679cb384
download SDL dlls if not present
bin/CMakeLists.txt
tools/build_windows.bat
tools/w32DownloadUnzip.vbs
--- a/bin/CMakeLists.txt	Wed Oct 24 10:17:38 2012 +0100
+++ b/bin/CMakeLists.txt	Wed Oct 24 10:18:42 2012 +0100
@@ -1,9 +1,11 @@
 if(WIN32 AND NOT UNIX)
 	file(GLOB DLLs *.dll)
 	file(GLOB ICOs *.ico)
+	file(GLOB TXTs *.txt)
 	
 	install(FILES
 		${DLLs}
 		${ICOs}
+		${TXTs}
 		DESTINATION bin)
 endif(WIN32 AND NOT UNIX)
--- a/tools/build_windows.bat	Wed Oct 24 10:17:38 2012 +0100
+++ b/tools/build_windows.bat	Wed Oct 24 10:18:42 2012 +0100
@@ -8,13 +8,20 @@
 set CURRDIR="%CD%"
 cd ..
 
-echo Copying the DLLs...
-REM xcopy /d/y %CD%\misc\winutils\bin\* .
-xcopy /d/y %QTDIR%\QtCore4.dll bin
-xcopy /d/y %QTDIR%\QtGui4.dll bin
-xcopy /d/y %QTDIR%\QtNetwork4.dll bin
-xcopy /d/y %QTDIR%\libgcc_s_dw2-1.dll bin
-xcopy /d/y %QTDIR%\mingwm10.dll bin
+echo Fetching all DLLs...
+for %%G in (QtCore4 QtGui4 QtNetwork4 libgcc_s_dw2-1 mingwm10) do (
+    xcopy /d/y %QTDIR%\%%G.dll bin\
+)
+
+if not exist %CD%\misc\winutils\bin\ mkdir %CD%\misc\winutils\bin\
+if not exist %CD%\misc\winutils\bin\SDL.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://www.libsdl.org/release/SDL-1.2.15-win32.zip %CD%\misc\winutils\bin
+if not exist %CD%\misc\winutils\bin\SDL_image.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.12-win32.zip %CD%\misc\winutils\bin
+if not exist %CD%\misc\winutils\bin\SDL_net.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://www.libsdl.org/projects/SDL_net/release/SDL_net-1.2.8-win32.zip %CD%\misc\winutils\bin
+if not exist %CD%\misc\winutils\bin\SDL_mixer.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.12-win32.zip %CD%\misc\winutils\bin
+if not exist %CD%\misc\winutils\bin\SDL_ttf.dll cscript %CD%\tools\w32DownloadUnzip.vbs  http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-2.0.11-win32.zip %CD%\misc\winutils\bin
+
+xcopy /d/y %CD%\misc\winutils\bin\*.dll bin
+xcopy /d/y %CD%\misc\winutils\bin\*.txt bin
 
 ::setting up the environment...
 call %QTDIR%\qtenv2.bat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/w32DownloadUnzip.vbs	Wed Oct 24 10:18:42 2012 +0100
@@ -0,0 +1,64 @@
+' w32DownloadUnzip.vbs
+'   Download a zipfile and uncompress it with no external tools in Windows
+'
+' Copyright (c) 2012, Vittorio Giovara, <vittorio.giovara@gmail.com>
+' Redistribution and use is allowed according to the terms of the BSD license.
+'
+' References
+'   http://superuser.com/questions/59465/is-it-possible-to-download-using-the-windows-command-line
+'   http://stackoverflow.com/questions/1021557/how-to-unzip-a-file-using-the-command-line
+
+Set ArgObj = WScript.Arguments
+
+If (Wscript.Arguments.Count = 1) Then
+    strFileURL = ArgObj(0)
+    strOutputPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
+Else
+    If (Wscript.Arguments.Count = 2) Then
+        strFileURL = ArgObj(0)
+        strOutputPath = ArgObj(1)
+    Else
+        WScript.Echo ("Usage: csript.exe w32DownloadUnzip.vbs url output")
+        WScript.Quit
+    End if
+End if
+
+strHDLocation = "C:\Windows\Temp\temp.zip"
+
+' Fetch the file
+Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
+objXMLHTTP.open "GET", strFileURL, false
+objXMLHTTP.send()
+
+If objXMLHTTP.Status = 200 Then
+    WScript.Echo ( "Downloading file from " & strFileURL)
+    Set objADOStream = CreateObject("ADODB.Stream")
+    objADOStream.Open
+    objADOStream.Type = 1 'adTypeBinary
+
+    objADOStream.Write objXMLHTTP.ResponseBody
+    objADOStream.Position = 0    'Set the stream position to the start
+
+    Set objFSO = Createobject("Scripting.FileSystemObject")
+    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
+    Set objFSO = Nothing
+
+    objADOStream.SaveToFile strHDLocation
+    objADOStream.Close
+    Set objADOStream = Nothing
+Else
+    WScript.Echo ("Error downloading file (error code: " & objXMLHTTP.Status & ")")
+    Set objXMLHTTP = Nothing
+    WScript.Quit
+End if
+Set objXMLHTTP = Nothing
+
+WScript.Echo ( "Extracting file to " & strOutputPath)
+Set objShell = CreateObject( "Shell.Application" )
+Set objSource = objShell.NameSpace(strHDLocation).Items()
+Set objTarget = objShell.NameSpace(strOutputPath)
+intOptions = 16 'no user prompt
+objTarget.CopyHere objSource, intOptions
+
+WScript.Echo ( "Extraction successful" )
+Set objShell = Nothing