Skip to content

Commit

Permalink
Qmake: Introduce and use QMAKE_NULL_DEVICE variable
Browse files Browse the repository at this point in the history
Task-number: QTBUG-62985
Change-Id: If1a4cabd54df7d69be1a580dc120f75d6c6b2092
Reviewed-by: Oswald Buddenhagen <[email protected]>
  • Loading branch information
orgads committed Sep 25, 2017
1 parent bd72ead commit b4e9cb4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 35 deletions.
14 changes: 2 additions & 12 deletions mkspecs/features/ctest_testcase_common.prf
Original file line number Diff line number Diff line change
@@ -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 =
Expand All @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions mkspecs/features/qt_functions.prf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions mkspecs/features/spec_post.prf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
18 changes: 6 additions & 12 deletions mkspecs/features/toolchain.prf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 1 addition & 7 deletions qmake/generators/win32/mingw_make.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b4e9cb4

Please sign in to comment.