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 6d4f957 commit 4d4fa5a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 43 deletions.
24 changes: 9 additions & 15 deletions build-qt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
COLOR
TITLE Configuring Qt
CLS
SETLOCAL EnableDelayedExpansion
SETLOCAL
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
Expand All @@ -18,14 +18,12 @@ SET "_INSTALL_DIR=%6"
REM Extra configure parameters, default is empty
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%"
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
Expand All @@ -35,16 +33,12 @@ IF /I "%_BUILD_TYPE%" == "lib" (
REM And don't forget to change it back after compiling Qt
SET "_BUILD_TYPE=-shared"
)
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 "_VC_BAT_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
IF NOT EXIST "%_VC_BAT_PATH%" SET "_VC_BAT_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat"
IF NOT EXIST "%_VC_BAT_PATH%" SET "_VC_BAT_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"
IF NOT EXIST "%_VC_BAT_PATH%" SET "_VC_BAT_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
IF NOT EXIST "%_VC_BAT_PATH%" SET "_VC_BAT_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat"
IF /I "%_QT_COMPILER%" NEQ "win32-msvc" 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.
Expand All @@ -65,7 +59,7 @@ ECHO Compiler: %_QT_COMPILER%
ECHO Target architecture: %_TARGET_ARCH%
ECHO Source code directory: %_ROOT%
ECHO Install directory: %_INSTALL_DIR%
IF /I "%_QT_COMPILER%" == "win32-msvc" ECHO vcvarsall.bat: %_VC_CMD%
IF /I "%_QT_COMPILER%" == "win32-msvc" ECHO vcvarsall.bat: %_VC_BAT_PATH%
ECHO Build tool: %_JOM%
ECHO Qt configure parameters: %_CFG_PARAMS%
ECHO ---------------------------------------
Expand All @@ -80,7 +74,7 @@ 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_CMD%" %_TARGET_ARCH%>>"%_BUILD_BAT%"
IF /I "%_QT_COMPILER%" == "win32-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%"
Expand Down
56 changes: 28 additions & 28 deletions win-deploy-qt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@
COLOR
TITLE Deploying application
CLS
SETLOCAL EnableDelayedExpansion
SET "_QT_DIR=%1"
IF /I "%_QT_DIR%" == "" ECHO Qt install dir not found && GOTO Fin
SET "_EXE_FILE=%2"
IF /I "%_EXE_FILE%" == "" ECHO Application exe not found && GOTO Fin
SET "_APP_DIR=%3"
IF /I "%_APP_DIR%" == "" ECHO Application dir not found && GOTO Fin
SETLOCAL
SET "_QT_DIR_PATH=%1"
IF /I "%_QT_DIR_PATH%" == "" ECHO Qt install dir not found && GOTO Fin
SET "_EXE_FILE_PATH=%2"
IF /I "%_EXE_FILE_PATH%" == "" ECHO Application exe not found && GOTO Fin
SET "_EXE_DIR_PATH=%3"
IF /I "%_EXE_DIR_PATH%" == "" ECHO Application dir not found && GOTO Fin
IF /I "%4" == "" (
SET _DEP_PARAMS=--plugindir "%_APP_DIR%\plugins" --force --compiler-runtime "%_EXE_FILE%"
SET _DEP_PARAMS=--plugindir "%_EXE_DIR_PATH%\plugins" --force --compiler-runtime "%_EXE_FILE_PATH%"
) ELSE (
SET _DEP_PARAMS=--dir "%_APP_DIR%\qml" --libdir "%_APP_DIR%" --plugindir "%_APP_DIR%\plugins" --force --qmldir "%_QT_DIR%\qml" --compiler-runtime "%_EXE_FILE%"
SET _DEP_PARAMS=--dir "%_EXE_DIR_PATH%\qml" --libdir "%_EXE_DIR_PATH%" --plugindir "%_EXE_DIR_PATH%\plugins" --force --qmldir "%_QT_DIR_PATH%\qml" --compiler-runtime "%_EXE_FILE_PATH%"
)
SET "PATH=%_QT_DIR%\bin;%PATH%"
IF EXIST "%_APP_DIR%\plugins" RD /S /Q "%_APP_DIR%\plugins"
IF EXIST "%_APP_DIR%\qml" RD /S /Q "%_APP_DIR%\qml"
IF EXIST "%_APP_DIR%\translations" RD /S /Q "%_APP_DIR%\translations"
IF EXIST "%_APP_DIR%\languages" RD /S /Q "%_APP_DIR%\languages"
IF EXIST "%_APP_DIR%\Qt*.dll" DEL /F /Q "%_APP_DIR%\Qt*.dll"
IF EXIST "%_APP_DIR%\qt.conf" DEL /F /Q "%_APP_DIR%\qt.conf"
SET "PATH=%_QT_DIR_PATH%\bin;%PATH%"
IF EXIST "%_EXE_DIR_PATH%\plugins" RD /S /Q "%_EXE_DIR_PATH%\plugins"
IF EXIST "%_EXE_DIR_PATH%\qml" RD /S /Q "%_EXE_DIR_PATH%\qml"
IF EXIST "%_EXE_DIR_PATH%\translations" RD /S /Q "%_EXE_DIR_PATH%\translations"
IF EXIST "%_EXE_DIR_PATH%\languages" RD /S /Q "%_EXE_DIR_PATH%\languages"
IF EXIST "%_EXE_DIR_PATH%\Qt*.dll" DEL /F /Q "%_EXE_DIR_PATH%\Qt*.dll"
IF EXIST "%_EXE_DIR_PATH%\qt.conf" DEL /F /Q "%_EXE_DIR_PATH%\qt.conf"
windeployqt %_DEP_PARAMS%
IF EXIST "%_APP_DIR%\qml\translations" MOVE /Y "%_APP_DIR%\qml\translations" "%_APP_DIR%"
IF EXIST "%_APP_DIR%\translations" (
CD /D "%_APP_DIR%"
IF EXIST "%_EXE_DIR_PATH%\qml\translations" MOVE /Y "%_EXE_DIR_PATH%\qml\translations" "%_EXE_DIR_PATH%"
IF EXIST "%_EXE_DIR_PATH%\translations" (
CD /D "%_EXE_DIR_PATH%"
REN "translations" "languages"
)
IF %ERRORLEVEL% NEQ 0 ECHO Something wrong happened, deploying process aborted && GOTO Fin
SET "_CONF_FILE=%_APP_DIR%\qt.conf"
ECHO [Paths]>"%_CONF_FILE%"
ECHO Prefix=.>>"%_CONF_FILE%"
ECHO Binaries=.>>"%_CONF_FILE%"
ECHO Libraries=.>>"%_CONF_FILE%"
ECHO Plugins=plugins>>"%_CONF_FILE%"
ECHO Imports=imports>>"%_CONF_FILE%"
ECHO Qml2Imports=qml>>"%_CONF_FILE%"
ECHO Translations=languages>>"%_CONF_FILE%"
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%"
TITLE Finished
CLS
ECHO Deploying process have completed successfully
Expand Down

0 comments on commit 4d4fa5a

Please sign in to comment.