MarceloHMariano

QBuilder.bat

Aug 26th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 5.25 KB | None | 0 0
  1. @echo off
  2.  
  3. REM ****************************************
  4. REM * File: QBuilder script                *
  5. REM * Author: Marcelo Mariano              *
  6. REM * E-mail: marcelo.hs.mariano@gmail.com *
  7. REM ****************************************
  8.  
  9. setlocal enableDelayedExpansion
  10.  
  11. set TARGET="%~1"
  12. set TARGETS=prepare build buildAll cleanPrepare cleanBuild cleanAll
  13.  
  14. for %%a in (%TARGETS%) do (
  15.     if "%~1"=="%%a" goto :%~1
  16. )
  17.  
  18. goto :usage
  19.  
  20. :preConfigure
  21.     call :configureLicense
  22.     call :configurePlatform
  23.     call :configureProfile
  24.     call :configureDirectories
  25.     call :configureDependenciesDirectories
  26.     call :configureOpenGL
  27.     call :configureSSL
  28.     call :configureCompilerDirectories
  29.     call :exportPath
  30.     call :storeOptions
  31. goto :eof
  32.  
  33. :configure
  34.     set commandLine=-platform %PLATFORM%
  35.     set commandLine=%commandLine% -prefix %PREFIX%
  36.     set commandLine=%commandLine% -%LICENSE% -confirm-license
  37.     set commandLine=%commandLine% -%PROFILE% -%DEBUG_INFO%
  38.     set commandLine=%commandLine% -nomake tests -nomake examples -no-compile-examples
  39.     set commandLine=%commandLine% -opengl %OPENGL_SUPPORT%
  40.     set commandLine=%commandLine% -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-doubleconversion
  41.     set commandLine=%commandLine% -%OPENSSL_LINK%
  42.     REM Uncomment the line bellow to use SQL drivers for your databases
  43.     REM SET sqldrivers=-qt-sql-mysql -qt-sql-psql -qt-sql-odbc -qt-sql-tds -qt-sql-db2 -qt-sql-sqlite -qt-sql-sqlite2 -qt-sql-ibase
  44.     set commandLine=%commandLine% %INCLUDE% %LIBRARY% %LIBS%
  45.    
  46.     echo call configure %commandLine%
  47. goto :eof
  48.  
  49. :configureLicense
  50.     call :switch license chooseLicense "Opensource, Commercial"
  51.     goto :eof
  52.    
  53.     :chooseLicense1
  54.         set LICENSE=opensource
  55.     goto :eof
  56.    
  57.     :chooseLicense2
  58.         set LICENSE=commercial
  59.     goto :eof
  60. goto :eof
  61.  
  62. :configurePlatform
  63.     call :switch platform choosePlatform "MinGW MSVC"
  64.     goto :eof
  65.    
  66.     :choosePlatform1:
  67.         set PLATFORM=win32-g++
  68.         set MAKE=mingw32-make
  69.     goto :eof
  70.  
  71.     :choosePlatform2:
  72.         set PLATFORM=win32-msvc2013
  73.         set MAKE=nmake
  74.     goto :eof  
  75. goto :eof
  76.  
  77. :configureProfile
  78.     set PROFILE=static
  79.     set DEBUG_INFO=release
  80. goto :eof
  81.  
  82. :configureDirectories
  83.     call :input "Qt sources directory:" QT_SRC_ROOT
  84.     call :input "Platform toolkit directory:" MAKE_DIR
  85.  
  86.     set QT_BASE_BIN=%QT_SRC_ROOT%\qtbase\bin
  87.     set QT_GNU_WIN32_BIN=%QT_SRC_ROOT%\gnuwin32\bin
  88.    
  89.     call :input "Installation directory:" PREFIX
  90. goto :eof
  91.  
  92. :configureDependenciesDirectories
  93.     call :input "DirectX SDK directory:" DIRECTX_SDK_DIR
  94.     call :input "ICU directory:" ICU
  95.     call :input "OpenSSL directory:" OPENSSL
  96. goto :eof
  97.  
  98. :configureOpenGL
  99.     call :switch OpenGL chooseOpenGL "Dynamic, Desktop, ES2"
  100.     goto :eof
  101.    
  102.     :chooseOpenGL1
  103.         set OPENGL_SUPPORT=dynamic
  104.     goto :eof
  105.    
  106.     :chooseOpenGL2
  107.         set OPENGL_SUPPORT=desktop
  108.     goto :eof
  109.    
  110.     :chooseOpenGL3
  111.         set OPENGL_SUPPORT=es2
  112.     goto :eof
  113. goto :eof
  114.  
  115. :configureSSL
  116.     call :switch OpenSSL chooseOpenSSL "Linked Dynamic"
  117.     goto :eof
  118.    
  119.     :chooseOpenSSL1
  120.         set OPENSSL_LINK=openssl-linked
  121.     goto :eof
  122.    
  123.     :chooseOpenSSL2
  124.         set OPENSSL_LINK=openssl
  125.     goto :eof
  126. goto :eof
  127.  
  128. :configureCompilerDirectories
  129.     set INCLUDE=-I "%ICU%\include" -I "%OPENSSL%\include"
  130.     set LIBRARY=-L "%ICU%\lib" -L "%OPENSSL%\lib"
  131.     set LIBS=-l ssl -l crypto
  132. goto :eof
  133.  
  134. :exportPath
  135.     set PATH=%MAKE_DIR%;%DIRECTX_SDK_DIR%;%QT_BASE_BIN%;%QT_GNU_WIN32_BIN%;%PATH%
  136. goto :eof
  137.  
  138. :readVar
  139.     if exist "%~1" (
  140.         for /f %%a in ('type "%~1"') do set "%~2=%%a"
  141.     )
  142. goto :eof
  143.  
  144. :loadOptions
  145.     call :readVar "%temp%\env.txt" PATH
  146.     call :readVar "%temp%\make.txt" MAKE
  147.     call :readVar "%temp%\source.txt" QT_SRC_ROOT
  148. goto :eof
  149.  
  150. :storeOptions
  151.     echo %QT_SRC_ROOT% > "%temp%\source.txt"
  152.     echo %PATH% > "%temp%\env.txt"
  153.     echo %MAKE% > "%temp%\make.txt"
  154. goto :eof
  155.  
  156. :usage
  157.     echo.
  158.     echo Usage: runConfigure [command]
  159.     echo.
  160.     echo Commands:
  161.     echo.
  162.     echo   prepare      - runs the "configure" script to generate the makefile to build Qt.
  163.     echo   build        - compile the source codes.
  164.     echo   buildAll     - calls "prepare" and "build" in one step.
  165.     echo   cleanPrepare - clean all the configuration generated by the "prepare" step.
  166.     echo   cleanBuild   - clean all files generated by the "build" step.
  167.     echo   cleanAll     - calls "clean" and "cleanBuild" in one step.
  168.    
  169.     exit /b 1
  170. goto :eof
  171.  
  172. REM call :switch <list title> <handler label prefix> option1 [option2 [option3 [...] ]
  173. :switch
  174.     set choices=
  175.     set /a i=0
  176.  
  177.     echo Choose one option for "%~1"
  178.     echo.
  179.  
  180.     for %%a in (%~3) do (
  181.         set /a i+=1
  182.         set choices=!choices!!i!
  183.         if /i !i! equ 1 (
  184.             echo   !i!. %%a ^(default^)
  185.         ) else (
  186.             echo   !i!. %%a
  187.         )
  188.     )
  189.  
  190.     echo.
  191.     echo Enter your choice:
  192.     choice /c %choices% /n /d 1 /t 10 /m "- "
  193.     call :%~2%ERRORLEVEL%
  194. goto :eof
  195.  
  196. :input
  197. REM call :input <prompt> <result var>
  198.     echo %~1
  199.     set /p %~2="- "
  200. goto :eof
  201.  
  202. :insideSourceDirectory
  203.     pushd %QT_SRC_ROOT%
  204.     call %*
  205.     popd
  206. goto :eof
  207.  
  208. :make
  209.     call :loadOptions
  210.     %MAKE% %~1
  211. goto :eof
  212.  
  213. :prepare
  214.     call :preConfigure
  215.     call :insideSourceDirectory :configure
  216. goto :eof
  217.  
  218. :build
  219.     call :insideSourceDirectory :make install
  220. goto :eof
  221.  
  222. :buildAll
  223.     call :prepare
  224.     call :build
  225. goto :eof
  226.  
  227. :cleanPrepare
  228.     call :insideSourceDirectory :make distclean
  229. goto :eof
  230.  
  231. :cleanBuild
  232.     call :insideSourceDirectory :make clean
  233. goto :eof
  234.  
  235. :cleanAll
  236.     call :cleanPrepare
  237.     call :cleanBuild
  238. goto :eof
Add Comment
Please, Sign In to add comment