Skip to content

Commit

Permalink
move all target spec handling to qmake-based configure system
Browse files Browse the repository at this point in the history
we pull this feat off by booting configure with a dummy spec. the proper
spec gets loaded subsequently.

note that it was necessary to move the cache loading after processing
the early checks (from which the spec handling is triggered). this is
just fine, as the cache is needed only by tests, which are forbidden at
this stage by definition.

Change-Id: I5120e25a8bf05fb8cc5485fd93cf6387301089aa
Reviewed-by: Jake Petroules <[email protected]>
  • Loading branch information
ossilator committed Dec 13, 2016
1 parent 8861b82 commit ab0cc30
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 155 deletions.
99 changes: 2 additions & 97 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,6 @@ getQMakeConf()
getSingleQMakeVariable "$1" "$specvals"
}

resolveDeviceMkspec()
{
result=$(find "$relpath/mkspecs/devices/" -type d -name "*$1*" | sed "s,^$relpath/mkspecs/,,")
match_count=$(echo "$result" | wc -w)
if [ "$match_count" -gt 1 ]; then
echo >&2 "Error: Multiple matches for device '$1'. Candidates are:"
tabbed_result=$(echo "$result" | sed 's,^, ,')
echo >&2 "$tabbed_result"
echo "undefined"
elif [ "$match_count" -eq 0 ]; then
echo >&2 "Error: No device matching '$1'"
echo "undefined"
else
echo "$result"
fi
}

#-------------------------------------------------------------------------------
# operating system detection
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -366,14 +349,6 @@ unset QTDIR

# initalize internal variables
CFG_RELEASE_TOOLS=no

XPLATFORM= # This seems to be the QMAKESPEC, like "linux-g++"
XPLATFORM_MAC=no # Whether target platform is macOS, iOS, tvOS, or watchOS
XPLATFORM_IOS=no # Whether target platform is iOS
XPLATFORM_TVOS=no # Whether target platform is tvOS
XPLATFORM_WATCHOS=no # Whether target platform is watchOS
XPLATFORM_ANDROID=no
XPLATFORM_MINGW=no # Whether target platform is MinGW (win32-g++*)
PLATFORM=
OPT_SHADOW=maybe
OPT_VERBOSE=no
Expand Down Expand Up @@ -503,13 +478,6 @@ while [ "$#" -gt 0 ]; do
platform)
PLATFORM="$VAL"
;;
xplatform)
XPLATFORM="$VAL"
;;
device)
XPLATFORM=`resolveDeviceMkspec $VAL`
[ "$XPLATFORM" = "undefined" ] && exit 101
;;
optimized-qmake|optimized-tools)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_RELEASE_TOOLS="$VAL"
Expand Down Expand Up @@ -711,44 +679,6 @@ if [ -z "$PLATFORM" ]; then
esac
fi

[ -z "$XPLATFORM" ] && XPLATFORM="$PLATFORM"

case "$XPLATFORM" in
*win32-g++*)
XPLATFORM_MINGW=yes
;;
*qnx-*)
;;
*haiku-*)
;;
*ios*)
XPLATFORM_MAC=yes
XPLATFORM_IOS=yes
;;
*tvos*)
XPLATFORM_MAC=yes
XPLATFORM_TVOS=yes
;;
*watchos*)
XPLATFORM_MAC=yes
XPLATFORM_WATCHOS=yes
;;
*macx*)
XPLATFORM_MAC=yes
;;
*integrity*)
;;
# XPLATFORM_ANDROID should not be set for unsupported/android-g++
*unsupported*)
;;
*android-g++*)
XPLATFORM_ANDROID=g++
;;
*android-clang*)
XPLATFORM_ANDROID=clang
;;
esac

#-------------------------------------------------------------------------------
# command line and environment validation
#-------------------------------------------------------------------------------
Expand All @@ -758,14 +688,9 @@ if [ -d "$PLATFORM" ]; then
else
QMAKESPEC="$relpath/mkspecs/${PLATFORM}"
fi
if [ -d "$XPLATFORM" ]; then
XQMAKESPEC="$XPLATFORM"
else
XQMAKESPEC="$relpath/mkspecs/${XPLATFORM}"
fi

