move license check to qmake-based configure system
this also removes the need for passing pre-processed options via configure.cfg, so get rid of that. a somewhat unfortunate side effect is that the android-style-assets feature had to move back to the top level, as the licensing options depend on it. Started-by: Lars Knoll <lars.knoll@qt.io> Change-Id: Id4d1e0ba18b3e3104400293b8f0c7f2f65e68dea Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
f882d2f443
commit
e2978d6097
195
configure
vendored
195
configure
vendored
@ -400,13 +400,6 @@ UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
||||
|
||||
# detect the "echo without newline" style. usage: echo $ECHO_N "<string>$ECHO_C"
|
||||
if echo '\c' | grep '\c' >/dev/null; then
|
||||
ECHO_N=-n
|
||||
else
|
||||
ECHO_C='\c'
|
||||
fi
|
||||
|
||||
BUILD_ON_MAC=no
|
||||
if [ -d /System/Library/Frameworks/Carbon.framework ]; then
|
||||
BUILD_ON_MAC=yes
|
||||
@ -469,7 +462,6 @@ unset QTDIR
|
||||
|
||||
# initalize internal variables
|
||||
CFG_RELEASE_TOOLS=no
|
||||
CFG_ANDROID_STYLE_ASSETS=yes
|
||||
|
||||
XPLATFORM= # This seems to be the QMAKESPEC, like "linux-g++"
|
||||
XPLATFORM_MAC=no # Whether target platform is macOS, iOS, tvOS, or watchOS
|
||||
@ -790,12 +782,6 @@ while [ "$#" -gt 0 ]; do
|
||||
android-toolchain-version)
|
||||
CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION="$VAL"
|
||||
;;
|
||||
android-style-assets)
|
||||
# Required to be able to show the correct license text
|
||||
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
|
||||
CFG_ANDROID_STYLE_ASSETS="$VAL"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
@ -1007,168 +993,6 @@ case "$XPLATFORM" in
|
||||
;;
|
||||
esac
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# check the license
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if [ "$COMMERCIAL_USER" = "ask" ]; then
|
||||
while true; do
|
||||
echo "Which edition of Qt do you want to use ?"
|
||||
echo
|
||||
echo "Type 'c' if you want to use the Commercial Edition."
|
||||
echo "Type 'o' if you want to use the Open Source Edition."
|
||||
echo
|
||||
read commercial
|
||||
echo
|
||||
if [ "$commercial" = "c" ]; then
|
||||
COMMERCIAL_USER="yes"
|
||||
OPT_CMDLINE="$OPT_CMDLINE
|
||||
-commercial"
|
||||
break
|
||||
elif [ "$commercial" = "o" ]; then
|
||||
COMMERCIAL_USER="no"
|
||||
OPT_CMDLINE="$OPT_CMDLINE
|
||||
-opensource"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -f "$relpath"/LICENSE.PREVIEW.COMMERCIAL ] && [ $COMMERCIAL_USER = "yes" ]; then
|
||||
# Commercial preview release
|
||||
Licensee="Preview"
|
||||
Edition="Preview"
|
||||
EditionString="Technology Preview"
|
||||
elif [ $COMMERCIAL_USER = "yes" ]; then
|
||||
if [ $UNAME_SYSTEM = "Linux" ]; then
|
||||
case "$PLATFORM" in
|
||||
*-32)
|
||||
Licheck=licheck32
|
||||
;;
|
||||
*-64)
|
||||
Licheck=licheck64
|
||||
;;
|
||||
*)
|
||||
if file -L /bin/sh | grep -q "64-bit" ; then
|
||||
Licheck=licheck64
|
||||
else
|
||||
Licheck=licheck32
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
elif [ $UNAME_SYSTEM = "Darwin" ]; then
|
||||
Licheck=licheck_mac
|
||||
else
|
||||
echo >&2 "Host operating system not supported by this edition of Qt."
|
||||
exit 1
|
||||
fi
|
||||
if [ -x "$relpath/bin/$Licheck" ]; then
|
||||
LicheckOutput=`$relpath/bin/$Licheck $OPT_CONFIRM_LICENSE $relpath $outpath\
|
||||
$PLATFORM $XPLATFORM`
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
eval "$LicheckOutput"
|
||||
fi
|
||||
else
|
||||
echo
|
||||
echo "Error: This is the Open Source version of Qt."
|
||||
echo "If you want to use Enterprise features of Qt,"
|
||||
echo "use the contact form at http://www.qt.io/contact-us"
|
||||
echo "to purchase a license."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
elif [ $COMMERCIAL_USER = "no" ]; then
|
||||
# Open Source edition - may only be used under the terms of the LGPLv3 or GPLv2.
|
||||
Licensee="Open Source"
|
||||
Edition="OpenSource"
|
||||
EditionString="Open Source"
|
||||
fi
|
||||
|
||||
if [ "$Edition" = "OpenSource" ] || [ "$Edition" = "Preview" ]; then
|
||||
echo
|
||||
echo "This is the Qt ${EditionString} Edition."
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ "$Edition" = "OpenSource" ]; then
|
||||
while true; do
|
||||
if [ "$CFG_ANDROID_STYLE_ASSETS" = "no" ] || [ "$XPLATFORM_ANDROID" = "no" ]; then
|
||||
echo "You are licensed to use this software under the terms of"
|
||||
echo "the GNU Lesser General Public License (LGPL) version 3."
|
||||
echo "You are also licensed to use this software under the terms of"
|
||||
echo "the GNU General Public License (GPL) version 2."
|
||||
affix="either"
|
||||
showGPL2="yes"
|
||||
else
|
||||
echo "You are licensed to use this software under the terms of"
|
||||
echo "the GNU Lesser General Public License (LGPL) version 3."
|
||||
showGPL2="no"
|
||||
affix="the"
|
||||
fi
|
||||
|
||||
echo
|
||||
if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
|
||||
echo "You have already accepted the terms of the $EditionString license."
|
||||
acceptance=yes
|
||||
else
|
||||
if [ -f "$relpath/LICENSE.LGPL3" ]; then
|
||||
echo "Type 'L' to view the GNU Lesser General Public License version 3."
|
||||
fi
|
||||
if [ "$showGPL2" = "yes" ]; then
|
||||
echo "Type 'G' to view the GNU General Public License version 2."
|
||||
fi
|
||||
echo "Type 'yes' to accept this license offer."
|
||||
echo "Type 'no' to decline this license offer."
|
||||
echo
|
||||
echo $ECHO_N "Do you accept the terms of $affix license? $ECHO_C"
|
||||
read acceptance
|
||||
fi
|
||||
echo
|
||||
if [ "$acceptance" = "yes" ] || [ "$acceptance" = "y" ]; then
|
||||
break
|
||||
elif [ "$acceptance" = "no" ]; then
|
||||
echo "You are not licensed to use this software."
|
||||
echo
|
||||
exit 1
|
||||
elif [ "$acceptance" = "L" ]; then
|
||||
more "$relpath/LICENSE.LGPL3"
|
||||
elif [ "$acceptance" = "G" ] && [ "$showGPL2" = "yes" ]; then
|
||||
more "$relpath/LICENSE.GPL2"
|
||||
fi
|
||||
done
|
||||
elif [ "$Edition" = "Preview" ]; then
|
||||
TheLicense=`head -n 1 "$relpath/LICENSE.PREVIEW.COMMERCIAL"`
|
||||
while true; do
|
||||
|
||||
if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
|
||||
echo "You have already accepted the terms of the $EditionString license."
|
||||
acceptance=yes
|
||||
else
|
||||
echo "You are licensed to use this software under the terms of"
|
||||
echo "the $TheLicense"
|
||||
echo
|
||||
echo "Type '?' to read the Preview License."
|
||||
echo "Type 'yes' to accept this license offer."
|
||||
echo "Type 'no' to decline this license offer."
|
||||
echo
|
||||
echo $ECHO_N "Do you accept the terms of the license? $ECHO_C"
|
||||
read acceptance
|
||||
fi
|
||||
echo
|
||||
if [ "$acceptance" = "yes" ]; then
|
||||
break
|
||||
elif [ "$acceptance" = "no" ] ;then
|
||||
echo "You are not licensed to use this software."
|
||||
echo
|
||||
exit 0
|
||||
elif [ "$acceptance" = "?" ]; then
|
||||
more "$relpath/LICENSE.PREVIEW.COMMERCIAL"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# command line and environment validation
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -1805,16 +1629,6 @@ fi
|
||||
# run configure tests
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# copy some variables that are still being computed in the shell script into an input file for configure
|
||||
# This should go away in the future
|
||||
|
||||
cat > "$outpath/config.tests/configure.cfg" <<EOF
|
||||
# Feature defaults set by configure command line
|
||||
config.input.qt_edition = $Edition
|
||||
config.input.qt_licheck = $Licheck
|
||||
config.input.qt_release_date = $ReleaseDate
|
||||
EOF
|
||||
|
||||
# recreate command line for qmake
|
||||
set -f
|
||||
SAVED_IFS=$IFS
|
||||
@ -1840,6 +1654,15 @@ fi
|
||||
# finally save the executed command to another script
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ $CFG_REDO = no ]; then
|
||||
if [ "$COMMERCIAL_USER" = "ask" ]; then
|
||||
if grep '^QT_EDITION = OpenSource$' "$outpath/mkspecs/qconfig.pri" >/dev/null 2>&1; then
|
||||
OPT_CMDLINE="$OPT_CMDLINE
|
||||
-opensource"
|
||||
else
|
||||
OPT_CMDLINE="$OPT_CMDLINE
|
||||
-commercial"
|
||||
fi
|
||||
fi
|
||||
if [ "$OPT_CONFIRM_LICENSE" = "no" ]; then
|
||||
OPT_CMDLINE="$OPT_CMDLINE
|
||||
-confirm-license"
|
||||
|
@ -56,6 +56,7 @@
|
||||
"android-toolchain-version": "string",
|
||||
|
||||
"accessibility": "boolean",
|
||||
"android-style-assets": "boolean",
|
||||
"avx": "boolean",
|
||||
"avx2": "boolean",
|
||||
"avx512": { "type": "boolean", "name": "avx512f" },
|
||||
@ -417,6 +418,12 @@
|
||||
},
|
||||
|
||||
"features": {
|
||||
"android-style-assets": {
|
||||
"label": "Android Style Assets",
|
||||
"condition": "config.android",
|
||||
"output": [ "privateFeature" ],
|
||||
"comment": "This belongs into gui, but the license check needs it here already."
|
||||
},
|
||||
"shared": {
|
||||
"label": "Building shared libraries",
|
||||
"condition": "!config.uikit && !config.integrity",
|
||||
@ -962,6 +969,11 @@
|
||||
},
|
||||
|
||||
"earlyReport": [
|
||||
{
|
||||
"type": "fatal",
|
||||
"condition": "!call.licenseCheck",
|
||||
"message": "You are not licensed to use this software."
|
||||
},
|
||||
{
|
||||
"type": "warning",
|
||||
"condition": "input.debug_and_release == 'yes' && !config.darwin && !config.win32",
|
||||
|
166
configure.pri
166
configure.pri
@ -1,3 +1,7 @@
|
||||
# this must be done outside any function
|
||||
QT_SOURCE_TREE = $$PWD
|
||||
QT_BUILD_TREE = $$shadowed($$PWD)
|
||||
|
||||
# custom command line handling
|
||||
|
||||
defineTest(qtConfCommandline_qmakeArgs) {
|
||||
@ -63,6 +67,165 @@ defineReplace(qtConfFunc_crossCompile) {
|
||||
return(false)
|
||||
}
|
||||
|
||||
defineReplace(qtConfFunc_licenseCheck) {
|
||||
exists($$QT_SOURCE_TREE/LICENSE.LGPL3)|exists($$QT_SOURCE_TREE/LICENSE.GPL2): \
|
||||
hasOpenSource = true
|
||||
else: \
|
||||
hasOpenSource = false
|
||||
exists($$QT_SOURCE_TREE/LICENSE.PREVIEW.COMMERCIAL)|exists($$QT_SOURCE_TREE/bin/licheck*): \
|
||||
hasCommercial = true
|
||||
else: \
|
||||
hasCommercial = false
|
||||
|
||||
commercial = $$config.input.commercial
|
||||
isEmpty(commercial) {
|
||||
$$hasOpenSource {
|
||||
$$hasCommercial {
|
||||
logn()
|
||||
logn("Selecting Qt Edition.")
|
||||
logn()
|
||||
logn("Type 'c' if you want to use the Commercial Edition.")
|
||||
logn("Type 'o' if you want to use the Open Source Edition.")
|
||||
logn()
|
||||
for(ever) {
|
||||
val = $$lower($$prompt("Which edition of Qt do you want to use? ", false))
|
||||
equals(val, c) {
|
||||
commercial = yes
|
||||
} else: equals(val, o) {
|
||||
commercial = no
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
break()
|
||||
}
|
||||
} else {
|
||||
commercial = no
|
||||
}
|
||||
} else {
|
||||
!$$hasCommercial: \
|
||||
qtConfFatalError("No license files and no licheck executables found." \
|
||||
"Cannot proceed. Try re-installing Qt.")
|
||||
commercial = yes
|
||||
}
|
||||
}
|
||||
|
||||
equals(commercial, no) {
|
||||
!$$hasOpenSource: \
|
||||
qtConfFatalError("This is the Qt Commercial Edition." \
|
||||
"Cannot proceed with -opensource.")
|
||||
|
||||
logn()
|
||||
logn("This is the Qt Open Source Edition.")
|
||||
|
||||
EditionString = "Open Source"
|
||||
config.input.qt_edition = OpenSource
|
||||
export(config.input.qt_edition)
|
||||
} else {
|
||||
!$$hasCommercial: \
|
||||
qtConfFatalError("This is the Qt Open Source Edition." \
|
||||
"Cannot proceed with -commercial.")
|
||||
|
||||
exists($$QT_SOURCE_TREE/LICENSE.PREVIEW.COMMERCIAL) {
|
||||
logn()
|
||||
logn("This is the Qt Technology Preview Edition.")
|
||||
|
||||
EditionString = "Technology Preview"
|
||||
config.input.qt_edition = Preview
|
||||
export(config.input.qt_edition)
|
||||
} else {
|
||||
equals(QMAKE_HOST.os, Linux) {
|
||||
equals(QMAKE_HOST.arch, x86): \
|
||||
Licheck = licheck32
|
||||
else: \
|
||||
Licheck = licheck64
|
||||
} else: equals(QMAKE_HOST.os, Darwin) {
|
||||
Licheck = licheck_mac
|
||||
} else: equals(QMAKE_HOST.os, Windows) {
|
||||
Licheck = licheck.exe
|
||||
} else {
|
||||
qtConfFatalError("Host operating system not supported by this edition of Qt.")
|
||||
}
|
||||
|
||||
!qtRunLoggedCommand("$$system_quote($$QT_SOURCE_TREE/bin/$$Licheck) \
|
||||
$$eval(config.input.confirm-license) \
|
||||
$$system_quote($$QT_SOURCE_TREE) $$system_quote($$QT_BUILD_TREE) \
|
||||
$$[QMAKE_SPEC] $$[QMAKE_XSPEC]", \
|
||||
LicheckOutput): \
|
||||
return(false)
|
||||
eval($$LicheckOutput)
|
||||
config.input.qt_edition = $$Edition
|
||||
config.input.qt_licheck = $$Licheck
|
||||
config.input.qt_release_date = $$ReleaseDate
|
||||
export(config.input.qt_edition)
|
||||
export(config.input.qt_licheck)
|
||||
export(config.input.qt_release_date)
|
||||
return(true)
|
||||
}
|
||||
}
|
||||
|
||||
!isEmpty(config.input.confirm-license) {
|
||||
logn()
|
||||
logn("You have already accepted the terms of the $$EditionString license.")
|
||||
return(true)
|
||||
}
|
||||
|
||||
affix = the
|
||||
equals(commercial, no) {
|
||||
theLicense = "GNU Lesser General Public License (LGPL) version 3"
|
||||
showWhat = "Type 'L' to view the GNU Lesser General Public License version 3 (LGPLv3)."
|
||||
gpl2Ok = false
|
||||
winrt {
|
||||
notTheLicense = "Note: GPL version 2 is not available on WinRT."
|
||||
} else: $$qtConfEvaluate("features.android-style-assets") {
|
||||
notTheLicense = "Note: GPL version 2 is not available due to using Android style assets."
|
||||
} else {
|
||||
theLicense += "or the GNU General Public License (GPL) version 2"
|
||||
showWhat += "Type 'G' to view the GNU General Public License version 2 (GPLv2)."
|
||||
gpl2Ok = true
|
||||
affix = either
|
||||
}
|
||||
} else {
|
||||
theLicense = $$cat($$QT_SOURCE_TREE/LICENSE.PREVIEW.COMMERCIAL, lines)
|
||||
theLicense = $$first(theLicense)
|
||||
showWhat = "Type '?' to view the $${theLicense}."
|
||||
}
|
||||
msg = \
|
||||
" " \
|
||||
"You are licensed to use this software under the terms of" \
|
||||
"the "$$theLicense"." \
|
||||
$$notTheLicense \
|
||||
" " \
|
||||
$$showWhat \
|
||||
"Type 'y' to accept this license offer." \
|
||||
"Type 'n' to decline this license offer." \
|
||||
" "
|
||||
|
||||
for(ever) {
|
||||
logn($$join(msg, $$escape_expand(\\n)))
|
||||
for(ever) {
|
||||
val = $$lower($$prompt("Do you accept the terms of $$affix license? ", false))
|
||||
equals(val, y)|equals(val, yes) {
|
||||
logn()
|
||||
return(true)
|
||||
} else: equals(val, n)|equals(val, no) {
|
||||
return(false)
|
||||
} else: equals(commercial, yes):equals(val, ?) {
|
||||
licenseFile = $$QT_SOURCE_TREE/LICENSE.PREVIEW.COMMERCIAL
|
||||
} else: equals(commercial, no):equals(val, l) {
|
||||
licenseFile = $$QT_SOURCE_TREE/LICENSE.LGPL3
|
||||
} else: equals(commercial, no):equals(val, g):$$gpl2Ok {
|
||||
licenseFile = $$QT_SOURCE_TREE/LICENSE.GPL2
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
break()
|
||||
}
|
||||
system("more $$system_quote($$system_path($$licenseFile))")
|
||||
logn()
|
||||
logn()
|
||||
}
|
||||
}
|
||||
|
||||
# custom tests
|
||||
|
||||
defineTest(qtConfTest_architecture) {
|
||||
@ -559,6 +722,3 @@ discard_from($$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)
|
||||
QMAKE_POST_CONFIGURE += \
|
||||
"include(\$\$[QT_HOST_DATA/get]/mkspecs/qconfig.pri)" \
|
||||
"include(\$\$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)"
|
||||
|
||||
# load and process input from configure.sh/.exe
|
||||
include($$shadowed($$PWD)/config.tests/configure.cfg)
|
||||
|
@ -28,6 +28,12 @@ defineTest(qtConfAddError) {
|
||||
}
|
||||
}
|
||||
|
||||
defineTest(qtConfFatalError) {
|
||||
qtConfAddError($$1, $$2)
|
||||
qtConfPrintReport()
|
||||
error()
|
||||
}
|
||||
|
||||
defineTest(qtConfCommandlineSetInput) {
|
||||
arg = $${1}
|
||||
val = $${2}
|
||||
@ -778,9 +784,7 @@ defineTest(qtConfTest_compile) {
|
||||
|
||||
defineTest(qtConfTest_verifySpec) {
|
||||
qtConfTest_compile($$1): return(true)
|
||||
qtConfAddError("Cannot compile a minimal program. The toolchain or QMakeSpec is broken.", log)
|
||||
qtConfPrintReport()
|
||||
error()
|
||||
qtConfFatalError("Cannot compile a minimal program. The toolchain or QMakeSpec is broken.", log)
|
||||
}
|
||||
|
||||
defineTest(qtConfTest_files) {
|
||||
@ -1310,6 +1314,10 @@ defineTest(qtConfReport_error) {
|
||||
qtConfAddError($${1}, log)
|
||||
}
|
||||
|
||||
defineTest(qtConfReport_fatal) {
|
||||
qtConfFatalError($${1})
|
||||
}
|
||||
|
||||
defineTest(qtConfCreateReportRecurse) {
|
||||
equals(2, false) {
|
||||
indent = ""
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
"commandline": {
|
||||
"options": {
|
||||
"android-style-assets": "boolean",
|
||||
"angle": "boolean",
|
||||
"direct2d": "boolean",
|
||||
"directfb": "boolean",
|
||||
@ -413,11 +412,6 @@
|
||||
"condition": "features.accessibility && features.xcb && features.dbus",
|
||||
"output": [ "privateFeature", "feature" ]
|
||||
},
|
||||
"android-style-assets": {
|
||||
"label": "Android Style Assets",
|
||||
"condition": "config.android",
|
||||
"output": [ "privateFeature" ]
|
||||
},
|
||||
"angle": {
|
||||
"label": "ANGLE",
|
||||
"autoDetect": "features.opengles2 || features.opengl-dynamic",
|
||||
|
@ -18,7 +18,6 @@ OBJECTS = \
|
||||
main.o \
|
||||
configureapp.o \
|
||||
environment.o \
|
||||
tools.o \
|
||||
qarraydata.o \
|
||||
qbytearray.o \
|
||||
qbytearraymatcher.o \
|
||||
@ -116,9 +115,8 @@ $(PCH): $(CONFSRC)/configure_pch.h
|
||||
VPATH = $(CONFSRC):$(TOOLSRC)/shared/windows:$(CORESRC)/global:$(CORESRC)/kernel:$(CORESRC)/tools:$(CORESRC)/codecs:$(CORESRC)/io:$(CORESRC)/xml:$(CORESRC)/plugin
|
||||
|
||||
main.o: $(CONFSRC)/configureapp.h
|
||||
configureapp.o: $(CONFSRC)/configureapp.h $(CONFSRC)/environment.h $(CONFSRC)/tools.h
|
||||
configureapp.o: $(CONFSRC)/configureapp.h $(CONFSRC)/environment.h
|
||||
environment.o: $(CONFSRC)/environment.h
|
||||
tools.o: $(CONFSRC)/tools.h
|
||||
|
||||
# Make sure qstring_compat.obj isn't compiled with PCH enabled
|
||||
qstring_compat.o: $(CORESRC)/tools/qstring_compat.cpp
|
||||
|
@ -23,7 +23,6 @@ OBJECTS = \
|
||||
main.obj \
|
||||
configureapp.obj \
|
||||
environment.obj \
|
||||
tools.obj \
|
||||
qarraydata.obj \
|
||||
qbytearray.obj \
|
||||
qbytearraymatcher.obj \
|
||||
@ -97,9 +96,8 @@ $(PCH): $(CONFSRC)\configure_pch.h
|
||||
$(OBJECTS): $(PCH)
|
||||
|
||||
main.obj: $(CONFSRC)\main.cpp $(CONFSRC)\configureapp.h $(PCH)
|
||||
configureapp.obj: $(CONFSRC)\configureapp.cpp $(CONFSRC)\configureapp.h $(CONFSRC)\environment.h $(CONFSRC)\tools.h $(PCH)
|
||||
configureapp.obj: $(CONFSRC)\configureapp.cpp $(CONFSRC)\configureapp.h $(CONFSRC)\environment.h $(PCH)
|
||||
environment.obj: $(CONFSRC)\environment.cpp $(CONFSRC)\environment.h $(PCH)
|
||||
tools.obj: $(CONFSRC)\tools.cpp $(CONFSRC)\tools.h $(PCH)
|
||||
registry.obj: $(TOOLSRC)\shared\windows\registry.cpp $(PCH)
|
||||
qarraydata.obj: $(CORESRC)\tools\qarraydata.cpp $(PCH)
|
||||
qbytearray.obj: $(CORESRC)\tools\qbytearray.cpp $(PCH)
|
||||
|
@ -31,7 +31,7 @@ INCLUDEPATH += \
|
||||
$$QT_BUILD_TREE/include/QtCore/$$QT.core.VERSION/QtCore \
|
||||
$$QT_SOURCE_TREE/tools/shared
|
||||
|
||||
HEADERS = configureapp.h environment.h tools.h\
|
||||
HEADERS = configureapp.h environment.h \
|
||||
$$QT_SOURCE_TREE/src/corelib/tools/qarraydata.h \
|
||||
$$QT_SOURCE_TREE/src/corelib/tools/qbytearray.h \
|
||||
$$QT_SOURCE_TREE/src/corelib/tools/qarraydatapointer.h \
|
||||
@ -80,7 +80,7 @@ HEADERS = configureapp.h environment.h tools.h\
|
||||
$$QT_SOURCE_TREE/tools/shared/windows/registry_p.h
|
||||
|
||||
|
||||
SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \
|
||||
SOURCES = main.cpp configureapp.cpp environment.cpp \
|
||||
$$QT_SOURCE_TREE/src/corelib/tools/qbytearray.cpp \
|
||||
$$QT_SOURCE_TREE/src/corelib/tools/qarraydata.cpp \
|
||||
$$QT_SOURCE_TREE/src/corelib/tools/qbytearraymatcher.cpp \
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include "configureapp.h"
|
||||
#include "environment.h"
|
||||
#include "tools.h"
|
||||
|
||||
#include <qdir.h>
|
||||
#include <qdiriterator.h>
|
||||
@ -46,7 +45,6 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <windows.h>
|
||||
#include <conio.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -66,13 +64,6 @@ std::ostream &operator<<(std::ostream &s, const QString &val) {
|
||||
|
||||
using namespace std;
|
||||
|
||||
static inline void promptKeyPress()
|
||||
{
|
||||
cout << "(Press any key to continue...)";
|
||||
if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
|
||||
exit(0); // Exit cleanly for Ctrl+C
|
||||
}
|
||||
|
||||
Configure::Configure(int& argc, char** argv)
|
||||
{
|
||||
int i;
|
||||
@ -183,7 +174,6 @@ void Configure::parseCmdLine()
|
||||
if (j == argCount)
|
||||
break;
|
||||
dictionary["XQMAKESPEC"] = configCmdLine.at(j);
|
||||
applySpecSpecifics();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -419,12 +409,6 @@ void Configure::parseCmdLine()
|
||||
break;
|
||||
dictionary[ "ANDROID_NDK_TOOLCHAIN_VERSION" ] = configCmdLine.at(i);
|
||||
}
|
||||
|
||||
else if (configCmdLine.at(i) == "-no-android-style-assets") {
|
||||
dictionary[ "ANDROID_STYLE_ASSETS" ] = "no";
|
||||
} else if (configCmdLine.at(i) == "-android-style-assets") {
|
||||
dictionary[ "ANDROID_STYLE_ASSETS" ] = "yes";
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that QMAKESPEC exists in the mkspecs folder
|
||||
@ -495,16 +479,6 @@ void Configure::parseCmdLine()
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Modifies the default configuration based on given -platform option.
|
||||
Eg. switches to different default styles for Windows CE.
|
||||
*/
|
||||
void Configure::applySpecSpecifics()
|
||||
{
|
||||
if (platform() == ANDROID)
|
||||
dictionary["ANDROID_STYLE_ASSETS"] = "yes";
|
||||
}
|
||||
|
||||
void Configure::prepareConfigTests()
|
||||
{
|
||||
// Generate an empty .qmake.cache file for config.tests
|
||||
@ -914,16 +888,6 @@ void Configure::buildQmake()
|
||||
|
||||
void Configure::configure()
|
||||
{
|
||||
FileWriter ci(buildPath + "/config.tests/configure.cfg");
|
||||
ci << "# Feature defaults set by configure command line\n"
|
||||
<< "config.input.qt_edition = " << dictionary["EDITION"] << "\n"
|
||||
<< "config.input.qt_licheck = " << dictionary["LICHECK"] << "\n"
|
||||
<< "config.input.qt_release_date = " << dictionary["RELEASEDATE"];
|
||||
if (!ci.flush()) {
|
||||
dictionary[ "DONE" ] = "error";
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList args;
|
||||
args << buildPath + "/bin/qmake"
|
||||
<< sourcePathMangled
|
||||
@ -941,155 +905,6 @@ void Configure::configure()
|
||||
saveCmdLine();
|
||||
}
|
||||
|
||||
bool Configure::showLicense(QString orgLicenseFile)
|
||||
{
|
||||
bool showGpl2 = true;
|
||||
QString licenseFile = orgLicenseFile;
|
||||
QString theLicense;
|
||||
if (dictionary["EDITION"] == "OpenSource") {
|
||||
if (platform() != WINDOWS_RT
|
||||
&& (platform() != ANDROID || dictionary["ANDROID_STYLE_ASSETS"] == "no")) {
|
||||
theLicense = "GNU Lesser General Public License (LGPL) version 3\n"
|
||||
"or the GNU General Public License (GPL) version 2";
|
||||
} else {
|
||||
theLicense = "GNU Lesser General Public License (LGPL) version 3";
|
||||
showGpl2 = false;
|
||||
}
|
||||
} else {
|
||||
// the first line of the license file tells us which license it is
|
||||
QFile file(licenseFile);
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
cout << "Failed to load LICENSE file" << endl;
|
||||
return false;
|
||||
}
|
||||
theLicense = file.readLine().trimmed();
|
||||
}
|
||||
|
||||
forever {
|
||||
char accept = '?';
|
||||
cout << "You are licensed to use this software under the terms of" << endl
|
||||
<< "the " << theLicense << "." << endl
|
||||
<< endl;
|
||||
if (dictionary["EDITION"] == "OpenSource") {
|
||||
cout << "Type 'L' to view the GNU Lesser General Public License version 3 (LGPLv3)." << endl;
|
||||
if (showGpl2)
|
||||
cout << "Type 'G' to view the GNU General Public License version 2 (GPLv2)." << endl;
|
||||
} else {
|
||||
cout << "Type '?' to view the " << theLicense << "." << endl;
|
||||
}
|
||||
cout << "Type 'y' to accept this license offer." << endl
|
||||
<< "Type 'n' to decline this license offer." << endl
|
||||
<< endl
|
||||
<< "Do you accept the terms of the license?" << endl;
|
||||
cin >> accept;
|
||||
accept = tolower(accept);
|
||||
|
||||
if (accept == 'y') {
|
||||
configCmdLine << "-confirm-license";
|
||||
return true;
|
||||
} else if (accept == 'n') {
|
||||
return false;
|
||||
} else {
|
||||
if (dictionary["EDITION"] == "OpenSource") {
|
||||
if (accept == 'l')
|
||||
licenseFile = orgLicenseFile + "/LICENSE.LGPL3";
|
||||
else
|
||||
licenseFile = orgLicenseFile + "/LICENSE.GPL2";
|
||||
}
|
||||
// Get console line height, to fill the screen properly
|
||||
int i = 0, screenHeight = 25; // default
|
||||
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
|
||||
HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (GetConsoleScreenBufferInfo(stdOut, &consoleInfo))
|
||||
screenHeight = consoleInfo.srWindow.Bottom
|
||||
- consoleInfo.srWindow.Top
|
||||
- 1; // Some overlap for context
|
||||
|
||||
// Prompt the license content to the user
|
||||
QFile file(licenseFile);
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
cout << "Failed to load LICENSE file" << licenseFile << endl;
|
||||
return false;
|
||||
}
|
||||
QStringList licenseContent = QString(file.readAll()).split('\n');
|
||||
while (i < licenseContent.size()) {
|
||||
cout << licenseContent.at(i) << endl;
|
||||
if (++i % screenHeight == 0) {
|
||||
promptKeyPress();
|
||||
cout << "\r"; // Overwrite text above
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Configure::readLicense()
|
||||
{
|
||||
dictionary["PLATFORM NAME"] = platformName();
|
||||
dictionary["LICENSE FILE"] = sourcePath;
|
||||
|
||||
bool openSource = false;
|
||||
bool hasOpenSource = QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.LGPL3") || QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.GPL2");
|
||||
if (dictionary["BUILDTYPE"] == "commercial") {
|
||||
openSource = false;
|
||||
} else if (dictionary["BUILDTYPE"] == "opensource") {
|
||||
openSource = true;
|
||||
} else if (hasOpenSource) { // No Open Source? Just display the commercial license right away
|
||||
forever {
|
||||
char accept = '?';
|
||||
cout << "Which edition of Qt do you want to use ?" << endl;
|
||||
cout << "Type 'c' if you want to use the Commercial Edition." << endl;
|
||||
cout << "Type 'o' if you want to use the Open Source Edition." << endl;
|
||||
cin >> accept;
|
||||
accept = tolower(accept);
|
||||
|
||||
if (accept == 'c') {
|
||||
openSource = false;
|
||||
break;
|
||||
} else if (accept == 'o') {
|
||||
openSource = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasOpenSource && openSource) {
|
||||
cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl << endl;
|
||||
dictionary["LICENSEE"] = "Open Source";
|
||||
dictionary["EDITION"] = "OpenSource";
|
||||
} else if (openSource) {
|
||||
cout << endl << "Cannot find the GPL license files! Please download the Open Source version of the library." << endl;
|
||||
dictionary["DONE"] = "error";
|
||||
return;
|
||||
} else {
|
||||
QString tpLicense = sourcePath + "/LICENSE.PREVIEW.COMMERCIAL";
|
||||
if (QFile::exists(tpLicense)) {
|
||||
cout << endl << "This is the Qt Preview Edition." << endl << endl;
|
||||
|
||||
dictionary["EDITION"] = "Preview";
|
||||
dictionary["LICENSE FILE"] = tpLicense;
|
||||
} else {
|
||||
Tools::checkLicense(dictionary, sourcePath, buildPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (dictionary["LICENSE_CONFIRMED"] != "yes") {
|
||||
if (!showLicense(dictionary["LICENSE FILE"])) {
|
||||
cout << "Configuration aborted since license was not accepted" << endl;
|
||||
dictionary["DONE"] = "error";
|
||||
return;
|
||||
}
|
||||
} else if (dictionary["LICHECK"].isEmpty()) { // licheck executable shows license
|
||||
cout << "You have already accepted the terms of the license." << endl << endl;
|
||||
}
|
||||
|
||||
if (dictionary["BUILDTYPE"] == "none") {
|
||||
if (openSource)
|
||||
configCmdLine << "-opensource";
|
||||
else
|
||||
configCmdLine << "-commercial";
|
||||
}
|
||||
}
|
||||
|
||||
bool Configure::reloadCmdLine(int idx)
|
||||
{
|
||||
QFile inFile(buildPathMangled + "/config.opt");
|
||||
@ -1112,6 +927,20 @@ bool Configure::reloadCmdLine(int idx)
|
||||
void Configure::saveCmdLine()
|
||||
{
|
||||
if (dictionary[ "REDO" ] != "yes") {
|
||||
if (dictionary["BUILDTYPE"] == "none") {
|
||||
bool openSource = false;
|
||||
QFile inFile(buildPath + "/mkspecs/qconfig.pri");
|
||||
if (inFile.open(QFile::ReadOnly | QFile::Text)) {
|
||||
QTextStream inStream(&inFile);
|
||||
while (!inStream.atEnd()) {
|
||||
if (inStream.readLine() == "QT_EDITION = OpenSource")
|
||||
openSource = true;
|
||||
}
|
||||
}
|
||||
configCmdLine.append(openSource ? "-opensource" : "-commercial");
|
||||
}
|
||||
if (dictionary["LICENSE_CONFIRMED"] != "yes")
|
||||
configCmdLine.append("-confirm-license");
|
||||
QFile outFile(buildPathMangled + "/config.opt");
|
||||
if (outFile.open(QFile::WriteOnly | QFile::Text)) {
|
||||
QTextStream outStream(&outFile);
|
||||
@ -1134,23 +963,6 @@ bool Configure::isOk()
|
||||
return (dictionary[ "DONE" ] != "error");
|
||||
}
|
||||
|
||||
QString Configure::platformName() const
|
||||
{
|
||||
switch (platform()) {
|
||||
default:
|
||||
case WINDOWS:
|
||||
return QStringLiteral("Qt for Windows");
|
||||
case WINDOWS_RT:
|
||||
return QStringLiteral("Qt for Windows Runtime");
|
||||
case QNX:
|
||||
return QStringLiteral("Qt for QNX");
|
||||
case ANDROID:
|
||||
return QStringLiteral("Qt for Android");
|
||||
case OTHER:
|
||||
return QStringLiteral("Qt for ???");
|
||||
}
|
||||
}
|
||||
|
||||
int Configure::platform() const
|
||||
{
|
||||
const QString xQMakeSpec = dictionary.value("XQMAKESPEC");
|
||||
|
@ -54,14 +54,10 @@ public:
|
||||
void generateQDevicePri();
|
||||
void prepareConfigTests();
|
||||
|
||||
bool showLicense(QString licenseFile);
|
||||
void readLicense();
|
||||
|
||||
bool isDone();
|
||||
bool isOk();
|
||||
|
||||
int platform() const;
|
||||
QString platformName() const;
|
||||
|
||||
private:
|
||||
int verbose;
|
||||
@ -86,8 +82,6 @@ private:
|
||||
|
||||
bool reloadCmdLine(int idx);
|
||||
void saveCmdLine();
|
||||
|
||||
void applySpecSpecifics();
|
||||
};
|
||||
|
||||
class FileWriter : public QTextStream
|
||||
|
@ -378,29 +378,4 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
/*!
|
||||
Executes \a command with _popen() and returns the stdout of the command.
|
||||
|
||||
Taken from qmake's system() command.
|
||||
*/
|
||||
QString Environment::execute(const QString &command, int *returnCode)
|
||||
{
|
||||
QString output;
|
||||
FILE *proc = _popen(command.toLatin1().constData(), "r");
|
||||
char buff[256];
|
||||
while (proc && !feof(proc)) {
|
||||
int read_in = int(fread(buff, 1, 255, proc));
|
||||
if (!read_in)
|
||||
break;
|
||||
buff[read_in] = '\0';
|
||||
output += buff;
|
||||
}
|
||||
if (proc) {
|
||||
int r = _pclose(proc);
|
||||
if (returnCode)
|
||||
*returnCode = r;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -52,7 +52,6 @@ public:
|
||||
static QString detectQMakeSpec();
|
||||
|
||||
static int execute(QStringList arguments, const QStringList &additionalEnv, const QStringList &removeEnv);
|
||||
static QString execute(const QString &command, int *returnCode = 0);
|
||||
|
||||
private:
|
||||
static Compiler detectedCompiler;
|
||||
|
@ -45,13 +45,6 @@ int runConfigure( int argc, char** argv )
|
||||
if (!app.isOk())
|
||||
return 3;
|
||||
|
||||
// Read license now, and exit if it doesn't pass.
|
||||
// This lets the user see the command-line options of configure
|
||||
// without having to load and parse the license file.
|
||||
app.readLicense();
|
||||
if (!app.isOk())
|
||||
return 3;
|
||||
|
||||
// Source file with path settings. Needed by qmake.
|
||||
app.generateQConfigCpp();
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "tools.h"
|
||||
#include "environment.h"
|
||||
|
||||
#include <qdir.h>
|
||||
#include <qfile.h>
|
||||
#include <qbytearray.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, const QString &val);
|
||||
using namespace std;
|
||||
|
||||
void Tools::checkLicense(QMap<QString,QString> &dictionary,
|
||||
const QString &sourcePath, const QString &buildPath)
|
||||
{
|
||||
dictionary["LICHECK"] = "licheck.exe";
|
||||
|
||||
const QString licenseChecker =
|
||||
QDir::toNativeSeparators(sourcePath + "/bin/licheck.exe");
|
||||
|
||||
if (QFile::exists(licenseChecker)) {
|
||||
const QString qMakeSpec =
|
||||
QDir::toNativeSeparators(dictionary.value("QMAKESPEC"));
|
||||
const QString xQMakeSpec =
|
||||
QDir::toNativeSeparators(dictionary.value("XQMAKESPEC"));
|
||||
|
||||
QString command = QString("%1 %2 %3 %4 %5 %6")
|
||||
.arg(licenseChecker,
|
||||
dictionary.value("LICENSE_CONFIRMED", "no"),
|
||||
QDir::toNativeSeparators(sourcePath),
|
||||
QDir::toNativeSeparators(buildPath),
|
||||
qMakeSpec, xQMakeSpec);
|
||||
|
||||
int returnValue = 0;
|
||||
QString licheckOutput = Environment::execute(command, &returnValue);
|
||||
|
||||
if (returnValue) {
|
||||
dictionary["DONE"] = "error";
|
||||
} else {
|
||||
foreach (const QString &var, licheckOutput.split('\n'))
|
||||
dictionary[var.section('=', 0, 0).toUpper()] = var.section('=', 1, 1);
|
||||
dictionary["LICENSE_CONFIRMED"] = "yes";
|
||||
}
|
||||
} else {
|
||||
cout << endl << "Error: Could not find licheck.exe" << endl
|
||||
<< "Try re-installing." << endl << endl;
|
||||
dictionary["DONE"] = "error";
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _TOOLS_H_
|
||||
#define _TOOLS_H_
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qmap.h>
|
||||
|
||||
class Tools
|
||||
{
|
||||
public:
|
||||
static void checkLicense(QMap<QString,QString> &dictionary,
|
||||
const QString &sourcePath, const QString &buildPath);
|
||||
};
|
||||
|
||||
#endif // _TOOLS_H_
|
||||
|
Loading…
Reference in New Issue
Block a user