Skip to content

Commit

Permalink
Run license checker in qmake
Browse files Browse the repository at this point in the history
Check for a valid license not only in configure, but also in qmake.
To limit the runtime overhead we cache the day of the last run in
a .stash file. This allows us to run licheck only for the top-level
qmake call, and only once per day.

This requires an updated licheck executable that supports the new
check mode.

[ChangeLog][Tools][qmake] For commercial builds, qmake now checks for
a valid Qt license. This requires setting up a Qt Account (or
.qt-license file) on the development machine.

Change-Id: I2c2a05a4602cc661560568b76ddf520cb8134769
Reviewed-by: Oswald Buddenhagen <[email protected]>
  • Loading branch information
Kai Koehne committed May 27, 2015
1 parent 40327b6 commit 6366040
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -6776,9 +6776,14 @@ QT_LIBINFIX = $QT_LIBINFIX
QT_NAMESPACE = $QT_NAMESPACE
QT_EDITION = $Edition
EOF

if [ "$Edition" != "OpenSource" ] && [ "$Edition" != "Preview" ]; then
echo "QT_LICHECK = $Licheck" >> "$QTCONFIG.tmp"
echo "QT_RELEASE_DATE = $ReleaseDate" >> "$QTCONFIG.tmp"
fi
echo >> "$QTCONFIG.tmp"

if [ "$CFG_SHARED" = "no" ]; then
echo "QT_DEFAULT_QPA_PLUGIN = q$QT_QPA_DEFAULT_PLATFORM" >> "$QTCONFIG.tmp"
echo >> "$QTCONFIG.tmp"
Expand Down
15 changes: 15 additions & 0 deletions mkspecs/features/default_pre.prf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,18 @@ CONFIG = \
lex yacc debug exceptions depend_includepath \
testcase_targets import_plugins import_qpa_plugin \
$$CONFIG

!build_pass:defined(QT_EDITION, var):!equals(QT_EDITION, "OpenSource"):!equals(QT_EDITION, "Preview") {
#
# call license checker (but cache result for one day)
#
today = $$section(_DATE_, " ", 0, 2)
!isEqual(QMAKE_LICHECK_TIMESTAMP, $$today) {
!system("$$system_quote($$system_path($$[QT_HOST_BINS/src]/$$QT_LICHECK)) check" \
"$$QT_RELEASE_DATE $$[QMAKE_SPEC] $$[QMAKE_XSPEC]"): \
error("License check failed! Giving up ...")

cache(QMAKE_LICHECK_TIMESTAMP, set stash, today)
}
unset(today)
}
5 changes: 5 additions & 0 deletions qtbase.pro
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ equals(QMAKE_HOST.os, Windows) {
}
INSTALLS += qmake

#licheck
licheck.path = $$[QT_HOST_BINS]
licheck.files = $$PWD/bin/$$QT_LICHECK
exists($$licheck.files): INSTALLS += licheck

#syncqt
syncqt.path = $$[QT_HOST_BINS]
syncqt.files = $$PWD/bin/syncqt.pl
Expand Down
5 changes: 5 additions & 0 deletions tools/configure/configureapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3463,6 +3463,11 @@ void Configure::generateQConfigPri()
configStream << endl
<< "QT_EDITION = " << dictionary["EDITION"] << endl;

if (dictionary["EDITION"] != "OpenSource" && dictionary["EDITION"] != "Preview") {
configStream << "QT_LICHECK = " << dictionary["LICHECK"] << endl;
configStream << "QT_RELEASE_DATE = " << dictionary["RELEASEDATE"] << endl;
}

if (!dictionary["CFG_SYSROOT"].isEmpty() && dictionary["CFG_GCC_SYSROOT"] == "yes") {
configStream << endl
<< "# sysroot" << endl
Expand Down
2 changes: 2 additions & 0 deletions tools/configure/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary,
return;
}

dictionary["LICHECK"] = "licheck.exe";

const QString licenseChecker =
QDir::toNativeSeparators(sourcePath + "/bin/licheck.exe");

Expand Down

0 comments on commit 6366040

Please sign in to comment.