From 910804a4202d5be645a841a1e2ec38ad63c0598d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 3 Jun 2020 19:59:04 +0200 Subject: pro2cmake: Parse "optional plugin" from qmldir files Task-number: QTBUG-84639 Change-Id: Iedfa2e53c686a7c7c855efc7b9deee097a15f4b7 Reviewed-by: Fabian Kosmale Reviewed-by: Alexandru Croitor --- util/cmake/pro2cmake.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 74905f38e8..441f8335e2 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -576,6 +576,7 @@ class QmlDir: def __init__(self) -> None: self.module = "" self.plugin_name = "" + self.plugin_optional = False self.plugin_path = "" self.classname = "" self.imports: List[str] = [] @@ -589,7 +590,7 @@ class QmlDir: imports_line = " \n".join(self.imports) string = f"""\ module: {self.module} - plugin: {self.plugin_name} {self.plugin_path} + plugin: {self.plugin_optional} {self.plugin_name} {self.plugin_path} classname: {self.classname} type_infos:{type_infos_line} imports:{imports_line} @@ -664,6 +665,13 @@ class QmlDir: self.plugin_name = entries[1] if len(entries) > 2: self.plugin_path = entries[2] + elif entries[0] == "optional": + if entries[1] != "plugin": + raise RuntimeError("Only plugins can be optional in qmldir files") + self.plugin_name = entries[2] + self.plugin_optional = True + if len(entries) > 3: + self.plugin_path = entries[3] elif entries[0] == "classname": self.classname = entries[1] elif entries[0] == "typeinfo": @@ -3427,6 +3435,8 @@ def write_example( add_target += f" IMPORTS\n{qml_dir_imports_line}" if qml_dir_dynamic_imports: add_target += " IMPORTS ${module_dynamic_qml_imports}\n" + if qml_dir.plugin_optional: + add_target += " PLUGIN_OPTIONAL\n" add_target += " INSTALL_LOCATION ${INSTALL_EXAMPLEDIR}\n)\n\n" add_target += f"target_sources({binary_name} PRIVATE" @@ -3720,6 +3730,8 @@ def write_qml_plugin( extra_lines.append("IMPORTS\n " f"{qml_dir_imports_line}") if qml_dir_dynamic_imports: extra_lines.append("IMPORTS ${module_dynamic_qml_imports}") + if qml_dir.plugin_optional: + extra_lines.append("PLUGIN_OPTIONAL") return qml_dir -- cgit v1.2.3