diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2018-07-13 18:33:17 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2018-12-19 19:21:54 +0000 |
commit | 6b39d51a2c39569f984ef90e905bdf43958f5431 (patch) | |
tree | 72b19defd09a532bb2664d4973ad5989c6092e7c /mkspecs/features | |
parent | a8207699ce282cdcaa9423374fdad20a63897d25 (diff) |
configure: enable sharing of inlined source code between tests
this is implemented by means of (multiple) inheritance, which applies
specifically only to the inlined source and header list, but not to
library sources or dependencies.
Change-Id: I8f1d5b34d1d2d12e39225dc50357ad6ec648c6b6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'mkspecs/features')
-rw-r--r-- | mkspecs/features/qt_configure.prf | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 83802cffca..72bbd42fa5 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -592,6 +592,16 @@ defineTest(qtConfResolvePathLibs) { return($$ret) } +defineReplace(qtConfGetTestSourceList) { + result = + !isEmpty($${1}.test.inherit) { + base = $$section(1, ., 0, -2) + for (i, $${1}.test.inherit): \ + result += $$qtConfGetTestSourceList($${base}.$$i) + } + return($$result $$1) +} + defineReplace(qtConfGetTestIncludes) { defined($${1}._KEYS_, var) { 1st = $$first($${1}._KEYS_) @@ -637,7 +647,10 @@ defineTest(qtConfResolvePathIncs) { # thus make the code below work. return($$ret) } - hdrs = $$qtConfGetTestIncludes($${3}.headers) + tests = $$qtConfGetTestSourceList($$3) + hdrs = + for (test, tests): \ + hdrs += $$qtConfGetTestIncludes($${test}.headers) for (hdr, hdrs) { h = $$qtConfFindInPathList($$hdr, $$2 $$EXTRA_INCLUDEPATH $$QMAKE_DEFAULT_INCDIRS) isEmpty(h) { @@ -1109,10 +1122,14 @@ defineTest(qtConfTestPrepare_compile) { } defineTest(qtConfPrepareCompileTestSource) { - test_dir = $$3 + test_dir = $$2 - test_lang = $$eval($${1}.lang) - isEmpty(test_lang): test_lang = "c++" + tests = $$qtConfGetTestSourceList($$1) + + test_lang = "c++" + for (test, tests): \ + test_lang += $$eval($${test}.test.lang) + test_lang = $$last(test_lang) # Last non-empty, that is. equals(test_lang, "c++"): suffix = "cpp" else: equals(test_lang, "c"): suffix = "c" @@ -1123,25 +1140,30 @@ defineTest(qtConfPrepareCompileTestSource) { # Create source code contents = "/* Generated by configure */" # Custom code before includes - for (ent, $$qtConfScalarOrList($${1}.head)): \ - contents += $$ent + for (test, tests): \ + for (ent, $$qtConfScalarOrList($${test}.test.head)): \ + contents += $$ent # Includes - hdrs = $$qtConfGetTestIncludes($${1}.include) - isEmpty(hdrs): \ - hdrs = $$qtConfGetTestIncludes($$2) - for (ent, hdrs): \ - contents += "$${LITERAL_HASH}include <$$ent>" + for (test, tests) { + hdrs = $$qtConfGetTestIncludes($${test}.test.include) + isEmpty(hdrs): \ + hdrs = $$qtConfGetTestIncludes($${test}.headers) + for (ent, hdrs): \ + contents += "$${LITERAL_HASH}include <$$ent>" + } # Custom code after includes - for (ent, $$qtConfScalarOrList($${1}.tail)): \ - contents += $$ent + for (test, tests): \ + for (ent, $$qtConfScalarOrList($${test}.test.tail)): \ + contents += $$ent # And finally the custom code inside main() contents += \ "int main(int argc, char **argv)" \ "{" \ " (void)argc; (void)argv;" \ " /* BEGIN TEST: */" - for (ent, $$qtConfScalarOrList($${1}.main)): \ - contents += " $$ent" + for (test, tests): \ + for (ent, $$qtConfScalarOrList($${test}.test.main)): \ + contents += " $$ent" contents += \ " /* END TEST */" \ " return 0;" \ @@ -1151,8 +1173,9 @@ defineTest(qtConfPrepareCompileTestSource) { # Create stub .pro file contents = "SOURCES = main.$$suffix" # Custom project code - for (ent, $$qtConfScalarOrList($${1}.qmake)): \ - contents += $$ent + for (test, tests): \ + for (ent, $$qtConfScalarOrList($${test}.test.qmake)): \ + contents += $$ent write_file($$test_dir/$$basename(test_dir).pro, contents)|error() } @@ -1165,7 +1188,7 @@ defineTest(qtConfTest_compile) { isEmpty(test) { test_dir = $$test_base_out_dir/$$section(1, ".", -1) test_out_dir = $$test_dir - qtConfPrepareCompileTestSource($${1}.test, $${1}.headers, $$test_dir) + qtConfPrepareCompileTestSource($$1, $$test_dir) } else { test_dir = $$QMAKE_CONFIG_TESTS_DIR/$$test test_out_dir = $$test_base_out_dir/$$test |