Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwenx190 committed Mar 26, 2018
1 parent c60ae0c commit 598033d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 60 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ A Windows batch script to help you compile Qt from source code. You must know th

**Usage**
1. Open cmd or power shell.
2. CALL "Script file path" [Option1] [Option2] [Option3] [Option4] [Option5] [Option6] [Option7]
2. CALL "Script file path" [Option1] [Option2] [Option3] [Option4] [Option5] [Option6] [Option7] [Option8]
- Script file path: The relative/absolute path of the batch file
- Option1: Compiler, win32-clang-g++, win32-clang-msvc, win32-g++, win32-icc, win32-icc-k1om or win32-msvc, default is win32-msvc
- Option2: Target architecture, x86 or x64, default is x64
- Option3: Target file type, dll or lib, default is dll
- Option4: Compile mode, debug, release or debug-and-release, default is release
- Option5: Qt source code dir, default is ".\src"
- Option6: Qt install dir, default is ".\qt"
- Option7: Extra parameters you want to pass to the config program, default is empty
- Option1: Qt version, default is 5.11.0
- Option2: Compiler, win32-clang-g++, win32-clang-msvc, win32-g++, win32-icc, win32-icc-k1om or win32-msvc, default is win32-msvc
- Option3: Target architecture, x86 or x64, default is x64
- Option4: Target file type, dll or lib, default is dll
- Option5: Compile mode, debug, release or debug-and-release, default is release
- Option6: Qt source code dir, default is ".\src"
- Option7: Qt install dir, default is ".\qt"
- Option8: Extra parameters you want to pass to the config program, default is empty
3. If all the prerequisites are installed correctly, the compiling process will start automatically and there is no more to do manually, the compiler will do all the rest things. The whole compiling process may take many hours, perhaps you should leave your computer and do some interesting things.
4. If you want to link Qt against [ICU](http://site.icu-project.org/) and [OpenSSL](https://www.openssl.org/) libraries, you will have to change the script file. Please add the following config parameters:
- ICU:
Expand All @@ -33,7 +34,7 @@ Notes:
*Example*
```bat
CALL "C:\Qt\build-qt.bat" win32-clang-g++ x86 lib debug-and-release "C:\Qt\src" "C:\Qt\msvc2017_Static_64" -force-debug-info
CALL "C:\Qt\build-qt.bat" 5.10.2 win32-clang-g++ x86 lib debug-and-release "C:\Qt\src" "C:\Qt\msvc2017_Static_64" -force-debug-info
```

**Tested on**
Expand Down
105 changes: 62 additions & 43 deletions build-qt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@ COLOR
TITLE Configuring Qt
CLS
SETLOCAL
REM Qt version, default is 5.11.0
SET "_QT_VERSION=%1"
REM win32-clang-g++, win32-clang-msvc, win32-g++, win32-icc, win32-icc-k1om or win32-msvc, default is win32-msvc
SET "_QT_COMPILER=%1"
SET "_QT_COMPILER=%2"
REM x86 or x64, default is x64
SET "_TARGET_ARCH=%2"
SET "_TARGET_ARCH=%3"
REM dll or lib, default is dll
SET "_BUILD_TYPE=%3"
SET "_BUILD_TYPE=%4"
REM debug, release or debug-and-release, default is release
SET "_COMP_MODE=%4"
SET "_COMP_MODE=%5"
REM Qt source code directory, default is ".\src"
SET "_ROOT=%5"
SET "_ROOT=%6"
REM Qt install directory, default is ".\qt"
SET "_INSTALL_DIR=%6"
SET "_INSTALL_DIR=%7"
REM Extra configure parameters, default is empty
SET "_EXTRA_PARAMS=%7"
SET "_EXTRA_PARAMS=%8"
IF /I "%_QT_VERSION%" == "" SET "_QT_VERSION=5.11.0"
IF /I "%_ROOT%" == "" SET "_ROOT=%~dp0src"
IF /I "%_QT_COMPILER%" == "" SET "_QT_COMPILER=win32-msvc"
IF /I "%_TARGET_ARCH%" == "" SET "_TARGET_ARCH=x64"
IF /I "%_COMP_MODE%" == "" SET "_COMP_MODE=release"
IF /I "%_BUILD_TYPE%" == "" SET "_BUILD_TYPE=dll"
IF /I "%_INSTALL_DIR%" == "" SET "_INSTALL_DIR=%~dp0qt-%_BUILD_TYPE%-%_COMP_MODE%-%_TARGET_ARCH%"
IF /I "%_INSTALL_DIR%" == "" SET "_INSTALL_DIR=%~dp0Qt_%_QT_VERSION%_%_QT_COMPILER%_%_TARGET_ARCH%_%_BUILD_TYPE%_%_COMP_MODE%"
IF EXIST "%_INSTALL_DIR%" RD /S /Q "%_INSTALL_DIR%"
SET "_COMP_MODE=-%_COMP_MODE%"
IF /I "%_BUILD_TYPE%" == "lib" (
Expand Down Expand Up @@ -82,41 +85,57 @@ ECHO Your build script will be saved to: %~dp0build.bat
PAUSE
SET "_BUILD_BAT=%~dp0build.bat"
IF EXIST "%_BUILD_BAT%" DEL /F /Q "%_BUILD_BAT%"
ECHO @ECHO OFF>"%_BUILD_BAT%"
ECHO COLOR>>"%_BUILD_BAT%"
ECHO TITLE Building Qt from source code>>"%_BUILD_BAT%"
ECHO CLS>>"%_BUILD_BAT%"
ECHO SETLOCAL>>"%_BUILD_BAT%"
IF /I "%_QT_COMPILER%" == "win32-msvc" ECHO CALL "%_VC_BAT_PATH%" %_TARGET_ARCH%>>"%_BUILD_BAT%"
IF /I "%_QT_COMPILER%" == "win32-icc" ECHO CALL "%_VC_BAT_PATH%" %_TARGET_ARCH%>>"%_BUILD_BAT%"
IF /I "%_QT_COMPILER%" == "win32-icc-k1om" ECHO CALL "%_VC_BAT_PATH%" %_TARGET_ARCH%>>"%_BUILD_BAT%"
IF /I "%_QT_COMPILER%" == "win32-clang-msvc" ECHO CALL "%_VC_BAT_PATH%" %_TARGET_ARCH%>>"%_BUILD_BAT%"
ECHO SET "_ROOT=%_ROOT%">>"%_BUILD_BAT%"
ECHO SET "PATH=%%_ROOT%%\qtbase\bin;%%_ROOT%%\gnuwin32\bin;%%PATH%%">>"%_BUILD_BAT%"
ECHO SET _ROOT=>>"%_BUILD_BAT%"
ECHO CD /D "%_ROOT%">>"%_BUILD_BAT%"
ECHO CALL "%_CFG_BAT%" %_CFG_PARAMS%>>"%_BUILD_BAT%"
ECHO IF %%ERRORLEVEL%% NEQ 0 GOTO ErrHappen>>"%_BUILD_BAT%"
ECHO %_JOM%>>"%_BUILD_BAT%"
ECHO IF %%ERRORLEVEL%% NEQ 0 GOTO ErrHappen>>"%_BUILD_BAT%"
ECHO %_JOM% install>>"%_BUILD_BAT%"
ECHO IF %%ERRORLEVEL%% NEQ 0 GOTO ErrHappen>>"%_BUILD_BAT%"
ECHO TITLE Compiling process finished>>"%_BUILD_BAT%"
ECHO ECHO Compiling process have finished successfully>>"%_BUILD_BAT%"
ECHO ECHO All binaries have been installed to: %_INSTALL_DIR%>>"%_BUILD_BAT%"
ECHO ECHO Press any key to exit this program>>"%_BUILD_BAT%"
ECHO GOTO Fin>>"%_BUILD_BAT%"
ECHO :ErrHappen>>"%_BUILD_BAT%"
ECHO TITLE Compiling process aborted>>"%_BUILD_BAT%"
ECHO ECHO Something wrong happened during the compiling process>>"%_BUILD_BAT%"
ECHO ECHO and the process have aborted because of this>>"%_BUILD_BAT%"
ECHO ECHO Please check the log file for more information>>"%_BUILD_BAT%"
ECHO ECHO Press any key to exit this program>>"%_BUILD_BAT%"
ECHO GOTO Fin>>"%_BUILD_BAT%"
ECHO :Fin>>"%_BUILD_BAT%"
ECHO ENDLOCAL>>"%_BUILD_BAT%"
ECHO PAUSE>>"%_BUILD_BAT%"
ECHO EXIT /B>>"%_BUILD_BAT%"

> "%_BUILD_BAT%" (
@ECHO @ECHO OFF
@ECHO COLOR
@ECHO TITLE Building Qt from source code
@ECHO CLS
@ECHO SETLOCAL
IF /I "%_QT_COMPILER%" == "win32-msvc" @ECHO CALL "%_VC_BAT_PATH%" %_TARGET_ARCH%
IF /I "%_QT_COMPILER%" == "win32-icc" @ECHO CALL "%_VC_BAT_PATH%" %_TARGET_ARCH%
IF /I "%_QT_COMPILER%" == "win32-icc-k1om" @ECHO CALL "%_VC_BAT_PATH%" %_TARGET_ARCH%
IF /I "%_QT_COMPILER%" == "win32-clang-msvc" @ECHO CALL "%_VC_BAT_PATH%" %_TARGET_ARCH%
@ECHO SET "_ROOT=%_ROOT%"
@ECHO SET "PATH=%%_ROOT%%\qtbase\bin;%%_ROOT%%\gnuwin32\bin;%%PATH%%"
@ECHO SET _ROOT=
@ECHO CD /D "%_ROOT%"
@ECHO CALL "%_CFG_BAT%" %_CFG_PARAMS%
@ECHO IF %%ERRORLEVEL%% NEQ 0 GOTO ErrHappen
@ECHO %_JOM%
@ECHO IF %%ERRORLEVEL%% NEQ 0 GOTO ErrHappen
@ECHO %_JOM% install
@ECHO IF %%ERRORLEVEL%% NEQ 0 GOTO ErrHappen
@ECHO ^> "%_INSTALL_DIR%\bin\qt.conf" ^(
@ECHO @ECHO [Paths]
@ECHO @ECHO Documentation=../../Docs/Qt-%_QT_VERSION%
@ECHO @ECHO Examples=../../Examples/Qt-%_QT_VERSION%
@ECHO @ECHO Prefix=..
@ECHO ^)
@ECHO ^> "%_INSTALL_DIR%\bin\qtenv2.bat" ^(
@ECHO @ECHO @echo off
@ECHO @ECHO echo Setting up environment for Qt usage...
@ECHO @ECHO set PATH=^%%%%~dp0;^%%%%PATH^%%%%
@ECHO @ECHO cd /D ^%%%%~dp0..
@ECHO @ECHO echo Remember to call vcvarsall.bat to complete environment setup!
@ECHO ^)
@ECHO TITLE Compiling process finished
@ECHO ECHO Compiling process have finished successfully
@ECHO ECHO All binaries have been installed to: %_INSTALL_DIR%
@ECHO ECHO Press any key to exit this program
@ECHO GOTO Fin
@ECHO :ErrHappen
@ECHO TITLE Compiling process aborted
@ECHO ECHO Something wrong happened during the compiling process
@ECHO ECHO and the process have aborted because of this
@ECHO ECHO Please check the log file for more information
@ECHO ECHO Press any key to exit this program
@ECHO GOTO Fin
@ECHO :Fin
@ECHO ENDLOCAL
@ECHO PAUSE
@ECHO EXIT /B
)
CLS
ECHO Build script have been saved to: %_BUILD_BAT%
ECHO Press any key to run it, or you can close this window and run it manually
Expand Down
18 changes: 10 additions & 8 deletions win-deploy-qt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ IF EXIST "%_EXE_DIR_PATH%\translations" (
)
IF %ERRORLEVEL% NEQ 0 ECHO Something wrong happened, deploying process aborted && GOTO Fin
SET "_CONF_FILE_PATH=%_EXE_DIR_PATH%\qt.conf"
ECHO [Paths]>"%_CONF_FILE_PATH%"
ECHO Prefix=.>>"%_CONF_FILE_PATH%"
ECHO Binaries=.>>"%_CONF_FILE_PATH%"
ECHO Libraries=.>>"%_CONF_FILE_PATH%"
ECHO Plugins=plugins>>"%_CONF_FILE_PATH%"
ECHO Imports=imports>>"%_CONF_FILE_PATH%"
ECHO Qml2Imports=qml>>"%_CONF_FILE_PATH%"
ECHO Translations=languages>>"%_CONF_FILE_PATH%"
> "%_CONF_FILE_PATH%" (
@ECHO [Paths]
@ECHO Prefix=.
@ECHO Binaries=.
@ECHO Libraries=.
@ECHO Plugins=plugins
@ECHO Imports=imports
@ECHO Qml2Imports=qml
@ECHO Translations=languages
)
TITLE Finished
CLS
ECHO Deploying process have completed successfully
Expand Down

0 comments on commit 598033d

Please sign in to comment.