diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-08-28 15:15:50 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-12-03 13:37:56 +0000 |
commit | 461020a86aa5822325edba9ec565db39e5df8092 (patch) | |
tree | bb772bfe8f19397bd24ba9b5558cf5c29ca64d1d /util | |
parent | 55a15a1c1b93d36d705fc69e44b5c806b807dd55 (diff) |
Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.
Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.
The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig
These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
information for each module
Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).
These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.
In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.
This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.
The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.
Note that "c++11" like features are normalized to "cxx11".
Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.
Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.
Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-x | util/cmake/configurejson2cmake.py | 90 |
1 files changed, 72 insertions, 18 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index 481701eaed..f986b65acb 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -803,22 +803,16 @@ def parseFeature(ctx, feature, data, cm_fh): negativeFeature = False # #define QT_NO_featurename in public header internalFeature = False # No custom or QT_FEATURE_ defines publicDefine = False # #define MY_CUSTOM_DEFINE in public header + publicConfig = False # add to CONFIG in public pri file + privateConfig = False # add to CONFIG in private pri file + publicQtConfig = False # add to QT_CONFIG in public pri file for o in output: outputType = o - outputArgs = {} if isinstance(o, dict): outputType = o["type"] - outputArgs = o - if outputType in [ - "varAssign", - "varAppend", - "varRemove", - "publicQtConfig", - "privateConfig", - "publicConfig", - ]: + if outputType in ["varAssign", "varAppend", "varRemove"]: continue elif outputType == "define": publicDefine = True @@ -830,15 +824,32 @@ def parseFeature(ctx, feature, data, cm_fh): privateFeature = True elif outputType == "internalFeature": internalFeature = True + elif outputType == "publicConfig": + publicConfig = True + elif outputType == "privateConfig": + privateConfig = True + elif outputType == "publicQtConfig": + publicQtConfig = True else: print(f" XXXX UNHANDLED OUTPUT TYPE {outputType} in feature {feature}.") continue - if not any([publicFeature, privateFeature, internalFeature, publicDefine, negativeFeature]): + if not any( + [ + publicFeature, + privateFeature, + internalFeature, + publicDefine, + negativeFeature, + publicConfig, + privateConfig, + publicQtConfig, + ] + ): print(f" **** Skipping feature {feature}: Not relevant for C++.") return - cxxFeature = featureName(feature) + normalized_feature_name = featureName(feature) def writeFeature( name, @@ -877,12 +888,12 @@ def parseFeature(ctx, feature, data, cm_fh): # Default internal feature case. featureCalls = {} - featureCalls[cxxFeature] = {"name": cxxFeature, "labelAppend": "", "autoDetect": autoDetect} + featureCalls[feature] = {"name": feature, "labelAppend": "", "autoDetect": autoDetect} # Go over all outputs to compute the number of features that have to be declared for o in output: outputType = o - name = cxxFeature + name = feature # The label append is to provide a unique label for features that have more than one output # with different names. @@ -899,13 +910,19 @@ 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 name != feature: + featureCalls[name]["superFeature"] = normalized_feature_name if outputType in ["feature", "publicFeature"]: featureCalls[name]["publicFeature"] = True elif outputType == "privateFeature": featureCalls[name]["privateFeature"] = True + elif outputType == "publicConfig": + featureCalls[name]["publicConfig"] = True + elif outputType == "privateConfig": + featureCalls[name]["privateConfig"] = True + elif outputType == "publicQtConfig": + featureCalls[name]["publicQtConfig"] = True # Write the qt_feature() calls from the computed feature map for _, args in featureCalls.items(): @@ -923,7 +940,7 @@ def parseFeature(ctx, feature, data, cm_fh): if outputType == "feature": outputType = "define" outputArgs = { - "name": f"QT_NO_{cxxFeature.upper()}", + "name": f"QT_NO_{normalized_feature_name.upper()}", "negative": True, "value": 1, "type": "define", @@ -937,13 +954,50 @@ def parseFeature(ctx, feature, data, cm_fh): continue out_name = outputArgs.get("name") - cm_fh.write(f'qt_feature_definition("{cxxFeature}" "{out_name}"') + cm_fh.write(f'qt_feature_definition("{feature}" "{out_name}"') if outputArgs.get("negative", False): cm_fh.write(" NEGATE") if outputArgs.get("value") is not None: cm_fh.write(f' VALUE "{outputArgs.get("value")}"') cm_fh.write(")\n") + # Write qt_feature_config() calls + for o in output: + outputType = o + name = feature + modified_name = name + + outputArgs = {} + if isinstance(o, dict): + outputType = o["type"] + outputArgs = o + if "name" in o: + modified_name = o["name"] + + if outputType not in ["publicConfig", "privateConfig", "publicQtConfig"]: + continue + + config_type = "" + if outputType == "publicConfig": + config_type = "QMAKE_PUBLIC_CONFIG" + elif outputType == "privateConfig": + config_type = "QMAKE_PRIVATE_CONFIG" + elif outputType == "publicQtConfig": + config_type = "QMAKE_PUBLIC_QT_CONFIG" + + if not config_type: + print(" XXXX config output without type in feature {}.".format(feature)) + continue + + cm_fh.write('qt_feature_config("{}" {}'.format(name, config_type)) + if outputArgs.get("negative", False): + cm_fh.write("\n NEGATE") + if modified_name != name: + cm_fh.write("\n") + cm_fh.write(lineify("NAME", modified_name, quote=True)) + + cm_fh.write(")\n") + def processInputs(ctx, data, cm_fh): print(" inputs:") |