diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-05-25 17:14:31 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-05-30 09:08:56 +0000 |
commit | c2fa20edac0622d44211d0ef58ff433130c1a683 (patch) | |
tree | cab1e47a90583fd4a578b46ea74768738b766220 /tests/auto/blackbox/testdata/loadablemodule | |
parent | 6f09ae52a21ec34b0d20e1c367ef2aa7807a0bdd (diff) |
Remove unnecessary Qt dependencies in several blackbox tests
The primary reason was simply for export macros from qglobal.h...
Change-Id: I760c67fe1cec26daa459751d136d44e812fd56b5
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/auto/blackbox/testdata/loadablemodule')
3 files changed, 46 insertions, 14 deletions
diff --git a/tests/auto/blackbox/testdata/loadablemodule/exported.h b/tests/auto/blackbox/testdata/loadablemodule/exported.h index 7745b5c97..24eb8b1a0 100644 --- a/tests/auto/blackbox/testdata/loadablemodule/exported.h +++ b/tests/auto/blackbox/testdata/loadablemodule/exported.h @@ -26,8 +26,12 @@ ** ****************************************************************************/ -#include <QtCore/QtGlobal> +#if defined(_WIN32) || defined(WIN32) +# define EXPORT __declspec(dllexport) +#else +# define EXPORT __attribute__((visibility("default"))) +#endif extern "C" { - Q_DECL_EXPORT int foo(); + EXPORT int foo(); } diff --git a/tests/auto/blackbox/testdata/loadablemodule/loadablemodule.qbs b/tests/auto/blackbox/testdata/loadablemodule/loadablemodule.qbs index f50442681..0fc8de8ca 100644 --- a/tests/auto/blackbox/testdata/loadablemodule/loadablemodule.qbs +++ b/tests/auto/blackbox/testdata/loadablemodule/loadablemodule.qbs @@ -4,7 +4,6 @@ Project { LoadableModule { Depends { name: "cpp" } Depends { name: "bundle" } - Depends { name: "Qt.core" } bundle.isBundle: false name: "CoolPlugIn" files: ["exported.cpp", "exported.h"] @@ -17,13 +16,19 @@ Project { CppApplication { Depends { name: "cpp" } - Depends { name: "CoolPlugIn" } + Depends { name: "CoolPlugIn"; cpp.link: false } Depends { name: "bundle" } - Depends { name: "Qt.core" } bundle.isBundle: false name: "CoolApp" files: ["main.cpp"] + cpp.dynamicLibraries: [qbs.targetOS.contains("windows") ? "kernel32" : "dl"] + + Properties { + condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("darwin") + cpp.rpaths: ["$ORIGIN"] + } + Group { fileTagsFilter: product.type qbs.install: true diff --git a/tests/auto/blackbox/testdata/loadablemodule/main.cpp b/tests/auto/blackbox/testdata/loadablemodule/main.cpp index 259d2bb76..442480442 100644 --- a/tests/auto/blackbox/testdata/loadablemodule/main.cpp +++ b/tests/auto/blackbox/testdata/loadablemodule/main.cpp @@ -49,16 +49,39 @@ ** ****************************************************************************/ -#include <QtCore/QDebug> -#include <QtCore/QLibrary> +#include <iostream> + +#ifdef _WIN32 +#include <windows.h> +#define PREFIX "" +#define SUFFIX ".dll" +#define dlopen(path, mode) LoadLibraryA(path) +#define dlsym(handle, symbol) GetProcAddress(handle, symbol) +#define dlclose(handle) FreeLibrary(handle) +#elif defined(__APPLE__) +#define PREFIX "" +#define SUFFIX ".bundle" +#else +#define PREFIX "lib" +#define SUFFIX ".so" +#endif + +#ifndef _WIN32 +#include <dlfcn.h> +#endif int main() { - QLibrary lib("CoolPlugIn"); - if (lib.load()) { - QFunctionPointer fptr = lib.resolve("foo"); - if (fptr) { - qDebug() << "foo =" << ((int (*)(void))fptr)(); - } + auto lib = dlopen(PREFIX "CoolPlugIn" SUFFIX, RTLD_LAZY); + if (lib) { + auto fptr = dlsym(lib, "foo"); + if (fptr) + std::cout << "foo = " << ((int (*)(void))fptr)() << std::endl; + else + std::cout << "function foo not found in CoolPlugIn" << std::endl; + dlclose(lib); + return fptr ? 0 : 1; + } else { + std::cout << "CoolPlugIn not loaded" << std::endl; } - return 0; + return 1; } |