Document and clean up tools directory a bit
authorWuzzy <Wuzzy2@mail.ru>
Thu, 19 Jul 2018 14:01:57 +0200
changeset 13516 b62b14aa88d4
parent 13515 60bcc20e6ab0
child 13517 4c5c8a83e298
Document and clean up tools directory a bit
tools/README.md
tools/build_windows.bat
tools/darkMagic.hs
tools/old/build_windows.bat
tools/old/w32DownloadUnzip.vbs
tools/update_frontend_locale_files.sh
tools/update_locale_files.sh
tools/update_lua_locale_files.sh
tools/w32DownloadUnzip.vbs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/README.md	Thu Jul 19 14:01:57 2018 +0200
@@ -0,0 +1,20 @@
+# tools/ directory
+
+This directory contains various tools for HW development.
+
+To learn more about each individual tool, open its source file in a text editor,
+it often contains a brief comment at the top.
+
+## List of tools (excerpt)
+
+### Files
+* `update_locale_files.sh`: Update locale files
+* `hwmap2lua.sh`: Convert HWMAP files to Lua code for usage in missions
+* `create_dmg.sh`: Generate a .dmg file (relevant for Mac)
+* `dmg_pkg_install.sh`: Downloads and install a .dmg from a URL (relevant for Mac)
+* `docgen.sh`: Generate QTfrontend documentation with Doxygen (it's not very good)
+
+### Directories
+* `hwmapconverter`: C++ application to edit HWMAP files in text form
+* `pas2c`: Pascal-to-C rewriter. Used when hwengine is built as C application with `BUILD_ENGINE_C=1`
+* `old`: Very outdated stuff that needs re-examination and possibly deletion
--- a/tools/build_windows.bat	Wed Jul 18 17:02:40 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-:: WARNNG WARNING WARNING ::
-:: This Batch script is BROKEN and EXTREMELY OUTDATED!
-:: It does not work with latest version and needs a complete redo or removal.
-:: Its functionality has been disabled.
-
-:: Print dummy text and return.
-echo Sorry, this script is outdated. You're on your own.
-exit
-
-
-::::::::::::::::::::::::::::::
-:: Old script code follows ...
-::::::::::::::::::::::::::::::
-@echo off
-::edit these variables if you need
-set PASCAL=C:\FPC\2.6.0\bin\i386-win32\
-:: FIXME: Go Qt 5
-set QTDIR=C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin
-set PATH=%PATH%;%PASCAL%
-set BUILD_TYPE="Debug"
-
-:setup
-set CURRDIR="%CD%"
-cd ..
-
-echo Fetching all DLLs...
-if %BUILD_TYPE%=="Debug" (
-    for %%G in (QtCored4 QtGuid4 QtNetworkd4) do xcopy /d/y %QTDIR%\%%G.dll %CD%\bin\
-)
-:: should you libgcc dynamically you should try adding libgcc_s_dw2-1 and mingwm10
-:: FIXME: Use Qt5
-for %%G in (QtCore4 QtGui4 QtNetwork4) do (
-    xcopy /d/y %QTDIR%\%%G.dll %CD%\bin\
-)
-
-:: FIXME: Use SDL 2.0
-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
-
-::for video recording
-:: FIXME: googlecode.com is defunct.
-if not exist %CD%\misc\winutils\bin\avformat-54.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://hedgewars.googlecode.com/files/libav-win32-20121022-dll.zip %CD%\misc\winutils\bin
-
-::this is needed because fpc png unit hardcodes libpng-1.2.12
-if not exist %CD%\misc\winutils\bin\libpng13.dll copy /y %CD%\misc\winutils\bin\libpng15-15.dll %CD%\misc\winutils\bin\libpng13.dll
-
-xcopy /d/y %CD%\misc\winutils\bin\*.dll %CD%\bin\
-
-::setting up the environment...
-call %QTDIR%\qtenv2.bat
-
-echo Running cmake...
-set ERRORLEVEL=
-cmake . -G "MinGW Makefiles" -DPNG_LIBRARY="%CD%\misc\winutils\bin\libpng13.dll" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_PREFIX_PATH="%CD%\misc\winutils\\"
-:: prefix should be last
-
-if %ERRORLEVEL% NEQ 0 goto exitpoint
-
-echo Running make...
-set ERRORLEVEL=
-mingw32-make VERBOSE=1
-if %ERRORLEVEL% NEQ 0 goto exitpoint
-
-echo Installing...
-set ERRORLEVEL=
-mingw32-make install > nul
-if %ERRORLEVEL% NEQ 0 goto exitpoint
-
-echo Creating commodity shortcut...
-copy /y %CD%\misc\winutils\Hedgewars.lnk C:%HOMEPATH%\Desktop\Hedgewars.lnk
-
-echo ALL DONE, Hedgewars has been successfully compiled and installed
-
-:exitpoint
-cd %CURRDIR%
-pause
--- a/tools/darkMagic.hs	Wed Jul 18 17:02:40 2018 +0200
+++ b/tools/darkMagic.hs	Thu Jul 19 14:01:57 2018 +0200
@@ -1,3 +1,5 @@
+{-# LANGUAGE FlexibleContexts #-}
+
 module Main where
 
 import System.Directory
@@ -156,4 +158,4 @@
 
     mapM_ processScript scripts
 
-    --putStrLn $ unlines l18ns
\ No newline at end of file
+    --putStrLn $ unlines l18ns
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/old/build_windows.bat	Thu Jul 19 14:01:57 2018 +0200
@@ -0,0 +1,80 @@
+:: WARNNG WARNING WARNING ::
+:: This Batch script is BROKEN and EXTREMELY OUTDATED!
+:: It does not work with latest version and needs a complete redo or removal.
+:: Its functionality has been disabled.
+
+:: Print dummy text and return.
+echo Sorry, this script is outdated. You're on your own.
+exit
+
+
+::::::::::::::::::::::::::::::
+:: Old script code follows ...
+::::::::::::::::::::::::::::::
+@echo off
+::edit these variables if you need
+set PASCAL=C:\FPC\2.6.0\bin\i386-win32\
+:: FIXME: Go Qt 5
+set QTDIR=C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin
+set PATH=%PATH%;%PASCAL%
+set BUILD_TYPE="Debug"
+
+:setup
+set CURRDIR="%CD%"
+cd ..
+
+echo Fetching all DLLs...
+if %BUILD_TYPE%=="Debug" (
+    for %%G in (QtCored4 QtGuid4 QtNetworkd4) do xcopy /d/y %QTDIR%\%%G.dll %CD%\bin\
+)
+:: should you libgcc dynamically you should try adding libgcc_s_dw2-1 and mingwm10
+:: FIXME: Use Qt5
+for %%G in (QtCore4 QtGui4 QtNetwork4) do (
+    xcopy /d/y %QTDIR%\%%G.dll %CD%\bin\
+)
+
+:: FIXME: Use SDL 2.0
+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
+
+::for video recording
+:: FIXME: googlecode.com is defunct.
+if not exist %CD%\misc\winutils\bin\avformat-54.dll cscript %CD%\tools\w32DownloadUnzip.vbs http://hedgewars.googlecode.com/files/libav-win32-20121022-dll.zip %CD%\misc\winutils\bin
+
+::this is needed because fpc png unit hardcodes libpng-1.2.12
+if not exist %CD%\misc\winutils\bin\libpng13.dll copy /y %CD%\misc\winutils\bin\libpng15-15.dll %CD%\misc\winutils\bin\libpng13.dll
+
+xcopy /d/y %CD%\misc\winutils\bin\*.dll %CD%\bin\
+
+::setting up the environment...
+call %QTDIR%\qtenv2.bat
+
+echo Running cmake...
+set ERRORLEVEL=
+cmake . -G "MinGW Makefiles" -DPNG_LIBRARY="%CD%\misc\winutils\bin\libpng13.dll" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_PREFIX_PATH="%CD%\misc\winutils\\"
+:: prefix should be last
+
+if %ERRORLEVEL% NEQ 0 goto exitpoint
+
+echo Running make...
+set ERRORLEVEL=
+mingw32-make VERBOSE=1
+if %ERRORLEVEL% NEQ 0 goto exitpoint
+
+echo Installing...
+set ERRORLEVEL=
+mingw32-make install > nul
+if %ERRORLEVEL% NEQ 0 goto exitpoint
+
+echo Creating commodity shortcut...
+copy /y %CD%\misc\winutils\Hedgewars.lnk C:%HOMEPATH%\Desktop\Hedgewars.lnk
+
+echo ALL DONE, Hedgewars has been successfully compiled and installed
+
+:exitpoint
+cd %CURRDIR%
+pause
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/old/w32DownloadUnzip.vbs	Thu Jul 19 14:01:57 2018 +0200
@@ -0,0 +1,66 @@
+' 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
+'   http://stackoverflow.com/questions/424331/get-the-current-temporary-directory-path-in-vbscript
+
+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
+
+' Temporary directory
+strHDLocation = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) + "\hwlibtemp.zip"
+
+' Fetch the file
+WScript.Echo ( "Trying to download from " & strFileURL)
+Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
+objXMLHTTP.open "GET", strFileURL, false
+objXMLHTTP.send()
+
+If objXMLHTTP.Status = 200 Then
+    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
+    Set objXMLHTTP = Nothing
+Else
+    WScript.Echo ("Error downloading file (error code: " & objXMLHTTP.Status & ")")
+    Set objXMLHTTP = Nothing
+    WScript.Quit
+End if
+
+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 ( "Success!" )
+Set objShell = Nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/update_frontend_locale_files.sh	Thu Jul 19 14:01:57 2018 +0200
@@ -0,0 +1,8 @@
+#!/bin/sh -
+# Script to update all frontend locale files.
+
+# HOW TO USE:
+# - Run this script in the tools/ directory.
+# Result: All .ts files in share/hedgewars/Data/Locale will be updated.
+
+lupdate ../QTfrontend -ts ../share/hedgewars/Data/Locale/hedgewars_*.ts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/update_locale_files.sh	Thu Jul 19 14:01:57 2018 +0200
@@ -0,0 +1,10 @@
+#!/bin/sh -
+# Script to update all Lua and frontend locale files.
+
+# HOW TO USE:
+# - Run this script in the tools/ directory.
+# Result: All .ts and .lua files in share/hedgewars/Data/Locale will be updated.
+# This will take a while!
+
+./update_frontend_locale_files.sh
+./update_lua_locale_files.sh
--- a/tools/update_lua_locale_files.sh	Wed Jul 18 17:02:40 2018 +0200
+++ b/tools/update_lua_locale_files.sh	Thu Jul 19 14:01:57 2018 +0200
@@ -5,13 +5,16 @@
 
 # HOW TO USE:
 # - Run this script in the tools/ directory.
-# - All .lua files in share/hedgewars/Data/Locale will be updated.
-# - Change LOCALEFILES below to limit the number of locale files to update
+# - (Optional) Change LOCALEFILES below to limit the number of locale files to update
+# Result: All .lua files in share/hedgewars/Data/Locale will be updated.
 
+# SETTINGS:
 # Space-separated list of locale files to update, or *.lua for all.
 # (Note: always include stub.lua)
 LOCALEFILES="*.lua"
 
+# END OF SETTINGS
+
 # List of all Lua files to scan:
 # * Missions
 # * Campaign missions
--- a/tools/w32DownloadUnzip.vbs	Wed Jul 18 17:02:40 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-' 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
-'   http://stackoverflow.com/questions/424331/get-the-current-temporary-directory-path-in-vbscript
-
-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
-
-' Temporary directory
-strHDLocation = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) + "\hwlibtemp.zip"
-
-' Fetch the file
-WScript.Echo ( "Trying to download from " & strFileURL)
-Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
-objXMLHTTP.open "GET", strFileURL, false
-objXMLHTTP.send()
-
-If objXMLHTTP.Status = 200 Then
-    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
-    Set objXMLHTTP = Nothing
-Else
-    WScript.Echo ("Error downloading file (error code: " & objXMLHTTP.Status & ")")
-    Set objXMLHTTP = Nothing
-    WScript.Quit
-End if
-
-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 ( "Success!" )
-Set objShell = Nothing