diff options
Diffstat (limited to 'configure.bat')
-rw-r--r-- | configure.bat | 266 |
1 files changed, 27 insertions, 239 deletions
diff --git a/configure.bat b/configure.bat index 4bb78f9069..0c22fdccca 100644 --- a/configure.bat +++ b/configure.bat @@ -1,31 +1,6 @@ -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: :: Copyright (C) 2016 The Qt Company Ltd. :: Copyright (C) 2016 Intel Corporation. -:: Contact: https://www.qt.io/licensing/ -:: -:: This file is part of the tools applications of the Qt Toolkit. -:: -:: $QT_BEGIN_LICENSE:GPL-EXCEPT$ -:: Commercial License Usage -:: Licensees holding valid commercial Qt licenses may use this file in -:: accordance with the commercial license agreement provided with the -:: Software or, alternatively, in accordance with the terms contained in -:: a written agreement between you and The Qt Company. For licensing terms -:: and conditions see https://www.qt.io/terms-conditions. For further -:: information use the contact form at https://www.qt.io/contact-us. -:: -:: GNU General Public License Usage -:: Alternatively, this file may be used under the terms of the GNU -:: General Public License version 3 as published by the Free Software -:: Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -:: included in the packaging of this file. Please review the following -:: information to ensure the GNU General Public License requirements will -:: be met: https://www.gnu.org/licenses/gpl-3.0.html. -:: -:: $QT_END_LICENSE$ -:: -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: SPDX-License-Identifier: BSD-3-Clause @echo off setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS @@ -34,19 +9,6 @@ set QTSRC=%~dp0 set QTSRC=%QTSRC:~0,-1% set QTDIR=%CD% -rem Make sure qmake is not confused by these. Recursion via Makefiles would -rem be still affected, so just unsetting them here is not an option. -if not "%QMAKESPEC%" == "" goto envfail -if not "%XQMAKESPEC%" == "" goto envfail -if not "%QMAKEPATH%" == "" goto envfail -if not "%QMAKEFEATURES%" == "" goto envfail -goto envok -:envfail -echo >&2 Please make sure to unset the QMAKESPEC, XQMAKESPEC, QMAKEPATH, -echo >&2 and QMAKEFEATURES environment variables prior to building Qt. -exit /b 1 -:envok - rem Parse command line set TOPLEVEL=false @@ -66,10 +28,6 @@ echo ERROR: You cannot configure qtbase separately within a top-level build. >&2 exit /b 1 :wastoplevel -set SYNCQT= -set PLATFORM= -set MAKE= -set CMAKE= call :doargs %ARGS% if errorlevel 1 exit /b goto doneargs @@ -88,18 +46,6 @@ goto doneargs if /i "%~1" == "-redo" goto redo if /i "%~1" == "--redo" goto redo - if /i "%~1" == "-platform" goto platform - if /i "%~1" == "--platform" goto platform - - if /i "%~1" == "-no-syncqt" goto nosyncqt - if /i "%~1" == "--no-syncqt" goto nosyncqt - - if /i "%~1" == "-make-tool" goto maketool - if /i "%~1" == "--make-tool" goto maketool - - if /i "%~1" == "-cmake" goto cmake - if /i "%~1" == "--cmake" goto cmake - :nextarg shift goto doargs @@ -119,201 +65,43 @@ goto doneargs :redo if not exist "%TOPQTDIR%\config.opt" goto redoerr - set rargs= - for /f "usebackq delims=" %%i in ("%TOPQTDIR%\config.opt") do set rargs=!rargs! "%%i" - call :doargs %rargs% + echo %ARGS% > %TOPQTDIR%\config.redo.in + set redoing="" goto nextarg :redoerr echo No config.opt present - cannot redo configuration. >&2 exit /b 1 -:platform - shift - set PLATFORM=%~1 - if "%PLATFORM:~0,10%" == "win32-msvc" goto msvc - goto nextarg -:msvc - echo. >&2 - echo Notice: re-mapping requested qmake spec to unified 'win32-msvc'. >&2 - echo. >&2 - set PLATFORM=win32-msvc - goto nextarg - -:nosyncqt - set SYNCQT=false - goto nextarg - -:maketool - shift - set MAKE=%~1 - goto nextarg - -:cmake - set CMAKE=true - goto nextarg - :doneargs -if "%CMAKE%" == "true" goto cmake - -rem Find various executables -for %%C in (clang-cl.exe clang.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C - -rem Determine host spec - -if "%PLATFORM%" == "" ( - if not "%icl.exe%" == "" ( - set PLATFORM=win32-icc - ) else if not "%cl.exe%" == "" ( - set PLATFORM=win32-msvc - ) else if not "%clang-cl.exe%" == "" ( - set PLATFORM=win32-clang-msvc - ) else if not "%clang.exe%" == "" ( - set PLATFORM=win32-clang-g++ - ) else if not "%g++.exe%" == "" ( - set PLATFORM=win32-g++ - ) else ( - echo Cannot detect host toolchain. Please use -platform. Aborting. >&2 - exit /b 1 - ) -) -if not exist "%QTSRC%\mkspecs\%PLATFORM%\qmake.conf" ( - echo Host platform '%PLATFORM%' is invalid. Aborting. >&2 - exit /b 1 -) -if "%PLATFORM:g++=%" == "%PLATFORM%" ( - if "%MAKE%" == "" ( - if not "%jom.exe%" == "" ( - set MAKE=jom - ) else ( - set MAKE=nmake - ) - ) - set tmpl=win32 -) else ( - if "%MAKE%" == "" ( - set MAKE=mingw32-make - ) - set tmpl=unix -) - -rem Prepare build dir - -if not exist mkspecs ( - md mkspecs - if errorlevel 1 exit /b -) -if not exist bin ( - md bin - if errorlevel 1 exit /b -) -if not exist qmake ( - md qmake - if errorlevel 1 exit /b -) - -rem Extract Qt's version from .qmake.conf -for /f "eol=# tokens=1,2,3,4 delims=.= " %%i in (%QTSRC%\.qmake.conf) do ( - if %%i == MODULE_VERSION ( - set QTVERMAJ=%%j - set QTVERMIN=%%k - set QTVERPAT=%%l - ) -) -set QTVERSION=%QTVERMAJ%.%QTVERMIN%.%QTVERPAT% - -rem Create forwarding headers - -if "%SYNCQT%" == "" ( - if exist "%QTSRC%\.git" ( - set SYNCQT=true - ) else ( - set SYNCQT=false - ) -) -if "%SYNCQT%" == "true" ( - if not "%perl.exe%" == "" ( - echo Running syncqt ... - "%perl.exe%" -w "%QTSRC%\bin\syncqt.pl" -minimal -version %QTVERSION% -module QtCore -outdir "%QTDIR%" %QTSRC% - if errorlevel 1 exit /b - ) else ( - echo Perl not found in PATH. Aborting. >&2 - exit /b 1 - ) -) - -rem Build qmake - -echo Bootstrapping qmake ... - -cd qmake -if errorlevel 1 exit /b +cd "%TOPQTDIR%" -echo #### Generated by configure.bat - DO NOT EDIT! ####> Makefile -echo/>> Makefile -echo BUILD_PATH = ..>> Makefile -if "%tmpl%" == "win32" ( - echo SOURCE_PATH = %QTSRC%>> Makefile -) else ( - echo SOURCE_PATH = %QTSRC:\=/%>> Makefile -) -if exist "%QTSRC%\.git" ( - echo INC_PATH = ../include>> Makefile -) else ( - echo INC_PATH = $^(SOURCE_PATH^)/include>> Makefile -) -echo QT_VERSION = %QTVERSION%>> Makefile -rem These must have trailing spaces to avoid misinterpretation as 5>>, etc. -echo QT_MAJOR_VERSION = %QTVERMAJ% >> Makefile -echo QT_MINOR_VERSION = %QTVERMIN% >> Makefile -echo QT_PATCH_VERSION = %QTVERPAT% >> Makefile -if "%tmpl%" == "win32" ( - echo QMAKESPEC = %PLATFORM%>> Makefile +rem Write config.opt if we're not currently -redo'ing +set OPT_FILE_PATH=%TOPQTDIR%\config.opt +set OPT_TMP_FILE_PATH=%TOPQTDIR%\config.opt.in +set REDO_FILE_PATH=%TOPQTDIR%\config.redo.last +set REDO_TMP_FILE_PATH=%TOPQTDIR%\config.redo.in +set FRESH_REQUESTED_ARG= +if not defined redoing ( + rem "The '.' in 'echo.%*' ensures we don't print "echo is off" when no arguments are passed" + rem "https://devblogs.microsoft.com/oldnewthing/20170802-00/?p=96735" + rem "The space before the '>' makes sure that when we have a digit at the end of the args, we" + rem "don't accidentally concatenate it with the '>' resulting in '0>' or '2>' which redirects" + rem "into the file from a stream different than stdout, leading to broken or empty content." + echo.%* >"%OPT_TMP_FILE_PATH%" + + cmake -DIN_FILE="%OPT_TMP_FILE_PATH%" -DOUT_FILE="%OPT_FILE_PATH%" -DIGNORE_ARGS=-top-level -P "%QTSRC%\cmake\QtWriteArgsFile.cmake" ) else ( - echo QMAKESPEC = $^(SOURCE_PATH^)/mkspecs/%PLATFORM%>> Makefile - echo CONFIG_CXXFLAGS = -std=c++17 -ffunction-sections>> Makefile - echo CONFIG_LFLAGS = -Wl,--gc-sections>> Makefile - type "%QTSRC%\qmake\Makefile.unix.win32" >> Makefile - type "%QTSRC%\qmake\Makefile.unix.mingw" >> Makefile -) -echo/>> Makefile -type "%QTSRC%\qmake\Makefile.%tmpl%" >> Makefile - -%MAKE% -if errorlevel 1 (cd .. & exit /b 1) - -cd .. - -rem Generate qt.conf - -> "%QTDIR%\bin\qt.conf" ( - @echo [EffectivePaths] - @echo Prefix=.. - @echo [Paths] - @echo TargetSpec=dummy - @echo HostSpec=%PLATFORM% -) -if not "%QTDIR%" == "%QTSRC%" ( - >> "%QTDIR%\bin\qt.conf" ( - @echo [EffectiveSourcePaths] - @echo Prefix=%QTSRC:\=/% - ) -) - -rem Launch qmake-based configure + echo. 2> "%OPT_TMP_FILE_PATH%" + for /F "usebackq tokens=*" %%A in ("%OPT_FILE_PATH%") do echo "%%A" >> "%OPT_TMP_FILE_PATH%" -cd "%TOPQTDIR%" -"%QTDIR%\bin\qmake.exe" "%TOPQTSRC%" -- %ARGS% -goto :eof - -:cmake + cmake -DIN_FILE="%OPT_TMP_FILE_PATH%" -DREDO_FILE="%REDO_TMP_FILE_PATH%" -DOUT_FILE="%REDO_FILE_PATH%" -DIGNORE_ARGS="-top-level;-redo;--redo" -P "%QTSRC%\cmake\QtWriteArgsFile.cmake" -rem Write config.opt if we're not currently -redo'ing -if "%rargs%" == "" ( - if exist "%TOPQTDIR%\config.opt" del "%TOPQTDIR%\config.opt" - for %%a in (%ARGS%) do echo %%a >> "%TOPQTDIR%\config.opt" + set OPT_FILE_PATH=%REDO_FILE_PATH% + set FRESH_REQUESTED_ARG=-DFRESH_REQUESTED=TRUE ) rem Launch CMake-based configure -cd "%TOPQTDIR%" -cmake -DOPTFILE=config.opt -P "%QTSRC%\cmake\QtProcessConfigureArgs.cmake" +set TOP_LEVEL_ARG= +if %TOPLEVEL% == true set TOP_LEVEL_ARG=-DTOP_LEVEL=TRUE +cmake -DOPTFILE="%OPT_FILE_PATH%" %TOP_LEVEL_ARG% %FRESH_REQUESTED_ARG% -P "%QTSRC%\cmake\QtProcessConfigureArgs.cmake" |