Fix mapping of features to private features

When a feature generates a private feature, we should not just repeat
the condition but also make it depend on the original feature. In qmake
features had different outputs, while we have a 1:1 mapping. For example
the developer_build feature had "private_tests" as an output feature.
There's no condition attached to the feature and auto-detect is off, so
we'd generate

    qt_feature("developer_build" AUTODETECT OFF)
    qt_feature("private_tests" AUTODETECT OFF)

and that's wrong, because when the user enables the visible feature
(developer_build) we want it to propagate to the private_tests feature.

Change-Id: Id8408864802fa1e1ed9e67a5f47d1d2fde38d321
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Simon Hausmann 2019-07-17 16:10:31 +02:00 committed by Alexandru Croitor
parent 3212f1b866
commit fecefdd369
3 changed files with 12 additions and 6 deletions

View File

@ -243,7 +243,7 @@ qt_feature("developer_build"
)
qt_feature("private_tests" PRIVATE
LABEL "Developer build: private_tests"
AUTODETECT OFF
CONDITION QT_FEATURE_developer_build
)
qt_feature_definition("developer_build" "QT_BUILD_INTERNAL")
qt_feature("appstore_compliant" PUBLIC

View File

@ -655,8 +655,7 @@ qt_feature("opengl_dynamic"
)
qt_feature("dynamicgl" PUBLIC
LABEL "Dynamic OpenGL: dynamicgl"
AUTODETECT OFF
CONDITION WIN32 AND NOT WINRT
CONDITION QT_FEATURE_opengl_dynamic
DISABLE INPUT_angle STREQUAL 'yes' OR INPUT_opengl STREQUAL 'no' OR INPUT_opengl STREQUAL 'desktop'
)
qt_feature_definition("opengl_dynamic" "QT_OPENGL_DYNAMIC")

View File

@ -788,7 +788,7 @@ def parseFeature(ctx, feature, data, cm_fh):
cxxFeature = featureName(feature)
def writeFeature(name, publicFeature=False, privateFeature=False, labelAppend=''):
def writeFeature(name, publicFeature=False, privateFeature=False, labelAppend='', superFeature=None, autoDetect=''):
if comment:
cm_fh.write('# {}\n'.format(comment))
@ -804,7 +804,11 @@ def parseFeature(ctx, feature, data, cm_fh):
if purpose != label:
cm_fh.write(lineify('PURPOSE', purpose))
cm_fh.write(lineify('AUTODETECT', autoDetect, quote=False))
cm_fh.write(lineify('CONDITION', condition, quote=False))
if superFeature:
feature_condition = "QT_FEATURE_{}".format(superFeature)
else:
feature_condition = condition
cm_fh.write(lineify('CONDITION', feature_condition, quote=False))
cm_fh.write(lineify('ENABLE', enable, quote=False))
cm_fh.write(lineify('DISABLE', disable, quote=False))
cm_fh.write(lineify('EMIT_IF', emitIf, quote=False))
@ -814,7 +818,7 @@ def parseFeature(ctx, feature, data, cm_fh):
# Default internal feature case.
featureCalls = {}
featureCalls[cxxFeature] = {'name': cxxFeature, 'labelAppend': ''}
featureCalls[cxxFeature] = {'name': cxxFeature, 'labelAppend': '', 'autoDetect': autoDetect}
# Go over all outputs to compute the number of features that have to be declared
for o in output:
@ -836,6 +840,9 @@ def parseFeature(ctx, feature, data, cm_fh):
if name not in featureCalls:
featureCalls[name] = {'name': name, 'labelAppend': labelAppend}
if name != cxxFeature:
featureCalls[name]['superFeature'] = cxxFeature
if outputType in ['feature', 'publicFeature']:
featureCalls[name]['publicFeature'] = True
elif outputType == 'privateFeature':