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>
This commit is contained in:
parent
a8207699ce
commit
6b39d51a2c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user