Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwenx190 committed Mar 25, 2018
1 parent 68638a4 commit 6d4f957
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ 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]
2. CALL "Script file path" [Option1] [Option2] [Option3] [Option4] [Option5] [Option6] [Option7]
- Script file path: The relative/absolute path of the batch file
- Option1: Target architecture, x86 or x64, default is x64
- Option2: Target file type, dll or lib, default is dll
- Option3: Compile mode, debug, release or debug-and-release, default is release
- Option4: Qt source code dir, default is ".\src"
- Option5: Qt install dir, default is ".\qt"
- Option6: Extra parameters you want to pass to the config program, default is empty
- 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
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 @@ -32,7 +33,7 @@ Notes:
*Example*
```bat
CALL "C:\Qt\build-qt.bat" x86 lib debug-and-release "C:\Qt\src" "C:\Qt\msvc2017_Static_64" -force-debug-info
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
```

**Tested on**
Expand Down
44 changes: 24 additions & 20 deletions build-qt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,30 @@ COLOR
TITLE Configuring Qt
CLS
SETLOCAL EnableDelayedExpansion
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"
REM x86 or x64, default is x64
SET "_TARGET_ARCH=%1"
SET "_TARGET_ARCH=%2"
REM dll or lib, default is dll
SET "_BUILD_TYPE=%2"
SET "_BUILD_TYPE=%3"
REM debug, release or debug-and-release, default is release
SET "_COMP_MODE=%3"
SET "_COMP_MODE=%4"
REM Qt source code directory, default is ".\src"
SET "_ROOT=%4"
SET "_ROOT=%5"
REM Qt install directory, default is ".\qt"
SET "_INSTALL_DIR=%5"
SET "_INSTALL_DIR=%6"
REM Extra configure parameters, default is empty
SET "_EXTRA_PARAMS=%6"
SET "_EXTRA_PARAMS=%7"
IF /I "%_ROOT%" == "" SET "_ROOT=%~dp0src"
IF NOT EXIST "%_ROOT%" ECHO Qt source code directory not found. Cannot continue compiling. && GOTO Fin
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 EXIST "%_INSTALL_DIR%" RD /S /Q "%_INSTALL_DIR%"
MD "%_INSTALL_DIR%"
IF /I "%_COMP_MODE%" == "debug" (
SET "_COMP_MODE=-%_COMP_MODE%"
) ELSE (
SET "_COMP_MODE=-%_COMP_MODE% -strip"
)
SET "_COMP_MODE=-%_COMP_MODE%"
IF /I "%_BUILD_TYPE%" == "lib" (
REM According to Qt official wiki, QWebEngine module cannot be compiled statically, so we have to skip it
SET "_BUILD_TYPE=-static -static-runtime -skip qtwebengine"
Expand All @@ -36,13 +35,17 @@ IF /I "%_BUILD_TYPE%" == "lib" (
REM And don't forget to change it back after compiling Qt
SET "_BUILD_TYPE=-shared"
)
SET "_VC_CMD=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
IF NOT EXIST "%_VC_CMD%" SET "_VC_CMD=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat"
IF NOT EXIST "%_VC_CMD%" SET "_VC_CMD=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"
IF NOT EXIST "%_VC_CMD%" SET "_VC_CMD=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
IF NOT EXIST "%_VC_CMD%" SET "_VC_CMD=C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat"
IF NOT EXIST "%_VC_CMD%" ECHO Cannot find [vcvarsall.bat], if you didn't install vs in it's default location, please change this script. && GOTO Fin
SET _CFG_PARAMS=-opensource -confirm-license %_COMP_MODE% %_BUILD_TYPE% -platform win32-msvc -ltcg -plugin-manifests -mp -silent -nomake examples -nomake tests -opengl dynamic -prefix "%_INSTALL_DIR%" %_EXTRA_PARAMS%
SET "_VC_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
IF /I "%_QT_COMPILER%" == "win32-msvc" (
IF NOT EXIST "%_VC_CMD%" SET "_VC_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat"
IF NOT EXIST "%_VC_CMD%" SET "_VC_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"
IF NOT EXIST "%_VC_CMD%" SET "_VC_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
IF NOT EXIST "%_VC_CMD%" SET "_VC_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat"
IF NOT EXIST "%_VC_CMD%" ECHO Cannot find [vcvarsall.bat], if you didn't install vs in it's default location, please change this script. && GOTO Fin
) ELSE (
SET "_EXTRA_PARAMS=-c++std c++1z %_EXTRA_PARAMS%"
)
SET _CFG_PARAMS=-opensource -confirm-license %_COMP_MODE% %_BUILD_TYPE% -platform %_QT_COMPILER% -ltcg -plugin-manifests -silent -nomake examples -nomake tests -opengl dynamic -prefix "%_INSTALL_DIR%" %_EXTRA_PARAMS%
SET "_CFG_BAT=%_ROOT%\configure.bat"
REM If you don't have jom, use nmake instead, which is provided by Visual Studio.
REM nmake is very slow, I recommend you use jom, you can download the latest jom
Expand All @@ -58,10 +61,11 @@ CLS
ECHO The configuring process have finished successfully
ECHO Your configuration is:
ECHO ---------------------------------------
ECHO Compiler: %_QT_COMPILER%
ECHO Target architecture: %_TARGET_ARCH%
ECHO Source code directory: %_ROOT%
ECHO Install directory: %_INSTALL_DIR%
ECHO vcvarsall.bat: %_VC_CMD%
IF /I "%_QT_COMPILER%" == "win32-msvc" ECHO vcvarsall.bat: %_VC_CMD%
ECHO Build tool: %_JOM%
ECHO Qt configure parameters: %_CFG_PARAMS%
ECHO ---------------------------------------
Expand All @@ -76,7 +80,7 @@ ECHO COLOR>>"%_BUILD_BAT%"
ECHO TITLE Building Qt from source code>>"%_BUILD_BAT%"
ECHO CLS>>"%_BUILD_BAT%"
ECHO SETLOCAL>>"%_BUILD_BAT%"
ECHO CALL "%_VC_CMD%" %_TARGET_ARCH%>>"%_BUILD_BAT%"
IF /I "%_QT_COMPILER%" == "win32-msvc" ECHO CALL "%_VC_CMD%" %_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%"
Expand Down

0 comments on commit 6d4f957

Please sign in to comment.