if [ "$BUILD_ON_MAC" = "yes" ]; then
if [ `basename $QMAKESPEC` = "macx-xcode" ] || [ `basename $XQMAKESPEC` = "macx-xcode" ]; then
if [ `basename $QMAKESPEC` = "macx-xcode" ]; then
echo >&2
echo " Platform 'macx-xcode' should not be used when building Qt/Mac." >&2
echo " Please build Qt/Mac with 'macx-clang' or 'macx-g++', then use" >&2
Expand All @@ -787,26 +712,6 @@ if [ '!' -d "$QMAKESPEC" ]; then
echo
exit 2
fi
if [ '!' -d "$XQMAKESPEC" ]; then
echo
echo " The specified system/compiler is not supported:"
echo
echo " $XQMAKESPEC"
echo
echo " Please see the README file for a complete list."
echo
exit 2
fi
if [ '!' -f "${XQMAKESPEC}/qplatformdefs.h" ]; then
echo
echo " The specified system/compiler port is not complete:"
echo
echo " $XQMAKESPEC/qplatformdefs.h"
echo
echo " Please information use the contact form at http://www.qt.io/contact-us"
echo
exit 2
fi

#-------------------------------------------------------------------------------
# build tree initialization
Expand Down Expand Up @@ -980,7 +885,7 @@ cat > "$QTCONFFILE" <<EOF
[EffectivePaths]
Prefix=..
[Paths]
TargetSpec=$XPLATFORM
TargetSpec=dummy
HostSpec=$PLATFORM
EOF
if [ x"$relpath" != x"$outpath" ]; then
Expand Down
7 changes: 6 additions & 1 deletion configure.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@

