qmake: add $$read_registry() function
Change-Id: I7f9f17e0f44c273e4754d1decc92a8594cad8658 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
fff59911a3
commit
f89ac0101a
@ -192,6 +192,9 @@ qmakeevaluator.o: $(QMKLIBSRC)/qmakeevaluator.cpp
|
|||||||
qmakebuiltins.o: $(QMKLIBSRC)/qmakebuiltins.cpp
|
qmakebuiltins.o: $(QMKLIBSRC)/qmakebuiltins.cpp
|
||||||
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
registry.o: $(QMKLIBSRC)/registry.cpp
|
||||||
|
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
||||||
|
|
||||||
project.o: $(QMKSRC)/project.cpp
|
project.o: $(QMKSRC)/project.cpp
|
||||||
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
||||||
|
|
||||||
@ -225,9 +228,6 @@ unixmake.o: $(QMKSRC)/generators/unix/unixmake.cpp
|
|||||||
unixmake2.o: $(QMKSRC)/generators/unix/unixmake2.cpp
|
unixmake2.o: $(QMKSRC)/generators/unix/unixmake2.cpp
|
||||||
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
||||||
|
|
||||||
registry.o: $(QMKSRC)/generators/win32/registry.cpp
|
|
||||||
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
|
||||||
|
|
||||||
winmakefile.o: $(QMKSRC)/generators/win32/winmakefile.cpp
|
winmakefile.o: $(QMKSRC)/generators/win32/winmakefile.cpp
|
||||||
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
||||||
|
|
||||||
|
@ -18,4 +18,4 @@ QTSRCS = \
|
|||||||
$(SOURCE_PATH)/src/corelib/io/qsettings_win.cpp \
|
$(SOURCE_PATH)/src/corelib/io/qsettings_win.cpp \
|
||||||
$(SOURCE_PATH)/src/corelib/tools/qlocale_win.cpp \
|
$(SOURCE_PATH)/src/corelib/tools/qlocale_win.cpp \
|
||||||
$(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp \
|
$(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp \
|
||||||
$(SOURCE_PATH)/qmake/generators/win32/registry.cpp
|
$(SOURCE_PATH)/qmake/library/registry.cpp
|
||||||
|
@ -3258,6 +3258,17 @@
|
|||||||
Returns the \c string with every special regular expression character
|
Returns the \c string with every special regular expression character
|
||||||
escaped with a backslash. This function is a wrapper around QRegExp::escape.
|
escaped with a backslash. This function is a wrapper around QRegExp::escape.
|
||||||
|
|
||||||
|
\section2 read_registry(tree, key[, flag])
|
||||||
|
|
||||||
|
Returns the value of registry key \c key inside the tree \c tree.
|
||||||
|
|
||||||
|
Only the trees \c HKEY_CURRENT_USER (\c HKCU) and \c HKEY_LOCAL_MACHINE
|
||||||
|
(\c HKLM) are supported.
|
||||||
|
|
||||||
|
The \c flag may be \c WOW64_32KEY (\c 32) or \c WOW64_64KEY (\c 64).
|
||||||
|
|
||||||
|
\note This function is available only on Windows hosts.
|
||||||
|
|
||||||
\section2 relative_path(filePath[, base])
|
\section2 relative_path(filePath[, base])
|
||||||
|
|
||||||
Returns the path to \c filePath relative to \c base.
|
Returns the path to \c filePath relative to \c base.
|
||||||
|
@ -52,6 +52,9 @@
|
|||||||
# include <qthreadpool.h>
|
# include <qthreadpool.h>
|
||||||
#endif
|
#endif
|
||||||
#include <qversionnumber.h>
|
#include <qversionnumber.h>
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
# include <registry_p.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -93,7 +96,7 @@ enum ExpandFunc {
|
|||||||
E_UPPER, E_LOWER, E_TITLE, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE,
|
E_UPPER, E_LOWER, E_TITLE, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE,
|
||||||
E_REPLACE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS,
|
E_REPLACE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS,
|
||||||
E_SHADOWED, E_ABSOLUTE_PATH, E_RELATIVE_PATH, E_CLEAN_PATH,
|
E_SHADOWED, E_ABSOLUTE_PATH, E_RELATIVE_PATH, E_CLEAN_PATH,
|
||||||
E_SYSTEM_PATH, E_SHELL_PATH, E_SYSTEM_QUOTE, E_SHELL_QUOTE, E_GETENV
|
E_SYSTEM_PATH, E_SHELL_PATH, E_SYSTEM_QUOTE, E_SHELL_QUOTE, E_GETENV, E_READ_REGISTRY
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TestFunc {
|
enum TestFunc {
|
||||||
@ -190,6 +193,7 @@ void QMakeEvaluator::initFunctionStatics()
|
|||||||
{ "system_quote", E_SYSTEM_QUOTE, -1, 1, "arg" },
|
{ "system_quote", E_SYSTEM_QUOTE, -1, 1, "arg" },
|
||||||
{ "shell_quote", E_SHELL_QUOTE, -1, 1, "arg" },
|
{ "shell_quote", E_SHELL_QUOTE, -1, 1, "arg" },
|
||||||
{ "getenv", E_GETENV, 1, 1, "arg" },
|
{ "getenv", E_GETENV, 1, 1, "arg" },
|
||||||
|
{ "read_registry", E_READ_REGISTRY, 2, 3, "tree, key, [wow64]" },
|
||||||
};
|
};
|
||||||
statics.expands.reserve((int)(sizeof(expandInits)/sizeof(expandInits[0])));
|
statics.expands.reserve((int)(sizeof(expandInits)/sizeof(expandInits[0])));
|
||||||
for (unsigned i = 0; i < sizeof(expandInits)/sizeof(expandInits[0]); ++i)
|
for (unsigned i = 0; i < sizeof(expandInits)/sizeof(expandInits[0]); ++i)
|
||||||
@ -1214,6 +1218,40 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
|
|||||||
ret << ProString(m_option->getEnv(u1.str()));
|
ret << ProString(m_option->getEnv(u1.str()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
case E_READ_REGISTRY: {
|
||||||
|
HKEY tree;
|
||||||
|
const auto par = args.at(0);
|
||||||
|
if (!par.compare(QLatin1String("HKCU"), Qt::CaseInsensitive)
|
||||||
|
|| !par.compare(QLatin1String("HKEY_CURRENT_USER"), Qt::CaseInsensitive)) {
|
||||||
|
tree = HKEY_CURRENT_USER;
|
||||||
|
} else if (!par.compare(QLatin1String("HKLM"), Qt::CaseInsensitive)
|
||||||
|
|| !par.compare(QLatin1String("HKEY_LOCAL_MACHINE"), Qt::CaseInsensitive)) {
|
||||||
|
tree = HKEY_LOCAL_MACHINE;
|
||||||
|
} else {
|
||||||
|
evalError(fL1S("read_registry(): invalid or unsupported registry tree %1.")
|
||||||
|
.arg(par.toQStringView()));
|
||||||
|
goto allfail;
|
||||||
|
}
|
||||||
|
int flags = 0;
|
||||||
|
if (args.count() > 2) {
|
||||||
|
const auto opt = args.at(2);
|
||||||
|
if (opt == "32"
|
||||||
|
|| !opt.compare(QLatin1String("wow64_32key"), Qt::CaseInsensitive)) {
|
||||||
|
flags = KEY_WOW64_32KEY;
|
||||||
|
} else if (opt == "64"
|
||||||
|
|| !opt.compare(QLatin1String("wow64_64key"), Qt::CaseInsensitive)) {
|
||||||
|
flags = KEY_WOW64_64KEY;
|
||||||
|
} else {
|
||||||
|
evalError(fL1S("read_registry(): invalid option %1.")
|
||||||
|
.arg(opt.toQStringView()));
|
||||||
|
goto allfail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret << ProString(qt_readRegistryKey(tree, args.at(1).toQString(m_tmp1), flags));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
evalError(fL1S("Function '%1' is not implemented.").arg(func.toQStringView()));
|
evalError(fL1S("Function '%1' is not implemented.").arg(func.toQStringView()));
|
||||||
break;
|
break;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
CONFIG += testcase
|
CONFIG += testcase
|
||||||
TARGET = tst_qmakelib
|
TARGET = tst_qmakelib
|
||||||
QT = core testlib
|
QT = core testlib
|
||||||
|
win32: LIBS += -ladvapi32
|
||||||
|
|
||||||
INCLUDEPATH += ../../../../qmake/library
|
INCLUDEPATH += ../../../../qmake/library
|
||||||
VPATH += ../../../../qmake/library
|
VPATH += ../../../../qmake/library
|
||||||
@ -13,6 +14,7 @@ SOURCES += \
|
|||||||
parsertest.cpp \
|
parsertest.cpp \
|
||||||
evaltest.cpp \
|
evaltest.cpp \
|
||||||
ioutils.cpp \
|
ioutils.cpp \
|
||||||
|
registry.cpp \
|
||||||
proitems.cpp \
|
proitems.cpp \
|
||||||
qmakevfs.cpp \
|
qmakevfs.cpp \
|
||||||
qmakeparser.cpp \
|
qmakeparser.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user