Qmake: Introduce and use QMAKE_NULL_DEVICE variable

Task-number: QTBUG-62985
Change-Id: If1a4cabd54df7d69be1a580dc120f75d6c6b2092
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
Orgad Shaneh 2017-09-24 08:26:30 +03:00 committed by Orgad Shaneh
parent bd72ead4d1
commit b4e9cb4c29
5 changed files with 12 additions and 35 deletions

View File

@ -1,10 +1,5 @@
win32 {
CMAKE_VERSION = $$system(cmake --version 2>NUL, lines)
} else {
CMAKE_VERSION = $$system(cmake --version 2>/dev/null, lines)
}
CMAKE_VERSION = $$system(cmake --version 2>$$QMAKE_NULL_DEVICE, lines)
CMAKE_VERSION = $$member(CMAKE_VERSION, 0, 0)
check.commands =
@ -15,12 +10,7 @@ isEmpty(CMAKE_VERSION) {
return()
}
win32 {
CTEST_VERSION = $$system(ctest --version 2>NUL)
} else {
CTEST_VERSION = $$system(ctest --version 2>/dev/null)
}
CTEST_VERSION = $$system(ctest --version 2>$$QMAKE_NULL_DEVICE)
isEmpty(CTEST_VERSION) {
message("ctest executable not found. Not running CMake unit tests")
return()

View File

@ -291,10 +291,7 @@ defineReplace(pkgConfigExecutable) {
}
}
equals(QMAKE_HOST.os, Windows): \
PKG_CONFIG += 2> NUL
else: \
PKG_CONFIG += 2> /dev/null
PKG_CONFIG += 2> $$QMAKE_NULL_DEVICE
return($$PKG_CONFIG)
}

View File

@ -82,6 +82,7 @@ equals(MAKEFILE_GENERATOR, MSBUILD) \
QMAKE_MKDIR = mkdir # legacy
QMAKE_MKDIR_CMD = if not exist %1 mkdir %1 & if not exist %1 exit 1
QMAKE_STREAM_EDITOR = $(QMAKE) -install sed
QMAKE_NULL_DEVICE = NUL
QMAKE_INSTALL_FILE = copy /y
QMAKE_INSTALL_PROGRAM = copy /y
} else {
@ -101,6 +102,7 @@ equals(MAKEFILE_GENERATOR, MSBUILD) \
QMAKE_MKDIR = mkdir -p # legacy
QMAKE_MKDIR_CMD = test -d %1 || mkdir -p %1
QMAKE_STREAM_EDITOR = sed
QMAKE_NULL_DEVICE = /dev/null
equals(QMAKE_HOST.os, Windows) {
MINGW_IN_SHELL = 1 # legacy

View File

@ -32,15 +32,11 @@ isEmpty($${target_prefix}.INCDIRS) {
# Get default include and library paths from compiler
#
gcc {
!equals(QMAKE_HOST.os, Windows) {
cmd_prefix = "LC_ALL=C"
cmd_suffix = "</dev/null >/dev/null"
null_file = /dev/null
} else {
cmd_suffix = "<$$QMAKE_NULL_DEVICE >$$QMAKE_NULL_DEVICE"
equals(QMAKE_HOST.os, Windows): \
cmd_prefix = "set LC_ALL=C&"
cmd_suffix = "<NUL >NUL"
null_file = NUL
}
else: \
cmd_prefix = "LC_ALL=C"
cxx_flags = $$QMAKE_CXXFLAGS
@ -59,7 +55,7 @@ isEmpty($${target_prefix}.INCDIRS) {
rim_qcc: \
# Need the cc1plus and ld command lines to pick up the paths
cxx_flags += $$QMAKE_LFLAGS_SHLIB -o $$null_file -v
cxx_flags += $$QMAKE_LFLAGS_SHLIB -o $$QMAKE_NULL_DEVICE -v
else: darwin:clang: \
# Need to link to pick up library paths
cxx_flags += $$QMAKE_LFLAGS_SHLIB -o /dev/null -v -Wl,-v
@ -175,9 +171,7 @@ defineReplace(qtVariablesFromMSVC) {
}
defineReplace(qtVariablesFromGCC) {
null_device = /dev/null
equals(QMAKE_HOST.os, Windows): null_device = NUL
ret = $$system("$$1 -E $$system_quote($$PWD/data/macros.cpp) <$$null_device 2>$$null_device", lines, ec)
ret = $$system("$$1 -E $$system_quote($$PWD/data/macros.cpp) <$$QMAKE_NULL_DEVICE 2>$$QMAKE_NULL_DEVICE", lines, ec)
!equals(ec, 0): qtCompilerErrror($$1)
return($$ret)
}

View File

@ -36,12 +36,6 @@
#include <stdlib.h>
#include <time.h>
#ifdef Q_OS_WIN
#define NULL_DEVICE "NUL"
#else
#define NULL_DEVICE "/dev/null"
#endif
QT_BEGIN_NAMESPACE
MingwMakefileGenerator::MingwMakefileGenerator() : Win32MakefileGenerator()
@ -329,7 +323,7 @@ void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t)
if(!project->isEmpty("QMAKE_PRE_LINK"))
t << "\n\t" <<var("QMAKE_PRE_LINK");
if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
t << "\n\t-$(DEL_FILE) $(DESTDIR_TARGET) 2>" NULL_DEVICE;
t << "\n\t-$(DEL_FILE) $(DESTDIR_TARGET) 2>$$QMAKE_NULL_DEVICE";
if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) {
t << "\n\t$(LIB) $(DESTDIR_TARGET) " << objectsLinkLine << " " ;
} else {