"features": {
"prepare": {
"output": [ "prepareOptions", "preparePaths" ]
"output": [ "prepareSpec", "prepareOptions", "preparePaths" ]
},
"machineTuple": {
"condition": "!config.linux || config.android || tests.machineTuple",
Expand Down Expand Up @@ -983,6 +983,11 @@
},

"earlyReport": [
{
"type": "fatal",
"condition": "input.xplatform != '' && input.device != ''",
"message": "Cannot specify both -xplatform and -device."
},
{
"condition": "!features.prepare",
"comment": "This is not an actual report - instead, it activates the early setup."
Expand Down
33 changes: 32 additions & 1 deletion configure.pri
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,37 @@ defineTest(reloadSpec) {
}
}

defineTest(qtConfOutput_prepareSpec) {
device = $$eval(config.input.device)
!isEmpty(device) {
devices = $$files($$[QT_HOST_DATA/src]/mkspecs/devices/*$$device*)
isEmpty(devices): \
qtConfFatalError("No device matching '$$device'.")
!count(devices, 1) {
err = "Multiple matches for device '$$device'. Candidates are:"
for (d, devices): \
err += " $$basename(d)"
qtConfFatalError($$err)
}
XSPEC = $$relative_path($$devices, $$[QT_HOST_DATA/src]/mkspecs)
}
xspec = $$eval(config.input.xplatform)
!isEmpty(xspec) {
!exists($$[QT_HOST_DATA/src]/mkspecs/$$xspec/qmake.conf): \
qtConfFatalError("Invalid target platform '$$xspec'.")
XSPEC = $$xspec
}
isEmpty(XSPEC): \
XSPEC = $$[QMAKE_SPEC]
export(XSPEC)
QMAKESPEC = $$[QT_HOST_DATA/src]/mkspecs/$$XSPEC
export(QMAKESPEC)

# deviceOptions() below contains conditionals coming form the spec,
# so this cannot be delayed for a batch reload.
reloadSpec()
}

defineTest(qtConfOutput_prepareOptions) {
$${currentConfig}.output.devicePro += \
$$replace(config.input.device-option, "^([^=]+) *= *(.*)$", "\\1 = \\2")
Expand Down Expand Up @@ -649,7 +680,7 @@ defineReplace(printHostPaths) {
$$printInstallPath(HostLibraries, hostlibdir, lib) \
$$printInstallPath(HostData, hostdatadir, .) \
"Sysroot=$$config.input.sysroot" \
"TargetSpec=$$[QMAKE_XSPEC]" \
"TargetSpec=$$XSPEC" \
"HostSpec=$$[QMAKE_SPEC]"
return($$ret)
}
Expand Down
8 changes: 8 additions & 0 deletions mkspecs/dummy/qmake.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Minimal qmake configuration qt_configure.prf is run with.
#

# Make spec_post.prf happy.
MAKEFILE_GENERATOR = DUMMY
QMAKE_PLATFORM = dummy_platform
QMAKE_COMPILER = dummy_compiler
16 changes: 8 additions & 8 deletions mkspecs/features/qt_configure.prf
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,14 @@ QMAKE_SAVED_ARGS = $$QMAKE_EXTRA_ARGS
QMAKE_REDO_CONFIG = false
qtConfParseCommandLine()

for (currentConfig, allConfigs) {
qtConfSetModuleName()
qtConfSetupModuleOutputs()
# do early checks, mainly to validate the command line
qtConfProcessEarlyChecks()
}
qtConfCheckErrors()

!isEmpty(_QMAKE_SUPER_CACHE_): \
QMAKE_CONFIG_CACHE = $$dirname(_QMAKE_SUPER_CACHE_)/config.cache
else: \
Expand All @@ -1790,14 +1798,6 @@ QMAKE_CONFIG_LOG = $$OUT_PWD/config.log
!equals(QMAKE_CONFIG_CACHE_USE, all): \
write_file($$QMAKE_CONFIG_LOG, "")

for (currentConfig, allConfigs) {
qtConfSetModuleName()
qtConfSetupModuleOutputs()
# do early checks, mainly to validate the command line
qtConfProcessEarlyChecks()
}
qtConfCheckErrors()

CONFIG += qt_conf_tests_allowed
logn()
logn("Running configuration tests...")
Expand Down
49 changes: 1 addition & 48 deletions tools/configure/configureapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,13 @@ void Configure::parseCmdLine()
}
}

// Then look for XQMAKESPEC
bool isDeviceMkspec = false;
for (int j = 0 ; j < argCount; ++j)
{
if ((configCmdLine.at(j) == "-xplatform") || (configCmdLine.at(j) == "-device")) {
isDeviceMkspec = (configCmdLine.at(j) == "-device");
++j;
if (j == argCount)
break;
dictionary["XQMAKESPEC"] = configCmdLine.at(j);
break;
}
}

for (; i<configCmdLine.size(); ++i) {
if (configCmdLine.at(i) == "-platform") {
++i;
if (i == argCount)
break;
dictionary[ "QMAKESPEC" ] = configCmdLine.at(i);
dictionary[ "QMAKESPEC_FROM" ] = "commandline";
} else if (configCmdLine.at(i) == "-xplatform"
|| configCmdLine.at(i) == "-device") {
++i;
// do nothing
}

else if (configCmdLine.at(i) == "-no-syncqt")
Expand Down Expand Up @@ -207,34 +189,6 @@ void Configure::parseCmdLine()
dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
}
}

if (isDeviceMkspec) {
const QStringList devices = mkspecs.filter("devices/", Qt::CaseInsensitive);
const QStringList family = devices.filter(dictionary["XQMAKESPEC"], Qt::CaseInsensitive);

if (family.isEmpty()) {
dictionary[ "DONE" ] = "error";
cout << "Error: No device matching '" << dictionary["XQMAKESPEC"] << "'." << endl;
} else if (family.size() > 1) {
dictionary[ "DONE" ] = "error";

cout << "Error: Multiple matches for device '" << dictionary["XQMAKESPEC"] << "'. Candidates are:" << endl;

foreach (const QString &device, family)
cout << "\t* " << device << endl;
} else {
Q_ASSERT(family.size() == 1);
dictionary["XQMAKESPEC"] = family.at(0);
}

} else {
// Ensure that -spec (XQMAKESPEC) exists in the mkspecs folder as well
if (dictionary.contains("XQMAKESPEC") &&
!mkspecs.contains(dictionary["XQMAKESPEC"], Qt::CaseInsensitive)) {
dictionary[ "DONE" ] = "error";
cout << "Invalid option \"" << dictionary["XQMAKESPEC"] << "\" for -xplatform." << endl;
}
}
}

void Configure::generateHeaders()
Expand Down Expand Up @@ -361,8 +315,7 @@ void Configure::buildQmake()
confStream << "[EffectivePaths]" << endl
<< "Prefix=.." << endl
<< "[Paths]" << endl
<< "TargetSpec=" << (dictionary.contains("XQMAKESPEC")
? dictionary["XQMAKESPEC"] : dictionary["QMAKESPEC"]) << endl
<< "TargetSpec=dummy" << endl
<< "HostSpec=" << dictionary["QMAKESPEC"] << endl;
if (sourcePath != buildPath)
confStream << "[EffectiveSourcePaths]" << endl
Expand Down

0 comments on commit ab0cc30

Please sign in to comment.