2018-10-24 13:20:27 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#############################################################################
|
|
|
|
##
|
|
|
|
## Copyright (C) 2018 The Qt Company Ltd.
|
|
|
|
## Contact: https://www.qt.io/licensing/
|
|
|
|
##
|
|
|
|
## This file is part of the plugins of the Qt Toolkit.
|
|
|
|
##
|
|
|
|
## $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
|
|
|
## Commercial License Usage
|
|
|
|
## Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
## accordance with the commercial license agreement provided with the
|
|
|
|
## Software or, alternatively, in accordance with the terms contained in
|
|
|
|
## a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
## and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
## information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
##
|
|
|
|
## GNU General Public License Usage
|
|
|
|
## Alternatively, this file may be used under the terms of the GNU
|
|
|
|
## General Public License version 3 as published by the Free Software
|
|
|
|
## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
## included in the packaging of this file. Please review the following
|
|
|
|
## information to ensure the GNU General Public License requirements will
|
|
|
|
## be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
##
|
|
|
|
## $QT_END_LICENSE$
|
|
|
|
##
|
|
|
|
#############################################################################
|
|
|
|
|
2019-01-24 15:01:17 +00:00
|
|
|
|
2020-03-09 12:26:39 +00:00
|
|
|
# Requires Python 3.7. The import statement needs to be the first line of code
|
|
|
|
# so it's not possible to conditionally check the version and raise an
|
|
|
|
# exception.
|
2019-01-24 15:01:17 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
import copy
|
2018-10-24 13:20:27 +00:00
|
|
|
import os.path
|
2019-09-11 08:13:06 +00:00
|
|
|
import posixpath
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
import sys
|
2018-10-24 13:20:27 +00:00
|
|
|
import re
|
|
|
|
import io
|
2022-02-28 20:03:13 +00:00
|
|
|
import itertools
|
2019-09-09 08:52:27 +00:00
|
|
|
import glob
|
2020-04-03 09:16:14 +00:00
|
|
|
import fnmatch
|
2019-09-17 08:39:13 +00:00
|
|
|
|
2019-09-30 16:11:15 +00:00
|
|
|
from condition_simplifier import simplify_condition
|
2019-10-07 13:28:05 +00:00
|
|
|
from condition_simplifier_cache import set_condition_simplified_cache_enabled
|
2019-09-30 16:11:15 +00:00
|
|
|
|
2019-10-07 10:22:04 +00:00
|
|
|
import pyparsing as pp # type: ignore
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
import xml.etree.ElementTree as ET
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
from argparse import ArgumentParser
|
|
|
|
from textwrap import dedent
|
2019-09-21 16:02:54 +00:00
|
|
|
from functools import lru_cache
|
2019-05-04 11:08:19 +00:00
|
|
|
from shutil import copyfile
|
2019-11-13 13:03:20 +00:00
|
|
|
from collections import defaultdict
|
2019-09-21 18:18:10 +00:00
|
|
|
from typing import (
|
|
|
|
List,
|
|
|
|
Optional,
|
|
|
|
Dict,
|
|
|
|
Set,
|
|
|
|
IO,
|
|
|
|
Union,
|
|
|
|
Any,
|
|
|
|
Callable,
|
|
|
|
FrozenSet,
|
|
|
|
Tuple,
|
|
|
|
Match,
|
2019-09-30 15:02:08 +00:00
|
|
|
Type,
|
2019-09-21 18:18:10 +00:00
|
|
|
)
|
2019-10-10 07:58:38 +00:00
|
|
|
|
|
|
|
from qmake_parser import parseProFile
|
2019-05-04 11:08:19 +00:00
|
|
|
from special_case_helper import SpecialCaseHandler
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
from helper import (
|
|
|
|
map_qt_library,
|
|
|
|
map_3rd_party_library,
|
|
|
|
is_known_3rd_party_library,
|
|
|
|
featureName,
|
|
|
|
map_platform,
|
|
|
|
find_library_info_for_target,
|
|
|
|
generate_find_package_info,
|
|
|
|
LibraryMapping,
|
|
|
|
)
|
2019-05-04 11:08:19 +00:00
|
|
|
|
2021-01-22 10:15:10 +00:00
|
|
|
cmake_version_string = "3.16"
|
2021-02-25 07:47:37 +00:00
|
|
|
cmake_api_version = 3
|
2019-09-09 08:52:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
def _parse_commandline():
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
parser = ArgumentParser(
|
|
|
|
description="Generate CMakeLists.txt files from ." "pro files.",
|
2020-02-27 09:11:35 +00:00
|
|
|
epilog="Requirements: pip install -r requirements.txt",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--debug", dest="debug", action="store_true", help="Turn on all debug output"
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--debug-parser",
|
|
|
|
dest="debug_parser",
|
|
|
|
action="store_true",
|
|
|
|
help="Print debug output from qmake parser.",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--debug-parse-result",
|
|
|
|
dest="debug_parse_result",
|
|
|
|
action="store_true",
|
|
|
|
help="Dump the qmake parser result.",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--debug-parse-dictionary",
|
|
|
|
dest="debug_parse_dictionary",
|
|
|
|
action="store_true",
|
|
|
|
help="Dump the qmake parser result as dictionary.",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--debug-pro-structure",
|
|
|
|
dest="debug_pro_structure",
|
|
|
|
action="store_true",
|
|
|
|
help="Dump the structure of the qmake .pro-file.",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--debug-full-pro-structure",
|
|
|
|
dest="debug_full_pro_structure",
|
|
|
|
action="store_true",
|
|
|
|
help="Dump the full structure of the qmake .pro-file " "(with includes).",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--debug-special-case-preservation",
|
|
|
|
dest="debug_special_case_preservation",
|
|
|
|
action="store_true",
|
|
|
|
help="Show all git commands and file copies.",
|
|
|
|
)
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
"--is-example",
|
|
|
|
action="store_true",
|
|
|
|
dest="is_example",
|
2022-03-04 14:49:02 +00:00
|
|
|
help="Treat the input .pro file as a Qt example.",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--is-user-project",
|
|
|
|
action="store_true",
|
|
|
|
dest="is_user_project",
|
|
|
|
help="Treat the input .pro file as a user project.",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-s",
|
|
|
|
"--skip-special-case-preservation",
|
|
|
|
dest="skip_special_case_preservation",
|
|
|
|
action="store_true",
|
|
|
|
help="Skips behavior to reapply " "special case modifications (requires git in PATH)",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-k",
|
|
|
|
"--keep-temporary-files",
|
|
|
|
dest="keep_temporary_files",
|
|
|
|
action="store_true",
|
|
|
|
help="Don't automatically remove CMakeLists.gen.txt and other " "intermediate files.",
|
|
|
|
)
|
|
|
|
|
2019-10-07 13:28:05 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"-e",
|
|
|
|
"--skip-condition-cache",
|
|
|
|
dest="skip_condition_cache",
|
|
|
|
action="store_true",
|
|
|
|
help="Don't use condition simplifier cache (conversion speed may decrease).",
|
|
|
|
)
|
|
|
|
|
2019-11-11 18:31:31 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"--skip-subdirs-project",
|
|
|
|
dest="skip_subdirs_project",
|
|
|
|
action="store_true",
|
|
|
|
help="Skip converting project if it ends up being a TEMPLATE=subdirs project.",
|
|
|
|
)
|
|
|
|
|
2019-10-08 09:57:27 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"-i",
|
|
|
|
"--ignore-skip-marker",
|
|
|
|
dest="ignore_skip_marker",
|
|
|
|
action="store_true",
|
|
|
|
help="If set, pro file will be converted even if skip marker is found in CMakeLists.txt.",
|
|
|
|
)
|
|
|
|
|
2019-11-13 13:03:20 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"--api-version",
|
|
|
|
dest="api_version",
|
|
|
|
type=int,
|
2021-02-25 07:47:37 +00:00
|
|
|
help="Specify which cmake api version should be generated. 1, 2 or 3, 3 is latest.",
|
2019-11-13 13:03:20 +00:00
|
|
|
)
|
|
|
|
|
2020-04-03 15:38:24 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"-o",
|
|
|
|
"--output-file",
|
|
|
|
dest="output_file",
|
|
|
|
type=str,
|
2020-04-28 09:49:19 +00:00
|
|
|
help="Specify a file path where the generated content should be written to. "
|
2020-04-06 07:42:01 +00:00
|
|
|
"Default is to write to CMakeLists.txt in the same directory as the .pro file.",
|
2020-04-03 15:38:24 +00:00
|
|
|
)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"files",
|
|
|
|
metavar="<.pro/.pri file>",
|
|
|
|
type=str,
|
|
|
|
nargs="+",
|
|
|
|
help="The .pro/.pri file to process",
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
return parser.parse_args()
|
|
|
|
|
2020-04-06 07:42:01 +00:00
|
|
|
|
2020-03-11 14:34:27 +00:00
|
|
|
def get_top_level_repo_project_path(project_file_path: str = "") -> str:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
|
|
|
return qmake_or_cmake_conf_dir_path
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2020-04-06 07:42:01 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def is_top_level_repo_project(project_file_path: str = "") -> bool:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
2019-09-09 08:52:27 +00:00
|
|
|
project_dir_path = os.path.dirname(project_file_path)
|
2021-09-22 15:34:00 +00:00
|
|
|
return qmake_or_cmake_conf_dir_path == project_dir_path
|
2019-09-09 08:52:27 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def is_top_level_repo_tests_project(project_file_path: str = "") -> bool:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
2019-09-09 08:52:27 +00:00
|
|
|
project_dir_path = os.path.dirname(project_file_path)
|
|
|
|
project_dir_name = os.path.basename(project_dir_path)
|
|
|
|
maybe_same_level_dir_path = os.path.join(project_dir_path, "..")
|
|
|
|
normalized_maybe_same_level_dir_path = os.path.normpath(maybe_same_level_dir_path)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return (
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_dir_path == normalized_maybe_same_level_dir_path
|
|
|
|
and project_dir_name == "tests"
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2019-09-09 08:52:27 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def is_top_level_repo_examples_project(project_file_path: str = "") -> bool:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
2019-09-09 08:52:27 +00:00
|
|
|
project_dir_path = os.path.dirname(project_file_path)
|
|
|
|
project_dir_name = os.path.basename(project_dir_path)
|
|
|
|
maybe_same_level_dir_path = os.path.join(project_dir_path, "..")
|
|
|
|
normalized_maybe_same_level_dir_path = os.path.normpath(maybe_same_level_dir_path)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return (
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_dir_path == normalized_maybe_same_level_dir_path
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
and project_dir_name == "examples"
|
|
|
|
)
|
2019-09-09 08:52:27 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def is_example_project(project_file_path: str = "") -> bool:
|
2021-09-22 16:45:14 +00:00
|
|
|
# If there's a .qmake.conf or .cmake.conf file in the parent
|
|
|
|
# directories of the given project path, it is likely that the
|
|
|
|
# project is an internal Qt project that uses private Qt CMake
|
|
|
|
# API.
|
|
|
|
found_qt_repo_version = False
|
|
|
|
qmake_conf = find_qmake_conf(project_file_path)
|
|
|
|
if qmake_conf:
|
|
|
|
repo_version = parse_qt_repo_module_version_from_qmake_conf(qmake_conf)
|
|
|
|
if repo_version:
|
|
|
|
found_qt_repo_version = True
|
|
|
|
|
|
|
|
cmake_conf = find_cmake_conf(project_file_path)
|
|
|
|
if cmake_conf:
|
|
|
|
repo_version = parse_qt_repo_module_version_from_cmake_conf(cmake_conf)
|
|
|
|
if repo_version:
|
|
|
|
found_qt_repo_version = True
|
|
|
|
|
|
|
|
# If we haven't found a conf file, we assume this is an example
|
|
|
|
# project and not a project under a qt source repository.
|
|
|
|
if not found_qt_repo_version:
|
|
|
|
return True
|
2019-09-09 12:16:26 +00:00
|
|
|
|
|
|
|
# If the project file is found in a subdir called 'examples'
|
2019-09-19 12:21:43 +00:00
|
|
|
# relative to the repo source dir, then it must be an example, but
|
|
|
|
# some examples contain 3rdparty libraries that do not need to be
|
|
|
|
# built as examples.
|
2021-09-22 16:45:14 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
|
|
|
project_relative_path = os.path.relpath(project_file_path, qmake_or_cmake_conf_dir_path)
|
|
|
|
|
|
|
|
is_example_under_repo_sources = (
|
|
|
|
project_relative_path.startswith("examples") and "3rdparty" not in project_relative_path
|
|
|
|
)
|
|
|
|
return is_example_under_repo_sources
|
2019-09-09 12:16:26 +00:00
|
|
|
|
|
|
|
|
2019-09-21 16:02:54 +00:00
|
|
|
def is_config_test_project(project_file_path: str = "") -> bool:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
|
|
|
dir_name_with_qmake_or_cmake_conf = os.path.basename(qmake_or_cmake_conf_dir_path)
|
2019-09-21 16:02:54 +00:00
|
|
|
|
2021-09-22 15:34:00 +00:00
|
|
|
project_relative_path = os.path.relpath(project_file_path, qmake_or_cmake_conf_dir_path)
|
2019-09-21 16:02:54 +00:00
|
|
|
# If the project file is found in a subdir called 'config.tests'
|
|
|
|
# relative to the repo source dir, then it's probably a config test.
|
|
|
|
# Also if the .qmake.conf is found within config.tests dir (like in qtbase)
|
|
|
|
# then the project is probably a config .test
|
2019-09-21 18:09:36 +00:00
|
|
|
return (
|
|
|
|
project_relative_path.startswith("config.tests")
|
2021-09-22 15:34:00 +00:00
|
|
|
or dir_name_with_qmake_or_cmake_conf == "config.tests"
|
2019-09-21 18:09:36 +00:00
|
|
|
)
|
2019-09-21 16:02:54 +00:00
|
|
|
|
|
|
|
|
2019-10-28 14:35:47 +00:00
|
|
|
def is_benchmark_project(project_file_path: str = "") -> bool:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
2019-10-28 14:35:47 +00:00
|
|
|
|
2021-09-22 15:34:00 +00:00
|
|
|
project_relative_path = os.path.relpath(project_file_path, qmake_or_cmake_conf_dir_path)
|
2019-10-28 14:35:47 +00:00
|
|
|
# If the project file is found in a subdir called 'tests/benchmarks'
|
2019-11-12 14:31:34 +00:00
|
|
|
# relative to the repo source dir, then it must be a benchmark
|
2019-10-28 14:35:47 +00:00
|
|
|
return project_relative_path.startswith("tests/benchmarks")
|
|
|
|
|
2019-11-13 09:53:59 +00:00
|
|
|
|
2019-11-13 09:53:13 +00:00
|
|
|
def is_manual_test_project(project_file_path: str = "") -> bool:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
2019-11-12 14:31:34 +00:00
|
|
|
|
2021-09-22 15:34:00 +00:00
|
|
|
project_relative_path = os.path.relpath(project_file_path, qmake_or_cmake_conf_dir_path)
|
2019-11-12 14:31:34 +00:00
|
|
|
# If the project file is found in a subdir called 'tests/manual'
|
|
|
|
# relative to the repo source dir, then it must be a manual test
|
|
|
|
return project_relative_path.startswith("tests/manual")
|
|
|
|
|
2019-10-28 14:35:47 +00:00
|
|
|
|
2019-09-21 16:02:54 +00:00
|
|
|
@lru_cache(maxsize=None)
|
2021-09-22 15:34:00 +00:00
|
|
|
def find_file_walking_parent_dirs(file_name: str, project_file_path: str = "") -> str:
|
|
|
|
assert file_name
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
if not os.path.isabs(project_file_path):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(
|
2021-09-22 15:34:00 +00:00
|
|
|
f"Warning: could not find {file_name} file, given path is not an "
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
f"absolute path: {project_file_path}"
|
|
|
|
)
|
2019-10-07 10:22:04 +00:00
|
|
|
return ""
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
|
|
|
|
cwd = os.path.dirname(project_file_path)
|
|
|
|
|
|
|
|
while os.path.isdir(cwd):
|
2019-09-11 08:13:06 +00:00
|
|
|
maybe_file = posixpath.join(cwd, file_name)
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
if os.path.isfile(maybe_file):
|
|
|
|
return maybe_file
|
|
|
|
else:
|
2020-02-21 14:52:04 +00:00
|
|
|
last_cwd = cwd
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
cwd = os.path.dirname(cwd)
|
2020-02-21 14:52:04 +00:00
|
|
|
if last_cwd == cwd:
|
|
|
|
# reached the top level directory, stop looking
|
|
|
|
break
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
|
2019-10-07 10:22:04 +00:00
|
|
|
return ""
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
|
|
|
|
|
2021-09-22 15:34:00 +00:00
|
|
|
def find_qmake_conf(project_file_path: str = "") -> str:
|
|
|
|
return find_file_walking_parent_dirs(".qmake.conf", project_file_path)
|
|
|
|
|
|
|
|
|
|
|
|
def find_cmake_conf(project_file_path: str = "") -> str:
|
|
|
|
return find_file_walking_parent_dirs(".cmake.conf", project_file_path)
|
|
|
|
|
|
|
|
|
|
|
|
def find_qmake_or_cmake_conf(project_file_path: str = "") -> str:
|
|
|
|
qmake_conf = find_qmake_conf(project_file_path)
|
|
|
|
if qmake_conf:
|
|
|
|
return qmake_conf
|
|
|
|
cmake_conf = find_cmake_conf(project_file_path)
|
|
|
|
return cmake_conf
|
|
|
|
|
|
|
|
|
2021-09-22 16:45:14 +00:00
|
|
|
def parse_qt_repo_module_version_from_qmake_conf(qmake_conf_path: str = "") -> str:
|
|
|
|
with open(qmake_conf_path) as f:
|
|
|
|
file_contents = f.read()
|
2022-02-24 10:31:10 +00:00
|
|
|
m = re.search(r"MODULE_VERSION\s*=\s*([0-9.]+)", file_contents)
|
2021-09-22 16:45:14 +00:00
|
|
|
return m.group(1) if m else ""
|
|
|
|
|
|
|
|
|
|
|
|
def parse_qt_repo_module_version_from_cmake_conf(cmake_conf_path: str = "") -> str:
|
|
|
|
with open(cmake_conf_path) as f:
|
|
|
|
file_contents = f.read()
|
2022-02-24 10:31:10 +00:00
|
|
|
m = re.search(r'set\(QT_REPO_MODULE_VERSION\s*"([0-9.]+)"\)', file_contents)
|
2021-09-22 16:45:14 +00:00
|
|
|
return m.group(1) if m else ""
|
|
|
|
|
|
|
|
|
2019-11-13 13:03:20 +00:00
|
|
|
def set_up_cmake_api_calls():
|
|
|
|
def nested_dict():
|
|
|
|
return defaultdict(nested_dict)
|
|
|
|
|
|
|
|
api = nested_dict()
|
|
|
|
|
|
|
|
api[1]["qt_extend_target"] = "extend_target"
|
|
|
|
api[1]["qt_add_module"] = "add_qt_module"
|
|
|
|
api[1]["qt_add_plugin"] = "add_qt_plugin"
|
|
|
|
api[1]["qt_add_tool"] = "add_qt_tool"
|
2020-07-27 09:10:48 +00:00
|
|
|
api[2]["qt_internal_add_app"] = "qt_internal_add_app"
|
2019-11-13 13:03:20 +00:00
|
|
|
api[1]["qt_add_test"] = "add_qt_test"
|
|
|
|
api[1]["qt_add_test_helper"] = "add_qt_test_helper"
|
|
|
|
api[1]["qt_add_manual_test"] = "add_qt_manual_test"
|
|
|
|
api[1]["qt_add_benchmark"] = "add_qt_benchmark"
|
|
|
|
api[1]["qt_add_executable"] = "add_qt_executable"
|
|
|
|
api[1]["qt_add_simd_part"] = "add_qt_simd_part"
|
|
|
|
api[1]["qt_add_docs"] = "add_qt_docs"
|
|
|
|
api[1]["qt_add_resource"] = "add_qt_resource"
|
|
|
|
api[1]["qt_add_qml_module"] = "add_qml_module"
|
|
|
|
api[1]["qt_add_cmake_library"] = "add_cmake_library"
|
2020-03-25 15:04:16 +00:00
|
|
|
api[1]["qt_add_3rdparty_library"] = "qt_add_3rdparty_library"
|
2020-09-22 08:02:27 +00:00
|
|
|
api[1]["qt_create_tracepoints"] = "qt_create_tracepoints"
|
2019-11-13 13:03:20 +00:00
|
|
|
|
|
|
|
api[2]["qt_extend_target"] = "qt_extend_target"
|
|
|
|
api[2]["qt_add_module"] = "qt_add_module"
|
2020-04-21 11:28:57 +00:00
|
|
|
api[2]["qt_add_plugin"] = "qt_internal_add_plugin"
|
2019-11-13 13:03:20 +00:00
|
|
|
api[2]["qt_add_tool"] = "qt_add_tool"
|
2020-07-27 09:10:48 +00:00
|
|
|
api[2]["qt_internal_add_app"] = "qt_internal_add_app"
|
2019-11-13 13:03:20 +00:00
|
|
|
api[2]["qt_add_test"] = "qt_add_test"
|
|
|
|
api[2]["qt_add_test_helper"] = "qt_add_test_helper"
|
|
|
|
api[2]["qt_add_manual_test"] = "qt_add_manual_test"
|
|
|
|
api[2]["qt_add_benchmark"] = "qt_add_benchmark"
|
|
|
|
api[2]["qt_add_executable"] = "qt_add_executable"
|
|
|
|
api[2]["qt_add_simd_part"] = "qt_add_simd_part"
|
|
|
|
api[2]["qt_add_docs"] = "qt_add_docs"
|
|
|
|
api[2]["qt_add_resource"] = "qt_add_resource"
|
|
|
|
api[2]["qt_add_qml_module"] = "qt_add_qml_module"
|
|
|
|
api[2]["qt_add_cmake_library"] = "qt_add_cmake_library"
|
2020-02-11 14:38:47 +00:00
|
|
|
api[2]["qt_add_3rdparty_library"] = "qt_add_3rdparty_library"
|
2020-09-22 08:02:27 +00:00
|
|
|
api[2]["qt_create_tracepoints"] = "qt_create_tracepoints"
|
|
|
|
|
|
|
|
api[3]["qt_extend_target"] = "qt_internal_extend_target"
|
|
|
|
api[3]["qt_add_module"] = "qt_internal_add_module"
|
|
|
|
api[3]["qt_add_plugin"] = "qt_internal_add_plugin"
|
|
|
|
api[3]["qt_add_tool"] = "qt_internal_add_tool"
|
|
|
|
api[3]["qt_internal_add_app"] = "qt_internal_add_app"
|
|
|
|
api[3]["qt_add_test"] = "qt_internal_add_test"
|
|
|
|
api[3]["qt_add_test_helper"] = "qt_internal_add_test_helper"
|
|
|
|
api[3]["qt_add_manual_test"] = "qt_internal_add_manual_test"
|
|
|
|
api[3]["qt_add_benchmark"] = "qt_internal_add_benchmark"
|
|
|
|
api[3]["qt_add_executable"] = "qt_internal_add_executable"
|
|
|
|
api[3]["qt_add_simd_part"] = "qt_internal_add_simd_part"
|
|
|
|
api[3]["qt_add_docs"] = "qt_internal_add_docs"
|
|
|
|
api[3]["qt_add_resource"] = "qt_internal_add_resource"
|
|
|
|
api[3]["qt_add_qml_module"] = "qt_internal_add_qml_module"
|
|
|
|
api[3]["qt_add_cmake_library"] = "qt_internal_add_cmake_library"
|
|
|
|
api[3]["qt_add_3rdparty_library"] = "qt_internal_add_3rdparty_library"
|
|
|
|
api[3]["qt_create_tracepoints"] = "qt_internal_create_tracepoints"
|
2019-11-13 13:03:20 +00:00
|
|
|
|
|
|
|
return api
|
|
|
|
|
|
|
|
|
|
|
|
cmake_api_calls = set_up_cmake_api_calls()
|
|
|
|
|
|
|
|
|
|
|
|
def detect_cmake_api_version_used_in_file_content(project_file_path: str) -> Optional[int]:
|
|
|
|
dir_path = os.path.dirname(project_file_path)
|
|
|
|
cmake_project_path = os.path.join(dir_path, "CMakeLists.txt")
|
|
|
|
|
|
|
|
# If file doesn't exist, None implies default version selected by
|
|
|
|
# script.
|
|
|
|
if not os.path.exists(cmake_project_path):
|
|
|
|
return None
|
|
|
|
|
|
|
|
with open(cmake_project_path, "r") as file_fd:
|
|
|
|
contents = file_fd.read()
|
|
|
|
|
2020-09-22 08:02:27 +00:00
|
|
|
api_call_versions = [version for version in cmake_api_calls]
|
|
|
|
api_call_versions = sorted(api_call_versions, reverse=True)
|
|
|
|
api_call_version_matches = {}
|
|
|
|
for version in api_call_versions:
|
2020-11-11 17:13:56 +00:00
|
|
|
versioned_api_calls = [
|
|
|
|
cmake_api_calls[version][api_call] for api_call in cmake_api_calls[version]
|
|
|
|
]
|
2020-09-22 08:02:27 +00:00
|
|
|
versioned_api_calls_alternatives = "|".join(versioned_api_calls)
|
2020-11-11 17:13:56 +00:00
|
|
|
api_call_version_matches[version] = re.search(
|
|
|
|
versioned_api_calls_alternatives, contents
|
|
|
|
)
|
2019-11-13 13:03:20 +00:00
|
|
|
|
|
|
|
# If new style found, return latest api version. Otherwise
|
2020-09-22 08:02:27 +00:00
|
|
|
# return the current version.
|
|
|
|
for version in api_call_version_matches:
|
|
|
|
if api_call_version_matches[version]:
|
|
|
|
return version
|
|
|
|
|
|
|
|
return 1
|
2019-11-13 13:03:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_cmake_api_call(api_name: str, api_version: Optional[int] = None) -> str:
|
|
|
|
if not api_version:
|
|
|
|
global cmake_api_version
|
|
|
|
api_version = cmake_api_version
|
|
|
|
if not cmake_api_calls[api_version][api_name]:
|
|
|
|
raise RuntimeError(f"No CMake API call {api_name} of version {api_version} found.")
|
|
|
|
|
|
|
|
return cmake_api_calls[api_version][api_name]
|
|
|
|
|
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
class QtResource:
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
name: str = "",
|
|
|
|
prefix: str = "",
|
|
|
|
base_dir: str = "",
|
|
|
|
files: Dict[str, str] = {},
|
|
|
|
lang: str = None,
|
|
|
|
generated: bool = False,
|
|
|
|
skip_qtquick_compiler: bool = False,
|
|
|
|
) -> None:
|
|
|
|
self.name = name
|
|
|
|
self.prefix = prefix
|
|
|
|
self.base_dir = base_dir
|
|
|
|
self.files = files
|
|
|
|
self.lang = lang
|
|
|
|
self.generated = generated
|
|
|
|
self.skip_qtquick_compiler = skip_qtquick_compiler
|
|
|
|
|
|
|
|
|
|
|
|
def read_qrc_file(
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
filepath: str,
|
|
|
|
base_dir: str = "",
|
|
|
|
project_file_path: str = "",
|
|
|
|
skip_qtquick_compiler: bool = False,
|
2022-02-28 20:03:13 +00:00
|
|
|
) -> List[QtResource]:
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
# Hack to handle QT_SOURCE_TREE. Assume currently that it's the same
|
|
|
|
# as the qtbase source path.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
qt_source_tree_literal = "${QT_SOURCE_TREE}"
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
if qt_source_tree_literal in filepath:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf = find_qmake_or_cmake_conf(project_file_path)
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
|
2021-09-22 15:34:00 +00:00
|
|
|
if qmake_or_cmake_conf:
|
|
|
|
qt_source_tree = os.path.dirname(qmake_or_cmake_conf)
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
filepath = filepath.replace(qt_source_tree_literal, qt_source_tree)
|
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(
|
|
|
|
f"Warning, could not determine QT_SOURCE_TREE location while trying "
|
|
|
|
f"to find: {filepath}"
|
|
|
|
)
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
|
2019-03-07 10:06:23 +00:00
|
|
|
resource_name = os.path.splitext(os.path.basename(filepath))[0]
|
2019-08-06 12:51:04 +00:00
|
|
|
dir_name = os.path.dirname(filepath)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
base_dir = posixpath.join("" if base_dir == "." else base_dir, dir_name)
|
2019-03-07 10:06:23 +00:00
|
|
|
|
2019-08-06 12:51:04 +00:00
|
|
|
# Small not very thorough check to see if this a shared qrc resource
|
|
|
|
# pattern is mostly used by the tests.
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
if not os.path.isfile(filepath):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
raise RuntimeError(f"Invalid file path given to process_qrc_file: {filepath}")
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
|
2019-03-07 10:06:23 +00:00
|
|
|
tree = ET.parse(filepath)
|
|
|
|
root = tree.getroot()
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
assert root.tag == "RCC"
|
2019-03-07 10:06:23 +00:00
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
result: List[QtResource] = []
|
2019-03-07 10:06:23 +00:00
|
|
|
for resource in root:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
assert resource.tag == "qresource"
|
2022-02-28 20:03:13 +00:00
|
|
|
r = QtResource(
|
|
|
|
name=resource_name,
|
|
|
|
prefix=resource.get("prefix", "/"),
|
|
|
|
base_dir=base_dir,
|
|
|
|
lang=resource.get("lang", ""),
|
|
|
|
skip_qtquick_compiler=skip_qtquick_compiler,
|
|
|
|
)
|
|
|
|
|
|
|
|
if len(result) > 0:
|
|
|
|
r.name += str(len(result))
|
2019-03-07 10:06:23 +00:00
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
if not r.prefix.startswith("/"):
|
|
|
|
r.prefix = f"/{r.prefix}"
|
2019-03-07 10:06:23 +00:00
|
|
|
|
|
|
|
for file in resource:
|
|
|
|
path = file.text
|
|
|
|
assert path
|
|
|
|
|
|
|
|
# Get alias:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
alias = file.get("alias", "")
|
2022-02-28 20:03:13 +00:00
|
|
|
r.files[path] = alias
|
2019-03-07 10:06:23 +00:00
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
result.append(r)
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def write_resource_source_file_properties(
|
|
|
|
sorted_files: List[str], files: Dict[str, str], base_dir: str, skip_qtquick_compiler: bool
|
|
|
|
) -> str:
|
|
|
|
output = ""
|
|
|
|
source_file_properties = defaultdict(list)
|
|
|
|
|
|
|
|
for source in sorted_files:
|
|
|
|
alias = files[source]
|
|
|
|
if alias:
|
|
|
|
source_file_properties[source].append(f'QT_RESOURCE_ALIAS "{alias}"')
|
|
|
|
# If a base dir is given, we have to write the source file property
|
|
|
|
# assignments that disable the quick compiler per file.
|
|
|
|
if base_dir and skip_qtquick_compiler:
|
|
|
|
source_file_properties[source].append("QT_SKIP_QUICKCOMPILER 1")
|
|
|
|
|
|
|
|
for full_source in source_file_properties:
|
|
|
|
per_file_props = source_file_properties[full_source]
|
|
|
|
if per_file_props:
|
|
|
|
prop_spaces = " "
|
|
|
|
per_file_props_joined = f"\n{prop_spaces}".join(per_file_props)
|
|
|
|
output += dedent(
|
|
|
|
f"""\
|
|
|
|
set_source_files_properties("{full_source}"
|
|
|
|
PROPERTIES {per_file_props_joined}
|
|
|
|
)
|
|
|
|
"""
|
|
|
|
)
|
2019-03-07 10:06:23 +00:00
|
|
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_add_qt_resource_call(
|
|
|
|
target: str,
|
2020-04-14 10:38:48 +00:00
|
|
|
scope: Scope,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
resource_name: str,
|
|
|
|
prefix: Optional[str],
|
2019-10-07 10:22:04 +00:00
|
|
|
base_dir: str,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
lang: Optional[str],
|
|
|
|
files: Dict[str, str],
|
|
|
|
skip_qtquick_compiler: bool,
|
|
|
|
is_example: bool,
|
|
|
|
) -> str:
|
|
|
|
output = ""
|
2019-08-09 12:15:42 +00:00
|
|
|
|
2020-07-06 15:46:10 +00:00
|
|
|
if base_dir:
|
|
|
|
base_dir_expanded = scope.expandString(base_dir)
|
|
|
|
if base_dir_expanded:
|
|
|
|
base_dir = base_dir_expanded
|
2021-05-14 13:31:30 +00:00
|
|
|
new_files = {}
|
|
|
|
for file_path, alias in files.items():
|
|
|
|
full_file_path = posixpath.join(base_dir, file_path)
|
|
|
|
new_files[full_file_path] = alias
|
|
|
|
files = new_files
|
|
|
|
|
|
|
|
sorted_files = sorted(files.keys())
|
|
|
|
assert sorted_files
|
2020-07-06 15:46:10 +00:00
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
output += write_resource_source_file_properties(
|
|
|
|
sorted_files, files, base_dir, skip_qtquick_compiler
|
|
|
|
)
|
2019-08-09 12:15:42 +00:00
|
|
|
|
2019-08-12 12:05:05 +00:00
|
|
|
# Quote file paths in case there are spaces.
|
2019-09-03 13:25:55 +00:00
|
|
|
sorted_files_backup = sorted_files
|
|
|
|
sorted_files = []
|
|
|
|
for source in sorted_files_backup:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if source.startswith("${"):
|
2019-09-03 13:25:55 +00:00
|
|
|
sorted_files.append(source)
|
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
sorted_files.append(f'"{source}"')
|
2019-08-12 12:05:05 +00:00
|
|
|
|
2019-09-20 09:34:16 +00:00
|
|
|
file_list = "\n ".join(sorted_files)
|
2019-09-21 18:09:36 +00:00
|
|
|
output += dedent(
|
|
|
|
f"""\
|
2019-09-20 09:34:16 +00:00
|
|
|
set({resource_name}_resource_files
|
|
|
|
{file_list}
|
|
|
|
)\n
|
2019-09-21 18:09:36 +00:00
|
|
|
"""
|
|
|
|
)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
file_list = f"${{{resource_name}_resource_files}}"
|
2020-07-06 15:46:10 +00:00
|
|
|
if skip_qtquick_compiler and not base_dir:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
output += (
|
|
|
|
f"set_source_files_properties(${{{resource_name}_resource_files}}"
|
|
|
|
" PROPERTIES QT_SKIP_QUICKCOMPILER 1)\n\n"
|
|
|
|
)
|
2019-08-12 14:31:30 +00:00
|
|
|
|
2020-07-30 13:56:37 +00:00
|
|
|
prefix_expanded = scope.expandString(str(prefix))
|
2020-04-14 10:38:48 +00:00
|
|
|
if prefix_expanded:
|
2020-07-06 15:46:10 +00:00
|
|
|
prefix = prefix_expanded
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
params = ""
|
2019-08-09 12:15:42 +00:00
|
|
|
if lang:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
params += f'{spaces(1)}LANG\n{spaces(2)}"{lang}"\n'
|
|
|
|
params += f'{spaces(1)}PREFIX\n{spaces(2)}"{prefix}"\n'
|
2019-08-09 12:15:42 +00:00
|
|
|
if base_dir:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
params += f'{spaces(1)}BASE\n{spaces(2)}"{base_dir}"\n'
|
2019-08-21 13:47:38 +00:00
|
|
|
if is_example:
|
2019-09-19 06:45:21 +00:00
|
|
|
add_resource_command = "qt6_add_resources"
|
2019-08-21 13:47:38 +00:00
|
|
|
else:
|
2019-11-13 13:03:20 +00:00
|
|
|
add_resource_command = get_cmake_api_call("qt_add_resource")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
output += (
|
|
|
|
f'{add_resource_command}({target} "{resource_name}"\n{params}{spaces(1)}FILES\n'
|
|
|
|
f"{spaces(2)}{file_list}\n)\n"
|
|
|
|
)
|
2019-08-09 12:15:42 +00:00
|
|
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
class QmlDirFileInfo:
|
2019-10-07 10:22:04 +00:00
|
|
|
def __init__(self, file_path: str, type_name: str) -> None:
|
2019-09-03 12:32:43 +00:00
|
|
|
self.file_path = file_path
|
2020-08-20 15:55:03 +00:00
|
|
|
self.versions = ""
|
2019-09-03 12:32:43 +00:00
|
|
|
self.type_name = type_name
|
|
|
|
self.internal = False
|
|
|
|
self.singleton = False
|
2019-10-07 10:22:04 +00:00
|
|
|
self.path = ""
|
2019-09-03 12:32:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class QmlDir:
|
2019-10-07 10:22:04 +00:00
|
|
|
def __init__(self) -> None:
|
2019-09-03 12:32:43 +00:00
|
|
|
self.module = ""
|
|
|
|
self.plugin_name = ""
|
2020-06-03 17:59:04 +00:00
|
|
|
self.plugin_optional = False
|
2019-09-03 12:32:43 +00:00
|
|
|
self.plugin_path = ""
|
|
|
|
self.classname = ""
|
2019-10-07 10:22:04 +00:00
|
|
|
self.imports: List[str] = []
|
2020-10-06 14:05:01 +00:00
|
|
|
self.optional_imports: List[str] = []
|
2019-10-07 10:22:04 +00:00
|
|
|
self.type_names: Dict[str, QmlDirFileInfo] = {}
|
|
|
|
self.type_infos: List[str] = []
|
2019-10-09 11:11:58 +00:00
|
|
|
self.depends: List[Tuple[str, str]] = []
|
2019-09-03 12:32:43 +00:00
|
|
|
self.designer_supported = False
|
|
|
|
|
2019-10-07 10:22:04 +00:00
|
|
|
def __str__(self) -> str:
|
2019-09-21 18:18:10 +00:00
|
|
|
type_infos_line = " \n".join(self.type_infos)
|
2019-09-20 09:34:16 +00:00
|
|
|
imports_line = " \n".join(self.imports)
|
2020-10-06 14:05:01 +00:00
|
|
|
optional_imports_line = " \n".join(self.optional_imports)
|
2019-09-20 09:34:16 +00:00
|
|
|
string = f"""\
|
|
|
|
module: {self.module}
|
2020-06-03 17:59:04 +00:00
|
|
|
plugin: {self.plugin_optional} {self.plugin_name} {self.plugin_path}
|
2019-09-20 09:34:16 +00:00
|
|
|
classname: {self.classname}
|
|
|
|
type_infos:{type_infos_line}
|
|
|
|
imports:{imports_line}
|
2020-10-06 14:05:01 +00:00
|
|
|
optional_imports:{optional_imports_line}
|
2019-09-20 09:34:16 +00:00
|
|
|
dependends:
|
|
|
|
"""
|
2019-09-03 12:32:43 +00:00
|
|
|
for dep in self.depends:
|
2019-09-20 09:34:16 +00:00
|
|
|
string += f" {dep[0]} {dep[1]}\n"
|
|
|
|
string += f"designer supported: {self.designer_supported}\n"
|
|
|
|
string += "type_names:\n"
|
2019-09-03 12:32:43 +00:00
|
|
|
for key in self.type_names:
|
|
|
|
file_info = self.type_names[key]
|
2019-09-20 09:34:16 +00:00
|
|
|
string += (
|
|
|
|
f" type:{file_info.type_name} "
|
2020-08-20 15:55:03 +00:00
|
|
|
f"versions:{file_info.versions} "
|
2019-09-20 09:34:16 +00:00
|
|
|
f"path:{file_info.file_path} "
|
|
|
|
f"internal:{file_info.internal} "
|
|
|
|
f"singleton:{file_info.singleton}\n"
|
2019-09-03 12:32:43 +00:00
|
|
|
)
|
2019-09-20 09:34:16 +00:00
|
|
|
return string
|
2019-09-03 12:32:43 +00:00
|
|
|
|
|
|
|
def get_or_create_file_info(self, path: str, type_name: str) -> QmlDirFileInfo:
|
2019-09-21 18:18:10 +00:00
|
|
|
if path not in self.type_names:
|
2019-09-03 12:32:43 +00:00
|
|
|
self.type_names[path] = QmlDirFileInfo(path, type_name)
|
|
|
|
qmldir_file = self.type_names[path]
|
|
|
|
if qmldir_file.type_name != type_name:
|
|
|
|
raise RuntimeError("Registered qmldir file type_name does not match.")
|
|
|
|
return qmldir_file
|
|
|
|
|
|
|
|
def handle_file_internal(self, type_name: str, path: str):
|
|
|
|
qmldir_file = self.get_or_create_file_info(path, type_name)
|
|
|
|
qmldir_file.internal = True
|
|
|
|
|
|
|
|
def handle_file_singleton(self, type_name: str, version: str, path: str):
|
|
|
|
qmldir_file = self.handle_file(type_name, version, path)
|
|
|
|
qmldir_file.singleton = True
|
|
|
|
|
|
|
|
def handle_file(self, type_name: str, version: str, path: str) -> QmlDirFileInfo:
|
|
|
|
qmldir_file = self.get_or_create_file_info(path, type_name)
|
2020-08-20 15:55:03 +00:00
|
|
|
# If this is not the first version we've found,
|
|
|
|
# append ';' to delineate the next version; e.g.: "2.0;2.6"
|
|
|
|
if qmldir_file.versions:
|
|
|
|
qmldir_file.versions += ";"
|
|
|
|
qmldir_file.versions += version
|
2019-09-03 12:32:43 +00:00
|
|
|
qmldir_file.type_name = type_name
|
|
|
|
qmldir_file.path = path
|
|
|
|
return qmldir_file
|
|
|
|
|
2020-01-29 14:36:21 +00:00
|
|
|
def from_lines(self, lines: List[str]):
|
2019-11-22 12:01:45 +00:00
|
|
|
for line in lines:
|
|
|
|
self.handle_line(line)
|
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
def from_file(self, path: str):
|
|
|
|
f = open(path, "r")
|
|
|
|
if not f:
|
2019-09-20 09:34:16 +00:00
|
|
|
raise RuntimeError(f"Failed to open qmldir file at: {path}")
|
2019-09-03 12:32:43 +00:00
|
|
|
for line in f:
|
2019-11-22 12:01:45 +00:00
|
|
|
self.handle_line(line)
|
|
|
|
|
|
|
|
def handle_line(self, line: str):
|
|
|
|
if line.startswith("#"):
|
|
|
|
return
|
|
|
|
line = line.strip().replace("\n", "")
|
|
|
|
if len(line) == 0:
|
|
|
|
return
|
|
|
|
|
|
|
|
entries = line.split(" ")
|
|
|
|
if len(entries) == 0:
|
|
|
|
raise RuntimeError("Unexpected QmlDir file line entry")
|
|
|
|
if entries[0] == "module":
|
|
|
|
self.module = entries[1]
|
2020-10-19 06:41:35 +00:00
|
|
|
elif entries[0] == "singleton":
|
2019-11-22 12:01:45 +00:00
|
|
|
self.handle_file_singleton(entries[1], entries[2], entries[3])
|
|
|
|
elif entries[0] == "internal":
|
|
|
|
self.handle_file_internal(entries[1], entries[2])
|
|
|
|
elif entries[0] == "plugin":
|
|
|
|
self.plugin_name = entries[1]
|
|
|
|
if len(entries) > 2:
|
|
|
|
self.plugin_path = entries[2]
|
2020-06-03 17:59:04 +00:00
|
|
|
elif entries[0] == "optional":
|
2020-10-06 14:05:01 +00:00
|
|
|
if entries[1] == "plugin":
|
|
|
|
self.plugin_name = entries[2]
|
|
|
|
self.plugin_optional = True
|
|
|
|
if len(entries) > 3:
|
|
|
|
self.plugin_path = entries[3]
|
|
|
|
elif entries[1] == "import":
|
|
|
|
if len(entries) == 4:
|
|
|
|
self.optional_imports.append(entries[2] + "/" + entries[3])
|
|
|
|
else:
|
|
|
|
self.optional_imports.append(entries[2])
|
|
|
|
else:
|
|
|
|
raise RuntimeError("Only plugins and imports can be optional in qmldir files")
|
2019-11-22 12:01:45 +00:00
|
|
|
elif entries[0] == "classname":
|
|
|
|
self.classname = entries[1]
|
|
|
|
elif entries[0] == "typeinfo":
|
|
|
|
self.type_infos.append(entries[1])
|
|
|
|
elif entries[0] == "depends":
|
|
|
|
self.depends.append((entries[1], entries[2]))
|
|
|
|
elif entries[0] == "designersupported":
|
|
|
|
self.designer_supported = True
|
|
|
|
elif entries[0] == "import":
|
2020-06-23 16:21:24 +00:00
|
|
|
if len(entries) == 3:
|
|
|
|
self.imports.append(entries[1] + "/" + entries[2])
|
|
|
|
else:
|
|
|
|
self.imports.append(entries[1])
|
2019-11-22 12:01:45 +00:00
|
|
|
elif len(entries) == 3:
|
|
|
|
self.handle_file(entries[0], entries[1], entries[2])
|
|
|
|
else:
|
|
|
|
raise RuntimeError(f"Uhandled qmldir entry {line}")
|
2019-09-03 12:32:43 +00:00
|
|
|
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
def spaces(indent: int) -> str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return " " * indent
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
|
2019-04-16 14:32:08 +00:00
|
|
|
def trim_leading_dot(file: str) -> str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
while file.startswith("./"):
|
2019-04-16 14:32:08 +00:00
|
|
|
file = file[2:]
|
|
|
|
return file
|
|
|
|
|
|
|
|
|
2019-03-28 12:54:56 +00:00
|
|
|
def map_to_file(f: str, scope: Scope, *, is_include: bool = False) -> str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
assert "$$" not in f
|
2019-03-28 12:54:56 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if f.startswith("${"): # Some cmake variable is prepended
|
2019-03-28 12:54:56 +00:00
|
|
|
return f
|
|
|
|
|
|
|
|
base_dir = scope.currentdir if is_include else scope.basedir
|
2019-09-11 08:13:06 +00:00
|
|
|
f = posixpath.join(base_dir, f)
|
2019-03-28 12:54:56 +00:00
|
|
|
|
2019-04-16 14:32:08 +00:00
|
|
|
return trim_leading_dot(f)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def handle_vpath(source: str, base_dir: str, vpath: List[str]) -> str:
|
|
|
|
assert "$$" not in source
|
2019-03-28 12:54:56 +00:00
|
|
|
|
|
|
|
if not source:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return ""
|
2019-03-28 12:54:56 +00:00
|
|
|
|
|
|
|
if not vpath:
|
|
|
|
return source
|
2018-12-20 09:41:56 +00:00
|
|
|
|
|
|
|
if os.path.exists(os.path.join(base_dir, source)):
|
|
|
|
return source
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
variable_pattern = re.compile(r"\$\{[A-Za-z0-9_]+\}")
|
2019-03-28 07:29:53 +00:00
|
|
|
match = re.match(variable_pattern, source)
|
|
|
|
if match:
|
|
|
|
# a complex, variable based path, skipping validation
|
|
|
|
# or resolving
|
|
|
|
return source
|
|
|
|
|
2018-12-20 09:41:56 +00:00
|
|
|
for v in vpath:
|
2019-09-11 08:13:06 +00:00
|
|
|
fullpath = posixpath.join(v, source)
|
2018-12-20 09:41:56 +00:00
|
|
|
if os.path.exists(fullpath):
|
2019-09-11 08:13:06 +00:00
|
|
|
return trim_leading_dot(posixpath.relpath(fullpath, base_dir))
|
2018-12-20 09:41:56 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f" XXXX: Source {source}: Not found.")
|
|
|
|
return f"{source}-NOTFOUND"
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
|
2018-12-20 15:15:10 +00:00
|
|
|
class Operation:
|
2019-11-08 14:42:35 +00:00
|
|
|
def __init__(self, value: Union[List[str], str], line_no: int = -1) -> None:
|
2019-05-17 16:09:21 +00:00
|
|
|
if isinstance(value, list):
|
|
|
|
self._value = value
|
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
self._value = [str(value)]
|
2019-11-08 14:42:35 +00:00
|
|
|
self._line_no = line_no
|
2018-12-20 15:15:10 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def process(
|
2019-10-08 13:07:41 +00:00
|
|
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> List[str]:
|
|
|
|
assert False
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2019-01-17 16:10:17 +00:00
|
|
|
def __repr__(self):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
assert False
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2019-01-22 13:16:41 +00:00
|
|
|
def _dump(self):
|
|
|
|
if not self._value:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return "<NOTHING>"
|
2019-01-22 13:16:41 +00:00
|
|
|
|
|
|
|
if not isinstance(self._value, list):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return "<NOT A LIST>"
|
2019-01-22 13:16:41 +00:00
|
|
|
|
|
|
|
result = []
|
|
|
|
for i in self._value:
|
|
|
|
if not i:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result.append("<NONE>")
|
2019-01-22 13:16:41 +00:00
|
|
|
else:
|
|
|
|
result.append(str(i))
|
|
|
|
return '"' + '", "'.join(result) + '"'
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2019-01-25 14:41:02 +00:00
|
|
|
|
2018-12-20 15:15:10 +00:00
|
|
|
class AddOperation(Operation):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def process(
|
2019-09-20 09:34:16 +00:00
|
|
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> List[str]:
|
2019-09-20 09:34:16 +00:00
|
|
|
return sinput + transformer(self._value)
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2019-01-17 16:10:17 +00:00
|
|
|
def __repr__(self):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return f"+({self._dump()})"
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2019-10-10 13:10:37 +00:00
|
|
|
|
2018-12-20 15:15:10 +00:00
|
|
|
class UniqueAddOperation(Operation):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def process(
|
2019-09-20 09:34:16 +00:00
|
|
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> List[str]:
|
2019-09-20 09:34:16 +00:00
|
|
|
result = sinput
|
2019-03-28 12:54:56 +00:00
|
|
|
for v in transformer(self._value):
|
2018-12-21 11:13:38 +00:00
|
|
|
if v not in result:
|
2019-03-28 12:54:56 +00:00
|
|
|
result.append(v)
|
2018-12-20 15:15:10 +00:00
|
|
|
return result
|
|
|
|
|
2019-01-17 16:10:17 +00:00
|
|
|
def __repr__(self):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return f"*({self._dump()})"
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2019-10-10 13:10:37 +00:00
|
|
|
|
2019-09-23 11:19:22 +00:00
|
|
|
class ReplaceOperation(Operation):
|
|
|
|
def process(
|
|
|
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
|
|
|
) -> List[str]:
|
|
|
|
result = []
|
|
|
|
for s in sinput:
|
|
|
|
for v in transformer(self._value):
|
|
|
|
pattern, replacement = self.split_rex(v)
|
|
|
|
result.append(re.sub(pattern, replacement, s))
|
|
|
|
return result
|
|
|
|
|
|
|
|
def split_rex(self, s):
|
|
|
|
pattern = ""
|
|
|
|
replacement = ""
|
|
|
|
if len(s) < 4:
|
|
|
|
return pattern, replacement
|
|
|
|
sep = s[1]
|
|
|
|
s = s[2:]
|
|
|
|
rex = re.compile(f"[^\\\\]{sep}")
|
|
|
|
m = rex.search(s)
|
|
|
|
if not m:
|
|
|
|
return pattern, replacement
|
2019-10-10 14:32:19 +00:00
|
|
|
pattern = s[: m.start() + 1]
|
|
|
|
replacement = s[m.end() :]
|
2019-09-23 11:19:22 +00:00
|
|
|
m = rex.search(replacement)
|
|
|
|
if m:
|
2019-10-10 14:32:19 +00:00
|
|
|
replacement = replacement[: m.start() + 1]
|
2019-09-23 11:19:22 +00:00
|
|
|
return pattern, replacement
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f"*({self._dump()})"
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2019-10-10 13:10:37 +00:00
|
|
|
|
2018-12-20 15:15:10 +00:00
|
|
|
class SetOperation(Operation):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def process(
|
2019-09-20 09:34:16 +00:00
|
|
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> List[str]:
|
|
|
|
values = [] # List[str]
|
2019-04-11 15:06:01 +00:00
|
|
|
for v in self._value:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if v != f"$${key}":
|
2019-04-11 15:06:01 +00:00
|
|
|
values.append(v)
|
|
|
|
else:
|
2019-09-20 09:34:16 +00:00
|
|
|
values += sinput
|
2019-04-11 15:06:01 +00:00
|
|
|
|
2019-03-28 12:54:56 +00:00
|
|
|
if transformer:
|
2019-04-11 15:06:01 +00:00
|
|
|
return list(transformer(values))
|
2019-03-28 12:54:56 +00:00
|
|
|
else:
|
2019-04-11 15:06:01 +00:00
|
|
|
return values
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2019-01-17 16:10:17 +00:00
|
|
|
def __repr__(self):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return f"=({self._dump()})"
|
2018-12-20 15:15:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RemoveOperation(Operation):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def process(
|
2019-09-20 09:34:16 +00:00
|
|
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> List[str]:
|
2019-09-20 09:34:16 +00:00
|
|
|
sinput_set = set(sinput)
|
2019-03-26 13:12:09 +00:00
|
|
|
value_set = set(self._value)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result: List[str] = []
|
2019-03-26 13:12:09 +00:00
|
|
|
|
|
|
|
# Add everything that is not going to get removed:
|
2019-09-20 09:34:16 +00:00
|
|
|
for v in sinput:
|
2019-03-26 13:12:09 +00:00
|
|
|
if v not in value_set:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result += [v]
|
2019-03-26 13:12:09 +00:00
|
|
|
|
|
|
|
# Add everything else with removal marker:
|
2019-03-28 12:54:56 +00:00
|
|
|
for v in transformer(self._value):
|
2019-09-20 09:34:16 +00:00
|
|
|
if v not in sinput_set:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result += [f"-{v}"]
|
2019-03-26 13:12:09 +00:00
|
|
|
|
2018-12-20 15:15:10 +00:00
|
|
|
return result
|
|
|
|
|
2019-01-17 16:10:17 +00:00
|
|
|
def __repr__(self):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return f"-({self._dump()})"
|
2018-12-20 15:15:10 +00:00
|
|
|
|
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
# Helper class that stores a list of tuples, representing a scope id and
|
|
|
|
# a line number within that scope's project file. The whole list
|
|
|
|
# represents the full path location for a certain operation while
|
|
|
|
# traversing include()'d scopes. Used for sorting when determining
|
|
|
|
# operation order when evaluating operations.
|
|
|
|
class OperationLocation(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.list_of_scope_ids_and_line_numbers = []
|
|
|
|
|
|
|
|
def clone_and_append(self, scope_id: int, line_number: int) -> OperationLocation:
|
|
|
|
new_location = OperationLocation()
|
|
|
|
new_location.list_of_scope_ids_and_line_numbers = list(
|
|
|
|
self.list_of_scope_ids_and_line_numbers
|
|
|
|
)
|
|
|
|
new_location.list_of_scope_ids_and_line_numbers.append((scope_id, line_number))
|
|
|
|
return new_location
|
|
|
|
|
|
|
|
def __lt__(self, other: OperationLocation) -> Any:
|
|
|
|
return self.list_of_scope_ids_and_line_numbers < other.list_of_scope_ids_and_line_numbers
|
|
|
|
|
|
|
|
def __repr__(self) -> str:
|
|
|
|
s = ""
|
|
|
|
for t in self.list_of_scope_ids_and_line_numbers:
|
|
|
|
s += f"s{t[0]}:{t[1]} "
|
|
|
|
s = s.strip(" ")
|
|
|
|
return s
|
|
|
|
|
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
class Scope(object):
|
2019-01-31 11:17:27 +00:00
|
|
|
|
|
|
|
SCOPE_ID: int = 1
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
*,
|
|
|
|
parent_scope: Optional[Scope],
|
2019-10-07 10:22:04 +00:00
|
|
|
qmake_file: str,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition: str = "",
|
|
|
|
base_dir: str = "",
|
2019-10-07 10:22:04 +00:00
|
|
|
operations: Union[Dict[str, List[Operation]], None] = None,
|
2019-11-08 14:42:35 +00:00
|
|
|
parent_include_line_no: int = -1,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> None:
|
2019-10-07 10:22:04 +00:00
|
|
|
if not operations:
|
2019-08-01 14:01:22 +00:00
|
|
|
operations = {
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"QT_SOURCE_TREE": [SetOperation(["${QT_SOURCE_TREE}"])],
|
2019-10-07 14:18:04 +00:00
|
|
|
"QT_BUILD_TREE": [SetOperation(["${PROJECT_BINARY_DIR}"])],
|
2019-10-04 12:03:42 +00:00
|
|
|
"QTRO_SOURCE_TREE": [SetOperation(["${CMAKE_SOURCE_DIR}"])],
|
2019-08-01 14:01:22 +00:00
|
|
|
}
|
|
|
|
|
2019-10-07 10:22:04 +00:00
|
|
|
self._operations: Dict[str, List[Operation]] = copy.deepcopy(operations)
|
2018-12-20 15:15:10 +00:00
|
|
|
if parent_scope:
|
|
|
|
parent_scope._add_child(self)
|
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
self._parent = None # type: Optional[Scope]
|
2019-08-01 14:39:43 +00:00
|
|
|
# Only add the "QT = core gui" Set operation once, on the
|
|
|
|
# very top-level .pro scope, aka it's basedir is empty.
|
|
|
|
if not base_dir:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
self._operations["QT"] = [SetOperation(["core", "gui"])]
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
self._basedir = base_dir
|
2019-10-07 10:22:04 +00:00
|
|
|
if qmake_file:
|
|
|
|
self._currentdir = os.path.dirname(qmake_file) or "."
|
2018-10-24 13:20:27 +00:00
|
|
|
if not self._basedir:
|
|
|
|
self._basedir = self._currentdir
|
|
|
|
|
2019-01-31 11:17:27 +00:00
|
|
|
self._scope_id = Scope.SCOPE_ID
|
|
|
|
Scope.SCOPE_ID += 1
|
2019-10-07 10:22:04 +00:00
|
|
|
self._file = qmake_file
|
|
|
|
self._file_absolute_path = os.path.abspath(qmake_file)
|
2018-10-24 13:20:27 +00:00
|
|
|
self._condition = map_condition(condition)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
self._children = [] # type: List[Scope]
|
|
|
|
self._included_children = [] # type: List[Scope]
|
2020-11-27 12:32:13 +00:00
|
|
|
self._including_scope = None # type: Optional[Scope]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
self._visited_keys = set() # type: Set[str]
|
|
|
|
self._total_condition = None # type: Optional[str]
|
2019-11-08 14:42:35 +00:00
|
|
|
self._parent_include_line_no = parent_include_line_no
|
2020-01-31 21:21:09 +00:00
|
|
|
self._is_public_module = False
|
|
|
|
self._has_private_module = False
|
2020-07-27 09:10:48 +00:00
|
|
|
self._is_internal_qt_app = False
|
2019-01-18 11:43:11 +00:00
|
|
|
|
2019-01-24 14:43:13 +00:00
|
|
|
def __repr__(self):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return (
|
|
|
|
f"{self._scope_id}:{self._basedir}:{self._currentdir}:{self._file}:"
|
|
|
|
f"{self._condition or '<TRUE>'}"
|
|
|
|
)
|
2019-01-24 14:43:13 +00:00
|
|
|
|
2019-01-18 11:43:11 +00:00
|
|
|
def reset_visited_keys(self):
|
|
|
|
self._visited_keys = set()
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def merge(self, other: "Scope") -> None:
|
2019-01-31 09:18:14 +00:00
|
|
|
assert self != other
|
2020-11-27 12:32:13 +00:00
|
|
|
other._including_scope = self
|
2019-03-28 12:54:56 +00:00
|
|
|
self._included_children.append(other)
|
2019-01-31 09:18:14 +00:00
|
|
|
|
2019-01-31 13:23:57 +00:00
|
|
|
@property
|
|
|
|
def scope_debug(self) -> bool:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
merge = self.get_string("PRO2CMAKE_SCOPE_DEBUG").lower()
|
|
|
|
return merge == "1" or merge == "on" or merge == "yes" or merge == "true"
|
2019-01-31 13:23:57 +00:00
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def parent(self) -> Optional[Scope]:
|
2019-01-24 15:01:17 +00:00
|
|
|
return self._parent
|
|
|
|
|
2020-11-27 12:32:13 +00:00
|
|
|
@property
|
|
|
|
def including_scope(self) -> Optional[Scope]:
|
|
|
|
return self._including_scope
|
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
2018-10-24 13:20:27 +00:00
|
|
|
def basedir(self) -> str:
|
|
|
|
return self._basedir
|
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
2018-10-24 13:20:27 +00:00
|
|
|
def currentdir(self) -> str:
|
|
|
|
return self._currentdir
|
|
|
|
|
2020-01-31 21:21:09 +00:00
|
|
|
@property
|
|
|
|
def is_public_module(self) -> bool:
|
|
|
|
return self._is_public_module
|
|
|
|
|
|
|
|
@property
|
|
|
|
def has_private_module(self) -> bool:
|
|
|
|
return self._has_private_module
|
|
|
|
|
2020-07-27 09:10:48 +00:00
|
|
|
@property
|
|
|
|
def is_internal_qt_app(self) -> bool:
|
|
|
|
is_app = self._is_internal_qt_app
|
|
|
|
current_scope = self
|
|
|
|
while not is_app and current_scope.parent:
|
|
|
|
current_scope = current_scope.parent
|
|
|
|
is_app = current_scope.is_internal_qt_app
|
|
|
|
|
|
|
|
return is_app
|
|
|
|
|
2019-01-31 13:26:06 +00:00
|
|
|
def can_merge_condition(self):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if self._condition == "else":
|
2019-01-31 13:26:06 +00:00
|
|
|
return False
|
|
|
|
if self._operations:
|
|
|
|
return False
|
|
|
|
|
|
|
|
child_count = len(self._children)
|
|
|
|
if child_count == 0 or child_count > 2:
|
|
|
|
return False
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
assert child_count != 1 or self._children[0]._condition != "else"
|
|
|
|
return child_count == 1 or self._children[1]._condition == "else"
|
2019-01-31 13:26:06 +00:00
|
|
|
|
|
|
|
def settle_condition(self):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
new_children: List[Scope] = []
|
2019-01-31 13:26:06 +00:00
|
|
|
for c in self._children:
|
|
|
|
c.settle_condition()
|
|
|
|
|
|
|
|
if c.can_merge_condition():
|
|
|
|
child = c._children[0]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
child._condition = "({c._condition}) AND ({child._condition})"
|
2019-01-31 13:26:06 +00:00
|
|
|
new_children += c._children
|
|
|
|
else:
|
|
|
|
new_children.append(c)
|
|
|
|
self._children = new_children
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
@staticmethod
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def FromDict(
|
2019-11-08 14:42:35 +00:00
|
|
|
parent_scope: Optional["Scope"],
|
|
|
|
file: str,
|
|
|
|
statements,
|
|
|
|
cond: str = "",
|
|
|
|
base_dir: str = "",
|
|
|
|
project_file_content: str = "",
|
|
|
|
parent_include_line_no: int = -1,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> Scope:
|
2019-11-08 14:42:35 +00:00
|
|
|
scope = Scope(
|
|
|
|
parent_scope=parent_scope,
|
|
|
|
qmake_file=file,
|
|
|
|
condition=cond,
|
|
|
|
base_dir=base_dir,
|
|
|
|
parent_include_line_no=parent_include_line_no,
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
for statement in statements:
|
|
|
|
if isinstance(statement, list): # Handle skipped parts...
|
|
|
|
assert not statement
|
|
|
|
continue
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
operation = statement.get("operation", None)
|
2018-10-24 13:20:27 +00:00
|
|
|
if operation:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
key = statement.get("key", "")
|
|
|
|
value = statement.get("value", [])
|
|
|
|
assert key != ""
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
op_location_start = operation["locn_start"]
|
|
|
|
operation = operation["value"]
|
|
|
|
op_line_no = pp.lineno(op_location_start, project_file_content)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if operation == "=":
|
2019-11-08 14:42:35 +00:00
|
|
|
scope._append_operation(key, SetOperation(value, line_no=op_line_no))
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
elif operation == "-=":
|
2019-11-08 14:42:35 +00:00
|
|
|
scope._append_operation(key, RemoveOperation(value, line_no=op_line_no))
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
elif operation == "+=":
|
2019-11-08 14:42:35 +00:00
|
|
|
scope._append_operation(key, AddOperation(value, line_no=op_line_no))
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
elif operation == "*=":
|
2019-11-08 14:42:35 +00:00
|
|
|
scope._append_operation(key, UniqueAddOperation(value, line_no=op_line_no))
|
2019-09-23 11:19:22 +00:00
|
|
|
elif operation == "~=":
|
2019-11-08 14:42:35 +00:00
|
|
|
scope._append_operation(key, ReplaceOperation(value, line_no=op_line_no))
|
2018-10-24 13:20:27 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f'Unexpected operation "{operation}" in scope "{scope}".')
|
|
|
|
assert False
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
continue
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition = statement.get("condition", None)
|
2018-10-24 13:20:27 +00:00
|
|
|
if condition:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
Scope.FromDict(scope, file, statement.get("statements"), condition, scope.basedir)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
else_statements = statement.get("else_statements")
|
2018-10-24 13:20:27 +00:00
|
|
|
if else_statements:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
Scope.FromDict(scope, file, else_statements, "else", scope.basedir)
|
2018-10-24 13:20:27 +00:00
|
|
|
continue
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
loaded = statement.get("loaded")
|
2018-10-24 13:20:27 +00:00
|
|
|
if loaded:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
scope._append_operation("_LOADED", UniqueAddOperation(loaded))
|
2018-10-24 13:20:27 +00:00
|
|
|
continue
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
option = statement.get("option", None)
|
2018-10-24 13:20:27 +00:00
|
|
|
if option:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
scope._append_operation("_OPTION", UniqueAddOperation(option))
|
2018-10-24 13:20:27 +00:00
|
|
|
continue
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
included = statement.get("included", None)
|
2018-10-24 13:20:27 +00:00
|
|
|
if included:
|
2019-11-08 14:42:35 +00:00
|
|
|
included_location_start = included["locn_start"]
|
|
|
|
included = included["value"]
|
|
|
|
included_line_no = pp.lineno(included_location_start, project_file_content)
|
|
|
|
scope._append_operation(
|
|
|
|
"_INCLUDED", UniqueAddOperation(included, line_no=included_line_no)
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
continue
|
|
|
|
|
2019-09-20 11:43:26 +00:00
|
|
|
project_required_condition = statement.get("project_required_condition")
|
|
|
|
if project_required_condition:
|
|
|
|
scope._append_operation("_REQUIREMENTS", AddOperation(project_required_condition))
|
|
|
|
|
2020-03-26 16:42:48 +00:00
|
|
|
qt_no_make_tools = statement.get("qt_no_make_tools_arguments")
|
|
|
|
if qt_no_make_tools:
|
|
|
|
qt_no_make_tools = qt_no_make_tools.strip("()").strip()
|
|
|
|
qt_no_make_tools = qt_no_make_tools.split()
|
|
|
|
for entry in qt_no_make_tools:
|
|
|
|
scope._append_operation("_QT_NO_MAKE_TOOLS", AddOperation(entry))
|
|
|
|
|
2019-01-31 13:26:06 +00:00
|
|
|
scope.settle_condition()
|
|
|
|
|
2019-01-31 13:23:57 +00:00
|
|
|
if scope.scope_debug:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f"..... [SCOPE_DEBUG]: Created scope {scope}:")
|
2019-01-31 13:23:57 +00:00
|
|
|
scope.dump(indent=1)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print("..... [SCOPE_DEBUG]: <<END OF SCOPE>>")
|
2018-10-24 13:20:27 +00:00
|
|
|
return scope
|
|
|
|
|
2018-12-20 15:15:10 +00:00
|
|
|
def _append_operation(self, key: str, op: Operation) -> None:
|
|
|
|
if key in self._operations:
|
|
|
|
self._operations[key].append(op)
|
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
self._operations[key] = [op]
|
2018-12-20 15:15:10 +00:00
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
2018-10-24 13:20:27 +00:00
|
|
|
def file(self) -> str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return self._file or ""
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
@property
|
|
|
|
def file_absolute_path(self) -> str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return self._file_absolute_path or ""
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
2019-05-04 11:08:19 +00:00
|
|
|
def generated_cmake_lists_path(self) -> str:
|
|
|
|
assert self.basedir
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return os.path.join(self.basedir, "CMakeLists.gen.txt")
|
2019-05-04 11:08:19 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def original_cmake_lists_path(self) -> str:
|
2019-01-29 09:18:21 +00:00
|
|
|
assert self.basedir
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return os.path.join(self.basedir, "CMakeLists.txt")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
2018-10-24 13:20:27 +00:00
|
|
|
def condition(self) -> str:
|
|
|
|
return self._condition
|
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def total_condition(self) -> Optional[str]:
|
2019-01-22 13:20:47 +00:00
|
|
|
return self._total_condition
|
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@total_condition.setter
|
|
|
|
def total_condition(self, condition: str) -> None:
|
|
|
|
self._total_condition = condition
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def _add_child(self, scope: "Scope") -> None:
|
2018-10-24 13:20:27 +00:00
|
|
|
scope._parent = self
|
|
|
|
self._children.append(scope)
|
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def children(self) -> List["Scope"]:
|
2019-03-28 12:54:56 +00:00
|
|
|
result = list(self._children)
|
|
|
|
for include_scope in self._included_children:
|
2019-05-29 15:39:56 +00:00
|
|
|
result += include_scope.children
|
2019-03-28 12:54:56 +00:00
|
|
|
return result
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
def dump(self, *, indent: int = 0) -> None:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
ind = spaces(indent)
|
|
|
|
print(f'{ind}Scope "{self}":')
|
2019-01-31 10:54:55 +00:00
|
|
|
if self.total_condition:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f"{ind} Total condition = {self.total_condition}")
|
|
|
|
print(f"{ind} Keys:")
|
2019-01-17 16:10:57 +00:00
|
|
|
keys = self._operations.keys()
|
|
|
|
if not keys:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f"{ind} -- NONE --")
|
2019-01-17 16:10:57 +00:00
|
|
|
else:
|
|
|
|
for k in sorted(keys):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f'{ind} {k} = "{self._operations.get(k, [])}"')
|
|
|
|
print(f"{ind} Children:")
|
2019-01-17 16:10:57 +00:00
|
|
|
if not self._children:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f"{ind} -- NONE --")
|
2019-01-17 16:10:57 +00:00
|
|
|
else:
|
|
|
|
for c in self._children:
|
|
|
|
c.dump(indent=indent + 1)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f"{ind} Includes:")
|
2019-03-28 12:54:56 +00:00
|
|
|
if not self._included_children:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f"{ind} -- NONE --")
|
2019-03-28 12:54:56 +00:00
|
|
|
else:
|
|
|
|
for c in self._included_children:
|
|
|
|
c.dump(indent=indent + 1)
|
|
|
|
|
2019-10-08 13:07:41 +00:00
|
|
|
def dump_structure(self, *, structure_type: str = "ROOT", indent: int = 0) -> None:
|
|
|
|
print(f"{spaces(indent)}{structure_type}: {self}")
|
2019-03-28 12:54:56 +00:00
|
|
|
for i in self._included_children:
|
2019-10-08 13:07:41 +00:00
|
|
|
i.dump_structure(structure_type="INCL", indent=indent + 1)
|
2019-03-28 12:54:56 +00:00
|
|
|
for i in self._children:
|
2019-10-08 13:07:41 +00:00
|
|
|
i.dump_structure(structure_type="CHLD", indent=indent + 1)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
2019-01-18 11:43:11 +00:00
|
|
|
def keys(self):
|
|
|
|
return self._operations.keys()
|
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
2019-01-18 11:43:11 +00:00
|
|
|
def visited_keys(self):
|
2019-01-25 14:41:02 +00:00
|
|
|
return self._visited_keys
|
2019-01-18 11:43:11 +00:00
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
# Traverses a scope and its children, and collects operations
|
|
|
|
# that need to be processed for a certain key.
|
|
|
|
def _gather_operations_from_scope(
|
|
|
|
self,
|
|
|
|
operations_result: List[Dict[str, Any]],
|
|
|
|
current_scope: Scope,
|
|
|
|
op_key: str,
|
|
|
|
current_location: OperationLocation,
|
|
|
|
):
|
|
|
|
for op in current_scope._operations.get(op_key, []):
|
|
|
|
new_op_location = current_location.clone_and_append(
|
|
|
|
current_scope._scope_id, op._line_no
|
|
|
|
)
|
|
|
|
op_info: Dict[str, Any] = {}
|
|
|
|
op_info["op"] = op
|
|
|
|
op_info["scope"] = current_scope
|
|
|
|
op_info["location"] = new_op_location
|
|
|
|
operations_result.append(op_info)
|
|
|
|
|
|
|
|
for included_child in current_scope._included_children:
|
|
|
|
new_scope_location = current_location.clone_and_append(
|
|
|
|
current_scope._scope_id, included_child._parent_include_line_no
|
|
|
|
)
|
|
|
|
self._gather_operations_from_scope(
|
|
|
|
operations_result, included_child, op_key, new_scope_location
|
|
|
|
)
|
|
|
|
|
|
|
|
# Partially applies a scope argument to a given transformer.
|
|
|
|
@staticmethod
|
|
|
|
def _create_transformer_for_operation(
|
|
|
|
given_transformer: Optional[Callable[[Scope, List[str]], List[str]]],
|
|
|
|
transformer_scope: Scope,
|
|
|
|
) -> Callable[[List[str]], List[str]]:
|
|
|
|
if given_transformer:
|
|
|
|
|
|
|
|
def wrapped_transformer(values):
|
|
|
|
return given_transformer(transformer_scope, values)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
def wrapped_transformer(values):
|
|
|
|
return values
|
|
|
|
|
|
|
|
return wrapped_transformer
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def _evalOps(
|
|
|
|
self,
|
|
|
|
key: str,
|
|
|
|
transformer: Optional[Callable[[Scope, List[str]], List[str]]],
|
|
|
|
result: List[str],
|
|
|
|
*,
|
|
|
|
inherit: bool = False,
|
|
|
|
) -> List[str]:
|
2019-01-18 11:43:11 +00:00
|
|
|
self._visited_keys.add(key)
|
2019-03-28 12:54:56 +00:00
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
# Inherit values from parent scope.
|
|
|
|
# This is a strange edge case which is wrong in principle, because
|
|
|
|
# .pro files are imperative and not declarative. Nevertheless
|
|
|
|
# this fixes certain mappings (e.g. for handling
|
|
|
|
# VERSIONTAGGING_SOURCES in src/corelib/global/global.pri).
|
2019-07-15 13:38:47 +00:00
|
|
|
if self._parent and inherit:
|
2019-04-12 09:45:43 +00:00
|
|
|
result = self._parent._evalOps(key, transformer, result)
|
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
operations_to_run: List[Dict[str, Any]] = []
|
|
|
|
starting_location = OperationLocation()
|
|
|
|
starting_scope = self
|
|
|
|
self._gather_operations_from_scope(
|
|
|
|
operations_to_run, starting_scope, key, starting_location
|
|
|
|
)
|
2019-10-23 07:38:19 +00:00
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
# Sorts the operations based on the location of each operation. Technically compares two
|
|
|
|
# lists of tuples.
|
|
|
|
operations_to_run = sorted(operations_to_run, key=lambda o: o["location"])
|
2019-03-28 12:54:56 +00:00
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
# Process the operations.
|
|
|
|
for op_info in operations_to_run:
|
|
|
|
op_transformer = self._create_transformer_for_operation(transformer, op_info["scope"])
|
|
|
|
result = op_info["op"].process(key, result, op_transformer)
|
2018-12-20 15:15:10 +00:00
|
|
|
return result
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def get(self, key: str, *, ignore_includes: bool = False, inherit: bool = False) -> List[str]:
|
2019-05-29 07:57:34 +00:00
|
|
|
is_same_path = self.currentdir == self.basedir
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if not is_same_path:
|
2019-11-22 14:09:00 +00:00
|
|
|
relative_path = posixpath.relpath(self.currentdir, self.basedir)
|
2019-05-29 07:57:34 +00:00
|
|
|
|
2019-09-20 11:37:36 +00:00
|
|
|
if key == "QQC2_SOURCE_TREE":
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(os.path.abspath(self.currentdir))
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
|
|
|
project_relative_path = os.path.relpath(qmake_or_cmake_conf_dir_path, self.currentdir)
|
2019-10-10 14:32:19 +00:00
|
|
|
return ["${CMAKE_CURRENT_SOURCE_DIR}/" + project_relative_path]
|
2019-09-20 11:37:36 +00:00
|
|
|
|
2019-10-14 13:18:50 +00:00
|
|
|
if key == "QT_ARCH":
|
2019-10-14 13:54:02 +00:00
|
|
|
return ["${CMAKE_SYSTEM_PROCESSOR}"]
|
2019-10-14 13:18:50 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if key == "_PRO_FILE_PWD_":
|
|
|
|
return ["${CMAKE_CURRENT_SOURCE_DIR}"]
|
|
|
|
if key == "PWD":
|
2019-05-29 07:57:34 +00:00
|
|
|
if is_same_path:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return ["${CMAKE_CURRENT_SOURCE_DIR}"]
|
2019-05-29 07:57:34 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return [f"${{CMAKE_CURRENT_SOURCE_DIR}}/{relative_path}"]
|
|
|
|
if key == "OUT_PWD":
|
2019-05-29 07:57:34 +00:00
|
|
|
if is_same_path:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return ["${CMAKE_CURRENT_BINARY_DIR}"]
|
2019-05-29 07:57:34 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return [f"${{CMAKE_CURRENT_BINARY_DIR}}/{relative_path}"]
|
2019-03-28 12:54:56 +00:00
|
|
|
|
2020-04-08 16:34:00 +00:00
|
|
|
# Horrible hack. If we're returning the values for some key
|
|
|
|
# that looks like source or header files, make sure to use a
|
|
|
|
# map_files transformer, so that $$PWD values are evaluated
|
|
|
|
# in the transformer scope, otherwise relative paths will be
|
|
|
|
# broken.
|
|
|
|
# Looking at you qmltyperegistrar.pro.
|
|
|
|
eval_ops_transformer = None
|
|
|
|
if key.endswith("SOURCES") or key.endswith("HEADERS"):
|
2020-07-30 13:50:22 +00:00
|
|
|
|
2020-04-08 16:34:00 +00:00
|
|
|
def file_transformer(scope, files):
|
|
|
|
return scope._map_files(files)
|
2020-07-30 13:50:22 +00:00
|
|
|
|
2020-04-08 16:34:00 +00:00
|
|
|
eval_ops_transformer = file_transformer
|
|
|
|
return self._evalOps(key, eval_ops_transformer, [], inherit=inherit)
|
2019-03-28 12:54:56 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def get_string(self, key: str, default: str = "", inherit: bool = False) -> str:
|
|
|
|
v = self.get(key, inherit=inherit)
|
2018-12-20 15:15:10 +00:00
|
|
|
if len(v) == 0:
|
|
|
|
return default
|
2020-05-14 09:52:58 +00:00
|
|
|
if len(v) > 1:
|
2020-07-30 13:50:22 +00:00
|
|
|
return " ".join(v)
|
2018-12-20 15:15:10 +00:00
|
|
|
return v[0]
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def _map_files(
|
|
|
|
self, files: List[str], *, use_vpath: bool = True, is_include: bool = False
|
|
|
|
) -> List[str]:
|
2019-03-28 12:54:56 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
expanded_files = [] # type: List[str]
|
2019-03-28 12:54:56 +00:00
|
|
|
for f in files:
|
2019-04-11 15:06:01 +00:00
|
|
|
r = self._expand_value(f)
|
|
|
|
expanded_files += r
|
2019-03-28 12:54:56 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
mapped_files = list(
|
|
|
|
map(lambda f: map_to_file(f, self, is_include=is_include), expanded_files)
|
|
|
|
)
|
2019-03-28 12:54:56 +00:00
|
|
|
|
|
|
|
if use_vpath:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result = list(
|
|
|
|
map(
|
|
|
|
lambda f: handle_vpath(f, self.basedir, self.get("VPATH", inherit=True)),
|
|
|
|
mapped_files,
|
|
|
|
)
|
|
|
|
)
|
2019-03-28 12:54:56 +00:00
|
|
|
else:
|
|
|
|
result = mapped_files
|
|
|
|
|
|
|
|
# strip ${CMAKE_CURRENT_SOURCE_DIR}:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result = list(
|
|
|
|
map(lambda f: f[28:] if f.startswith("${CMAKE_CURRENT_SOURCE_DIR}/") else f, result)
|
|
|
|
)
|
2019-03-28 12:54:56 +00:00
|
|
|
|
2019-04-16 14:32:08 +00:00
|
|
|
# strip leading ./:
|
|
|
|
result = list(map(lambda f: trim_leading_dot(f), result))
|
|
|
|
|
2019-03-28 12:54:56 +00:00
|
|
|
return result
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def get_files(
|
|
|
|
self, key: str, *, use_vpath: bool = False, is_include: bool = False
|
|
|
|
) -> List[str]:
|
|
|
|
def transformer(scope, files):
|
|
|
|
return scope._map_files(files, use_vpath=use_vpath, is_include=is_include)
|
|
|
|
|
2019-03-28 12:54:56 +00:00
|
|
|
return list(self._evalOps(key, transformer, []))
|
|
|
|
|
2019-09-18 13:17:09 +00:00
|
|
|
@staticmethod
|
2019-09-21 16:02:54 +00:00
|
|
|
def _replace_env_var_value(value: Any) -> Any:
|
2019-09-18 13:17:09 +00:00
|
|
|
if not isinstance(value, str):
|
|
|
|
return value
|
|
|
|
|
2019-09-22 15:54:34 +00:00
|
|
|
pattern = re.compile(r"\$\$\(([A-Za-z_][A-Za-z0-9_]*)\)")
|
2019-09-18 13:17:09 +00:00
|
|
|
match = re.search(pattern, value)
|
|
|
|
if match:
|
|
|
|
value = re.sub(pattern, r"$ENV{\1}", value)
|
|
|
|
|
|
|
|
return value
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def _expand_value(self, value: str) -> List[str]:
|
2019-02-07 14:30:44 +00:00
|
|
|
result = value
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
pattern = re.compile(r"\$\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?")
|
2019-02-07 14:30:44 +00:00
|
|
|
match = re.search(pattern, result)
|
|
|
|
while match:
|
2019-02-11 16:46:31 +00:00
|
|
|
old_result = result
|
2019-09-18 13:17:09 +00:00
|
|
|
match_group_0 = match.group(0)
|
|
|
|
if match_group_0 == value:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
get_result = self.get(match.group(1), inherit=True)
|
2019-07-15 13:38:47 +00:00
|
|
|
if len(get_result) == 1:
|
|
|
|
result = get_result[0]
|
2019-09-18 13:17:09 +00:00
|
|
|
result = self._replace_env_var_value(result)
|
2019-07-15 13:38:47 +00:00
|
|
|
else:
|
2019-09-16 11:54:03 +00:00
|
|
|
# Recursively expand each value from the result list
|
|
|
|
# returned from self.get().
|
2019-10-07 10:22:04 +00:00
|
|
|
result_list: List[str] = []
|
2019-09-16 11:54:03 +00:00
|
|
|
for entry_value in get_result:
|
2019-09-18 13:17:09 +00:00
|
|
|
result_list += self._expand_value(self._replace_env_var_value(entry_value))
|
2019-09-16 11:54:03 +00:00
|
|
|
return result_list
|
2019-07-15 13:38:47 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
replacement = self.get(match.group(1), inherit=True)
|
|
|
|
replacement_str = replacement[0] if replacement else ""
|
2019-10-31 15:52:23 +00:00
|
|
|
if replacement_str == value:
|
|
|
|
# we have recursed
|
|
|
|
replacement_str = ""
|
2019-10-10 14:32:19 +00:00
|
|
|
result = result[: match.start()] + replacement_str + result[match.end() :]
|
2019-09-18 13:17:09 +00:00
|
|
|
result = self._replace_env_var_value(result)
|
2019-02-11 16:46:31 +00:00
|
|
|
|
|
|
|
if result == old_result:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return [result] # Do not go into infinite loop
|
2019-02-11 16:46:31 +00:00
|
|
|
|
2019-02-07 14:30:44 +00:00
|
|
|
match = re.search(pattern, result)
|
2019-09-18 13:17:09 +00:00
|
|
|
|
|
|
|
result = self._replace_env_var_value(result)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return [result]
|
2019-02-07 14:30:44 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def expand(self, key: str) -> List[str]:
|
2019-03-28 12:54:56 +00:00
|
|
|
value = self.get(key)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result: List[str] = []
|
2019-02-07 14:30:44 +00:00
|
|
|
assert isinstance(value, list)
|
|
|
|
for v in value:
|
|
|
|
result += self._expand_value(v)
|
|
|
|
return result
|
|
|
|
|
|
|
|
def expandString(self, key: str) -> str:
|
2019-03-28 12:54:56 +00:00
|
|
|
result = self._expand_value(self.get_string(key))
|
2019-02-07 14:30:44 +00:00
|
|
|
assert len(result) == 1
|
|
|
|
return result[0]
|
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
def _get_operation_at_index(self, key, index):
|
|
|
|
return self._operations[key][index]
|
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
|
|
|
def TEMPLATE(self) -> str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return self.get_string("TEMPLATE", "app")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
def _rawTemplate(self) -> str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return self.get_string("TEMPLATE")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
|
|
|
def TARGET(self) -> str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
target = self.expandString("TARGET") or os.path.splitext(os.path.basename(self.file))[0]
|
|
|
|
return re.sub(r"\.\./", "", target)
|
2019-08-26 08:52:17 +00:00
|
|
|
|
2020-01-14 12:30:12 +00:00
|
|
|
@property
|
|
|
|
def TARGET_ORIGINAL(self) -> str:
|
|
|
|
return self.expandString("TARGET") or os.path.splitext(os.path.basename(self.file))[0]
|
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
@property
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def _INCLUDED(self) -> List[str]:
|
|
|
|
return self.get("_INCLUDED")
|
2019-01-17 12:41:17 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-09-22 14:44:29 +00:00
|
|
|
# Given "if(a|b):c" returns "(a|b):c". Uses pyparsing to keep the parentheses
|
|
|
|
# balanced.
|
|
|
|
def unwrap_if(input_string):
|
|
|
|
# Compute the grammar only once.
|
|
|
|
if not hasattr(unwrap_if, "if_grammar"):
|
2019-10-10 14:32:19 +00:00
|
|
|
|
2020-07-30 13:56:37 +00:00
|
|
|
def handle_expr_with_parentheses(s, l_unused, t):
|
2019-10-07 14:56:29 +00:00
|
|
|
# The following expression unwraps the condition via the
|
|
|
|
# additional info set by originalTextFor, thus returning the
|
|
|
|
# condition without parentheses.
|
2019-10-10 14:32:19 +00:00
|
|
|
condition_without_parentheses = s[t._original_start + 1 : t._original_end - 1]
|
2019-10-07 14:56:29 +00:00
|
|
|
|
|
|
|
# Re-add the parentheses, but with spaces in-between. This
|
|
|
|
# fixes map_condition -> map_platform to apply properly.
|
|
|
|
condition_with_parentheses = "( " + condition_without_parentheses + " )"
|
|
|
|
return condition_with_parentheses
|
|
|
|
|
2019-09-22 14:44:29 +00:00
|
|
|
expr_with_parentheses = pp.originalTextFor(pp.nestedExpr())
|
2019-10-07 14:56:29 +00:00
|
|
|
expr_with_parentheses.setParseAction(handle_expr_with_parentheses)
|
|
|
|
|
2019-09-22 14:44:29 +00:00
|
|
|
if_keyword = pp.Suppress(pp.Keyword("if"))
|
|
|
|
unwrap_if.if_grammar = if_keyword + expr_with_parentheses
|
|
|
|
|
|
|
|
output_string = unwrap_if.if_grammar.transformString(input_string)
|
|
|
|
return output_string
|
|
|
|
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
def map_condition(condition: str) -> str:
|
2019-05-29 15:39:56 +00:00
|
|
|
# Some hardcoded cases that are too bothersome to generalize.
|
2019-11-22 17:26:41 +00:00
|
|
|
condition = re.sub(
|
|
|
|
r"qtConfig\(opengles\.\)",
|
|
|
|
r"(QT_FEATURE_opengles2 OR QT_FEATURE_opengles3 OR QT_FEATURE_opengles31 OR QT_FEATURE_opengles32)",
|
|
|
|
condition,
|
|
|
|
)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition = re.sub(
|
|
|
|
r"qtConfig\(opengl\(es1\|es2\)\?\)",
|
2020-03-09 13:55:17 +00:00
|
|
|
r"(QT_FEATURE_opengl OR QT_FEATURE_opengles2 OR QT_FEATURE_opengles3)",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition,
|
|
|
|
)
|
|
|
|
condition = re.sub(r"qtConfig\(opengl\.\*\)", r"QT_FEATURE_opengl", condition)
|
|
|
|
condition = re.sub(r"^win\*$", r"win", condition)
|
|
|
|
condition = re.sub(r"^no-png$", r"NOT QT_FEATURE_png", condition)
|
|
|
|
condition = re.sub(r"contains\(CONFIG, static\)", r"NOT QT_BUILD_SHARED_LIBS", condition)
|
|
|
|
condition = re.sub(r"contains\(QT_CONFIG,\w*shared\)", r"QT_BUILD_SHARED_LIBS", condition)
|
2020-03-16 12:36:47 +00:00
|
|
|
condition = re.sub(r"CONFIG\(osx\)", r"MACOS", condition)
|
2019-05-29 15:39:56 +00:00
|
|
|
|
2019-09-21 18:18:10 +00:00
|
|
|
def gcc_version_handler(match_obj: Match):
|
2019-06-03 15:42:43 +00:00
|
|
|
operator = match_obj.group(1)
|
|
|
|
version_type = match_obj.group(2)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if operator == "equals":
|
|
|
|
operator = "STREQUAL"
|
|
|
|
elif operator == "greaterThan":
|
|
|
|
operator = "STRGREATER"
|
|
|
|
elif operator == "lessThan":
|
|
|
|
operator = "STRLESS"
|
2019-06-03 15:42:43 +00:00
|
|
|
|
|
|
|
version = match_obj.group(3)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return f"(QT_COMPILER_VERSION_{version_type} {operator} {version})"
|
2019-06-03 15:42:43 +00:00
|
|
|
|
|
|
|
# TODO: Possibly fix for other compilers.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
pattern = r"(equals|greaterThan|lessThan)\(QT_GCC_([A-Z]+)_VERSION,[ ]*([0-9]+)\)"
|
2019-06-03 15:42:43 +00:00
|
|
|
condition = re.sub(pattern, gcc_version_handler, condition)
|
|
|
|
|
2019-09-25 12:16:57 +00:00
|
|
|
def windows_sdk_version_handler(match_obj: Match):
|
|
|
|
operator = match_obj.group(1)
|
|
|
|
if operator == "equals":
|
|
|
|
operator = "STREQUAL"
|
|
|
|
elif operator == "greaterThan":
|
|
|
|
operator = "STRGREATER"
|
|
|
|
elif operator == "lessThan":
|
|
|
|
operator = "STRLESS"
|
|
|
|
|
|
|
|
version = match_obj.group(2)
|
|
|
|
return f"(QT_WINDOWS_SDK_VERSION {operator} {version})"
|
|
|
|
|
|
|
|
pattern = r"(equals|greaterThan|lessThan)\(WINDOWS_SDK_VERSION,[ ]*([0-9]+)\)"
|
|
|
|
condition = re.sub(pattern, windows_sdk_version_handler, condition)
|
|
|
|
|
2022-03-04 11:49:44 +00:00
|
|
|
def qt_version_handler(match_obj: Match):
|
|
|
|
operator = match_obj.group(1)
|
|
|
|
if operator == "equals":
|
|
|
|
operator = "EQUAL"
|
|
|
|
elif operator == "greaterThan":
|
|
|
|
operator = "GREATER"
|
|
|
|
elif operator == "lessThan":
|
|
|
|
operator = "LESS"
|
|
|
|
|
|
|
|
operator_prefix = "VERSION_"
|
|
|
|
version_variable = "QT_VERSION"
|
|
|
|
version_flavor = match_obj.group(2)
|
|
|
|
if version_flavor:
|
|
|
|
version_variable += "_" + version_flavor[:-1]
|
|
|
|
operator_prefix = ""
|
|
|
|
|
|
|
|
version = match_obj.group(3)
|
|
|
|
return f"({version_variable} {operator_prefix}{operator} {version})"
|
|
|
|
|
|
|
|
pattern = r"(equals|greaterThan|lessThan)\(QT_(MAJOR_|MINOR_|PATCH_)?VERSION,[ ]*([0-9.]+)\)"
|
|
|
|
condition = re.sub(pattern, qt_version_handler, condition)
|
|
|
|
|
2019-11-08 09:37:38 +00:00
|
|
|
# Generic lessThan|equals|lessThan()
|
|
|
|
|
|
|
|
def generic_version_handler(match_obj: Match):
|
|
|
|
operator = match_obj.group(1)
|
|
|
|
if operator == "equals":
|
|
|
|
operator = "EQUAL"
|
|
|
|
elif operator == "greaterThan":
|
|
|
|
operator = "GREATER"
|
|
|
|
elif operator == "lessThan":
|
|
|
|
operator = "LESS"
|
|
|
|
|
|
|
|
variable = match_obj.group(2)
|
|
|
|
version = match_obj.group(3)
|
|
|
|
return f"({variable} {operator} {version})"
|
|
|
|
|
2019-11-13 13:52:54 +00:00
|
|
|
pattern = r"(equals|greaterThan|lessThan)\(([^,]+?),[ ]*([0-9]+)\)"
|
2019-11-08 09:37:38 +00:00
|
|
|
condition = re.sub(pattern, generic_version_handler, condition)
|
|
|
|
|
2019-09-22 14:44:29 +00:00
|
|
|
# Handle if(...) conditions.
|
|
|
|
condition = unwrap_if(condition)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
|
|
|
condition = re.sub(r"\bisEmpty\s*\((.*?)\)", r"\1_ISEMPTY", condition)
|
2019-10-14 09:12:47 +00:00
|
|
|
condition = re.sub(
|
|
|
|
r"\bcontains\s*\(\s*(?:QT_)?CONFIG\s*,\s*c\+\+(\d+)\)",
|
|
|
|
r"cxx_std_\1 IN_LIST CMAKE_CXX_COMPILE_FEATURES",
|
|
|
|
condition,
|
|
|
|
)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition = re.sub(r'\bcontains\s*\((.*?),\s*"?(.*?)"?\)', r"\1___contains___\2", condition)
|
|
|
|
condition = re.sub(r'\bequals\s*\((.*?),\s*"?(.*?)"?\)', r"\1___equals___\2", condition)
|
|
|
|
condition = re.sub(r'\bisEqual\s*\((.*?),\s*"?(.*?)"?\)', r"\1___equals___\2", condition)
|
|
|
|
condition = re.sub(r"\s*==\s*", "___STREQUAL___", condition)
|
|
|
|
condition = re.sub(r"\bexists\s*\((.*?)\)", r"EXISTS \1", condition)
|
|
|
|
|
2019-10-09 13:18:56 +00:00
|
|
|
# checking mkspec, predating gcc scope in qmake, will then be replaced by platform_mapping in helper.py
|
|
|
|
condition = condition.replace("*-g++*", "GCC")
|
2019-10-28 10:33:44 +00:00
|
|
|
condition = condition.replace("*g++*", "GCC")
|
2019-10-23 07:50:10 +00:00
|
|
|
condition = condition.replace("aix-g++*", "AIX")
|
2019-10-09 13:18:56 +00:00
|
|
|
condition = condition.replace("*-icc*", "ICC")
|
|
|
|
condition = condition.replace("*-clang*", "CLANG")
|
|
|
|
condition = condition.replace("*-llvm", "CLANG")
|
|
|
|
condition = condition.replace("win32-*", "WIN32")
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
pattern = r"CONFIG\((debug|release),debug\|release\)"
|
2019-05-28 12:16:01 +00:00
|
|
|
match_result = re.match(pattern, condition)
|
|
|
|
if match_result:
|
|
|
|
build_type = match_result.group(1)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if build_type == "debug":
|
|
|
|
build_type = "Debug"
|
|
|
|
elif build_type == "release":
|
|
|
|
build_type = "Release"
|
|
|
|
condition = re.sub(pattern, f"(CMAKE_BUILD_TYPE STREQUAL {build_type})", condition)
|
2019-01-23 11:57:06 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition = condition.replace("*", "_x_")
|
|
|
|
condition = condition.replace(".$$", "__ss_")
|
|
|
|
condition = condition.replace("$$", "_ss_")
|
2019-01-23 11:57:06 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition = condition.replace("!", "NOT ")
|
|
|
|
condition = condition.replace("&&", " AND ")
|
|
|
|
condition = condition.replace("|", " OR ")
|
2019-01-17 16:11:52 +00:00
|
|
|
|
2019-10-15 08:00:42 +00:00
|
|
|
# new conditions added by the android multi arch qmake build
|
2019-11-11 18:09:59 +00:00
|
|
|
condition = re.sub(r"(^| )x86((?=[^\w])|$)", "TEST_architecture_arch STREQUAL i386", condition)
|
2019-10-29 08:57:19 +00:00
|
|
|
condition = re.sub(r"(^| )x86_64", " TEST_architecture_arch STREQUAL x86_64", condition)
|
|
|
|
condition = re.sub(r"(^| )arm64-v8a", "TEST_architecture_arch STREQUAL arm64", condition)
|
|
|
|
condition = re.sub(r"(^| )armeabi-v7a", "TEST_architecture_arch STREQUAL arm", condition)
|
2019-10-15 08:00:42 +00:00
|
|
|
|
2019-11-14 10:23:18 +00:00
|
|
|
# some defines replacements
|
2019-11-25 15:00:32 +00:00
|
|
|
condition = re.sub(r"DEFINES___contains___QT_NO_CURSOR", r"(NOT QT_FEATURE_cursor)", condition)
|
|
|
|
condition = re.sub(
|
|
|
|
r"DEFINES___contains___QT_NO_TRANSLATION", r"(NOT QT_FEATURE_translation)", condition
|
|
|
|
)
|
|
|
|
condition = re.sub(r"styles___contains___fusion", r"QT_FEATURE_style_fusion", condition)
|
2020-03-24 15:29:54 +00:00
|
|
|
condition = re.sub(r"CONFIG___contains___largefile", r"QT_FEATURE_largefile", condition)
|
2019-11-14 10:23:18 +00:00
|
|
|
|
2020-01-13 09:22:30 +00:00
|
|
|
condition = condition.replace("cross_compile", "CMAKE_CROSSCOMPILING")
|
2019-12-11 10:22:05 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cmake_condition = ""
|
2018-10-24 13:20:27 +00:00
|
|
|
for part in condition.split():
|
2018-12-21 11:13:38 +00:00
|
|
|
# some features contain e.g. linux, that should not be
|
|
|
|
# turned upper case
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
feature = re.match(r"(qtConfig|qtHaveModule)\(([a-zA-Z0-9_-]+)\)", part)
|
2018-10-24 13:20:27 +00:00
|
|
|
if feature:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if feature.group(1) == "qtHaveModule":
|
|
|
|
part = f"TARGET {map_qt_library(feature.group(2))}"
|
2018-11-01 13:56:13 +00:00
|
|
|
else:
|
2019-05-08 14:45:25 +00:00
|
|
|
feature_name = featureName(feature.group(2))
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
if (
|
|
|
|
feature_name.startswith("system_")
|
|
|
|
and is_known_3rd_party_library(feature_name[7:])
|
|
|
|
and not feature_name.startswith("system_jpeg")
|
|
|
|
and not feature_name.startswith("system_zlib")
|
2020-03-17 07:52:42 +00:00
|
|
|
and not feature_name.startswith("system_tiff")
|
2020-03-20 16:31:18 +00:00
|
|
|
and not feature_name.startswith("system_assimp")
|
2020-02-21 14:52:58 +00:00
|
|
|
and not feature_name.startswith("system_doubleconversion")
|
2020-03-24 15:29:54 +00:00
|
|
|
and not feature_name.startswith("system_sqlite")
|
2020-04-15 11:57:13 +00:00
|
|
|
and not feature_name.startswith("system_hunspell")
|
2019-12-13 20:19:26 +00:00
|
|
|
and not feature_name.startswith("system_libb2")
|
2020-12-09 14:22:14 +00:00
|
|
|
and not feature_name.startswith("system_webp")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
):
|
|
|
|
part = "ON"
|
|
|
|
elif feature == "dlopen":
|
|
|
|
part = "ON"
|
2019-01-28 14:06:44 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
part = "QT_FEATURE_" + feature_name
|
2018-10-24 13:20:27 +00:00
|
|
|
else:
|
2019-05-06 10:26:31 +00:00
|
|
|
part = map_platform(part)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
part = part.replace("true", "ON")
|
|
|
|
part = part.replace("false", "OFF")
|
|
|
|
cmake_condition += " " + part
|
2018-10-24 13:20:27 +00:00
|
|
|
return cmake_condition.strip()
|
|
|
|
|
|
|
|
|
2019-10-04 15:02:53 +00:00
|
|
|
_path_replacements = {
|
|
|
|
"$$[QT_INSTALL_PREFIX]": "${INSTALL_DIRECTORY}",
|
|
|
|
"$$[QT_INSTALL_EXAMPLES]": "${INSTALL_EXAMPLESDIR}",
|
|
|
|
"$$[QT_INSTALL_TESTS]": "${INSTALL_TESTSDIR}",
|
2019-10-09 11:54:03 +00:00
|
|
|
"$$OUT_PWD": "${CMAKE_CURRENT_BINARY_DIR}",
|
2020-04-15 11:57:13 +00:00
|
|
|
"$$MODULE_BASE_OUTDIR": "${QT_BUILD_DIR}",
|
2019-10-10 13:10:37 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 15:02:53 +00:00
|
|
|
|
|
|
|
def replace_path_constants(path: str, scope: Scope) -> str:
|
2022-02-24 10:31:10 +00:00
|
|
|
"""Clean up DESTDIR and target.path"""
|
2019-10-04 15:02:53 +00:00
|
|
|
if path.startswith("./"):
|
|
|
|
path = f"${{CMAKE_CURRENT_BINARY_DIR}}/{path[2:]}"
|
|
|
|
elif path.startswith("../"):
|
|
|
|
path = f"${{CMAKE_CURRENT_BINARY_DIR}}/{path}"
|
2019-10-07 09:04:13 +00:00
|
|
|
for original, replacement in _path_replacements.items():
|
2019-10-04 15:02:53 +00:00
|
|
|
path = path.replace(original, replacement)
|
|
|
|
path = path.replace("$$TARGET", scope.TARGET)
|
|
|
|
return path
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def handle_subdir(
|
2022-03-04 14:49:02 +00:00
|
|
|
scope: Scope,
|
|
|
|
cm_fh: IO[str],
|
|
|
|
*,
|
|
|
|
indent: int = 0,
|
|
|
|
is_example: bool = False,
|
|
|
|
is_user_project: bool = False,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> None:
|
2019-08-01 17:14:58 +00:00
|
|
|
|
|
|
|
# Global nested dictionary that will contain sub_dir assignments and their conditions.
|
|
|
|
# Declared as a global in order not to pollute the nested function signatures with giant
|
|
|
|
# type hints.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
sub_dirs: Dict[str, Dict[str, Set[FrozenSet[str]]]] = {}
|
2019-08-01 17:14:58 +00:00
|
|
|
|
|
|
|
# Collects assignment conditions into global sub_dirs dict.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def collect_subdir_info(sub_dir_assignment: str, *, current_conditions: FrozenSet[str] = None):
|
|
|
|
subtraction = sub_dir_assignment.startswith("-")
|
2019-08-01 17:14:58 +00:00
|
|
|
if subtraction:
|
|
|
|
subdir_name = sub_dir_assignment[1:]
|
|
|
|
else:
|
|
|
|
subdir_name = sub_dir_assignment
|
|
|
|
if subdir_name not in sub_dirs:
|
|
|
|
sub_dirs[subdir_name] = {}
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
additions = sub_dirs[subdir_name].get("additions", set())
|
|
|
|
subtractions = sub_dirs[subdir_name].get("subtractions", set())
|
2019-08-01 17:14:58 +00:00
|
|
|
if current_conditions:
|
|
|
|
if subtraction:
|
|
|
|
subtractions.add(current_conditions)
|
|
|
|
else:
|
|
|
|
additions.add(current_conditions)
|
|
|
|
if additions:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
sub_dirs[subdir_name]["additions"] = additions
|
2019-08-01 17:14:58 +00:00
|
|
|
if subtractions:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
sub_dirs[subdir_name]["subtractions"] = subtractions
|
2019-08-01 17:14:58 +00:00
|
|
|
|
|
|
|
# Recursive helper that collects subdir info for given scope,
|
|
|
|
# and the children of the given scope.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def handle_subdir_helper(
|
|
|
|
scope: Scope,
|
|
|
|
cm_fh: IO[str],
|
|
|
|
*,
|
|
|
|
indent: int = 0,
|
2019-10-09 08:54:00 +00:00
|
|
|
current_conditions: FrozenSet[str] = frozenset(),
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
is_example: bool = False,
|
|
|
|
):
|
|
|
|
for sd in scope.get_files("SUBDIRS"):
|
2019-08-01 17:14:58 +00:00
|
|
|
# Collect info about conditions and SUBDIR assignments in the
|
|
|
|
# current scope.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if os.path.isdir(sd) or sd.startswith("-"):
|
2019-08-01 17:14:58 +00:00
|
|
|
collect_subdir_info(sd, current_conditions=current_conditions)
|
|
|
|
# For the file case, directly write into the file handle.
|
|
|
|
elif os.path.isfile(sd):
|
2019-08-08 07:52:36 +00:00
|
|
|
# Handle cases with SUBDIRS += Foo/bar/z.pro. We want to be able
|
|
|
|
# to generate add_subdirectory(Foo/bar) instead of parsing the full
|
|
|
|
# .pro file in the current CMakeLists.txt. This causes issues
|
|
|
|
# with relative paths in certain projects otherwise.
|
|
|
|
dirname = os.path.dirname(sd)
|
|
|
|
if dirname:
|
|
|
|
collect_subdir_info(dirname, current_conditions=current_conditions)
|
|
|
|
else:
|
2019-11-08 14:42:35 +00:00
|
|
|
subdir_result, project_file_content = parseProFile(sd, debug=False)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
subdir_scope = Scope.FromDict(
|
2019-11-08 14:42:35 +00:00
|
|
|
scope,
|
|
|
|
sd,
|
|
|
|
subdir_result.asDict().get("statements"),
|
|
|
|
"",
|
|
|
|
scope.basedir,
|
|
|
|
project_file_content=project_file_content,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2019-08-08 07:52:36 +00:00
|
|
|
|
|
|
|
do_include(subdir_scope)
|
2022-03-04 14:49:02 +00:00
|
|
|
cmakeify_scope(
|
|
|
|
subdir_scope,
|
|
|
|
cm_fh,
|
|
|
|
indent=indent,
|
|
|
|
is_example=is_example,
|
|
|
|
is_user_project=is_user_project,
|
|
|
|
)
|
2019-08-01 17:14:58 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f" XXXX: SUBDIR {sd} in {scope}: Not found.")
|
2019-08-01 17:14:58 +00:00
|
|
|
|
|
|
|
# Collect info about conditions and SUBDIR assignments in child
|
|
|
|
# scopes, aka recursively call the same function, but with an
|
|
|
|
# updated current_conditions frozen set.
|
|
|
|
for c in scope.children:
|
2019-08-27 17:17:44 +00:00
|
|
|
# Use total_condition for 'else' conditions, otherwise just use the regular value to
|
|
|
|
# simplify the logic.
|
2019-10-09 08:54:00 +00:00
|
|
|
child_conditions = current_conditions
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
child_condition = c.total_condition if c.condition == "else" else c.condition
|
2019-10-09 08:54:00 +00:00
|
|
|
if child_condition:
|
|
|
|
child_conditions = frozenset((*child_conditions, child_condition))
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
handle_subdir_helper(
|
|
|
|
c,
|
|
|
|
cm_fh,
|
|
|
|
indent=indent + 1,
|
2019-10-09 08:54:00 +00:00
|
|
|
current_conditions=child_conditions,
|
2019-10-07 10:22:04 +00:00
|
|
|
is_example=is_example,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2019-08-01 17:14:58 +00:00
|
|
|
|
2019-10-07 10:22:04 +00:00
|
|
|
def group_and_print_sub_dirs(scope: Scope, indent: int = 0) -> None:
|
2019-08-01 17:14:58 +00:00
|
|
|
# Simplify conditions, and group
|
|
|
|
# subdirectories with the same conditions.
|
2019-10-07 10:22:04 +00:00
|
|
|
grouped_sub_dirs: Dict[str, List[str]] = {}
|
2019-08-27 17:17:44 +00:00
|
|
|
|
|
|
|
# Wraps each element in the given interable with parentheses,
|
|
|
|
# to make sure boolean simplification happens correctly.
|
|
|
|
def wrap_in_parenthesis(iterable):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return [f"({c})" for c in iterable]
|
2019-08-27 17:17:44 +00:00
|
|
|
|
|
|
|
def join_all_conditions(set_of_alternatives):
|
|
|
|
# Elements within one frozen set represent one single
|
|
|
|
# alternative whose pieces are ANDed together.
|
|
|
|
# This is repeated for each alternative that would
|
|
|
|
# enable a subdir, and are thus ORed together.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
final_str = ""
|
2019-08-27 17:17:44 +00:00
|
|
|
if set_of_alternatives:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
wrapped_set_of_alternatives = [
|
|
|
|
wrap_in_parenthesis(alternative) for alternative in set_of_alternatives
|
|
|
|
]
|
|
|
|
alternatives = [
|
|
|
|
f'({" AND ".join(alternative)})' for alternative in wrapped_set_of_alternatives
|
|
|
|
]
|
|
|
|
final_str = " OR ".join(sorted(alternatives))
|
2019-08-27 17:17:44 +00:00
|
|
|
return final_str
|
|
|
|
|
2019-08-01 17:14:58 +00:00
|
|
|
for subdir_name in sub_dirs:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
additions = sub_dirs[subdir_name].get("additions", set())
|
|
|
|
subtractions = sub_dirs[subdir_name].get("subtractions", set())
|
2019-08-01 17:14:58 +00:00
|
|
|
|
|
|
|
# An empty condition key represents the group of sub dirs
|
|
|
|
# that should be added unconditionally.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition_key = ""
|
2019-08-01 17:14:58 +00:00
|
|
|
if additions or subtractions:
|
2019-08-27 17:17:44 +00:00
|
|
|
addition_str = join_all_conditions(additions)
|
|
|
|
if addition_str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
addition_str = f"({addition_str})"
|
2019-08-27 17:17:44 +00:00
|
|
|
subtraction_str = join_all_conditions(subtractions)
|
|
|
|
if subtraction_str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
subtraction_str = f"NOT ({subtraction_str})"
|
2019-08-01 17:14:58 +00:00
|
|
|
|
|
|
|
condition_str = addition_str
|
|
|
|
if condition_str and subtraction_str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition_str += " AND "
|
2019-08-01 17:14:58 +00:00
|
|
|
condition_str += subtraction_str
|
2019-09-19 12:27:18 +00:00
|
|
|
if not condition_str.rstrip("()").strip():
|
|
|
|
continue
|
2019-08-01 17:14:58 +00:00
|
|
|
condition_simplified = simplify_condition(condition_str)
|
|
|
|
condition_key = condition_simplified
|
|
|
|
|
2019-10-07 10:22:04 +00:00
|
|
|
sub_dir_list_by_key: List[str] = grouped_sub_dirs.get(condition_key, [])
|
2019-08-01 17:14:58 +00:00
|
|
|
sub_dir_list_by_key.append(subdir_name)
|
|
|
|
grouped_sub_dirs[condition_key] = sub_dir_list_by_key
|
|
|
|
|
2019-09-22 16:28:01 +00:00
|
|
|
# Print any requires() blocks.
|
2019-09-23 12:08:43 +00:00
|
|
|
cm_fh.write(expand_project_requirements(scope, skip_message=True))
|
2019-09-22 16:28:01 +00:00
|
|
|
|
2019-08-01 17:14:58 +00:00
|
|
|
# Print the groups.
|
2019-09-18 13:22:34 +00:00
|
|
|
ind = spaces(indent)
|
2019-08-01 17:14:58 +00:00
|
|
|
for condition_key in grouped_sub_dirs:
|
2019-07-03 12:39:03 +00:00
|
|
|
cond_ind = ind
|
2019-08-01 17:14:58 +00:00
|
|
|
if condition_key:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{ind}if({condition_key})\n")
|
2019-07-03 12:39:03 +00:00
|
|
|
cond_ind += " "
|
2019-08-01 17:14:58 +00:00
|
|
|
|
|
|
|
sub_dir_list_by_key = grouped_sub_dirs.get(condition_key, [])
|
|
|
|
for subdir_name in sub_dir_list_by_key:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{cond_ind}add_subdirectory({subdir_name})\n")
|
2019-08-01 17:14:58 +00:00
|
|
|
if condition_key:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{ind}endif()\n")
|
2019-08-01 17:14:58 +00:00
|
|
|
|
|
|
|
# A set of conditions which will be ANDed together. The set is recreated with more conditions
|
|
|
|
# as the scope deepens.
|
2019-10-07 10:22:04 +00:00
|
|
|
current_conditions: FrozenSet[str] = frozenset()
|
2019-08-01 17:14:58 +00:00
|
|
|
|
2019-08-27 17:17:44 +00:00
|
|
|
# Compute the total condition for scopes. Needed for scopes that
|
|
|
|
# have 'else' as a condition.
|
|
|
|
recursive_evaluate_scope(scope)
|
|
|
|
|
2019-08-01 17:14:58 +00:00
|
|
|
# Do the work.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
handle_subdir_helper(
|
|
|
|
scope, cm_fh, indent=indent, current_conditions=current_conditions, is_example=is_example
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2020-04-06 16:45:19 +00:00
|
|
|
# Make sure to exclude targets within subdirectories first.
|
2020-03-26 16:42:48 +00:00
|
|
|
qt_no_make_tools = scope.get("_QT_NO_MAKE_TOOLS")
|
|
|
|
if qt_no_make_tools:
|
|
|
|
ind = spaces(indent + 1)
|
|
|
|
directories_string = ""
|
|
|
|
for directory in qt_no_make_tools:
|
|
|
|
directories_string += f"{ind}{directory}\n"
|
|
|
|
cm_fh.write(
|
|
|
|
f"\nqt_exclude_tool_directories_from_default_target(\n{directories_string})\n\n"
|
|
|
|
)
|
|
|
|
|
2020-04-06 16:45:19 +00:00
|
|
|
# Then write the subdirectories.
|
|
|
|
group_and_print_sub_dirs(scope, indent=indent)
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def sort_sources(sources: List[str]) -> List[str]:
|
|
|
|
to_sort = {} # type: Dict[str, List[str]]
|
2018-10-24 13:20:27 +00:00
|
|
|
for s in sources:
|
|
|
|
if s is None:
|
|
|
|
continue
|
|
|
|
|
2019-10-08 13:07:41 +00:00
|
|
|
path = os.path.dirname(s)
|
2018-10-24 13:20:27 +00:00
|
|
|
base = os.path.splitext(os.path.basename(s))[0]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if base.endswith("_p"):
|
2018-10-24 13:20:27 +00:00
|
|
|
base = base[:-2]
|
2019-10-08 13:07:41 +00:00
|
|
|
sort_name = posixpath.join(path, base)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
array = to_sort.get(sort_name, [])
|
|
|
|
array.append(s)
|
|
|
|
|
|
|
|
to_sort[sort_name] = array
|
|
|
|
|
|
|
|
lines = []
|
|
|
|
for k in sorted(to_sort.keys()):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
lines.append(" ".join(sorted(to_sort[k])))
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
return lines
|
|
|
|
|
|
|
|
|
2019-10-10 14:32:19 +00:00
|
|
|
def _map_libraries_to_cmake(
|
|
|
|
libraries: List[str], known_libraries: Set[str], is_example: bool = False
|
|
|
|
) -> List[str]:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result = [] # type: List[str]
|
2019-05-09 08:02:37 +00:00
|
|
|
is_framework = False
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
for lib in libraries:
|
|
|
|
if lib == "-framework":
|
2019-05-09 08:02:37 +00:00
|
|
|
is_framework = True
|
|
|
|
continue
|
|
|
|
if is_framework:
|
2019-10-09 12:58:37 +00:00
|
|
|
if is_example:
|
|
|
|
lib = f'"-framework {lib}"'
|
|
|
|
else:
|
|
|
|
lib = f"${{FW{lib}}}"
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if lib.startswith("-l"):
|
|
|
|
lib = lib[2:]
|
2019-05-09 08:02:37 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if lib.startswith("-"):
|
|
|
|
lib = f"# Remove: {lib[1:]}"
|
2019-05-09 08:02:37 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
lib = map_3rd_party_library(lib)
|
2019-05-09 08:02:37 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if not lib or lib in result or lib in known_libraries:
|
2019-05-09 08:02:37 +00:00
|
|
|
continue
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result.append(lib)
|
2019-05-09 08:02:37 +00:00
|
|
|
is_framework = False
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def extract_cmake_libraries(
|
2019-10-10 14:32:19 +00:00
|
|
|
scope: Scope, *, known_libraries: Optional[Set[str]] = None, is_example: bool = False
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> Tuple[List[str], List[str]]:
|
2019-09-21 18:30:08 +00:00
|
|
|
if known_libraries is None:
|
|
|
|
known_libraries = set()
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
public_dependencies = [] # type: List[str]
|
|
|
|
private_dependencies = [] # type: List[str]
|
2019-05-09 08:02:37 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
for key in ["QMAKE_USE", "LIBS"]:
|
2019-05-09 08:02:37 +00:00
|
|
|
public_dependencies += scope.expand(key)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
for key in ["QMAKE_USE_PRIVATE", "QMAKE_USE_FOR_PRIVATE", "LIBS_PRIVATE"]:
|
2019-05-09 08:02:37 +00:00
|
|
|
private_dependencies += scope.expand(key)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
for key in ["QT_FOR_PRIVATE", "QT_PRIVATE"]:
|
2019-05-09 08:02:37 +00:00
|
|
|
private_dependencies += [map_qt_library(q) for q in scope.expand(key)]
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
for key in ["QT"]:
|
2019-05-09 08:02:37 +00:00
|
|
|
for lib in scope.expand(key):
|
|
|
|
mapped_lib = map_qt_library(lib)
|
2020-01-31 21:21:09 +00:00
|
|
|
public_dependencies.append(mapped_lib)
|
2019-05-09 08:02:37 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return (
|
2019-10-09 12:58:37 +00:00
|
|
|
_map_libraries_to_cmake(public_dependencies, known_libraries, is_example=is_example),
|
|
|
|
_map_libraries_to_cmake(private_dependencies, known_libraries, is_example=is_example),
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2019-05-09 08:02:37 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_header(cm_fh: IO[str], name: str, typename: str, *, indent: int = 0):
|
|
|
|
ind = spaces(indent)
|
|
|
|
comment_line = "#" * 69
|
|
|
|
cm_fh.write(f"{ind}{comment_line}\n")
|
|
|
|
cm_fh.write(f"{ind}## {name} {typename}:\n")
|
|
|
|
cm_fh.write(f"{ind}{comment_line}\n\n")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_scope_header(cm_fh: IO[str], *, indent: int = 0):
|
|
|
|
ind = spaces(indent)
|
|
|
|
comment_line = "#" * 69
|
|
|
|
cm_fh.write(f"\n{ind}## Scopes:\n")
|
|
|
|
cm_fh.write(f"{ind}{comment_line}\n")
|
|
|
|
|
|
|
|
|
|
|
|
def write_list(
|
|
|
|
cm_fh: IO[str],
|
|
|
|
entries: List[str],
|
|
|
|
cmake_parameter: str,
|
|
|
|
indent: int = 0,
|
|
|
|
*,
|
|
|
|
header: str = "",
|
|
|
|
footer: str = "",
|
2019-09-20 07:23:51 +00:00
|
|
|
prefix: str = "",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
):
|
2019-05-08 15:00:48 +00:00
|
|
|
if not entries:
|
|
|
|
return
|
|
|
|
|
|
|
|
ind = spaces(indent)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra_indent = ""
|
2019-05-08 15:00:48 +00:00
|
|
|
|
|
|
|
if header:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{ind}{header}")
|
|
|
|
extra_indent += " "
|
2019-05-08 15:00:48 +00:00
|
|
|
if cmake_parameter:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{ind}{extra_indent}{cmake_parameter}\n")
|
|
|
|
extra_indent += " "
|
2019-05-08 15:00:48 +00:00
|
|
|
for s in sort_sources(entries):
|
2019-09-20 07:23:51 +00:00
|
|
|
cm_fh.write(f"{ind}{extra_indent}{prefix}{s}\n")
|
2019-05-08 15:00:48 +00:00
|
|
|
if footer:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{ind}{footer}\n")
|
|
|
|
|
|
|
|
|
|
|
|
def write_source_file_list(
|
|
|
|
cm_fh: IO[str],
|
|
|
|
scope,
|
|
|
|
cmake_parameter: str,
|
|
|
|
keys: List[str],
|
|
|
|
indent: int = 0,
|
|
|
|
*,
|
|
|
|
header: str = "",
|
|
|
|
footer: str = "",
|
|
|
|
):
|
2019-03-28 12:54:56 +00:00
|
|
|
# collect sources
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
sources: List[str] = []
|
2019-03-28 12:54:56 +00:00
|
|
|
for key in keys:
|
|
|
|
sources += scope.get_files(key, use_vpath=True)
|
|
|
|
|
2019-09-30 15:02:08 +00:00
|
|
|
# Remove duplicates, like in the case when NO_PCH_SOURCES ends up
|
|
|
|
# adding the file to SOURCES, but SOURCES might have already
|
|
|
|
# contained it before. Preserves order in Python 3.7+ because
|
|
|
|
# dict keys are ordered.
|
|
|
|
sources = list(dict.fromkeys(sources))
|
|
|
|
|
2019-05-08 15:00:48 +00:00
|
|
|
write_list(cm_fh, sources, cmake_parameter, indent, header=header, footer=footer)
|
2019-03-28 12:54:56 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_all_source_file_lists(
|
|
|
|
cm_fh: IO[str],
|
|
|
|
scope: Scope,
|
|
|
|
header: str,
|
|
|
|
*,
|
|
|
|
indent: int = 0,
|
|
|
|
footer: str = "",
|
|
|
|
extra_keys: Optional[List[str]] = None,
|
|
|
|
):
|
2019-06-04 20:40:42 +00:00
|
|
|
if extra_keys is None:
|
|
|
|
extra_keys = []
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_source_file_list(
|
|
|
|
cm_fh,
|
|
|
|
scope,
|
|
|
|
header,
|
2019-09-21 18:09:36 +00:00
|
|
|
["SOURCES", "HEADERS", "OBJECTIVE_SOURCES", "OBJECTIVE_HEADERS", "NO_PCH_SOURCES", "FORMS"]
|
|
|
|
+ extra_keys,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
indent,
|
|
|
|
footer=footer,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def write_defines(
|
|
|
|
cm_fh: IO[str], scope: Scope, cmake_parameter: str, *, indent: int = 0, footer: str = ""
|
|
|
|
):
|
|
|
|
defines = scope.expand("DEFINES")
|
|
|
|
defines += [d[2:] for d in scope.expand("QMAKE_CXXFLAGS") if d.startswith("-D")]
|
|
|
|
defines = [
|
|
|
|
d.replace('=\\\\\\"$$PWD/\\\\\\"', '="${CMAKE_CURRENT_SOURCE_DIR}/"') for d in defines
|
|
|
|
]
|
|
|
|
|
2020-03-10 13:49:46 +00:00
|
|
|
# Handle LIBS_SUFFIX='\\"_$${QT_ARCH}.so\\"'.
|
|
|
|
# The escaping of backslashes is still needed even if it's a raw
|
|
|
|
# string, because backslashes have a special meaning for regular
|
|
|
|
# expressions (escape next char). So we actually expect to match
|
|
|
|
# 2 backslashes in the input string.
|
|
|
|
pattern = r"""([^ ]+)='\\\\"([^ ]*)\\\\"'"""
|
|
|
|
|
|
|
|
# Replace with regular quotes, CMake will escape the quotes when
|
|
|
|
# passing the define to the compiler.
|
|
|
|
replacement = r'\1="\2"'
|
|
|
|
defines = [re.sub(pattern, replacement, d) for d in defines]
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if "qml_debug" in scope.get("CONFIG"):
|
|
|
|
defines.append("QT_QML_DEBUG")
|
2019-08-12 11:38:17 +00:00
|
|
|
|
2019-06-04 14:19:46 +00:00
|
|
|
write_list(cm_fh, defines, cmake_parameter, indent, footer=footer)
|
2019-05-08 15:00:48 +00:00
|
|
|
|
|
|
|
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
def write_3rd_party_defines(
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh: IO[str], scope: Scope, cmake_parameter: str, *, indent: int = 0, footer: str = ""
|
|
|
|
):
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
defines = scope.expand("MODULE_DEFINES")
|
|
|
|
write_list(cm_fh, defines, cmake_parameter, indent, footer=footer)
|
|
|
|
|
2019-05-07 09:27:33 +00:00
|
|
|
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
def get_include_paths_helper(scope: Scope, include_var_name: str) -> List[str]:
|
|
|
|
includes = [i.rstrip("/") or ("/") for i in scope.get_files(include_var_name)]
|
|
|
|
return includes
|
|
|
|
|
|
|
|
|
|
|
|
def write_include_paths(
|
|
|
|
cm_fh: IO[str], scope: Scope, cmake_parameter: str, *, indent: int = 0, footer: str = ""
|
|
|
|
):
|
|
|
|
includes = get_include_paths_helper(scope, "INCLUDEPATH")
|
2019-06-04 14:19:46 +00:00
|
|
|
write_list(cm_fh, includes, cmake_parameter, indent, footer=footer)
|
2019-05-07 09:27:33 +00:00
|
|
|
|
|
|
|
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
def write_3rd_party_include_paths(
|
|
|
|
cm_fh: IO[str], scope: Scope, cmake_parameter: str, *, indent: int = 0, footer: str = ""
|
|
|
|
):
|
|
|
|
# Used in qt_helper_lib.prf.
|
|
|
|
includes = get_include_paths_helper(scope, "MODULE_INCLUDEPATH")
|
|
|
|
|
|
|
|
# Wrap the includes in BUILD_INTERFACE generator expression, because
|
|
|
|
# the include paths point to a source dir, and CMake will error out
|
|
|
|
# when trying to create consumable exported targets.
|
|
|
|
processed_includes = []
|
|
|
|
for i in includes:
|
|
|
|
# CMake generator expressions don't seem to like relative paths.
|
|
|
|
# Make them absolute relative to the source dir.
|
2020-07-27 09:10:48 +00:00
|
|
|
if is_path_relative_ish(i):
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
i = f"${{CMAKE_CURRENT_SOURCE_DIR}}/{i}"
|
|
|
|
i = f"$<BUILD_INTERFACE:{i}>"
|
|
|
|
processed_includes.append(i)
|
|
|
|
|
|
|
|
write_list(cm_fh, processed_includes, cmake_parameter, indent, footer=footer)
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_compile_options(
|
|
|
|
cm_fh: IO[str], scope: Scope, cmake_parameter: str, *, indent: int = 0, footer: str = ""
|
|
|
|
):
|
|
|
|
compile_options = [d for d in scope.expand("QMAKE_CXXFLAGS") if not d.startswith("-D")]
|
2019-05-08 15:00:48 +00:00
|
|
|
|
2019-06-04 14:19:46 +00:00
|
|
|
write_list(cm_fh, compile_options, cmake_parameter, indent, footer=footer)
|
2019-05-07 09:27:33 +00:00
|
|
|
|
2019-04-08 12:44:34 +00:00
|
|
|
|
2020-11-27 12:32:13 +00:00
|
|
|
# Return True if given scope belongs to a public module.
|
|
|
|
# First, traverse the parent/child hierarchy. Then, traverse the include hierarchy.
|
|
|
|
def recursive_is_public_module(scope: Scope):
|
|
|
|
if scope.is_public_module:
|
|
|
|
return True
|
|
|
|
if scope.parent:
|
|
|
|
return recursive_is_public_module(scope.parent)
|
|
|
|
if scope.including_scope:
|
|
|
|
return recursive_is_public_module(scope.including_scope)
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_library_section(
|
2019-09-21 18:30:08 +00:00
|
|
|
cm_fh: IO[str], scope: Scope, *, indent: int = 0, known_libraries: Optional[Set[str]] = None
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
):
|
2019-09-21 18:30:08 +00:00
|
|
|
if known_libraries is None:
|
|
|
|
known_libraries = set()
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
public_dependencies, private_dependencies = extract_cmake_libraries(
|
|
|
|
scope, known_libraries=known_libraries
|
|
|
|
)
|
2019-04-08 12:44:34 +00:00
|
|
|
|
2020-11-27 12:32:13 +00:00
|
|
|
is_public_module = recursive_is_public_module(scope)
|
2020-01-31 21:21:09 +00:00
|
|
|
|
|
|
|
# When handling module dependencies, handle QT += foo-private magic.
|
|
|
|
# This implies:
|
|
|
|
# target_link_libraries(Module PUBLIC Qt::Foo)
|
|
|
|
# target_link_libraries(Module PRIVATE Qt::FooPrivate)
|
|
|
|
# target_link_libraries(ModulePrivate INTERFACE Qt::FooPrivate)
|
|
|
|
if is_public_module:
|
|
|
|
private_module_dep_pattern = re.compile(r"^(Qt::(.+))Private$")
|
|
|
|
|
|
|
|
public_module_public_deps = []
|
|
|
|
public_module_private_deps = private_dependencies
|
|
|
|
private_module_interface_deps = []
|
|
|
|
|
|
|
|
for dep in public_dependencies:
|
|
|
|
match = re.match(private_module_dep_pattern, dep)
|
|
|
|
if match:
|
|
|
|
if match[1] not in public_module_public_deps:
|
|
|
|
public_module_public_deps.append(match[1])
|
|
|
|
private_module_interface_deps.append(dep)
|
|
|
|
if dep not in public_module_private_deps:
|
|
|
|
public_module_private_deps.append(dep)
|
|
|
|
else:
|
|
|
|
if dep not in public_module_public_deps:
|
|
|
|
public_module_public_deps.append(dep)
|
2020-04-28 11:32:08 +00:00
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
private_module_interface_deps.extend(
|
|
|
|
[map_qt_library(q) for q in scope.expand("QT_FOR_PRIVATE")]
|
|
|
|
)
|
|
|
|
private_module_interface_deps.extend(
|
|
|
|
_map_libraries_to_cmake(scope.expand("QMAKE_USE_FOR_PRIVATE"), known_libraries)
|
|
|
|
)
|
2020-04-28 11:32:08 +00:00
|
|
|
|
2020-01-31 21:21:09 +00:00
|
|
|
write_list(cm_fh, public_module_private_deps, "LIBRARIES", indent + 1)
|
|
|
|
write_list(cm_fh, public_module_public_deps, "PUBLIC_LIBRARIES", indent + 1)
|
|
|
|
write_list(cm_fh, private_module_interface_deps, "PRIVATE_MODULE_INTERFACE", indent + 1)
|
|
|
|
else:
|
|
|
|
write_list(cm_fh, private_dependencies, "LIBRARIES", indent + 1)
|
|
|
|
write_list(cm_fh, public_dependencies, "PUBLIC_LIBRARIES", indent + 1)
|
2019-04-08 12:44:34 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_autogen_section(cm_fh: IO[str], scope: Scope, *, indent: int = 0):
|
|
|
|
forms = scope.get_files("FORMS")
|
2019-05-22 13:09:39 +00:00
|
|
|
if forms:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_list(cm_fh, ["uic"], "ENABLE_AUTOGEN_TOOLS", indent)
|
2019-05-22 13:09:39 +00:00
|
|
|
|
2019-04-08 12:44:34 +00:00
|
|
|
|
2019-09-21 18:30:08 +00:00
|
|
|
def write_sources_section(
|
|
|
|
cm_fh: IO[str], scope: Scope, *, indent: int = 0, known_libraries: Optional[Set[str]] = None
|
|
|
|
):
|
|
|
|
if known_libraries is None:
|
|
|
|
known_libraries = set()
|
2018-10-24 13:20:27 +00:00
|
|
|
ind = spaces(indent)
|
|
|
|
|
2019-03-07 10:06:23 +00:00
|
|
|
# mark RESOURCES as visited:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
scope.get("RESOURCES")
|
2019-03-07 10:06:23 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_all_source_file_lists(cm_fh, scope, "SOURCES", indent=indent + 1)
|
2019-03-07 10:06:23 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_source_file_list(cm_fh, scope, "DBUS_ADAPTOR_SOURCES", ["DBUS_ADAPTORS"], indent + 1)
|
|
|
|
dbus_adaptor_flags = scope.expand("QDBUSXML2CPP_ADAPTOR_HEADER_FLAGS")
|
2019-03-28 14:31:07 +00:00
|
|
|
if dbus_adaptor_flags:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
dbus_adaptor_flags_line = '" "'.join(dbus_adaptor_flags)
|
|
|
|
cm_fh.write(f"{ind} DBUS_ADAPTOR_FLAGS\n")
|
|
|
|
cm_fh.write(f'{ind} "{dbus_adaptor_flags_line}"\n')
|
2019-03-18 18:13:41 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_source_file_list(cm_fh, scope, "DBUS_INTERFACE_SOURCES", ["DBUS_INTERFACES"], indent + 1)
|
|
|
|
dbus_interface_flags = scope.expand("QDBUSXML2CPP_INTERFACE_HEADER_FLAGS")
|
2019-03-28 14:31:07 +00:00
|
|
|
if dbus_interface_flags:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
dbus_interface_flags_line = '" "'.join(dbus_interface_flags)
|
|
|
|
cm_fh.write(f"{ind} DBUS_INTERFACE_FLAGS\n")
|
|
|
|
cm_fh.write(f'{ind} "{dbus_interface_flags_line}"\n')
|
2019-03-18 18:13:41 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_defines(cm_fh, scope, "DEFINES", indent=indent + 1)
|
2019-05-07 09:27:33 +00:00
|
|
|
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
write_3rd_party_defines(cm_fh, scope, "PUBLIC_DEFINES", indent=indent + 1)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_include_paths(cm_fh, scope, "INCLUDE_DIRECTORIES", indent=indent + 1)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
write_3rd_party_include_paths(cm_fh, scope, "PUBLIC_INCLUDE_DIRECTORIES", indent=indent + 1)
|
|
|
|
|
2019-05-09 08:02:37 +00:00
|
|
|
write_library_section(cm_fh, scope, indent=indent, known_libraries=known_libraries)
|
2019-03-28 14:08:00 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_compile_options(cm_fh, scope, "COMPILE_OPTIONS", indent=indent + 1)
|
2019-01-29 11:07:24 +00:00
|
|
|
|
2019-05-22 13:09:39 +00:00
|
|
|
write_autogen_section(cm_fh, scope, indent=indent + 1)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
link_options = scope.get("QMAKE_LFLAGS")
|
2019-01-29 11:07:24 +00:00
|
|
|
if link_options:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{ind} LINK_OPTIONS\n")
|
2019-01-29 11:07:24 +00:00
|
|
|
for lo in link_options:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f'{ind} "{lo}"\n')
|
2019-01-29 11:07:24 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
moc_options = scope.get("QMAKE_MOC_OPTIONS")
|
2019-01-30 15:43:11 +00:00
|
|
|
if moc_options:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{ind} MOC_OPTIONS\n")
|
2019-01-30 15:43:11 +00:00
|
|
|
for mo in moc_options:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f'{ind} "{mo}"\n')
|
2019-01-30 15:43:11 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
precompiled_header = scope.get("PRECOMPILED_HEADER")
|
2019-07-05 08:47:26 +00:00
|
|
|
if precompiled_header:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{ind} PRECOMPILED_HEADER\n")
|
2019-07-05 08:47:26 +00:00
|
|
|
for header in precompiled_header:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f'{ind} "{header}"\n')
|
2019-07-05 08:47:26 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
no_pch_sources = scope.get("NO_PCH_SOURCES")
|
2019-07-05 08:47:26 +00:00
|
|
|
if no_pch_sources:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{ind} NO_PCH_SOURCES\n")
|
2019-07-05 08:47:26 +00:00
|
|
|
for source in no_pch_sources:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f'{ind} "{source}"\n')
|
2019-07-05 08:47:26 +00:00
|
|
|
|
2019-01-17 16:11:52 +00:00
|
|
|
|
|
|
|
def is_simple_condition(condition: str) -> bool:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
return " " not in condition or (condition.startswith("NOT ") and " " not in condition[4:])
|
2019-01-17 16:11:52 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-03-12 18:55:51 +00:00
|
|
|
def write_ignored_keys(scope: Scope, indent: str) -> str:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result = ""
|
2019-03-12 18:55:51 +00:00
|
|
|
ignored_keys = scope.keys - scope.visited_keys
|
2019-01-18 11:43:11 +00:00
|
|
|
for k in sorted(ignored_keys):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if k in {
|
|
|
|
"_INCLUDED",
|
2019-11-12 13:05:35 +00:00
|
|
|
"_LOADED",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"TARGET",
|
|
|
|
"QMAKE_DOCS",
|
|
|
|
"QT_SOURCE_TREE",
|
|
|
|
"QT_BUILD_TREE",
|
2019-10-08 16:36:30 +00:00
|
|
|
"QTRO_SOURCE_TREE",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"TRACEPOINT_PROVIDER",
|
2019-09-20 08:33:04 +00:00
|
|
|
"PLUGIN_TYPE",
|
|
|
|
"PLUGIN_CLASS_NAME",
|
|
|
|
"CLASS_NAME",
|
|
|
|
"MODULE_PLUGIN_TYPES",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
}:
|
2019-01-25 14:41:02 +00:00
|
|
|
# All these keys are actually reported already
|
2019-01-18 11:43:11 +00:00
|
|
|
continue
|
|
|
|
values = scope.get(k)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
value_string = "<EMPTY>" if not values else '"' + '" "'.join(scope.get(k)) + '"'
|
|
|
|
result += f"{indent}# {k} = {value_string}\n"
|
2019-03-12 18:55:51 +00:00
|
|
|
|
|
|
|
if result:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
result = f"\n#### Keys ignored in scope {scope}:\n{result}"
|
2019-03-12 18:55:51 +00:00
|
|
|
|
2019-01-18 11:43:11 +00:00
|
|
|
return result
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def recursive_evaluate_scope(
|
|
|
|
scope: Scope, parent_condition: str = "", previous_condition: str = ""
|
|
|
|
) -> str:
|
2019-01-29 09:18:21 +00:00
|
|
|
current_condition = scope.condition
|
2019-01-22 13:23:59 +00:00
|
|
|
total_condition = current_condition
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if total_condition == "else":
|
|
|
|
assert previous_condition, f"Else branch without previous condition in: {scope.file}"
|
|
|
|
total_condition = f"NOT ({previous_condition})"
|
2018-10-24 13:20:27 +00:00
|
|
|
if parent_condition:
|
2019-01-17 16:11:52 +00:00
|
|
|
if not total_condition:
|
|
|
|
total_condition = parent_condition
|
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
total_condition = f"({parent_condition}) AND ({total_condition})"
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-01-29 09:18:21 +00:00
|
|
|
scope.total_condition = simplify_condition(total_condition)
|
2019-01-22 13:20:47 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
prev_condition = ""
|
2019-01-29 09:18:21 +00:00
|
|
|
for c in scope.children:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
prev_condition = recursive_evaluate_scope(c, total_condition, prev_condition)
|
2019-01-22 13:20:47 +00:00
|
|
|
|
2019-01-22 13:23:59 +00:00
|
|
|
return current_condition
|
2019-01-22 13:20:47 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def map_to_cmake_condition(condition: str = "") -> str:
|
2019-06-05 11:39:41 +00:00
|
|
|
condition = condition.replace("QTDIR_build", "QT_BUILDING_QT")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
condition = re.sub(
|
|
|
|
r"\bQT_ARCH___equals___([a-zA-Z_0-9]*)",
|
|
|
|
r'(TEST_architecture_arch STREQUAL "\1")',
|
|
|
|
condition or "",
|
|
|
|
)
|
|
|
|
condition = re.sub(
|
|
|
|
r"\bQT_ARCH___contains___([a-zA-Z_0-9]*)",
|
|
|
|
r'(TEST_architecture_arch STREQUAL "\1")',
|
|
|
|
condition or "",
|
|
|
|
)
|
2019-11-11 18:03:36 +00:00
|
|
|
condition = condition.replace("QT___contains___opengl", "QT_FEATURE_opengl")
|
|
|
|
condition = condition.replace("QT___contains___widgets", "QT_FEATURE_widgets")
|
|
|
|
condition = condition.replace(
|
|
|
|
"DEFINES___contains___QT_NO_PRINTER", "(QT_FEATURE_printer EQUAL FALSE)"
|
|
|
|
)
|
2019-03-01 14:00:19 +00:00
|
|
|
return condition
|
|
|
|
|
|
|
|
|
2019-09-03 13:25:55 +00:00
|
|
|
resource_file_expansion_counter = 0
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
|
|
|
|
2019-09-19 14:29:14 +00:00
|
|
|
def expand_resource_glob(cm_fh: IO[str], expression: str) -> str:
|
|
|
|
global resource_file_expansion_counter
|
|
|
|
r = expression.replace('"', "")
|
|
|
|
|
|
|
|
cm_fh.write(
|
|
|
|
dedent(
|
|
|
|
f"""
|
|
|
|
file(GLOB resource_glob_{resource_file_expansion_counter} RELATIVE "${{CMAKE_CURRENT_SOURCE_DIR}}" "{r}")
|
|
|
|
foreach(file IN LISTS resource_glob_{resource_file_expansion_counter})
|
|
|
|
set_source_files_properties("${{CMAKE_CURRENT_SOURCE_DIR}}/${{file}}" PROPERTIES QT_RESOURCE_ALIAS "${{file}}")
|
|
|
|
endforeach()
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
expanded_var = f"${{resource_glob_{resource_file_expansion_counter}}}"
|
|
|
|
resource_file_expansion_counter += 1
|
|
|
|
return expanded_var
|
|
|
|
|
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
def extract_resources(
|
2020-07-30 13:50:22 +00:00
|
|
|
target: str,
|
|
|
|
scope: Scope,
|
2022-02-28 20:03:13 +00:00
|
|
|
) -> Tuple[List[QtResource], List[str]]:
|
|
|
|
"""Read the resources of the given scope.
|
|
|
|
Return a tuple:
|
|
|
|
- list of QtResource objects
|
|
|
|
- list of standalone sources files that are marked as QTQUICK_COMPILER_SKIPPED_RESOURCES"""
|
|
|
|
|
|
|
|
resource_infos: List[QtResource] = []
|
|
|
|
skipped_standalone_files: List[str] = []
|
2019-03-07 10:06:23 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
resources = scope.get_files("RESOURCES")
|
|
|
|
qtquickcompiler_skipped = scope.get_files("QTQUICK_COMPILER_SKIPPED_RESOURCES")
|
2019-03-07 10:06:23 +00:00
|
|
|
if resources:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
standalone_files: List[str] = []
|
2019-03-07 10:06:23 +00:00
|
|
|
for r in resources:
|
2019-08-09 12:15:42 +00:00
|
|
|
skip_qtquick_compiler = r in qtquickcompiler_skipped
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if r.endswith(".qrc"):
|
2019-09-23 08:27:00 +00:00
|
|
|
if "${CMAKE_CURRENT_BINARY_DIR}" in r:
|
2022-02-28 20:03:13 +00:00
|
|
|
resource_infos.append(
|
|
|
|
QtResource(
|
|
|
|
name=r, generated=True, skip_qtquick_compiler=skip_qtquick_compiler
|
|
|
|
)
|
|
|
|
)
|
2019-09-23 08:27:00 +00:00
|
|
|
continue
|
2022-02-28 20:03:13 +00:00
|
|
|
resource_infos += read_qrc_file(
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
r,
|
|
|
|
scope.basedir,
|
|
|
|
scope.file_absolute_path,
|
2022-02-28 20:03:13 +00:00
|
|
|
skip_qtquick_compiler=skip_qtquick_compiler,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2019-03-07 10:06:23 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
immediate_files = {f: "" for f in scope.get_files(f"{r}.files")}
|
2019-08-09 12:15:42 +00:00
|
|
|
if immediate_files:
|
2019-09-19 14:29:14 +00:00
|
|
|
immediate_files_filtered = []
|
|
|
|
for f in immediate_files:
|
2022-02-28 20:03:13 +00:00
|
|
|
immediate_files_filtered.append(f)
|
2019-09-19 14:29:14 +00:00
|
|
|
immediate_files = {f: "" for f in immediate_files_filtered}
|
2019-10-07 10:22:04 +00:00
|
|
|
scope_prefix = scope.get(f"{r}.prefix")
|
|
|
|
if scope_prefix:
|
|
|
|
immediate_prefix = scope_prefix[0]
|
2019-08-09 12:15:42 +00:00
|
|
|
else:
|
|
|
|
immediate_prefix = "/"
|
2019-10-07 10:22:04 +00:00
|
|
|
immediate_base_list = scope.get(f"{r}.base")
|
2019-10-10 14:32:19 +00:00
|
|
|
assert (
|
|
|
|
len(immediate_base_list) < 2
|
2022-02-24 10:31:10 +00:00
|
|
|
), "immediate base directory must be at most one entry"
|
2019-10-09 11:54:03 +00:00
|
|
|
immediate_base = replace_path_constants("".join(immediate_base_list), scope)
|
2019-08-09 12:15:42 +00:00
|
|
|
immediate_lang = None
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
immediate_name = f"qmake_{r}"
|
2022-02-28 20:03:13 +00:00
|
|
|
resource_infos.append(
|
|
|
|
QtResource(
|
|
|
|
name=immediate_name,
|
|
|
|
prefix=immediate_prefix,
|
|
|
|
base_dir=immediate_base,
|
|
|
|
lang=immediate_lang,
|
|
|
|
files=immediate_files,
|
|
|
|
skip_qtquick_compiler=skip_qtquick_compiler,
|
|
|
|
)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2019-08-09 12:15:42 +00:00
|
|
|
else:
|
2022-02-28 20:03:13 +00:00
|
|
|
standalone_files.append(r)
|
|
|
|
if not ("*" in r) and skip_qtquick_compiler:
|
|
|
|
skipped_standalone_files.append(r)
|
2019-08-09 12:15:42 +00:00
|
|
|
|
|
|
|
if standalone_files:
|
2022-02-28 20:03:13 +00:00
|
|
|
resource_infos.append(
|
|
|
|
QtResource(
|
|
|
|
name="qmake_immediate",
|
|
|
|
prefix="/",
|
|
|
|
base_dir="",
|
|
|
|
files={f: "" for f in standalone_files},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
return (resource_infos, skipped_standalone_files)
|
|
|
|
|
|
|
|
|
|
|
|
def write_resources(
|
|
|
|
cm_fh: IO[str],
|
|
|
|
target: str,
|
|
|
|
scope: Scope,
|
|
|
|
indent: int = 0,
|
|
|
|
is_example=False,
|
|
|
|
target_ref: str = None,
|
|
|
|
resources: List[QtResource] = None,
|
|
|
|
skipped_standalone_files: List[str] = None,
|
|
|
|
):
|
|
|
|
if resources is None:
|
|
|
|
(resources, skipped_standalone_files) = extract_resources(target, scope)
|
|
|
|
if target_ref is None:
|
|
|
|
target_ref = target
|
|
|
|
|
|
|
|
qrc_output = ""
|
|
|
|
for r in resources:
|
|
|
|
name = r.name
|
|
|
|
if "*" in name:
|
|
|
|
name = expand_resource_glob(cm_fh, name)
|
|
|
|
qrc_output += write_add_qt_resource_call(
|
|
|
|
target=target_ref,
|
|
|
|
scope=scope,
|
|
|
|
resource_name=name,
|
|
|
|
prefix=r.prefix,
|
|
|
|
base_dir=r.base_dir,
|
|
|
|
lang=r.lang,
|
|
|
|
files=r.files,
|
|
|
|
skip_qtquick_compiler=r.skip_qtquick_compiler,
|
|
|
|
is_example=is_example,
|
|
|
|
)
|
|
|
|
|
|
|
|
if skipped_standalone_files:
|
|
|
|
for f in skipped_standalone_files:
|
|
|
|
qrc_output += (
|
|
|
|
f'set_source_files_properties("{f}" PROPERTIES ' f"QT_SKIP_QUICKCOMPILER 1)\n\n"
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2019-03-07 10:06:23 +00:00
|
|
|
|
|
|
|
if qrc_output:
|
2019-10-15 08:48:53 +00:00
|
|
|
str_indent = spaces(indent)
|
|
|
|
cm_fh.write(f"\n{str_indent}# Resources:\n")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
for line in qrc_output.split("\n"):
|
2019-10-23 07:50:58 +00:00
|
|
|
if line:
|
|
|
|
cm_fh.write(f"{str_indent}{line}\n")
|
|
|
|
else:
|
|
|
|
# do not add spaces to empty lines
|
|
|
|
cm_fh.write("\n")
|
2019-03-07 10:06:23 +00:00
|
|
|
|
2019-09-21 18:09:36 +00:00
|
|
|
|
2019-09-20 14:24:57 +00:00
|
|
|
def write_statecharts(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0, is_example=False):
|
2019-10-04 12:04:10 +00:00
|
|
|
sources = scope.get_files("STATECHARTS", use_vpath=True)
|
2019-09-20 09:50:22 +00:00
|
|
|
if not sources:
|
|
|
|
return
|
|
|
|
cm_fh.write("\n# Statecharts:\n")
|
2019-09-20 14:24:57 +00:00
|
|
|
if is_example:
|
|
|
|
cm_fh.write(f"qt6_add_statecharts({target}\n")
|
|
|
|
else:
|
|
|
|
cm_fh.write(f"add_qt_statecharts({target} FILES\n")
|
2019-09-20 09:50:22 +00:00
|
|
|
indent += 1
|
|
|
|
for f in sources:
|
|
|
|
cm_fh.write(f"{spaces(indent)}{f}\n")
|
|
|
|
cm_fh.write(")\n")
|
2019-03-07 10:06:23 +00:00
|
|
|
|
2019-10-10 13:10:37 +00:00
|
|
|
|
2019-10-01 06:47:00 +00:00
|
|
|
def write_qlalrsources(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
|
|
|
sources = scope.get_files("QLALRSOURCES", use_vpath=True)
|
|
|
|
if not sources:
|
|
|
|
return
|
|
|
|
cm_fh.write("\n# QLALR Grammars:\n")
|
2022-02-24 10:31:10 +00:00
|
|
|
cm_fh.write("qt_process_qlalr(\n")
|
2019-10-01 06:47:00 +00:00
|
|
|
indent += 1
|
|
|
|
cm_fh.write(f"{spaces(indent)}{target}\n")
|
2019-10-11 11:42:06 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)}{';'.join(sources)}\n")
|
2019-10-10 14:32:19 +00:00
|
|
|
cm_fh.write(f'{spaces(indent)}""\n')
|
2019-10-01 06:47:00 +00:00
|
|
|
cm_fh.write(")\n")
|
2019-09-21 18:09:36 +00:00
|
|
|
|
2019-10-10 13:10:37 +00:00
|
|
|
|
2019-10-01 12:40:00 +00:00
|
|
|
def write_repc_files(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
|
|
|
for t in ["SOURCE", "REPLICA", "MERGED"]:
|
|
|
|
sources = scope.get_files("REPC_" + t, use_vpath=True)
|
|
|
|
if not sources:
|
|
|
|
continue
|
|
|
|
cm_fh.write(f"qt6_add_repc_{t.lower()}({target}\n")
|
|
|
|
indent += 1
|
|
|
|
for f in sources:
|
|
|
|
cm_fh.write(f"{spaces(indent)}{f}\n")
|
|
|
|
cm_fh.write(")\n")
|
|
|
|
|
2019-10-10 13:10:37 +00:00
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
def write_generic_cmake_command(
|
|
|
|
cm_fh: IO[str], command_name: str, arguments: List[str], indent: int = 0
|
|
|
|
):
|
2020-07-27 09:10:48 +00:00
|
|
|
ind = spaces(indent)
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
arguments_str = " ".join(arguments)
|
2020-07-27 09:10:48 +00:00
|
|
|
cm_fh.write(f"{ind}{command_name}({arguments_str})\n")
|
|
|
|
|
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
def write_set_target_properties(
|
|
|
|
cm_fh: IO[str], targets: List[str], properties: List[str], indent: int = 0
|
|
|
|
):
|
2020-07-27 09:10:48 +00:00
|
|
|
ind = spaces(indent)
|
2020-07-30 13:50:22 +00:00
|
|
|
command_name = "set_target_properties"
|
2020-07-27 09:10:48 +00:00
|
|
|
arguments_ind = spaces(indent + 1)
|
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
prop_pairs = [(properties[i] + " " + properties[i + 1]) for i in range(0, len(properties), 2)]
|
2020-07-27 09:10:48 +00:00
|
|
|
properties_str = f"\n{arguments_ind}" + f"\n{arguments_ind}".join(prop_pairs)
|
|
|
|
|
|
|
|
if len(targets) == 1:
|
2020-07-30 13:50:22 +00:00
|
|
|
targets_str = targets[0] + " "
|
2020-07-27 09:10:48 +00:00
|
|
|
else:
|
2020-07-30 13:50:22 +00:00
|
|
|
targets_str = (
|
|
|
|
f"\n{arguments_ind}" + f"\n{arguments_ind}".join(targets) + f"\n{arguments_ind}"
|
|
|
|
)
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
cm_fh.write(f"{ind}{command_name}({targets_str}PROPERTIES{properties_str}\n{ind})\n")
|
|
|
|
|
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
def write_set_source_files_properties(
|
|
|
|
cm_fh: IO[str], files: List[str], properties: List[str], indent: int = 0
|
|
|
|
):
|
2020-07-27 09:10:48 +00:00
|
|
|
ind = spaces(indent)
|
2020-07-30 13:50:22 +00:00
|
|
|
command_name = "set_source_files_properties"
|
2020-07-27 09:10:48 +00:00
|
|
|
arguments_ind = spaces(indent + 1)
|
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
prop_pairs = [(properties[i] + " " + properties[i + 1]) for i in range(0, len(properties), 2)]
|
2020-07-27 09:10:48 +00:00
|
|
|
properties_str = f"\n{arguments_ind}" + f"\n{arguments_ind}".join(prop_pairs)
|
|
|
|
|
|
|
|
if len(files) == 1:
|
2020-07-30 13:50:22 +00:00
|
|
|
targets_str = files[0] + " "
|
2020-07-27 09:10:48 +00:00
|
|
|
else:
|
|
|
|
targets_str = f"\n{arguments_ind}" + f"\n{arguments_ind}".join(files) + f"\n{arguments_ind}"
|
|
|
|
|
|
|
|
cm_fh.write(f"{ind}{command_name}({targets_str}PROPERTIES{properties_str}\n{ind})\n")
|
|
|
|
|
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
def write_target_sources(
|
|
|
|
cm_fh: IO[str], target: str, sources: List[str], visibility: str = "PRIVATE", indent: int = 0
|
|
|
|
):
|
|
|
|
command_name = "target_sources"
|
|
|
|
header = f"{command_name}({target} {visibility}\n"
|
2022-02-24 10:31:10 +00:00
|
|
|
write_list(cm_fh, sources, "", indent, footer=")", header=header)
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
|
|
|
|
|
2019-09-22 16:28:01 +00:00
|
|
|
def expand_project_requirements(scope: Scope, skip_message: bool = False) -> str:
|
2019-09-20 11:43:26 +00:00
|
|
|
requirements = ""
|
|
|
|
for requirement in scope.get("_REQUIREMENTS"):
|
|
|
|
original_condition = simplify_condition(map_condition(requirement))
|
2019-09-22 16:28:01 +00:00
|
|
|
inverted_requirement = simplify_condition(f"NOT ({map_condition(requirement)})")
|
|
|
|
if not skip_message:
|
|
|
|
message = f"""
|
|
|
|
{spaces(7)}message(NOTICE "Skipping the build as the condition \\"{original_condition}\\" is not met.")"""
|
|
|
|
else:
|
|
|
|
message = ""
|
2019-09-21 18:09:36 +00:00
|
|
|
requirements += dedent(
|
|
|
|
f"""\
|
2019-09-22 16:28:01 +00:00
|
|
|
if({inverted_requirement}){message}
|
2019-09-20 11:43:26 +00:00
|
|
|
return()
|
|
|
|
endif()
|
2019-09-22 16:28:01 +00:00
|
|
|
"""
|
2019-09-21 18:09:36 +00:00
|
|
|
)
|
2019-09-20 11:43:26 +00:00
|
|
|
return requirements
|
|
|
|
|
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
def write_extend_target(
|
|
|
|
cm_fh: IO[str], target: str, scope: Scope, indent: int = 0, target_ref: str = None
|
|
|
|
):
|
2020-04-27 13:04:57 +00:00
|
|
|
if target_ref is None:
|
|
|
|
target_ref = target
|
2019-03-12 18:55:51 +00:00
|
|
|
ind = spaces(indent)
|
2018-10-24 13:20:27 +00:00
|
|
|
extend_qt_io_string = io.StringIO()
|
2019-03-12 18:55:51 +00:00
|
|
|
write_sources_section(extend_qt_io_string, scope)
|
2018-10-24 13:20:27 +00:00
|
|
|
extend_qt_string = extend_qt_io_string.getvalue()
|
|
|
|
|
2019-10-07 10:22:04 +00:00
|
|
|
assert scope.total_condition, "Cannot write CONDITION when scope.condition is None"
|
2019-10-15 08:48:53 +00:00
|
|
|
|
|
|
|
condition = map_to_cmake_condition(scope.total_condition)
|
|
|
|
|
2019-11-13 13:03:20 +00:00
|
|
|
cmake_api_call = get_cmake_api_call("qt_extend_target")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extend_scope = (
|
2020-04-27 13:04:57 +00:00
|
|
|
f"\n{ind}{cmake_api_call}({target_ref} CONDITION"
|
2019-11-13 13:03:20 +00:00
|
|
|
f" {condition}\n"
|
|
|
|
f"{extend_qt_string}{ind})\n"
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
if not extend_qt_string:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extend_scope = "" # Nothing to report, so don't!
|
2019-01-18 11:43:11 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
cm_fh.write(extend_scope)
|
|
|
|
|
2019-10-15 08:48:53 +00:00
|
|
|
io_string = io.StringIO()
|
2020-04-27 13:04:57 +00:00
|
|
|
write_resources(io_string, target, scope, indent + 1, target_ref=target_ref)
|
2019-10-15 08:48:53 +00:00
|
|
|
resource_string = io_string.getvalue()
|
|
|
|
if len(resource_string) != 0:
|
2019-10-29 08:57:19 +00:00
|
|
|
resource_string = resource_string.strip("\n").rstrip(f"\n{spaces(indent + 1)}")
|
2019-10-15 08:48:53 +00:00
|
|
|
cm_fh.write(f"\n{spaces(indent)}if({condition})\n{resource_string}")
|
|
|
|
cm_fh.write(f"\n{spaces(indent)}endif()\n")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
2019-10-29 08:57:19 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def flatten_scopes(scope: Scope) -> List[Scope]:
|
|
|
|
result = [scope] # type: List[Scope]
|
2019-01-29 09:18:21 +00:00
|
|
|
for c in scope.children:
|
2019-01-22 13:20:47 +00:00
|
|
|
result += flatten_scopes(c)
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def merge_scopes(scopes: List[Scope]) -> List[Scope]:
|
|
|
|
result = [] # type: List[Scope]
|
2019-01-22 13:20:47 +00:00
|
|
|
|
2019-01-24 15:01:17 +00:00
|
|
|
# Merge scopes with their parents:
|
2019-10-07 10:22:04 +00:00
|
|
|
known_scopes = {} # type: Dict[str, Scope]
|
2019-01-22 13:20:47 +00:00
|
|
|
for scope in scopes:
|
2019-01-29 09:18:21 +00:00
|
|
|
total_condition = scope.total_condition
|
2019-05-08 14:45:25 +00:00
|
|
|
assert total_condition
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if total_condition == "OFF":
|
2019-01-24 15:01:17 +00:00
|
|
|
# ignore this scope entirely!
|
|
|
|
pass
|
|
|
|
elif total_condition in known_scopes:
|
|
|
|
known_scopes[total_condition].merge(scope)
|
|
|
|
else:
|
|
|
|
# Keep everything else:
|
|
|
|
result.append(scope)
|
|
|
|
known_scopes[total_condition] = scope
|
2019-01-22 13:20:47 +00:00
|
|
|
|
|
|
|
return result
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_simd_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
|
|
|
simd_options = [
|
|
|
|
"sse2",
|
|
|
|
"sse3",
|
|
|
|
"ssse3",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"aesni",
|
|
|
|
"shani",
|
|
|
|
"avx",
|
|
|
|
"avx2",
|
|
|
|
"avx512f",
|
|
|
|
"avx512cd",
|
|
|
|
"avx512er",
|
|
|
|
"avx512pf",
|
|
|
|
"avx512dq",
|
|
|
|
"avx512bw",
|
|
|
|
"avx512vl",
|
|
|
|
"avx512ifma",
|
|
|
|
"avx512vbmi",
|
|
|
|
"f16c",
|
|
|
|
"rdrnd",
|
|
|
|
"neon",
|
|
|
|
"mips_dsp",
|
|
|
|
"mips_dspr2",
|
|
|
|
"arch_haswell",
|
|
|
|
"avx512common",
|
|
|
|
"avx512core",
|
|
|
|
]
|
2019-10-10 13:56:16 +00:00
|
|
|
|
|
|
|
simd_io_string = io.StringIO()
|
|
|
|
|
|
|
|
condition = "ON"
|
|
|
|
if scope.total_condition:
|
|
|
|
condition = map_to_cmake_condition(scope.total_condition)
|
|
|
|
|
|
|
|
if condition != "ON":
|
|
|
|
indent += 1
|
|
|
|
|
2019-03-11 14:09:33 +00:00
|
|
|
for simd in simd_options:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
SIMD = simd.upper()
|
|
|
|
write_source_file_list(
|
2019-10-10 13:56:16 +00:00
|
|
|
simd_io_string,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
scope,
|
|
|
|
"SOURCES",
|
|
|
|
[f"{SIMD}_HEADERS", f"{SIMD}_SOURCES", f"{SIMD}_C_SOURCES", f"{SIMD}_ASM"],
|
2019-10-10 13:56:16 +00:00
|
|
|
indent=indent,
|
2019-11-13 13:03:20 +00:00
|
|
|
header=f"{get_cmake_api_call('qt_add_simd_part')}({target} SIMD {simd}\n",
|
2019-10-10 13:56:16 +00:00
|
|
|
footer=")\n",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
|
|
|
|
2019-10-10 13:56:16 +00:00
|
|
|
simd_string = simd_io_string.getvalue()
|
|
|
|
if simd_string:
|
|
|
|
simd_string = simd_string.rstrip("\n")
|
|
|
|
cond_start = ""
|
|
|
|
cond_end = ""
|
|
|
|
if condition != "ON":
|
|
|
|
cond_start = f"{spaces(indent - 1)}if({condition})"
|
|
|
|
cond_end = f"{spaces(indent - 1)}endif()"
|
|
|
|
|
|
|
|
extend_scope = f"\n{cond_start}\n" f"{simd_string}" f"\n{cond_end}\n"
|
|
|
|
cm_fh.write(extend_scope)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
2020-02-17 13:58:16 +00:00
|
|
|
def write_reduce_relocations_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
|
|
|
ind = spaces(indent)
|
|
|
|
dynlist_file = scope.get_files("QMAKE_DYNAMIC_LIST_FILE")
|
|
|
|
if dynlist_file:
|
|
|
|
dynlist_path = "${CMAKE_CURRENT_LIST_DIR}/" + dynlist_file[0]
|
2020-03-11 18:14:35 +00:00
|
|
|
cm_fh.write(f"{ind}if(QT_FEATURE_reduce_relocations AND UNIX AND GCC)\n")
|
2020-02-17 13:58:16 +00:00
|
|
|
ind = spaces(indent + 1)
|
2020-03-11 18:14:35 +00:00
|
|
|
cm_fh.write(f"{ind}target_link_options({target} PRIVATE\n")
|
2020-02-17 13:58:16 +00:00
|
|
|
cm_fh.write(f'{ind} "LINKER:--dynamic-list={dynlist_path}")\n')
|
|
|
|
ind = spaces(indent)
|
2020-03-11 18:14:35 +00:00
|
|
|
cm_fh.write(f"{ind}endif()\n")
|
2020-02-17 13:58:16 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_android_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
|
|
|
keys = [
|
|
|
|
"ANDROID_BUNDLED_JAR_DEPENDENCIES",
|
|
|
|
"ANDROID_LIB_DEPENDENCIES",
|
|
|
|
"ANDROID_JAR_DEPENDENCIES",
|
|
|
|
"ANDROID_LIB_DEPENDENCY_REPLACEMENTS",
|
|
|
|
"ANDROID_BUNDLED_FILES",
|
|
|
|
"ANDROID_PERMISSIONS",
|
2019-10-29 08:57:19 +00:00
|
|
|
"ANDROID_PACKAGE_SOURCE_DIR",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
]
|
2019-06-24 12:54:40 +00:00
|
|
|
|
|
|
|
has_no_values = True
|
|
|
|
for key in keys:
|
2019-10-22 12:14:30 +00:00
|
|
|
value = scope.expand(key)
|
2019-06-24 12:54:40 +00:00
|
|
|
if len(value) != 0:
|
|
|
|
if has_no_values:
|
|
|
|
if scope.condition:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"\n{spaces(indent)}if(ANDROID AND ({scope.condition}))\n")
|
2019-06-24 12:54:40 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"\n{spaces(indent)}if(ANDROID)\n")
|
2019-06-24 12:54:40 +00:00
|
|
|
indent += 1
|
|
|
|
has_no_values = False
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)}set_property(TARGET {target} APPEND PROPERTY QT_{key}\n")
|
|
|
|
write_list(cm_fh, value, "", indent + 1)
|
|
|
|
cm_fh.write(f"{spaces(indent)})\n")
|
2019-06-24 12:54:40 +00:00
|
|
|
indent -= 1
|
|
|
|
|
|
|
|
if not has_no_values:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)}endif()\n")
|
|
|
|
|
|
|
|
|
2019-10-10 13:10:37 +00:00
|
|
|
def write_wayland_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
2019-10-10 14:32:19 +00:00
|
|
|
client_sources = scope.get_files("WAYLANDCLIENTSOURCES", use_vpath=True)
|
|
|
|
server_sources = scope.get_files("WAYLANDSERVERSOURCES", use_vpath=True)
|
2019-09-20 07:23:51 +00:00
|
|
|
if len(client_sources) == 0 and len(server_sources) == 0:
|
|
|
|
return
|
|
|
|
|
2020-07-27 09:10:48 +00:00
|
|
|
condition, indent = write_scope_condition_begin(cm_fh, scope, indent=indent)
|
2019-09-20 07:23:51 +00:00
|
|
|
|
|
|
|
if len(client_sources) != 0:
|
|
|
|
cm_fh.write(f"\n{spaces(indent)}qt6_generate_wayland_protocol_client_sources({target}\n")
|
2019-10-10 14:32:19 +00:00
|
|
|
write_list(
|
|
|
|
cm_fh, client_sources, "FILES", indent + 1, prefix="${CMAKE_CURRENT_SOURCE_DIR}/"
|
|
|
|
)
|
2019-09-20 07:23:51 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)})\n")
|
|
|
|
|
|
|
|
if len(server_sources) != 0:
|
|
|
|
cm_fh.write(f"\n{spaces(indent)}qt6_generate_wayland_protocol_server_sources({target}\n")
|
2019-10-10 14:32:19 +00:00
|
|
|
write_list(
|
|
|
|
cm_fh, server_sources, "FILES", indent + 1, prefix="${CMAKE_CURRENT_SOURCE_DIR}/"
|
|
|
|
)
|
2019-09-20 07:23:51 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)})\n")
|
|
|
|
|
2020-07-27 09:10:48 +00:00
|
|
|
write_scope_condition_end(cm_fh, condition, indent=indent)
|
|
|
|
|
|
|
|
|
|
|
|
def write_scope_condition_begin(cm_fh: IO[str], scope: Scope, indent: int = 0) -> Tuple[str, int]:
|
|
|
|
condition = "ON"
|
|
|
|
if scope.total_condition:
|
|
|
|
condition = map_to_cmake_condition(scope.total_condition)
|
|
|
|
|
|
|
|
if condition != "ON":
|
|
|
|
cm_fh.write(f"\n{spaces(indent)}if({condition})\n")
|
|
|
|
indent += 1
|
|
|
|
|
|
|
|
return condition, indent
|
|
|
|
|
|
|
|
|
|
|
|
def write_scope_condition_end(cm_fh: IO[str], condition: str, indent: int = 0) -> int:
|
2019-09-20 07:23:51 +00:00
|
|
|
if condition != "ON":
|
|
|
|
indent -= 1
|
2020-07-27 09:10:48 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)}endif()\n")
|
|
|
|
return indent
|
|
|
|
|
|
|
|
|
|
|
|
def is_path_relative_ish(path: str) -> bool:
|
|
|
|
if not os.path.isabs(path) and not path.startswith("$"):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
def absolutify_path(path: str, base_dir: str = "${CMAKE_CURRENT_SOURCE_DIR}") -> str:
|
2020-07-27 09:10:48 +00:00
|
|
|
if not path:
|
|
|
|
return path
|
|
|
|
if is_path_relative_ish(path):
|
|
|
|
path = posixpath.join(base_dir, path)
|
|
|
|
return path
|
|
|
|
|
|
|
|
|
|
|
|
def write_version_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
|
|
|
if scope.is_internal_qt_app:
|
|
|
|
version_value = scope.get_string("VERSION")
|
|
|
|
if version_value:
|
|
|
|
version_value = re.sub(r"\$\${QT_VERSION\}", "${PROJECT_VERSION}", version_value)
|
|
|
|
target_description = scope.expandString("QMAKE_TARGET_DESCRIPTION")
|
|
|
|
|
|
|
|
if version_value or target_description:
|
|
|
|
condition, indent = write_scope_condition_begin(cm_fh, scope, indent=indent)
|
|
|
|
|
|
|
|
properties = []
|
|
|
|
if version_value:
|
2020-07-30 13:50:22 +00:00
|
|
|
properties.extend(["QT_TARGET_VERSION", f'"{version_value}"'])
|
2020-07-27 09:10:48 +00:00
|
|
|
if target_description:
|
2020-07-30 13:50:22 +00:00
|
|
|
properties.extend(["QT_TARGET_DESCRIPTION", f'"{target_description}"'])
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
if properties:
|
|
|
|
write_set_target_properties(cm_fh, [target], properties, indent=indent)
|
|
|
|
|
|
|
|
write_scope_condition_end(cm_fh, condition, indent=indent)
|
|
|
|
|
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
def write_darwin_part(
|
|
|
|
cm_fh: IO[str], target: str, scope: Scope, main_scope_target_name: str = "", indent: int = 0
|
|
|
|
):
|
2020-07-27 09:10:48 +00:00
|
|
|
if scope.is_internal_qt_app:
|
|
|
|
# Embed custom provided Info.plist file.
|
|
|
|
info_plist = scope.expandString("QMAKE_INFO_PLIST")
|
|
|
|
info_plist = absolutify_path(info_plist)
|
|
|
|
|
|
|
|
icon_path = scope.expandString("ICON")
|
2020-07-30 13:50:22 +00:00
|
|
|
icon_basename = ""
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
new_output_name = None
|
|
|
|
current_scope_output_name = scope.TARGET
|
|
|
|
if current_scope_output_name != main_scope_target_name:
|
|
|
|
new_output_name = current_scope_output_name
|
|
|
|
|
|
|
|
if icon_path:
|
|
|
|
icon_basename = os.path.basename(icon_path)
|
|
|
|
|
|
|
|
if info_plist or icon_path or new_output_name:
|
|
|
|
condition, indent = write_scope_condition_begin(cm_fh, scope, indent=indent)
|
|
|
|
|
|
|
|
properties = []
|
|
|
|
if info_plist:
|
2020-07-30 13:50:22 +00:00
|
|
|
properties.extend(["MACOSX_BUNDLE_INFO_PLIST", f'"{info_plist}"'])
|
|
|
|
properties.extend(["MACOSX_BUNDLE", "TRUE"])
|
2020-07-27 09:10:48 +00:00
|
|
|
if icon_path:
|
2020-07-30 13:50:22 +00:00
|
|
|
properties.extend(["MACOSX_BUNDLE_ICON_FILE", f'"{icon_basename}"'])
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
if new_output_name:
|
2020-07-30 13:50:22 +00:00
|
|
|
properties.extend(["OUTPUT_NAME", f'"{new_output_name}"'])
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
if properties:
|
|
|
|
write_set_target_properties(cm_fh, [target], properties, indent=indent)
|
|
|
|
if icon_path:
|
2020-07-30 13:50:22 +00:00
|
|
|
source_properties = ["MACOSX_PACKAGE_LOCATION", "Resources"]
|
|
|
|
write_set_source_files_properties(
|
|
|
|
cm_fh, [icon_path], source_properties, indent=indent
|
|
|
|
)
|
2020-07-27 09:10:48 +00:00
|
|
|
write_target_sources(cm_fh, target, [icon_path], indent=indent)
|
|
|
|
|
|
|
|
write_scope_condition_end(cm_fh, condition, indent=indent)
|
|
|
|
|
|
|
|
|
|
|
|
def write_windows_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
|
|
|
if scope.is_internal_qt_app:
|
|
|
|
# Handle CONFIG += console assignments.
|
|
|
|
is_console = "console" in scope.get("CONFIG")
|
|
|
|
rc_file = scope.expandString("RC_FILE")
|
|
|
|
rc_file = absolutify_path(rc_file)
|
|
|
|
rc_icons = scope.expandString("RC_ICONS")
|
|
|
|
rc_icons = absolutify_path(rc_icons)
|
|
|
|
|
|
|
|
if is_console or rc_file or rc_icons:
|
|
|
|
condition, indent = write_scope_condition_begin(cm_fh, scope, indent=indent)
|
|
|
|
|
|
|
|
properties = []
|
|
|
|
if is_console:
|
2020-07-30 13:50:22 +00:00
|
|
|
properties.extend(["WIN32_EXECUTABLE", "FALSE"])
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
if rc_file:
|
2020-07-30 13:50:22 +00:00
|
|
|
properties.extend(["QT_TARGET_WINDOWS_RC_FILE", f'"{rc_file}"'])
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
if rc_icons:
|
2020-07-30 13:50:22 +00:00
|
|
|
properties.extend(["QT_TARGET_RC_ICONS", f'"{rc_icons}"'])
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
if properties:
|
2020-07-30 13:50:22 +00:00
|
|
|
write_set_target_properties(cm_fh, [target], properties, indent=indent)
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
write_scope_condition_end(cm_fh, condition, indent=indent)
|
2019-09-20 07:23:51 +00:00
|
|
|
|
|
|
|
|
2020-11-11 13:25:45 +00:00
|
|
|
def write_aux_qml_file_install_call(cm_fh: IO[str], file_list: List[str], indent: int = 0):
|
|
|
|
cm_fh.write(f"\n{spaces(indent)}qt_copy_or_install(\n")
|
2020-11-11 17:13:56 +00:00
|
|
|
write_list(cm_fh, file_list, "FILES", indent + 1)
|
2020-11-11 13:25:45 +00:00
|
|
|
|
|
|
|
destination_option = 'DESTINATION "${__aux_qml_files_install_dir}"'
|
2020-11-11 17:13:56 +00:00
|
|
|
cm_fh.write(f"{spaces(indent + 1)}{destination_option})\n")
|
2020-11-11 13:25:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
def write_aux_qml_path_setup(cm_fh: IO[str], base_dir: str, indent: int = 0):
|
|
|
|
path_join_args = f'__aux_qml_files_install_dir "${{__aux_qml_files_install_base}}" "{base_dir}"'
|
|
|
|
cm_fh.write(f"\n{spaces(indent)}qt_path_join({path_join_args})\n")
|
|
|
|
|
|
|
|
|
|
|
|
def write_aux_qml_files_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
|
|
|
aux_files = scope.get_files("AUX_QML_FILES")
|
|
|
|
if aux_files and isinstance(aux_files, list):
|
|
|
|
aux_files_per_dir = defaultdict(list)
|
|
|
|
aux_files_globs = []
|
|
|
|
|
|
|
|
# Handle globs differently from regular paths.
|
|
|
|
# For regular paths, group by base dir. Each base dir will get
|
|
|
|
# its own install call.
|
|
|
|
for path in aux_files:
|
|
|
|
if "*" in path:
|
|
|
|
aux_files_globs.append(path)
|
|
|
|
else:
|
|
|
|
base_dir = os.path.dirname(path)
|
|
|
|
aux_files_per_dir[base_dir].append(path)
|
|
|
|
|
|
|
|
condition, indent = write_scope_condition_begin(cm_fh, scope, indent=indent)
|
|
|
|
|
|
|
|
# Extract the location of $prefix/qml, where we want to install
|
|
|
|
# files.
|
|
|
|
get_prop_args = f"__aux_qml_files_install_base {target} QT_QML_MODULE_INSTALL_DIR"
|
|
|
|
cm_fh.write(f"{spaces(indent)}get_target_property({get_prop_args})\n")
|
|
|
|
|
|
|
|
# Handle glob installs.
|
|
|
|
for path in aux_files_globs:
|
|
|
|
cm_fh.write(
|
|
|
|
f"""
|
|
|
|
{spaces(indent)}file(GLOB_RECURSE __aux_qml_glob_files
|
|
|
|
{spaces(indent + 1)}RELATIVE "${{CMAKE_CURRENT_SOURCE_DIR}}"
|
|
|
|
{spaces(indent + 1)}"{path}")"""
|
|
|
|
)
|
|
|
|
file_list = ["${__aux_qml_glob_files}"]
|
|
|
|
|
|
|
|
# Extract base dir. Hopes that the globs only appear in the
|
|
|
|
# file name part.
|
|
|
|
base_dir = os.path.dirname(path)
|
|
|
|
write_aux_qml_path_setup(cm_fh, base_dir, indent=indent)
|
|
|
|
write_aux_qml_file_install_call(cm_fh, file_list, indent=indent)
|
|
|
|
|
|
|
|
# Handle regular per base-dir installs.
|
|
|
|
for base_dir in aux_files_per_dir:
|
|
|
|
file_list = aux_files_per_dir[base_dir]
|
|
|
|
write_aux_qml_path_setup(cm_fh, base_dir, indent=indent)
|
|
|
|
write_aux_qml_file_install_call(cm_fh, file_list, indent=indent)
|
|
|
|
write_scope_condition_end(cm_fh, condition, indent=indent)
|
|
|
|
|
|
|
|
|
2019-09-30 15:02:08 +00:00
|
|
|
def handle_source_subtractions(scopes: List[Scope]):
|
|
|
|
"""
|
|
|
|
Handles source subtractions like SOURCES -= painting/qdrawhelper.cpp
|
|
|
|
by creating a new scope with a new condition containing all addition
|
|
|
|
and subtraction conditions.
|
|
|
|
|
|
|
|
Algorithm is as follows:
|
|
|
|
- Go through each scope and find files in SOURCES starting with "-"
|
|
|
|
- Save that file and the scope condition in modified_sources dict.
|
|
|
|
- Remove the file from the found scope (optionally remove the
|
|
|
|
NO_PCH_SOURCES entry for that file as well).
|
|
|
|
- Go through each file in modified_sources dict.
|
|
|
|
- Find scopes where the file is added, remove the file from that
|
|
|
|
scope and save the condition.
|
|
|
|
- Create a new scope just for that file with a new simplified
|
|
|
|
condition that takes all the other conditions into account.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def remove_file_from_operation(
|
|
|
|
scope: Scope, ops_key: str, file: str, op_type: Type[Operation]
|
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
Remove a source file from an operation in a scope.
|
|
|
|
Example: remove foo.cpp from any operations that have
|
|
|
|
ops_key="SOURCES" in "scope", where the operation is of
|
|
|
|
type "op_type".
|
|
|
|
|
|
|
|
The implementation is very rudimentary and might not work in
|
|
|
|
all cases.
|
|
|
|
|
|
|
|
Returns True if a file was found and removed in any operation.
|
|
|
|
"""
|
|
|
|
file_removed = False
|
|
|
|
ops = scope._operations.get(ops_key, list())
|
|
|
|
for op in ops:
|
|
|
|
if not isinstance(op, op_type):
|
|
|
|
continue
|
|
|
|
if file in op._value:
|
|
|
|
op._value.remove(file)
|
|
|
|
file_removed = True
|
|
|
|
for include_child_scope in scope._included_children:
|
|
|
|
file_removed = file_removed or remove_file_from_operation(
|
|
|
|
include_child_scope, ops_key, file, op_type
|
|
|
|
)
|
|
|
|
return file_removed
|
|
|
|
|
|
|
|
def join_all_conditions(set_of_alternatives: Set[str]):
|
|
|
|
final_str = ""
|
|
|
|
if set_of_alternatives:
|
|
|
|
alternatives = [f"({alternative})" for alternative in set_of_alternatives]
|
|
|
|
final_str = " OR ".join(sorted(alternatives))
|
|
|
|
return final_str
|
|
|
|
|
|
|
|
modified_sources: Dict[str, Dict[str, Union[Set[str], bool]]] = {}
|
|
|
|
|
|
|
|
new_scopes = []
|
|
|
|
top_most_scope = scopes[0]
|
|
|
|
|
|
|
|
for scope in scopes:
|
|
|
|
sources = scope.get_files("SOURCES")
|
|
|
|
for file in sources:
|
|
|
|
# Find subtractions.
|
|
|
|
if file.startswith("-"):
|
|
|
|
file_without_minus = file[1:]
|
|
|
|
|
|
|
|
if file_without_minus not in modified_sources:
|
|
|
|
modified_sources[file_without_minus] = {}
|
|
|
|
|
|
|
|
subtractions = modified_sources[file_without_minus].get("subtractions", set())
|
2019-10-07 10:22:04 +00:00
|
|
|
assert isinstance(subtractions, set)
|
2019-09-30 15:02:08 +00:00
|
|
|
|
|
|
|
# Add the condition to the set of conditions and remove
|
|
|
|
# the file subtraction from the processed scope, which
|
|
|
|
# will be later re-added in a new scope.
|
|
|
|
if scope.condition:
|
2019-10-07 10:22:04 +00:00
|
|
|
assert scope.total_condition
|
2019-09-30 15:02:08 +00:00
|
|
|
subtractions.add(scope.total_condition)
|
|
|
|
remove_file_from_operation(scope, "SOURCES", file_without_minus, RemoveOperation)
|
|
|
|
if subtractions:
|
|
|
|
modified_sources[file_without_minus]["subtractions"] = subtractions
|
|
|
|
|
|
|
|
# In case if the source is also listed in a
|
|
|
|
# NO_PCH_SOURCES operation, remove it from there as
|
|
|
|
# well, and add it back later.
|
|
|
|
no_pch_source_removed = remove_file_from_operation(
|
|
|
|
scope, "NO_PCH_SOURCES", file_without_minus, AddOperation
|
|
|
|
)
|
|
|
|
if no_pch_source_removed:
|
|
|
|
modified_sources[file_without_minus]["add_to_no_pch_sources"] = True
|
|
|
|
|
|
|
|
for modified_source in modified_sources:
|
|
|
|
additions = modified_sources[modified_source].get("additions", set())
|
2019-10-07 10:22:04 +00:00
|
|
|
assert isinstance(additions, set), f"Additions must be a set, got {additions} instead."
|
2019-09-30 15:02:08 +00:00
|
|
|
subtractions = modified_sources[modified_source].get("subtractions", set())
|
2019-10-10 14:32:19 +00:00
|
|
|
assert isinstance(
|
|
|
|
subtractions, set
|
|
|
|
), f"Subtractions must be a set, got {additions} instead."
|
2019-09-30 15:02:08 +00:00
|
|
|
add_to_no_pch_sources = modified_sources[modified_source].get(
|
|
|
|
"add_to_no_pch_sources", False
|
|
|
|
)
|
|
|
|
|
|
|
|
for scope in scopes:
|
|
|
|
sources = scope.get_files("SOURCES")
|
|
|
|
if modified_source in sources:
|
|
|
|
# Remove the source file from any addition operations
|
|
|
|
# that mention it.
|
|
|
|
remove_file_from_operation(scope, "SOURCES", modified_source, AddOperation)
|
|
|
|
if scope.total_condition:
|
|
|
|
additions.add(scope.total_condition)
|
|
|
|
|
|
|
|
# Construct a condition that takes into account all addition
|
|
|
|
# and subtraction conditions.
|
|
|
|
addition_str = join_all_conditions(additions)
|
|
|
|
if addition_str:
|
|
|
|
addition_str = f"({addition_str})"
|
|
|
|
subtraction_str = join_all_conditions(subtractions)
|
|
|
|
if subtraction_str:
|
|
|
|
subtraction_str = f"NOT ({subtraction_str})"
|
|
|
|
|
|
|
|
condition_str = addition_str
|
|
|
|
if condition_str and subtraction_str:
|
|
|
|
condition_str += " AND "
|
|
|
|
condition_str += subtraction_str
|
|
|
|
condition_simplified = simplify_condition(condition_str)
|
|
|
|
|
|
|
|
# Create a new scope with that condition and add the source
|
|
|
|
# operations.
|
|
|
|
new_scope = Scope(
|
|
|
|
parent_scope=top_most_scope,
|
2019-10-07 10:22:04 +00:00
|
|
|
qmake_file=top_most_scope.file,
|
2019-09-30 15:02:08 +00:00
|
|
|
condition=condition_simplified,
|
|
|
|
base_dir=top_most_scope.basedir,
|
|
|
|
)
|
|
|
|
new_scope.total_condition = condition_simplified
|
|
|
|
new_scope._append_operation("SOURCES", AddOperation([modified_source]))
|
|
|
|
if add_to_no_pch_sources:
|
|
|
|
new_scope._append_operation("NO_PCH_SOURCES", AddOperation([modified_source]))
|
|
|
|
|
|
|
|
new_scopes.append(new_scope)
|
|
|
|
|
|
|
|
# Add all the newly created scopes.
|
|
|
|
scopes += new_scopes
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_main_part(
|
|
|
|
cm_fh: IO[str],
|
|
|
|
name: str,
|
|
|
|
typename: str,
|
|
|
|
cmake_function: str,
|
|
|
|
scope: Scope,
|
|
|
|
*,
|
2019-09-21 18:30:08 +00:00
|
|
|
extra_lines: Optional[List[str]] = None,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
indent: int = 0,
|
|
|
|
extra_keys: List[str],
|
|
|
|
**kwargs: Any,
|
|
|
|
):
|
2019-01-24 15:01:17 +00:00
|
|
|
# Evaluate total condition of all scopes:
|
2019-09-21 18:30:08 +00:00
|
|
|
if extra_lines is None:
|
|
|
|
extra_lines = []
|
2019-01-24 15:01:17 +00:00
|
|
|
recursive_evaluate_scope(scope)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if "exceptions" in scope.get("CONFIG"):
|
|
|
|
extra_lines.append("EXCEPTIONS")
|
2019-06-04 13:55:41 +00:00
|
|
|
|
2019-01-24 15:01:17 +00:00
|
|
|
# Get a flat list of all scopes but the main one:
|
|
|
|
scopes = flatten_scopes(scope)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
# total_scopes = len(scopes)
|
2019-01-24 15:01:17 +00:00
|
|
|
# Merge scopes based on their conditions:
|
|
|
|
scopes = merge_scopes(scopes)
|
|
|
|
|
2019-09-30 15:02:08 +00:00
|
|
|
# Handle SOURCES -= foo calls, and merge scopes one more time
|
|
|
|
# because there might have been several files removed with the same
|
|
|
|
# scope condition.
|
|
|
|
handle_source_subtractions(scopes)
|
|
|
|
scopes = merge_scopes(scopes)
|
|
|
|
|
2019-01-24 15:01:17 +00:00
|
|
|
assert len(scopes)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
assert scopes[0].total_condition == "ON"
|
2019-01-24 15:01:17 +00:00
|
|
|
|
2019-03-12 18:55:51 +00:00
|
|
|
scopes[0].reset_visited_keys()
|
2019-03-18 18:16:40 +00:00
|
|
|
for k in extra_keys:
|
|
|
|
scopes[0].get(k)
|
2019-03-12 18:55:51 +00:00
|
|
|
|
2019-01-24 15:01:17 +00:00
|
|
|
# Now write out the scopes:
|
2018-10-24 13:20:27 +00:00
|
|
|
write_header(cm_fh, name, typename, indent=indent)
|
|
|
|
|
2019-07-12 14:54:26 +00:00
|
|
|
# collect all testdata and insert globbing commands
|
|
|
|
has_test_data = False
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if typename == "Test":
|
2020-11-10 19:30:29 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)}if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)\n")
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}cmake_minimum_required(VERSION 3.16)\n")
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}project({name} LANGUAGES C CXX ASM)\n")
|
2021-09-08 13:53:29 +00:00
|
|
|
cm_fh.write(
|
|
|
|
f"{spaces(indent+1)}find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST)\n"
|
|
|
|
)
|
2020-11-10 19:30:29 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)}endif()\n\n")
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
test_data = scope.expand("TESTDATA")
|
2019-07-12 14:54:26 +00:00
|
|
|
if test_data:
|
|
|
|
has_test_data = True
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write("# Collect test data\n")
|
2019-07-12 14:54:26 +00:00
|
|
|
for data in test_data:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if "*" in data:
|
|
|
|
cm_fh.write(
|
|
|
|
dedent(
|
2019-09-19 14:01:09 +00:00
|
|
|
f"""\
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
{spaces(indent)}file(GLOB_RECURSE test_data_glob
|
|
|
|
{spaces(indent+1)}RELATIVE ${{CMAKE_CURRENT_SOURCE_DIR}}
|
2019-09-19 14:01:09 +00:00
|
|
|
{spaces(indent+1)}{data})
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
)
|
|
|
|
cm_fh.write(f"{spaces(indent)}list(APPEND test_data ${{test_data_glob}})\n")
|
2019-07-12 14:54:26 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f'{spaces(indent)}list(APPEND test_data "{data}")\n')
|
|
|
|
cm_fh.write("\n")
|
2019-07-12 14:54:26 +00:00
|
|
|
|
2020-04-27 13:04:57 +00:00
|
|
|
target_ref = name
|
|
|
|
if typename == "Tool":
|
|
|
|
target_ref = "${target_name}"
|
|
|
|
cm_fh.write(f"{spaces(indent)}qt_get_tool_target_name(target_name {name})\n")
|
|
|
|
|
2019-08-07 12:45:17 +00:00
|
|
|
# Check for DESTDIR override
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
destdir = scope.get_string("DESTDIR")
|
2019-08-07 12:45:17 +00:00
|
|
|
if destdir:
|
2020-01-16 08:29:29 +00:00
|
|
|
already_added = False
|
|
|
|
for line in extra_lines:
|
|
|
|
if line.startswith("OUTPUT_DIRECTORY"):
|
|
|
|
already_added = True
|
|
|
|
break
|
|
|
|
if not already_added:
|
|
|
|
destdir = replace_path_constants(destdir, scope)
|
|
|
|
extra_lines.append(f'OUTPUT_DIRECTORY "{destdir}"')
|
2019-08-07 12:45:17 +00:00
|
|
|
|
2020-04-27 13:04:57 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)}{cmake_function}({target_ref}\n")
|
2018-10-24 13:20:27 +00:00
|
|
|
for extra_line in extra_lines:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)} {extra_line}\n")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-03-12 18:55:51 +00:00
|
|
|
write_sources_section(cm_fh, scopes[0], indent=indent, **kwargs)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-07-12 14:54:26 +00:00
|
|
|
if has_test_data:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)} TESTDATA ${{test_data}}\n")
|
2018-10-24 13:20:27 +00:00
|
|
|
# Footer:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)})\n")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2021-09-14 19:02:14 +00:00
|
|
|
if typename == "Tool":
|
|
|
|
cm_fh.write(f"{spaces(indent)}qt_internal_return_unless_building_tools()\n")
|
|
|
|
|
2020-04-27 13:04:57 +00:00
|
|
|
write_resources(cm_fh, name, scope, indent, target_ref=target_ref)
|
2019-03-07 10:06:23 +00:00
|
|
|
|
2019-09-20 09:50:22 +00:00
|
|
|
write_statecharts(cm_fh, name, scope, indent)
|
|
|
|
|
2019-10-01 06:47:00 +00:00
|
|
|
write_qlalrsources(cm_fh, name, scope, indent)
|
|
|
|
|
2019-10-01 12:40:00 +00:00
|
|
|
write_repc_files(cm_fh, name, scope, indent)
|
|
|
|
|
2019-03-11 14:09:33 +00:00
|
|
|
write_simd_part(cm_fh, name, scope, indent)
|
|
|
|
|
2020-02-17 13:58:16 +00:00
|
|
|
write_reduce_relocations_part(cm_fh, name, scope, indent)
|
|
|
|
|
2019-06-24 12:54:40 +00:00
|
|
|
write_android_part(cm_fh, name, scopes[0], indent)
|
|
|
|
|
2019-09-20 07:23:51 +00:00
|
|
|
write_wayland_part(cm_fh, name, scopes[0], indent)
|
|
|
|
|
2020-07-27 09:10:48 +00:00
|
|
|
write_windows_part(cm_fh, name, scopes[0], indent)
|
|
|
|
|
|
|
|
write_darwin_part(cm_fh, name, scopes[0], main_scope_target_name=name, indent=indent)
|
|
|
|
|
|
|
|
write_version_part(cm_fh, name, scopes[0], indent)
|
|
|
|
|
2020-11-11 13:25:45 +00:00
|
|
|
write_aux_qml_files_part(cm_fh, name, scopes[0], indent)
|
|
|
|
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
if "warn_off" in scope.get("CONFIG"):
|
|
|
|
write_generic_cmake_command(cm_fh, "qt_disable_warnings", [name])
|
|
|
|
|
|
|
|
if "hide_symbols" in scope.get("CONFIG"):
|
|
|
|
write_generic_cmake_command(cm_fh, "qt_set_symbol_visibility_hidden", [name])
|
|
|
|
|
2019-03-12 18:55:51 +00:00
|
|
|
ignored_keys_report = write_ignored_keys(scopes[0], spaces(indent))
|
|
|
|
if ignored_keys_report:
|
|
|
|
cm_fh.write(ignored_keys_report)
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
# Scopes:
|
2019-01-24 15:01:17 +00:00
|
|
|
if len(scopes) == 1:
|
2018-10-24 13:20:27 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
write_scope_header(cm_fh, indent=indent)
|
|
|
|
|
2019-01-24 15:01:17 +00:00
|
|
|
for c in scopes[1:]:
|
2019-03-12 18:55:51 +00:00
|
|
|
c.reset_visited_keys()
|
2019-06-24 12:54:40 +00:00
|
|
|
write_android_part(cm_fh, name, c, indent=indent)
|
2019-09-20 07:23:51 +00:00
|
|
|
write_wayland_part(cm_fh, name, c, indent=indent)
|
2020-07-27 09:10:48 +00:00
|
|
|
write_windows_part(cm_fh, name, c, indent=indent)
|
|
|
|
write_darwin_part(cm_fh, name, c, main_scope_target_name=name, indent=indent)
|
|
|
|
write_version_part(cm_fh, name, c, indent=indent)
|
2020-11-11 13:25:45 +00:00
|
|
|
write_aux_qml_files_part(cm_fh, name, c, indent=indent)
|
2020-04-27 13:04:57 +00:00
|
|
|
write_extend_target(cm_fh, name, c, target_ref=target_ref, indent=indent)
|
2019-10-10 13:56:16 +00:00
|
|
|
write_simd_part(cm_fh, name, c, indent=indent)
|
|
|
|
|
2019-03-12 18:55:51 +00:00
|
|
|
ignored_keys_report = write_ignored_keys(c, spaces(indent))
|
|
|
|
if ignored_keys_report:
|
|
|
|
cm_fh.write(ignored_keys_report)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
2020-02-11 14:38:47 +00:00
|
|
|
def write_3rdparty_library(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
|
|
|
# Remove default QT libs.
|
|
|
|
scope._append_operation("QT", RemoveOperation(["core", "gui"]))
|
|
|
|
|
|
|
|
target_name = re.sub(r"^qt", "", scope.TARGET)
|
|
|
|
target_name = target_name.replace("-", "_")
|
2020-04-22 19:01:32 +00:00
|
|
|
qmake_lib_name = target_name
|
2020-02-11 14:38:47 +00:00
|
|
|
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
# Capitalize the first letter for a nicer name.
|
|
|
|
target_name = target_name.title()
|
|
|
|
|
|
|
|
# Prefix with Bundled, to avoid possible duplicate target names
|
|
|
|
# e.g. "BundledFreetype" instead of "freetype".
|
|
|
|
target_name = f"Bundled{target_name}"
|
2020-02-11 14:38:47 +00:00
|
|
|
|
|
|
|
if "dll" in scope.get("CONFIG"):
|
|
|
|
library_type = "SHARED"
|
|
|
|
else:
|
|
|
|
library_type = "STATIC"
|
|
|
|
|
2020-04-22 19:01:32 +00:00
|
|
|
extra_lines = [f"QMAKE_LIB_NAME {qmake_lib_name}"]
|
2020-02-11 14:38:47 +00:00
|
|
|
|
|
|
|
if library_type:
|
|
|
|
extra_lines.append(library_type)
|
|
|
|
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
if "installed" in scope.get("CONFIG"):
|
|
|
|
extra_lines.append("INSTALL")
|
|
|
|
|
2020-02-11 14:38:47 +00:00
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
target_name,
|
|
|
|
"Generic Library",
|
|
|
|
get_cmake_api_call("qt_add_3rdparty_library"),
|
|
|
|
scope,
|
|
|
|
extra_lines=extra_lines,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries={},
|
|
|
|
extra_keys=[],
|
|
|
|
)
|
|
|
|
|
|
|
|
return target_name
|
|
|
|
|
|
|
|
|
2019-10-10 13:40:38 +00:00
|
|
|
def write_generic_library(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
|
|
|
|
|
|
|
target_name = scope.TARGET
|
|
|
|
|
|
|
|
library_type = ""
|
|
|
|
|
2019-10-10 14:32:19 +00:00
|
|
|
if "dll" in scope.get("CONFIG"):
|
2019-10-10 13:40:38 +00:00
|
|
|
library_type = "SHARED"
|
|
|
|
|
2019-10-23 12:45:20 +00:00
|
|
|
is_plugin = False
|
|
|
|
if "plugin" in scope.get("CONFIG"):
|
|
|
|
library_type = "MODULE"
|
|
|
|
is_plugin = True
|
|
|
|
|
|
|
|
# static after plugin in order to handle static library plugins
|
2019-10-10 14:32:19 +00:00
|
|
|
if "static" in scope.get("CONFIG"):
|
2019-10-10 13:40:38 +00:00
|
|
|
library_type = "STATIC"
|
|
|
|
|
|
|
|
extra_lines = []
|
|
|
|
|
|
|
|
if library_type:
|
|
|
|
extra_lines.append(library_type)
|
|
|
|
|
2019-10-10 14:32:19 +00:00
|
|
|
target_path = scope.expandString("target.path")
|
2019-10-10 13:40:38 +00:00
|
|
|
target_path = replace_path_constants(target_path, scope)
|
|
|
|
if target_path:
|
|
|
|
extra_lines.append(f'INSTALL_DIRECTORY "{target_path}"')
|
|
|
|
|
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
target_name,
|
|
|
|
"Generic Library",
|
2019-11-13 13:03:20 +00:00
|
|
|
get_cmake_api_call("qt_add_cmake_library"),
|
2019-10-10 13:40:38 +00:00
|
|
|
scope,
|
|
|
|
extra_lines=extra_lines,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries={},
|
|
|
|
extra_keys=[],
|
|
|
|
)
|
|
|
|
|
2019-10-23 12:45:20 +00:00
|
|
|
if is_plugin:
|
|
|
|
# Plugins need to be able to run auto moc
|
|
|
|
cm_fh.write(f"\nqt_autogen_tools_initial_setup({target_name})\n")
|
|
|
|
|
|
|
|
if library_type == "STATIC":
|
|
|
|
cm_fh.write(f"\ntarget_compile_definitions({target_name} PRIVATE QT_STATICPLUGIN)\n")
|
|
|
|
|
2019-10-10 13:40:38 +00:00
|
|
|
return target_name
|
|
|
|
|
2020-07-27 09:10:48 +00:00
|
|
|
|
2020-07-30 13:56:37 +00:00
|
|
|
def forward_target_info(scope: Scope, extra: List[str], skip: Optional[Dict[str, bool]] = None):
|
2020-05-12 11:22:49 +00:00
|
|
|
s = scope.get_string("QMAKE_TARGET_PRODUCT")
|
|
|
|
if s:
|
2020-07-30 13:50:22 +00:00
|
|
|
extra.append(f'TARGET_PRODUCT "{s}"')
|
2020-05-12 11:22:49 +00:00
|
|
|
s = scope.get_string("QMAKE_TARGET_DESCRIPTION")
|
2020-07-30 13:50:22 +00:00
|
|
|
if s and (not skip or "QMAKE_TARGET_DESCRIPTION" not in skip):
|
|
|
|
extra.append(f'TARGET_DESCRIPTION "{s}"')
|
2020-05-12 11:22:49 +00:00
|
|
|
s = scope.get_string("QMAKE_TARGET_COMPANY")
|
|
|
|
if s:
|
2020-07-30 13:50:22 +00:00
|
|
|
extra.append(f'TARGET_COMPANY "{s}"')
|
2020-05-12 11:22:49 +00:00
|
|
|
s = scope.get_string("QMAKE_TARGET_COPYRIGHT")
|
|
|
|
if s:
|
2020-07-30 13:50:22 +00:00
|
|
|
extra.append(f'TARGET_COPYRIGHT "{s}"')
|
2019-10-10 14:32:19 +00:00
|
|
|
|
2020-07-27 09:10:48 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
2020-10-30 10:41:17 +00:00
|
|
|
# e.g. QtCore
|
|
|
|
qt_module_name = scope.TARGET
|
|
|
|
if not qt_module_name.startswith("Qt"):
|
|
|
|
print(f"XXXXXX Module name {qt_module_name} does not start with Qt!")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
extra = []
|
2019-06-07 16:13:53 +00:00
|
|
|
|
|
|
|
# A module should be static when 'static' is in CONFIG
|
|
|
|
# or when option(host_build) is used, as described in qt_module.prf.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
is_static = "static" in scope.get("CONFIG") or "host_build" in scope.get("_OPTION")
|
2019-06-07 16:13:53 +00:00
|
|
|
|
2020-01-31 21:21:09 +00:00
|
|
|
is_public_module = True
|
|
|
|
|
2020-10-30 10:41:17 +00:00
|
|
|
# CMake target name as passed to qt_internal_add_module()
|
|
|
|
# e.g. Core
|
|
|
|
cmake_target_name = qt_module_name[2:]
|
|
|
|
|
|
|
|
# MODULE is used for the name of the generated .pri file.
|
|
|
|
# If MODULE is not explicitly set, qmake computes its value in
|
|
|
|
# mkspecs/features/qt_build_config.prf
|
|
|
|
module_name_for_pri = scope.expandString("MODULE")
|
|
|
|
if not module_name_for_pri:
|
|
|
|
module_name_for_pri_as_qmake_computes_it = scope.file[:-4]
|
|
|
|
module_name_for_pri = module_name_for_pri_as_qmake_computes_it
|
|
|
|
|
|
|
|
# Given 'qt_internal_add_module(Core)', computes 'core'.
|
|
|
|
module_name_for_pri_as_cmake_computes_it = cmake_target_name.lower()
|
|
|
|
|
|
|
|
if module_name_for_pri != module_name_for_pri_as_cmake_computes_it:
|
2020-11-11 17:13:56 +00:00
|
|
|
extra.append(f"CONFIG_MODULE_NAME {module_name_for_pri}")
|
2020-10-30 10:41:17 +00:00
|
|
|
|
2019-06-07 16:13:53 +00:00
|
|
|
if is_static:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra.append("STATIC")
|
|
|
|
if "internal_module" in scope.get("CONFIG"):
|
2020-01-31 21:21:09 +00:00
|
|
|
is_public_module = False
|
2021-09-08 13:53:29 +00:00
|
|
|
cmake_target_name += "Private" # Assume all internal modules have the 'Private' suffix
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra.append("INTERNAL_MODULE")
|
|
|
|
if "no_module_headers" in scope.get("CONFIG"):
|
|
|
|
extra.append("NO_MODULE_HEADERS")
|
|
|
|
if "minimal_syncqt" in scope.get("CONFIG"):
|
|
|
|
extra.append("NO_SYNC_QT")
|
|
|
|
if "no_private_module" in scope.get("CONFIG"):
|
|
|
|
extra.append("NO_PRIVATE_MODULE")
|
2020-01-31 21:21:09 +00:00
|
|
|
else:
|
|
|
|
scope._has_private_module = True
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if "header_module" in scope.get("CONFIG"):
|
|
|
|
extra.append("HEADER_MODULE")
|
2019-12-04 10:09:33 +00:00
|
|
|
if "metatypes" in scope.get("CONFIG") or "qmltypes" in scope.get("CONFIG"):
|
2019-11-26 09:10:55 +00:00
|
|
|
extra.append("GENERATE_METATYPES")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-05-29 14:56:49 +00:00
|
|
|
module_config = scope.get("MODULE_CONFIG")
|
|
|
|
if len(module_config):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra.append(f'QMAKE_MODULE_CONFIG {" ".join(module_config)}')
|
2019-05-29 14:56:49 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
module_plugin_types = scope.get_files("MODULE_PLUGIN_TYPES")
|
2019-05-03 14:03:15 +00:00
|
|
|
if module_plugin_types:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra.append(f"PLUGIN_TYPES {' '.join(module_plugin_types)}")
|
2019-05-03 14:03:15 +00:00
|
|
|
|
2020-01-31 21:21:09 +00:00
|
|
|
scope._is_public_module = is_public_module
|
|
|
|
|
2020-05-12 11:22:49 +00:00
|
|
|
forward_target_info(scope, extra)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
2020-10-30 10:41:17 +00:00
|
|
|
cmake_target_name,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"Module",
|
2019-11-13 13:03:20 +00:00
|
|
|
f"{get_cmake_api_call('qt_add_module')}",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
scope,
|
|
|
|
extra_lines=extra,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries={},
|
|
|
|
extra_keys=[],
|
|
|
|
)
|
|
|
|
|
|
|
|
if "qt_tracepoints" in scope.get("CONFIG"):
|
|
|
|
tracepoints = scope.get_files("TRACEPOINT_PROVIDER")
|
2020-09-22 08:02:27 +00:00
|
|
|
create_trace_points = get_cmake_api_call("qt_create_tracepoints")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(
|
2020-10-30 10:41:17 +00:00
|
|
|
f"\n\n{spaces(indent)}{create_trace_points}({cmake_target_name} {' '.join(tracepoints)})\n"
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2020-10-30 10:41:17 +00:00
|
|
|
return cmake_target_name
|
2019-09-18 07:27:22 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2020-07-30 13:56:37 +00:00
|
|
|
def write_tool(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> Tuple[str, str]:
|
2019-01-29 09:18:21 +00:00
|
|
|
tool_name = scope.TARGET
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-10-07 13:58:44 +00:00
|
|
|
if "force_bootstrap" in scope.get("CONFIG"):
|
|
|
|
extra = ["BOOTSTRAP"]
|
|
|
|
|
|
|
|
# Remove default QT libs.
|
|
|
|
scope._append_operation("QT", RemoveOperation(["core", "gui"]))
|
|
|
|
else:
|
|
|
|
extra = []
|
2019-03-01 12:32:44 +00:00
|
|
|
|
2020-05-12 11:22:49 +00:00
|
|
|
forward_target_info(scope, extra)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
tool_name,
|
|
|
|
"Tool",
|
2019-11-13 13:03:20 +00:00
|
|
|
get_cmake_api_call("qt_add_tool"),
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
scope,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries={"Qt::Core"},
|
|
|
|
extra_lines=extra,
|
|
|
|
extra_keys=["CONFIG"],
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2020-04-27 13:04:57 +00:00
|
|
|
return tool_name, "${target_name}"
|
2019-09-18 07:27:22 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2020-07-27 09:10:48 +00:00
|
|
|
def write_qt_app(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
|
|
|
app_name = scope.TARGET
|
|
|
|
|
2020-07-30 13:56:37 +00:00
|
|
|
extra: List[str] = []
|
2020-07-27 09:10:48 +00:00
|
|
|
|
|
|
|
target_info_skip = {}
|
2020-07-30 13:50:22 +00:00
|
|
|
target_info_skip["QMAKE_TARGET_DESCRIPTION"] = True
|
2020-07-27 09:10:48 +00:00
|
|
|
forward_target_info(scope, extra, target_info_skip)
|
|
|
|
|
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
app_name,
|
|
|
|
"App",
|
|
|
|
get_cmake_api_call("qt_internal_add_app"),
|
|
|
|
scope,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries={"Qt::Core"},
|
|
|
|
extra_lines=extra,
|
|
|
|
extra_keys=["CONFIG"],
|
|
|
|
)
|
|
|
|
|
|
|
|
return app_name
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_test(cm_fh: IO[str], scope: Scope, gui: bool = False, *, indent: int = 0) -> str:
|
2019-01-29 09:18:21 +00:00
|
|
|
test_name = scope.TARGET
|
2018-10-24 13:20:27 +00:00
|
|
|
assert test_name
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra = ["GUI"] if gui else []
|
|
|
|
libraries = {"Qt::Core", "Qt::Test"}
|
2019-07-22 10:55:48 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if "qmltestcase" in scope.get("CONFIG"):
|
|
|
|
libraries.add("Qt::QmlTest")
|
|
|
|
extra.append("QMLTEST")
|
|
|
|
importpath = scope.expand("IMPORTPATH")
|
2019-07-22 10:55:48 +00:00
|
|
|
if importpath:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra.append("QML_IMPORTPATH")
|
2019-09-17 09:27:47 +00:00
|
|
|
for path in importpath:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra.append(f' "{path}"')
|
|
|
|
|
2020-01-14 12:30:12 +00:00
|
|
|
target_original = scope.TARGET_ORIGINAL
|
|
|
|
if target_original and target_original.startswith("../"):
|
2020-01-16 08:39:26 +00:00
|
|
|
extra.append('OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../"')
|
2020-01-14 12:30:12 +00:00
|
|
|
|
2019-09-22 16:28:01 +00:00
|
|
|
requires_content = expand_project_requirements(scope, skip_message=True)
|
|
|
|
if requires_content:
|
|
|
|
requires_content += "\n"
|
|
|
|
cm_fh.write(requires_content)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
test_name,
|
|
|
|
"Test",
|
2019-11-13 13:03:20 +00:00
|
|
|
get_cmake_api_call("qt_add_test"),
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
scope,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries=libraries,
|
|
|
|
extra_lines=extra,
|
|
|
|
extra_keys=[],
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-09-18 07:27:22 +00:00
|
|
|
return test_name
|
|
|
|
|
2020-07-30 13:50:22 +00:00
|
|
|
|
2019-09-21 18:18:10 +00:00
|
|
|
def write_binary(cm_fh: IO[str], scope: Scope, gui: bool = False, *, indent: int = 0) -> str:
|
2019-01-29 09:18:21 +00:00
|
|
|
binary_name = scope.TARGET
|
2018-10-24 13:20:27 +00:00
|
|
|
assert binary_name
|
|
|
|
|
2019-10-28 14:35:47 +00:00
|
|
|
is_benchmark = is_benchmark_project(scope.file_absolute_path)
|
2019-11-13 09:53:13 +00:00
|
|
|
is_manual_test = is_manual_test_project(scope.file_absolute_path)
|
2019-10-28 14:35:47 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
is_qt_test_helper = "qt_test_helper" in scope.get("_LOADED")
|
2019-08-12 13:51:17 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra = ["GUI"] if gui and not is_qt_test_helper else []
|
2019-11-13 13:03:20 +00:00
|
|
|
cmake_function_call = get_cmake_api_call("qt_add_executable")
|
2019-11-11 18:03:36 +00:00
|
|
|
extra_keys: List[str] = []
|
2019-08-12 13:51:17 +00:00
|
|
|
|
|
|
|
if is_qt_test_helper:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
binary_name += "_helper"
|
2019-11-13 13:03:20 +00:00
|
|
|
cmake_function_call = get_cmake_api_call("qt_add_test_helper")
|
2019-03-18 18:15:22 +00:00
|
|
|
|
2019-10-28 14:35:47 +00:00
|
|
|
if is_benchmark:
|
2019-11-13 13:03:20 +00:00
|
|
|
cmake_function_call = get_cmake_api_call("qt_add_benchmark")
|
2019-11-12 14:31:34 +00:00
|
|
|
elif is_manual_test:
|
2019-11-13 13:03:20 +00:00
|
|
|
cmake_function_call = get_cmake_api_call("qt_add_manual_test")
|
2019-10-28 14:35:47 +00:00
|
|
|
else:
|
|
|
|
extra_keys = ["target.path", "INSTALLS"]
|
|
|
|
target_path = scope.get_string("target.path")
|
|
|
|
if target_path:
|
|
|
|
target_path = replace_path_constants(target_path, scope)
|
|
|
|
if not scope.get("DESTDIR"):
|
|
|
|
extra.append(f'OUTPUT_DIRECTORY "{target_path}"')
|
|
|
|
if "target" in scope.get("INSTALLS"):
|
|
|
|
extra.append(f'INSTALL_DIRECTORY "{target_path}"')
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
binary_name,
|
|
|
|
"Binary",
|
|
|
|
cmake_function_call,
|
|
|
|
scope,
|
|
|
|
extra_lines=extra,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries={"Qt::Core"},
|
2019-10-28 14:35:47 +00:00
|
|
|
extra_keys=extra_keys,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-09-18 07:27:22 +00:00
|
|
|
return binary_name
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_find_package_section(
|
2022-03-03 16:15:04 +00:00
|
|
|
cm_fh: IO[str],
|
|
|
|
public_libs: List[str],
|
|
|
|
private_libs: List[str],
|
|
|
|
*,
|
|
|
|
indent: int = 0,
|
|
|
|
is_required: bool = True,
|
|
|
|
end_with_extra_newline: bool = True,
|
2022-03-04 10:06:58 +00:00
|
|
|
qt_package_name: str = "Qt6",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
):
|
|
|
|
packages = [] # type: List[LibraryMapping]
|
2019-05-09 08:59:13 +00:00
|
|
|
all_libs = public_libs + private_libs
|
|
|
|
|
2020-07-30 13:56:37 +00:00
|
|
|
for one_lib in all_libs:
|
|
|
|
info = find_library_info_for_target(one_lib)
|
2019-05-09 08:59:13 +00:00
|
|
|
if info and info not in packages:
|
|
|
|
packages.append(info)
|
|
|
|
|
2022-03-03 11:04:48 +00:00
|
|
|
qt_components: List[str] = []
|
|
|
|
for p in filter(LibraryMapping.is_qt, packages):
|
|
|
|
if p.components is not None:
|
|
|
|
qt_components += p.components
|
|
|
|
if qt_components:
|
2022-03-04 10:06:58 +00:00
|
|
|
if "Core" in qt_components:
|
|
|
|
qt_components.remove("Core")
|
2022-03-03 11:04:48 +00:00
|
|
|
qt_components = sorted(qt_components)
|
2022-03-04 10:06:58 +00:00
|
|
|
qt_package = LibraryMapping("unknown", qt_package_name, "unknown", components=qt_components)
|
2022-03-03 16:15:04 +00:00
|
|
|
if is_required:
|
|
|
|
qt_package.extra = ["REQUIRED"]
|
2022-03-03 11:04:48 +00:00
|
|
|
cm_fh.write(
|
|
|
|
generate_find_package_info(
|
|
|
|
qt_package,
|
|
|
|
use_qt_find_package=False,
|
|
|
|
remove_REQUIRED_from_extra=False,
|
2022-03-03 16:15:04 +00:00
|
|
|
components_required=is_required,
|
2022-03-03 11:04:48 +00:00
|
|
|
indent=indent,
|
|
|
|
)
|
|
|
|
)
|
2019-05-09 08:59:13 +00:00
|
|
|
|
2022-03-03 11:04:48 +00:00
|
|
|
for p in itertools.filterfalse(LibraryMapping.is_qt, packages):
|
2019-05-09 08:59:13 +00:00
|
|
|
cm_fh.write(generate_find_package_info(p, use_qt_find_package=False, indent=indent))
|
|
|
|
|
2022-03-03 16:15:04 +00:00
|
|
|
if packages and end_with_extra_newline:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write("\n")
|
2019-05-09 08:59:13 +00:00
|
|
|
|
|
|
|
|
2019-10-18 12:28:08 +00:00
|
|
|
def write_jar(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
|
|
|
|
|
|
|
target = scope.TARGET
|
|
|
|
|
|
|
|
install_dir = scope.expandString("target.path")
|
|
|
|
if not install_dir:
|
|
|
|
raise RuntimeError("Could not locate jar install path")
|
|
|
|
install_dir = install_dir.replace("$$[QT_INSTALL_PREFIX]/", "")
|
|
|
|
|
|
|
|
android_sdk_jar = "${QT_ANDROID_JAR}"
|
|
|
|
android_api_level = scope.get_string("API_VERSION")
|
|
|
|
if android_api_level:
|
2019-10-29 08:57:19 +00:00
|
|
|
cm_fh.write(
|
|
|
|
f'{spaces(indent)}qt_get_android_sdk_jar_for_api("{android_api_level}" android_sdk)\n\n'
|
|
|
|
)
|
|
|
|
android_sdk_jar = "${android_sdk}"
|
2019-10-18 12:28:08 +00:00
|
|
|
|
|
|
|
write_source_file_list(
|
2022-02-24 10:31:10 +00:00
|
|
|
cm_fh, scope, "", ["JAVASOURCES"], indent=indent, header="set(java_sources\n", footer=")\n"
|
2019-10-18 12:28:08 +00:00
|
|
|
)
|
|
|
|
|
2020-09-11 17:28:01 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)}qt_internal_add_jar({target}\n")
|
2019-10-18 12:28:08 +00:00
|
|
|
cm_fh.write(f"{spaces(indent+1)}INCLUDE_JARS {android_sdk_jar}\n")
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}SOURCES ${{java_sources}}\n")
|
2020-07-03 13:05:42 +00:00
|
|
|
cm_fh.write(f'{spaces(indent+1)}OUTPUT_DIR "${{QT_BUILD_DIR}}/{install_dir}"\n')
|
2019-10-18 12:28:08 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)})\n\n")
|
|
|
|
|
|
|
|
cm_fh.write(f"{spaces(indent)}install_jar({target}\n")
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}DESTINATION {install_dir}\n")
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}COMPONENT Devel\n")
|
|
|
|
cm_fh.write(f"{spaces(indent)})\n\n")
|
|
|
|
|
|
|
|
return target
|
|
|
|
|
|
|
|
|
2021-09-06 15:03:41 +00:00
|
|
|
def get_win32_and_mac_bundle_properties(scope: Scope) -> tuple:
|
CMake: pro2cmake: Handle CONFIG+=console app_bundle in examples
Now that qt_add_executable doesn't set the WIN32_EXECUTABLE and
MACOSX_BUNDLE properties anymore, pro2cmake needs to look at the qmake
example projects and generate appropriate set_target_properties calls.
The relevant CONFIG entries to look at are windows, console,
app_bundle and cmdline.
CONFIG += windows implies 'subsystem windows' on Windows, which maps
to WIN32_EXECUTABLE == TRUE.
CONFIG += console implies 'subsystem console' on Windows, which maps
to WIN32_EXECUTABLE == FALSE. Aka the opposite of CONFIG += windows.
Whichever is the last one set, cancels out the other one.
CONFIG += app_bundle implies a macOS bundle executable, which maps
to MACOSX_BUNDLE == TRUE.
CONFIG += cmdline is the same as CONFIG += console and CONFIG -=
app_bundle, aka WIN32_EXECUTABLE and MACOSX_BUNDLE set to false.
In qmake, if no CONFIG is specified in an example project,
the default is CONFIG += windows app_bundle, aka WIN32_EXECUTABLE
and MACOSX_BUNDLE set to true.
The script uses a heuristic to try and not write the properties for
every single subscope, except for values different from the default.
This is not strictly correct, but it covers most use cases, and keeps
the generated projects a bit cleaner.
Task-number: QTBUG-87664
Task-number: QTBUG-86827
Change-Id: If05606ec3205e0fe7c1803c07e114d9fd9c3e4f7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 15:07:44 +00:00
|
|
|
config = scope.get("CONFIG")
|
|
|
|
win32 = all(val not in config for val in ["cmdline", "console"])
|
|
|
|
mac_bundle = all(val not in config for val in ["cmdline", "-app_bundle"])
|
|
|
|
|
2021-09-06 15:03:41 +00:00
|
|
|
return win32, mac_bundle
|
|
|
|
|
|
|
|
|
|
|
|
def write_win32_and_mac_bundle_properties(
|
|
|
|
cm_fh: IO[str], scope: Scope, target: str, *, handling_first_scope=False, indent: int = 0
|
|
|
|
):
|
|
|
|
win32, mac_bundle = get_win32_and_mac_bundle_properties(scope)
|
|
|
|
|
CMake: pro2cmake: Handle CONFIG+=console app_bundle in examples
Now that qt_add_executable doesn't set the WIN32_EXECUTABLE and
MACOSX_BUNDLE properties anymore, pro2cmake needs to look at the qmake
example projects and generate appropriate set_target_properties calls.
The relevant CONFIG entries to look at are windows, console,
app_bundle and cmdline.
CONFIG += windows implies 'subsystem windows' on Windows, which maps
to WIN32_EXECUTABLE == TRUE.
CONFIG += console implies 'subsystem console' on Windows, which maps
to WIN32_EXECUTABLE == FALSE. Aka the opposite of CONFIG += windows.
Whichever is the last one set, cancels out the other one.
CONFIG += app_bundle implies a macOS bundle executable, which maps
to MACOSX_BUNDLE == TRUE.
CONFIG += cmdline is the same as CONFIG += console and CONFIG -=
app_bundle, aka WIN32_EXECUTABLE and MACOSX_BUNDLE set to false.
In qmake, if no CONFIG is specified in an example project,
the default is CONFIG += windows app_bundle, aka WIN32_EXECUTABLE
and MACOSX_BUNDLE set to true.
The script uses a heuristic to try and not write the properties for
every single subscope, except for values different from the default.
This is not strictly correct, but it covers most use cases, and keeps
the generated projects a bit cleaner.
Task-number: QTBUG-87664
Task-number: QTBUG-86827
Change-Id: If05606ec3205e0fe7c1803c07e114d9fd9c3e4f7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 15:07:44 +00:00
|
|
|
true_value = "TRUE"
|
|
|
|
false_value = "FALSE"
|
|
|
|
|
2020-11-11 17:13:56 +00:00
|
|
|
properties_mapping = {
|
|
|
|
"WIN32_EXECUTABLE": true_value if win32 else false_value,
|
|
|
|
"MACOSX_BUNDLE": true_value if mac_bundle else false_value,
|
|
|
|
}
|
CMake: pro2cmake: Handle CONFIG+=console app_bundle in examples
Now that qt_add_executable doesn't set the WIN32_EXECUTABLE and
MACOSX_BUNDLE properties anymore, pro2cmake needs to look at the qmake
example projects and generate appropriate set_target_properties calls.
The relevant CONFIG entries to look at are windows, console,
app_bundle and cmdline.
CONFIG += windows implies 'subsystem windows' on Windows, which maps
to WIN32_EXECUTABLE == TRUE.
CONFIG += console implies 'subsystem console' on Windows, which maps
to WIN32_EXECUTABLE == FALSE. Aka the opposite of CONFIG += windows.
Whichever is the last one set, cancels out the other one.
CONFIG += app_bundle implies a macOS bundle executable, which maps
to MACOSX_BUNDLE == TRUE.
CONFIG += cmdline is the same as CONFIG += console and CONFIG -=
app_bundle, aka WIN32_EXECUTABLE and MACOSX_BUNDLE set to false.
In qmake, if no CONFIG is specified in an example project,
the default is CONFIG += windows app_bundle, aka WIN32_EXECUTABLE
and MACOSX_BUNDLE set to true.
The script uses a heuristic to try and not write the properties for
every single subscope, except for values different from the default.
This is not strictly correct, but it covers most use cases, and keeps
the generated projects a bit cleaner.
Task-number: QTBUG-87664
Task-number: QTBUG-86827
Change-Id: If05606ec3205e0fe7c1803c07e114d9fd9c3e4f7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 15:07:44 +00:00
|
|
|
|
|
|
|
properties = []
|
|
|
|
|
|
|
|
# Always write the properties for the first scope.
|
|
|
|
# For conditional scopes, only write them if the value is different
|
|
|
|
# from the default value (aka different from TRUE).
|
|
|
|
# This is a heurestic that should cover 90% of the example projects
|
|
|
|
# without creating excess noise of setting the properties in every
|
|
|
|
# single scope.
|
|
|
|
for name, value in properties_mapping.items():
|
2021-09-06 15:03:41 +00:00
|
|
|
if not handling_first_scope and value != true_value:
|
CMake: pro2cmake: Handle CONFIG+=console app_bundle in examples
Now that qt_add_executable doesn't set the WIN32_EXECUTABLE and
MACOSX_BUNDLE properties anymore, pro2cmake needs to look at the qmake
example projects and generate appropriate set_target_properties calls.
The relevant CONFIG entries to look at are windows, console,
app_bundle and cmdline.
CONFIG += windows implies 'subsystem windows' on Windows, which maps
to WIN32_EXECUTABLE == TRUE.
CONFIG += console implies 'subsystem console' on Windows, which maps
to WIN32_EXECUTABLE == FALSE. Aka the opposite of CONFIG += windows.
Whichever is the last one set, cancels out the other one.
CONFIG += app_bundle implies a macOS bundle executable, which maps
to MACOSX_BUNDLE == TRUE.
CONFIG += cmdline is the same as CONFIG += console and CONFIG -=
app_bundle, aka WIN32_EXECUTABLE and MACOSX_BUNDLE set to false.
In qmake, if no CONFIG is specified in an example project,
the default is CONFIG += windows app_bundle, aka WIN32_EXECUTABLE
and MACOSX_BUNDLE set to true.
The script uses a heuristic to try and not write the properties for
every single subscope, except for values different from the default.
This is not strictly correct, but it covers most use cases, and keeps
the generated projects a bit cleaner.
Task-number: QTBUG-87664
Task-number: QTBUG-86827
Change-Id: If05606ec3205e0fe7c1803c07e114d9fd9c3e4f7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 15:07:44 +00:00
|
|
|
properties.extend([name, value])
|
|
|
|
|
|
|
|
if properties:
|
|
|
|
write_set_target_properties(cm_fh, [target], properties, indent=indent)
|
|
|
|
|
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
def is_qtquick_source_file(filename: str):
|
|
|
|
return filename.endswith(".qml") or filename.endswith(".js") or filename.endswith(".mjs")
|
|
|
|
|
|
|
|
|
|
|
|
def looks_like_qml_resource(resource: QtResource):
|
|
|
|
if resource.generated or "*" in resource.name:
|
|
|
|
return False
|
|
|
|
for f in resource.files:
|
|
|
|
if is_qtquick_source_file(f):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def find_qml_resource(resources: List[QtResource]):
|
|
|
|
"""Return the resource object that's most likely the one that should be used for
|
|
|
|
qt_add_qml_module. Return None if there's no such resource."""
|
|
|
|
return next(filter(looks_like_qml_resource, resources), None)
|
|
|
|
|
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
def write_example(
|
2022-03-04 14:49:02 +00:00
|
|
|
cm_fh: IO[str],
|
|
|
|
scope: Scope,
|
|
|
|
gui: bool = False,
|
|
|
|
*,
|
|
|
|
indent: int = 0,
|
|
|
|
is_plugin: bool = False,
|
|
|
|
is_user_project: bool = False,
|
2019-09-03 12:32:43 +00:00
|
|
|
) -> str:
|
2019-05-07 09:27:33 +00:00
|
|
|
binary_name = scope.TARGET
|
|
|
|
assert binary_name
|
2022-02-28 20:03:13 +00:00
|
|
|
config = scope.get("CONFIG")
|
|
|
|
is_qml_plugin = ("qml" in scope.get("QT")) or "qmltypes" in config
|
2019-05-07 09:27:33 +00:00
|
|
|
|
2022-03-04 14:49:02 +00:00
|
|
|
if not is_user_project:
|
|
|
|
example_install_dir = scope.expandString("target.path")
|
|
|
|
if not example_install_dir:
|
|
|
|
example_install_dir = "${INSTALL_EXAMPLESDIR}"
|
|
|
|
example_install_dir = example_install_dir.replace(
|
|
|
|
"$$[QT_INSTALL_EXAMPLES]", "${INSTALL_EXAMPLESDIR}"
|
|
|
|
)
|
2019-10-09 09:23:03 +00:00
|
|
|
|
2022-02-25 12:04:35 +00:00
|
|
|
project_version = scope.get_string("VERSION", "1.0")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(
|
2021-09-06 15:03:41 +00:00
|
|
|
f"cmake_minimum_required(VERSION {cmake_version_string})\n"
|
2022-02-25 12:04:35 +00:00
|
|
|
f"project({binary_name} VERSION {project_version} LANGUAGES CXX)\n\n"
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"set(CMAKE_INCLUDE_CURRENT_DIR ON)\n\n"
|
|
|
|
"set(CMAKE_AUTOMOC ON)\n"
|
2022-03-03 11:11:58 +00:00
|
|
|
)
|
|
|
|
if scope.get_files("FORMS"):
|
|
|
|
cm_fh.write("set(CMAKE_AUTOUIC ON)\n")
|
|
|
|
cm_fh.write("\n")
|
2022-03-04 14:49:02 +00:00
|
|
|
if not is_user_project:
|
|
|
|
cm_fh.write(
|
|
|
|
"if(NOT DEFINED INSTALL_EXAMPLESDIR)\n"
|
|
|
|
' set(INSTALL_EXAMPLESDIR "examples")\n'
|
|
|
|
"endif()\n\n"
|
|
|
|
f'set(INSTALL_EXAMPLEDIR "{example_install_dir}")\n\n'
|
|
|
|
)
|
2019-05-07 09:27:33 +00:00
|
|
|
|
2019-10-09 11:39:38 +00:00
|
|
|
recursive_evaluate_scope(scope)
|
|
|
|
|
|
|
|
# Get a flat list of all scopes but the main one:
|
|
|
|
scopes = flatten_scopes(scope)
|
|
|
|
# Merge scopes based on their conditions:
|
|
|
|
scopes = merge_scopes(scopes)
|
|
|
|
# Handle SOURCES -= foo calls, and merge scopes one more time
|
|
|
|
# because there might have been several files removed with the same
|
|
|
|
# scope condition.
|
|
|
|
handle_source_subtractions(scopes)
|
|
|
|
scopes = merge_scopes(scopes)
|
|
|
|
|
2022-03-04 10:06:58 +00:00
|
|
|
# Write find_package call for Qt5/Qt6 and make it available as package QT.
|
|
|
|
cm_fh.write("find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core)\n")
|
|
|
|
|
2022-03-03 16:15:04 +00:00
|
|
|
# Write find_package calls for required packages.
|
|
|
|
# We consider packages as required if they appear at the top-level scope.
|
2019-10-10 13:10:37 +00:00
|
|
|
(public_libs, private_libs) = extract_cmake_libraries(scope, is_example=True)
|
2022-03-03 16:15:04 +00:00
|
|
|
write_find_package_section(
|
2022-03-04 10:06:58 +00:00
|
|
|
cm_fh,
|
|
|
|
public_libs,
|
|
|
|
private_libs,
|
|
|
|
indent=indent,
|
|
|
|
end_with_extra_newline=False,
|
|
|
|
qt_package_name="Qt${QT_VERSION_MAJOR}",
|
2022-03-03 16:15:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Write find_package calls for optional packages.
|
|
|
|
# We consider packages inside scopes other than the top-level one as optional.
|
|
|
|
optional_public_libs: List[str] = []
|
|
|
|
optional_private_libs: List[str] = []
|
|
|
|
handling_first_scope = True
|
|
|
|
for inner_scope in scopes:
|
|
|
|
if handling_first_scope:
|
|
|
|
handling_first_scope = False
|
|
|
|
continue
|
|
|
|
(public_libs, private_libs) = extract_cmake_libraries(inner_scope, is_example=True)
|
|
|
|
optional_public_libs += public_libs
|
|
|
|
optional_private_libs += private_libs
|
|
|
|
write_find_package_section(
|
|
|
|
cm_fh,
|
|
|
|
optional_public_libs,
|
|
|
|
optional_private_libs,
|
|
|
|
indent=indent,
|
|
|
|
is_required=False,
|
|
|
|
end_with_extra_newline=False,
|
2022-03-04 10:06:58 +00:00
|
|
|
qt_package_name="Qt${QT_VERSION_MAJOR}",
|
2022-03-03 16:15:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
cm_fh.write("\n")
|
2019-05-09 08:59:13 +00:00
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
(resources, standalone_qtquick_compiler_skipped_files) = extract_resources(binary_name, scope)
|
|
|
|
qml_resource = find_qml_resource(resources) if is_qml_plugin else None
|
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
add_target = ""
|
|
|
|
|
|
|
|
if is_plugin:
|
2022-02-28 20:03:13 +00:00
|
|
|
if is_qml_plugin:
|
|
|
|
extra_args = [f"PLUGIN_TARGET {binary_name}"]
|
|
|
|
io_string = io.StringIO()
|
|
|
|
write_qml_module(
|
|
|
|
io_string,
|
|
|
|
binary_name,
|
|
|
|
scope,
|
|
|
|
scopes,
|
|
|
|
indent=indent,
|
|
|
|
resource=qml_resource,
|
|
|
|
extra_add_qml_module_args=extra_args,
|
2019-11-22 12:01:45 +00:00
|
|
|
)
|
2022-02-28 20:03:13 +00:00
|
|
|
add_target += io_string.getvalue()
|
2019-09-03 12:32:43 +00:00
|
|
|
else:
|
2020-04-21 11:28:57 +00:00
|
|
|
add_target = f"qt_add_plugin({binary_name}"
|
|
|
|
if "static" in scope.get("CONFIG"):
|
|
|
|
add_target += " STATIC"
|
|
|
|
add_target += ")\n"
|
2022-02-28 20:03:13 +00:00
|
|
|
add_target += f"target_sources({binary_name} PRIVATE"
|
2019-09-03 12:32:43 +00:00
|
|
|
else:
|
2020-11-11 17:13:56 +00:00
|
|
|
add_target = f"qt_add_executable({binary_name}"
|
2019-09-03 12:32:43 +00:00
|
|
|
|
2021-09-06 15:03:41 +00:00
|
|
|
property_win32, property_mac_bundle = get_win32_and_mac_bundle_properties(scope)
|
|
|
|
|
|
|
|
if property_win32:
|
2021-09-08 13:53:29 +00:00
|
|
|
add_target += " " + "WIN32"
|
2021-09-06 15:03:41 +00:00
|
|
|
if property_mac_bundle:
|
2021-09-08 13:53:29 +00:00
|
|
|
add_target += " " + "MACOSX_BUNDLE"
|
2021-09-06 15:03:41 +00:00
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
write_all_source_file_lists(cm_fh, scope, add_target, indent=0)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(")\n")
|
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
if is_qml_plugin and not is_plugin:
|
|
|
|
write_qml_module(cm_fh, binary_name, scope, scopes, indent=indent, resource=qml_resource)
|
|
|
|
|
2019-10-11 12:32:43 +00:00
|
|
|
handling_first_scope = True
|
|
|
|
|
2019-10-10 13:10:37 +00:00
|
|
|
for scope in scopes:
|
2019-10-09 11:39:38 +00:00
|
|
|
# write wayland already has condition scope handling
|
|
|
|
write_wayland_part(cm_fh, binary_name, scope, indent=0)
|
2019-09-27 13:10:50 +00:00
|
|
|
|
2019-10-09 11:39:38 +00:00
|
|
|
# The following options do not
|
2019-10-11 14:43:29 +00:00
|
|
|
io_string = io.StringIO()
|
|
|
|
condition_str = ""
|
2019-10-09 11:39:38 +00:00
|
|
|
condition = "ON"
|
|
|
|
if scope.total_condition:
|
|
|
|
condition = map_to_cmake_condition(scope.total_condition)
|
|
|
|
|
|
|
|
if condition != "ON":
|
2019-10-11 14:43:29 +00:00
|
|
|
condition_str = f"\n{spaces(indent)}if({condition})\n"
|
2019-10-09 11:39:38 +00:00
|
|
|
indent += 1
|
|
|
|
|
2019-10-11 12:32:43 +00:00
|
|
|
if not handling_first_scope:
|
|
|
|
target_sources = f"target_sources({binary_name} PUBLIC"
|
2019-10-14 09:12:47 +00:00
|
|
|
write_all_source_file_lists(
|
|
|
|
io_string, scope, target_sources, indent=indent, footer=")\n"
|
|
|
|
)
|
2019-10-11 12:32:43 +00:00
|
|
|
|
2020-11-11 17:13:56 +00:00
|
|
|
write_win32_and_mac_bundle_properties(
|
|
|
|
io_string, scope, binary_name, handling_first_scope=handling_first_scope, indent=indent
|
|
|
|
)
|
CMake: pro2cmake: Handle CONFIG+=console app_bundle in examples
Now that qt_add_executable doesn't set the WIN32_EXECUTABLE and
MACOSX_BUNDLE properties anymore, pro2cmake needs to look at the qmake
example projects and generate appropriate set_target_properties calls.
The relevant CONFIG entries to look at are windows, console,
app_bundle and cmdline.
CONFIG += windows implies 'subsystem windows' on Windows, which maps
to WIN32_EXECUTABLE == TRUE.
CONFIG += console implies 'subsystem console' on Windows, which maps
to WIN32_EXECUTABLE == FALSE. Aka the opposite of CONFIG += windows.
Whichever is the last one set, cancels out the other one.
CONFIG += app_bundle implies a macOS bundle executable, which maps
to MACOSX_BUNDLE == TRUE.
CONFIG += cmdline is the same as CONFIG += console and CONFIG -=
app_bundle, aka WIN32_EXECUTABLE and MACOSX_BUNDLE set to false.
In qmake, if no CONFIG is specified in an example project,
the default is CONFIG += windows app_bundle, aka WIN32_EXECUTABLE
and MACOSX_BUNDLE set to true.
The script uses a heuristic to try and not write the properties for
every single subscope, except for values different from the default.
This is not strictly correct, but it covers most use cases, and keeps
the generated projects a bit cleaner.
Task-number: QTBUG-87664
Task-number: QTBUG-86827
Change-Id: If05606ec3205e0fe7c1803c07e114d9fd9c3e4f7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 15:07:44 +00:00
|
|
|
|
2019-10-09 11:39:38 +00:00
|
|
|
write_include_paths(
|
2019-10-11 14:43:29 +00:00
|
|
|
io_string,
|
2019-10-10 14:32:19 +00:00
|
|
|
scope,
|
|
|
|
f"target_include_directories({binary_name} PUBLIC",
|
|
|
|
indent=indent,
|
2019-10-11 14:43:29 +00:00
|
|
|
footer=")\n",
|
2019-10-09 11:39:38 +00:00
|
|
|
)
|
|
|
|
write_defines(
|
2019-10-11 14:43:29 +00:00
|
|
|
io_string,
|
2019-10-10 14:32:19 +00:00
|
|
|
scope,
|
|
|
|
f"target_compile_definitions({binary_name} PUBLIC",
|
|
|
|
indent=indent,
|
2019-10-11 14:43:29 +00:00
|
|
|
footer=")\n",
|
2019-10-09 11:39:38 +00:00
|
|
|
)
|
2019-10-09 12:10:12 +00:00
|
|
|
|
2019-10-10 13:10:37 +00:00
|
|
|
(scope_public_libs, scope_private_libs) = extract_cmake_libraries(scope, is_example=True)
|
2019-10-09 12:10:12 +00:00
|
|
|
|
2019-10-09 11:39:38 +00:00
|
|
|
write_list(
|
2019-10-11 14:43:29 +00:00
|
|
|
io_string,
|
2019-10-09 12:10:12 +00:00
|
|
|
scope_private_libs,
|
2019-10-09 11:39:38 +00:00
|
|
|
"",
|
|
|
|
indent=indent,
|
|
|
|
header=f"target_link_libraries({binary_name} PRIVATE\n",
|
2019-10-11 14:43:29 +00:00
|
|
|
footer=")\n",
|
2019-10-09 11:39:38 +00:00
|
|
|
)
|
|
|
|
write_list(
|
2019-10-11 14:43:29 +00:00
|
|
|
io_string,
|
2019-10-09 12:10:12 +00:00
|
|
|
scope_public_libs,
|
2019-10-09 11:39:38 +00:00
|
|
|
"",
|
|
|
|
indent=indent,
|
|
|
|
header=f"target_link_libraries({binary_name} PUBLIC\n",
|
2019-10-11 14:43:29 +00:00
|
|
|
footer=")\n",
|
2019-10-09 11:39:38 +00:00
|
|
|
)
|
|
|
|
write_compile_options(
|
2019-10-11 14:43:29 +00:00
|
|
|
io_string, scope, f"target_compile_options({binary_name}", indent=indent, footer=")\n"
|
2019-10-09 11:39:38 +00:00
|
|
|
)
|
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
(resources, standalone_qtquick_compiler_skipped_files) = extract_resources(
|
|
|
|
binary_name, scope
|
|
|
|
)
|
|
|
|
|
|
|
|
# Remove the QML resource, because we've handled it in write_qml_module.
|
|
|
|
if qml_resource is not None:
|
|
|
|
resources = list(filter(lambda r: r.name != qml_resource.name, resources))
|
|
|
|
|
|
|
|
write_resources(
|
|
|
|
io_string,
|
|
|
|
binary_name,
|
|
|
|
scope,
|
|
|
|
indent=indent,
|
|
|
|
is_example=True,
|
|
|
|
resources=resources,
|
|
|
|
skipped_standalone_files=standalone_qtquick_compiler_skipped_files,
|
|
|
|
)
|
2019-10-11 14:43:29 +00:00
|
|
|
write_statecharts(io_string, binary_name, scope, indent=indent, is_example=True)
|
|
|
|
write_repc_files(io_string, binary_name, scope, indent=indent)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
2019-10-09 11:39:38 +00:00
|
|
|
if condition != "ON":
|
|
|
|
indent -= 1
|
2019-10-11 14:43:29 +00:00
|
|
|
string = io_string.getvalue()
|
|
|
|
if len(string) != 0:
|
|
|
|
string = string.rstrip("\n")
|
|
|
|
cm_fh.write(f"{condition_str}{string}\n")
|
|
|
|
if condition != "ON":
|
|
|
|
cm_fh.write(f"{spaces(indent)}endif()\n")
|
|
|
|
|
2019-10-11 12:32:43 +00:00
|
|
|
handling_first_scope = False
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
2022-03-04 14:49:02 +00:00
|
|
|
if not is_user_project:
|
|
|
|
cm_fh.write(
|
|
|
|
f"\ninstall(TARGETS {binary_name}\n"
|
|
|
|
f' RUNTIME DESTINATION "${{INSTALL_EXAMPLEDIR}}"\n'
|
|
|
|
f' BUNDLE DESTINATION "${{INSTALL_EXAMPLEDIR}}"\n'
|
|
|
|
f' LIBRARY DESTINATION "${{INSTALL_EXAMPLEDIR}}"\n'
|
|
|
|
f")\n"
|
|
|
|
)
|
2019-05-07 09:27:33 +00:00
|
|
|
|
2019-09-18 07:27:22 +00:00
|
|
|
return binary_name
|
|
|
|
|
2019-05-07 09:27:33 +00:00
|
|
|
|
2019-09-18 07:27:22 +00:00
|
|
|
def write_plugin(cm_fh, scope, *, indent: int = 0) -> str:
|
2020-01-22 13:22:19 +00:00
|
|
|
extra = []
|
2020-01-27 14:15:00 +00:00
|
|
|
is_qml_plugin = any("qml_plugin" == s for s in scope.get("_LOADED"))
|
2020-01-22 13:22:19 +00:00
|
|
|
qmake_target_name = scope.TARGET
|
|
|
|
|
|
|
|
# Forward the original Qt5 plugin target name, to correctly name the
|
|
|
|
# final library file name, and also for .prl generation.
|
2020-01-27 14:15:00 +00:00
|
|
|
if qmake_target_name and not is_qml_plugin:
|
2020-01-22 13:22:19 +00:00
|
|
|
extra.append(f"OUTPUT_NAME {qmake_target_name}")
|
|
|
|
|
|
|
|
# In Qt 6 CMake, the CMake target name for a plugin should be the
|
|
|
|
# same as it is in Qt5. qmake in Qt 5 derived the CMake target name
|
|
|
|
# from the "plugin class name", so use that.
|
|
|
|
# If the class name isn't empty, use that as the target name.
|
|
|
|
# Otherwise use the of value qmake TARGET
|
|
|
|
plugin_class_name = scope.get_string("PLUGIN_CLASS_NAME")
|
|
|
|
if plugin_class_name:
|
|
|
|
plugin_name = plugin_class_name
|
|
|
|
else:
|
|
|
|
plugin_name = qmake_target_name
|
2018-10-24 13:20:27 +00:00
|
|
|
assert plugin_name
|
|
|
|
|
2020-01-22 13:22:19 +00:00
|
|
|
# If the target name is derived from the class name, no need to
|
|
|
|
# forward the class name.
|
|
|
|
if plugin_class_name and plugin_class_name != plugin_name:
|
|
|
|
extra.append(f"CLASS_NAME {plugin_class_name}")
|
2019-05-03 14:03:15 +00:00
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
qmldir = None
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
plugin_type = scope.get_string("PLUGIN_TYPE")
|
2019-11-13 13:03:20 +00:00
|
|
|
plugin_function_name = get_cmake_api_call("qt_add_plugin")
|
2019-05-03 14:03:15 +00:00
|
|
|
if plugin_type:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra.append(f"TYPE {plugin_type}")
|
2019-06-05 11:39:41 +00:00
|
|
|
elif is_qml_plugin:
|
2019-11-13 13:03:20 +00:00
|
|
|
plugin_function_name = get_cmake_api_call("qt_add_qml_module")
|
2019-09-03 12:32:43 +00:00
|
|
|
qmldir = write_qml_plugin(cm_fh, plugin_name, scope, indent=indent, extra_lines=extra)
|
2019-10-10 12:21:02 +00:00
|
|
|
else:
|
2019-10-10 14:32:19 +00:00
|
|
|
target_path = scope.expandString("target.path")
|
2019-10-10 12:21:02 +00:00
|
|
|
target_path = replace_path_constants(target_path, scope)
|
|
|
|
if target_path:
|
|
|
|
extra.append(f'INSTALL_DIRECTORY "{target_path}"')
|
2019-10-10 15:02:59 +00:00
|
|
|
else:
|
2019-10-14 09:12:47 +00:00
|
|
|
extra.append("SKIP_INSTALL")
|
2020-11-10 20:35:19 +00:00
|
|
|
|
|
|
|
past_major_versions = scope.expandString("QML_PAST_MAJOR_VERSIONS")
|
|
|
|
if past_major_versions:
|
|
|
|
extra.append(f"PAST_MAJOR_VERSIONS {past_major_versions}")
|
|
|
|
|
2019-12-04 10:09:33 +00:00
|
|
|
if "qmltypes" in scope.get("CONFIG"):
|
|
|
|
extra.append("GENERATE_QMLTYPES")
|
2019-05-03 14:03:15 +00:00
|
|
|
|
2020-10-08 12:19:36 +00:00
|
|
|
if "install_qmltypes" in scope.get("CONFIG"):
|
|
|
|
extra.append("INSTALL_QMLTYPES")
|
|
|
|
|
2019-10-10 14:32:19 +00:00
|
|
|
if "static" in scope.get("CONFIG"):
|
|
|
|
extra.append("STATIC")
|
2019-10-10 13:28:12 +00:00
|
|
|
|
2020-11-06 16:18:18 +00:00
|
|
|
plugin_extends = scope.get_string("PLUGIN_EXTENDS")
|
|
|
|
if plugin_type != "platform" and plugin_extends == "-":
|
|
|
|
extra.append("DEFAULT_IF FALSE")
|
|
|
|
|
2020-05-12 11:22:49 +00:00
|
|
|
forward_target_info(scope, extra)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
plugin_name,
|
|
|
|
"Plugin",
|
|
|
|
plugin_function_name,
|
|
|
|
scope,
|
|
|
|
indent=indent,
|
|
|
|
extra_lines=extra,
|
|
|
|
known_libraries={},
|
|
|
|
extra_keys=[],
|
|
|
|
)
|
2019-09-03 12:32:43 +00:00
|
|
|
|
|
|
|
if qmldir:
|
|
|
|
write_qml_plugin_epilogue(cm_fh, plugin_name, scope, qmldir, indent)
|
|
|
|
|
2019-09-18 07:27:22 +00:00
|
|
|
return plugin_name
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-08-01 13:43:36 +00:00
|
|
|
|
2020-03-06 09:29:30 +00:00
|
|
|
def get_qml_import_version(scope: Scope, target: str) -> str:
|
|
|
|
import_version = scope.get_string("IMPORT_VERSION")
|
|
|
|
if not import_version:
|
|
|
|
import_version = scope.get_string("QML_IMPORT_VERSION")
|
|
|
|
if not import_version:
|
|
|
|
import_major_version = scope.get_string("QML_IMPORT_MAJOR_VERSION")
|
|
|
|
import_minor_version = scope.get_string("QML_IMPORT_MINOR_VERSION")
|
|
|
|
|
|
|
|
if not import_major_version and not import_minor_version:
|
|
|
|
raise RuntimeError(f"No QML_IMPORT_VERSION info found for target {target}.")
|
|
|
|
|
|
|
|
if not import_minor_version:
|
|
|
|
import_minor_version = str(0)
|
|
|
|
import_version = f"{import_major_version}.{import_minor_version}"
|
|
|
|
|
|
|
|
if import_version:
|
|
|
|
replacements = [
|
2021-04-15 10:12:45 +00:00
|
|
|
("$$QT_MINOR_VERSION", "${PROJECT_VERSION_MINOR}"),
|
|
|
|
("$$QT_VERSION", "${PROJECT_VERSION}"),
|
2020-03-06 09:29:30 +00:00
|
|
|
]
|
|
|
|
for needle, replacement in replacements:
|
|
|
|
import_version = import_version.replace(needle, replacement)
|
|
|
|
return import_version
|
|
|
|
|
|
|
|
|
2022-02-28 20:03:13 +00:00
|
|
|
def write_qml_module(
|
|
|
|
cm_fh: IO[str],
|
|
|
|
target: str,
|
|
|
|
scope: Scope,
|
|
|
|
scopes: List[Scope],
|
|
|
|
resource: QtResource,
|
|
|
|
extra_add_qml_module_args: List[str] = [],
|
|
|
|
indent: int = 0,
|
|
|
|
):
|
|
|
|
uri = scope.get_string("QML_IMPORT_NAME")
|
|
|
|
if not uri:
|
|
|
|
uri = target
|
|
|
|
|
|
|
|
try:
|
|
|
|
version = get_qml_import_version(scope, target)
|
|
|
|
except RuntimeError:
|
|
|
|
version = "${PROJECT_VERSION}"
|
|
|
|
|
|
|
|
dest_dir = scope.expandString("DESTDIR")
|
|
|
|
if dest_dir:
|
|
|
|
dest_dir = f"${{CMAKE_CURRENT_BINARY_DIR}}/{dest_dir}"
|
|
|
|
|
|
|
|
content = ""
|
|
|
|
|
|
|
|
qml_dir = None
|
|
|
|
qml_dir_dynamic_imports = False
|
|
|
|
|
|
|
|
qmldir_file_path_list = scope.get_files("qmldir.files")
|
|
|
|
assert len(qmldir_file_path_list) < 2, "File path must only contain one path"
|
|
|
|
qmldir_file_path = qmldir_file_path_list[0] if qmldir_file_path_list else "qmldir"
|
|
|
|
qmldir_file_path = os.path.join(os.getcwd(), qmldir_file_path[0])
|
|
|
|
|
|
|
|
dynamic_qmldir = scope.get("DYNAMIC_QMLDIR")
|
|
|
|
if os.path.exists(qmldir_file_path):
|
|
|
|
qml_dir = QmlDir()
|
|
|
|
qml_dir.from_file(qmldir_file_path)
|
|
|
|
elif dynamic_qmldir:
|
|
|
|
qml_dir = QmlDir()
|
|
|
|
qml_dir.from_lines(dynamic_qmldir)
|
|
|
|
qml_dir_dynamic_imports = True
|
|
|
|
|
|
|
|
content += "set(module_dynamic_qml_imports\n "
|
|
|
|
if len(qml_dir.imports) != 0:
|
|
|
|
content += "\n ".join(qml_dir.imports)
|
|
|
|
content += "\n)\n\n"
|
|
|
|
|
|
|
|
for sc in scopes[1:]:
|
|
|
|
import_list = []
|
|
|
|
qml_imports = sc.get("DYNAMIC_QMLDIR")
|
|
|
|
for qml_import in qml_imports:
|
|
|
|
if not qml_import.startswith("import "):
|
|
|
|
raise RuntimeError(
|
|
|
|
"Only qmldir import statements expected in conditional scope!"
|
|
|
|
)
|
|
|
|
import_list.append(qml_import[len("import ") :].replace(" ", "/"))
|
|
|
|
if len(import_list) == 0:
|
|
|
|
continue
|
|
|
|
|
|
|
|
assert sc.condition
|
|
|
|
|
|
|
|
content += f"if ({sc.condition})\n"
|
|
|
|
content += " list(APPEND module_dynamic_qml_imports\n "
|
|
|
|
content += "\n ".join(import_list)
|
|
|
|
content += "\n )\nendif()\n\n"
|
|
|
|
|
|
|
|
content += dedent(
|
|
|
|
f"""\
|
|
|
|
qt_add_qml_module({target}
|
|
|
|
URI {uri}
|
|
|
|
VERSION {version}
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
if resource is not None:
|
|
|
|
qml_files = list(filter(is_qtquick_source_file, resource.files.keys()))
|
|
|
|
if qml_files:
|
|
|
|
content += " QML_FILES\n"
|
|
|
|
for file in qml_files:
|
|
|
|
content += f" {file}\n"
|
|
|
|
other_files = list(itertools.filterfalse(is_qtquick_source_file, resource.files.keys()))
|
|
|
|
if other_files:
|
|
|
|
content += " RESOURCES\n"
|
|
|
|
for file in other_files:
|
|
|
|
content += f" {file}\n"
|
|
|
|
if resource.prefix != "/":
|
|
|
|
content += f" RESOURCE_PREFIX {resource.prefix}\n"
|
|
|
|
if scope.TEMPLATE == "app":
|
|
|
|
content += " NO_RESOURCE_TARGET_PATH\n"
|
|
|
|
if dest_dir:
|
|
|
|
content += f" OUTPUT_DIRECTORY {dest_dir}\n"
|
|
|
|
|
|
|
|
if qml_dir is not None:
|
|
|
|
if qml_dir.designer_supported:
|
|
|
|
content += " DESIGNER_SUPPORTED\n"
|
|
|
|
if len(qml_dir.classname) != 0:
|
|
|
|
content += f" CLASSNAME {qml_dir.classname}\n"
|
|
|
|
if len(qml_dir.depends) != 0:
|
|
|
|
content += " DEPENDENCIES\n"
|
|
|
|
for dep in qml_dir.depends:
|
|
|
|
content += f" {dep[0]}/{dep[1]}\n"
|
|
|
|
if len(qml_dir.type_names) == 0:
|
|
|
|
content += " SKIP_TYPE_REGISTRATION\n"
|
|
|
|
if len(qml_dir.imports) != 0 and not qml_dir_dynamic_imports:
|
|
|
|
qml_dir_imports_line = " \n".join(qml_dir.imports)
|
|
|
|
content += f" IMPORTS\n{qml_dir_imports_line}"
|
|
|
|
if qml_dir_dynamic_imports:
|
|
|
|
content += " IMPORTS ${module_dynamic_qml_imports}\n"
|
|
|
|
if len(qml_dir.optional_imports) != 0:
|
|
|
|
qml_dir_optional_imports_line = " \n".join(qml_dir.optional_imports)
|
|
|
|
content += f" OPTIONAL_IMPORTS\n{qml_dir_optional_imports_line}"
|
|
|
|
if qml_dir.plugin_optional:
|
|
|
|
content += " PLUGIN_OPTIONAL\n"
|
|
|
|
|
|
|
|
for arg in extra_add_qml_module_args:
|
|
|
|
content += " "
|
|
|
|
content += arg
|
|
|
|
content += "\n"
|
2022-03-04 11:00:15 +00:00
|
|
|
content += ")\n"
|
2022-02-28 20:03:13 +00:00
|
|
|
|
|
|
|
if resource:
|
|
|
|
content += write_resource_source_file_properties(
|
|
|
|
sorted(resource.files.keys()),
|
|
|
|
resource.files,
|
|
|
|
resource.base_dir,
|
|
|
|
resource.skip_qtquick_compiler,
|
|
|
|
)
|
|
|
|
|
|
|
|
content += "\n"
|
|
|
|
cm_fh.write(content)
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def write_qml_plugin(
|
|
|
|
cm_fh: IO[str],
|
|
|
|
target: str,
|
|
|
|
scope: Scope,
|
|
|
|
*,
|
2019-09-21 18:30:08 +00:00
|
|
|
extra_lines: Optional[List[str]] = None,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
indent: int = 0,
|
2019-09-21 18:18:10 +00:00
|
|
|
**kwargs: Any,
|
|
|
|
) -> Optional[QmlDir]:
|
2019-06-05 11:39:41 +00:00
|
|
|
# Collect other args if available
|
2019-09-21 18:30:08 +00:00
|
|
|
if extra_lines is None:
|
|
|
|
extra_lines = []
|
2019-07-18 07:38:37 +00:00
|
|
|
indent += 2
|
2019-07-25 14:45:11 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
target_path = scope.get_string("TARGETPATH")
|
2019-07-18 07:38:37 +00:00
|
|
|
if target_path:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
uri = target_path.replace("/", ".")
|
|
|
|
import_name = scope.get_string("IMPORT_NAME")
|
2019-08-01 13:43:36 +00:00
|
|
|
# Catch special cases such as foo.QtQuick.2.bar, which when converted
|
|
|
|
# into a target path via cmake will result in foo/QtQuick/2/bar, which is
|
|
|
|
# not what we want. So we supply the target path override.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
target_path_from_uri = uri.replace(".", "/")
|
2019-08-01 13:43:36 +00:00
|
|
|
if target_path != target_path_from_uri:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra_lines.append(f'TARGET_PATH "{target_path}"')
|
2019-08-06 12:06:47 +00:00
|
|
|
if import_name:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra_lines.append(f'URI "{import_name}"')
|
2019-08-06 12:06:47 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
uri = re.sub("\\.\\d+", "", uri)
|
|
|
|
extra_lines.append(f'URI "{uri}"')
|
2019-08-01 13:43:36 +00:00
|
|
|
|
2020-03-06 09:29:30 +00:00
|
|
|
import_version = get_qml_import_version(scope, target)
|
2019-06-05 11:39:41 +00:00
|
|
|
if import_version:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra_lines.append(f'VERSION "{import_version}"')
|
2019-08-01 13:43:36 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
plugindump_dep = scope.get_string("QML_PLUGINDUMP_DEPENDENCIES")
|
2019-08-01 13:43:36 +00:00
|
|
|
|
2019-06-05 11:39:41 +00:00
|
|
|
if plugindump_dep:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
extra_lines.append(f'QML_PLUGINDUMP_DEPENDENCIES "{plugindump_dep}"')
|
2019-06-05 11:39:41 +00:00
|
|
|
|
2019-11-22 12:01:45 +00:00
|
|
|
qml_dir = None
|
2019-09-03 12:32:43 +00:00
|
|
|
qmldir_file_path = os.path.join(os.getcwd(), "qmldir")
|
2019-11-22 12:01:45 +00:00
|
|
|
qml_dir_dynamic_imports = False
|
2019-09-03 12:32:43 +00:00
|
|
|
if os.path.exists(qmldir_file_path):
|
|
|
|
qml_dir = QmlDir()
|
|
|
|
qml_dir.from_file(qmldir_file_path)
|
2019-11-22 12:01:45 +00:00
|
|
|
else:
|
|
|
|
dynamic_qmldir = scope.get("DYNAMIC_QMLDIR")
|
|
|
|
if not dynamic_qmldir:
|
|
|
|
return None
|
|
|
|
qml_dir = QmlDir()
|
|
|
|
qml_dir.from_lines(dynamic_qmldir)
|
|
|
|
qml_dir_dynamic_imports = True
|
|
|
|
|
|
|
|
# Check scopes for conditional entries
|
|
|
|
scopes = flatten_scopes(scope)
|
|
|
|
cm_fh.write("set(module_dynamic_qml_imports\n ")
|
|
|
|
if len(qml_dir.imports) != 0:
|
|
|
|
cm_fh.write("\n ".join(qml_dir.imports))
|
|
|
|
cm_fh.write("\n)\n\n")
|
|
|
|
|
|
|
|
for sc in scopes[1:]:
|
|
|
|
import_list = []
|
|
|
|
qml_imports = sc.get("DYNAMIC_QMLDIR")
|
|
|
|
for qml_import in qml_imports:
|
|
|
|
if not qml_import.startswith("import "):
|
|
|
|
raise RuntimeError(
|
|
|
|
"Only qmldir import statements expected in conditional scope!"
|
|
|
|
)
|
2020-06-23 16:21:24 +00:00
|
|
|
import_list.append(qml_import[len("import ") :].replace(" ", "/"))
|
2019-11-22 12:01:45 +00:00
|
|
|
if len(import_list) == 0:
|
|
|
|
continue
|
|
|
|
|
|
|
|
assert sc.condition
|
|
|
|
|
|
|
|
cm_fh.write(f"if ({sc.condition})\n")
|
2022-02-24 10:31:10 +00:00
|
|
|
cm_fh.write(" list(APPEND module_dynamic_qml_imports\n ")
|
2019-11-22 12:01:45 +00:00
|
|
|
cm_fh.write("\n ".join(import_list))
|
2022-02-24 10:31:10 +00:00
|
|
|
cm_fh.write("\n )\nendif()\n\n")
|
2019-11-22 12:01:45 +00:00
|
|
|
|
2020-01-29 14:36:21 +00:00
|
|
|
if qml_dir is not None:
|
2019-09-03 12:32:43 +00:00
|
|
|
if qml_dir.designer_supported:
|
|
|
|
extra_lines.append("DESIGNER_SUPPORTED")
|
|
|
|
if len(qml_dir.classname) != 0:
|
|
|
|
extra_lines.append(f"CLASSNAME {qml_dir.classname}")
|
|
|
|
if len(qml_dir.depends) != 0:
|
|
|
|
extra_lines.append("DEPENDENCIES")
|
|
|
|
for dep in qml_dir.depends:
|
|
|
|
extra_lines.append(f" {dep[0]}/{dep[1]}")
|
2019-09-24 09:39:26 +00:00
|
|
|
if len(qml_dir.type_names) == 0:
|
|
|
|
extra_lines.append("SKIP_TYPE_REGISTRATION")
|
2019-11-22 12:01:45 +00:00
|
|
|
if len(qml_dir.imports) != 0 and not qml_dir_dynamic_imports:
|
|
|
|
qml_dir_imports_line = "\n ".join(qml_dir.imports)
|
|
|
|
extra_lines.append("IMPORTS\n " f"{qml_dir_imports_line}")
|
|
|
|
if qml_dir_dynamic_imports:
|
|
|
|
extra_lines.append("IMPORTS ${module_dynamic_qml_imports}")
|
2020-10-06 14:05:01 +00:00
|
|
|
if len(qml_dir.optional_imports):
|
|
|
|
qml_dir_optional_imports_line = "\n ".join(qml_dir.optional_imports)
|
|
|
|
extra_lines.append("OPTIONAL_IMPORTS\n " f"{qml_dir_optional_imports_line}")
|
2020-06-03 17:59:04 +00:00
|
|
|
if qml_dir.plugin_optional:
|
|
|
|
extra_lines.append("PLUGIN_OPTIONAL")
|
2019-09-03 12:32:43 +00:00
|
|
|
|
2019-11-22 12:01:45 +00:00
|
|
|
return qml_dir
|
2019-09-03 12:32:43 +00:00
|
|
|
|
2019-08-01 13:43:36 +00:00
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
def write_qml_plugin_epilogue(
|
2019-09-21 18:18:10 +00:00
|
|
|
cm_fh: IO[str], target: str, scope: Scope, qmldir: QmlDir, indent: int = 0
|
2019-09-03 12:32:43 +00:00
|
|
|
):
|
2019-08-01 13:43:36 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
qml_files = scope.get_files("QML_FILES", use_vpath=True)
|
2019-06-05 11:39:41 +00:00
|
|
|
if qml_files:
|
2019-08-12 12:05:05 +00:00
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
indent_0 = spaces(indent)
|
|
|
|
indent_1 = spaces(indent + 1)
|
2019-08-12 12:05:05 +00:00
|
|
|
# Quote file paths in case there are spaces.
|
2019-09-20 09:34:16 +00:00
|
|
|
qml_files_quoted = [f'"{qf}"' for qf in qml_files]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
2019-09-20 09:34:16 +00:00
|
|
|
indented_qml_files = f"\n{indent_1}".join(qml_files_quoted)
|
|
|
|
cm_fh.write(f"\n{indent_0}set(qml_files\n{indent_1}" f"{indented_qml_files}\n)\n")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
for qml_file in qml_files:
|
|
|
|
if qml_file in qmldir.type_names:
|
|
|
|
qmldir_file_info = qmldir.type_names[qml_file]
|
2019-09-20 09:34:16 +00:00
|
|
|
cm_fh.write(f"{indent_0}set_source_files_properties({qml_file} PROPERTIES\n")
|
2020-08-20 15:55:03 +00:00
|
|
|
cm_fh.write(f'{indent_1}QT_QML_SOURCE_VERSION "{qmldir_file_info.versions}"\n')
|
2019-09-03 12:32:43 +00:00
|
|
|
# Only write typename if they are different, CMake will infer
|
|
|
|
# the name by default
|
|
|
|
if (
|
|
|
|
os.path.splitext(os.path.basename(qmldir_file_info.path))[0]
|
|
|
|
!= qmldir_file_info.type_name
|
|
|
|
):
|
2019-09-20 09:34:16 +00:00
|
|
|
cm_fh.write(f"{indent_1}QT_QML_SOURCE_TYPENAME {qmldir_file_info.type_name}\n")
|
2019-09-03 12:32:43 +00:00
|
|
|
if qmldir_file_info.singleton:
|
2019-09-20 09:34:16 +00:00
|
|
|
cm_fh.write(f"{indent_1}QT_QML_SINGLETON_TYPE TRUE\n")
|
2019-09-03 12:32:43 +00:00
|
|
|
if qmldir_file_info.internal:
|
2019-09-20 09:34:16 +00:00
|
|
|
cm_fh.write(f"{indent_1}QT_QML_INTERNAL_TYPE TRUE\n")
|
|
|
|
cm_fh.write(f"{indent_0})\n")
|
2020-03-16 15:29:17 +00:00
|
|
|
else:
|
|
|
|
cm_fh.write(
|
|
|
|
f"{indent_0}set_source_files_properties({qml_file} PROPERTIES\n"
|
|
|
|
f"{indent_1}QT_QML_SKIP_QMLDIR_ENTRY TRUE\n"
|
2020-04-06 07:42:01 +00:00
|
|
|
f"{indent_0})\n"
|
|
|
|
)
|
2019-09-03 12:32:43 +00:00
|
|
|
|
|
|
|
cm_fh.write(
|
2019-09-20 09:34:16 +00:00
|
|
|
f"\n{indent_0}qt6_target_qml_files({target}\n{indent_1}FILES\n"
|
|
|
|
f"{spaces(indent+2)}${{qml_files}}\n)\n"
|
2019-09-03 12:32:43 +00:00
|
|
|
)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
def handle_app_or_lib(
|
2022-03-04 14:49:02 +00:00
|
|
|
scope: Scope,
|
|
|
|
cm_fh: IO[str],
|
|
|
|
*,
|
|
|
|
indent: int = 0,
|
|
|
|
is_example: bool = False,
|
|
|
|
is_user_project=False,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> None:
|
|
|
|
assert scope.TEMPLATE in ("app", "lib")
|
|
|
|
|
|
|
|
config = scope.get("CONFIG")
|
2019-10-18 12:28:08 +00:00
|
|
|
is_jar = "java" in config
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
is_lib = scope.TEMPLATE == "lib"
|
|
|
|
is_qml_plugin = any("qml_plugin" == s for s in scope.get("_LOADED"))
|
2019-10-23 12:45:20 +00:00
|
|
|
is_plugin = "plugin" in config
|
2019-10-29 08:57:19 +00:00
|
|
|
is_qt_plugin = any("qt_plugin" == s for s in scope.get("_LOADED")) or is_qml_plugin
|
2019-09-18 07:27:22 +00:00
|
|
|
target = ""
|
2020-04-27 13:04:57 +00:00
|
|
|
target_ref = None
|
2020-03-19 11:42:04 +00:00
|
|
|
gui = all(val not in config for val in ["console", "cmdline", "-app_bundle"]) and all(
|
|
|
|
val not in scope.expand("QT") for val in ["testlib", "testlib-private"]
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-10-18 12:28:08 +00:00
|
|
|
if is_jar:
|
2019-11-11 18:03:36 +00:00
|
|
|
write_jar(cm_fh, scope, indent=indent)
|
2020-02-11 14:38:47 +00:00
|
|
|
elif "qt_helper_lib" in scope.get("_LOADED"):
|
|
|
|
assert not is_example
|
|
|
|
target = write_3rdparty_library(cm_fh, scope, indent=indent)
|
2019-10-18 12:28:08 +00:00
|
|
|
elif is_example:
|
2022-03-04 14:49:02 +00:00
|
|
|
target = write_example(
|
|
|
|
cm_fh, scope, gui, indent=indent, is_plugin=is_plugin, is_user_project=is_user_project
|
|
|
|
)
|
2019-10-23 12:45:20 +00:00
|
|
|
elif is_qt_plugin:
|
2019-05-07 09:27:33 +00:00
|
|
|
assert not is_example
|
2019-09-18 07:27:22 +00:00
|
|
|
target = write_plugin(cm_fh, scope, indent=indent)
|
2019-10-23 12:45:20 +00:00
|
|
|
elif (is_lib and "qt_module" not in scope.get("_LOADED")) or is_plugin:
|
2019-10-10 13:40:38 +00:00
|
|
|
assert not is_example
|
|
|
|
target = write_generic_library(cm_fh, scope, indent=indent)
|
2019-10-10 14:47:17 +00:00
|
|
|
elif is_lib or "qt_module" in scope.get("_LOADED"):
|
|
|
|
assert not is_example
|
|
|
|
target = write_module(cm_fh, scope, indent=indent)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
elif "qt_tool" in scope.get("_LOADED"):
|
2019-05-07 09:27:33 +00:00
|
|
|
assert not is_example
|
2020-04-27 13:04:57 +00:00
|
|
|
target, target_ref = write_tool(cm_fh, scope, indent=indent)
|
2020-07-27 09:10:48 +00:00
|
|
|
elif "qt_app" in scope.get("_LOADED"):
|
|
|
|
assert not is_example
|
|
|
|
scope._is_internal_qt_app = True
|
|
|
|
target = write_qt_app(cm_fh, scope, indent=indent)
|
2018-10-24 13:20:27 +00:00
|
|
|
else:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if "testcase" in config or "testlib" in config or "qmltestcase" in config:
|
2019-05-07 09:27:33 +00:00
|
|
|
assert not is_example
|
2019-09-18 07:27:22 +00:00
|
|
|
target = write_test(cm_fh, scope, gui, indent=indent)
|
2018-10-24 13:20:27 +00:00
|
|
|
else:
|
2019-09-03 12:32:43 +00:00
|
|
|
target = write_binary(cm_fh, scope, gui, indent=indent)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2020-04-27 13:04:57 +00:00
|
|
|
if target_ref is None:
|
|
|
|
target_ref = target
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
# ind = spaces(indent)
|
2019-11-13 13:03:20 +00:00
|
|
|
cmake_api_call = get_cmake_api_call("qt_add_docs")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
write_source_file_list(
|
2019-11-13 13:03:20 +00:00
|
|
|
cm_fh,
|
|
|
|
scope,
|
|
|
|
"",
|
|
|
|
["QMAKE_DOCS"],
|
|
|
|
indent,
|
2020-04-27 13:04:57 +00:00
|
|
|
header=f"{cmake_api_call}({target_ref}\n",
|
2019-11-13 13:03:20 +00:00
|
|
|
footer=")\n",
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-12-04 10:09:33 +00:00
|
|
|
# Generate qmltypes instruction for anything that may have CONFIG += qmltypes
|
|
|
|
# that is not a qml plugin
|
2022-02-28 20:03:13 +00:00
|
|
|
if (
|
|
|
|
not is_example
|
|
|
|
and "qmltypes" in scope.get("CONFIG")
|
|
|
|
and "qml_plugin" not in scope.get("_LOADED")
|
|
|
|
):
|
2020-04-27 13:04:57 +00:00
|
|
|
cm_fh.write(f"\n{spaces(indent)}set_target_properties({target_ref} PROPERTIES\n")
|
2020-05-28 14:29:17 +00:00
|
|
|
|
|
|
|
install_dir = scope.expandString("QMLTYPES_INSTALL_DIR")
|
|
|
|
if install_dir:
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_INSTALL_QMLTYPES TRUE\n")
|
2020-01-24 13:04:15 +00:00
|
|
|
|
2020-03-06 09:29:30 +00:00
|
|
|
import_version = get_qml_import_version(scope, target)
|
2020-01-24 13:04:15 +00:00
|
|
|
if import_version:
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_VERSION {import_version}\n")
|
2019-12-04 10:09:33 +00:00
|
|
|
|
2020-11-05 12:29:19 +00:00
|
|
|
past_major_versions = scope.expandString("QML_PAST_MAJOR_VERSIONS")
|
|
|
|
if past_major_versions:
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}QT_QML_PAST_MAJOR_VERSIONS {past_major_versions}\n")
|
|
|
|
|
2020-01-24 13:04:15 +00:00
|
|
|
import_name = scope.expandString("QML_IMPORT_NAME")
|
|
|
|
if import_name:
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_URI {import_name}\n")
|
2019-12-04 10:09:33 +00:00
|
|
|
|
2020-04-29 14:18:57 +00:00
|
|
|
json_output_filename = scope.expandString("QMLTYPES_FILENAME")
|
|
|
|
if json_output_filename:
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}QT_QMLTYPES_FILENAME {json_output_filename}\n")
|
|
|
|
|
2020-01-24 13:04:15 +00:00
|
|
|
target_path = scope.get("TARGETPATH")
|
|
|
|
if target_path:
|
|
|
|
cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_TARGET_PATH {target_path}\n")
|
2019-12-04 10:09:33 +00:00
|
|
|
|
2020-01-24 13:04:15 +00:00
|
|
|
if install_dir:
|
2020-02-06 14:58:09 +00:00
|
|
|
install_dir = install_dir.replace("$$[QT_INSTALL_QML]", "${INSTALL_QMLDIR}")
|
2020-01-24 13:04:15 +00:00
|
|
|
cm_fh.write(f'{spaces(indent+1)}QT_QML_MODULE_INSTALL_DIR "{install_dir}"\n')
|
2019-12-04 10:09:33 +00:00
|
|
|
|
2020-01-24 13:04:15 +00:00
|
|
|
cm_fh.write(f"{spaces(indent)})\n\n")
|
2020-04-27 13:04:57 +00:00
|
|
|
cm_fh.write(f"qt6_qml_type_registration({target_ref})\n")
|
2019-12-04 10:09:33 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def handle_top_level_repo_project(scope: Scope, cm_fh: IO[str]):
|
2019-09-09 08:52:27 +00:00
|
|
|
# qtdeclarative
|
|
|
|
project_file_name = os.path.splitext(os.path.basename(scope.file_absolute_path))[0]
|
|
|
|
|
|
|
|
# declarative
|
|
|
|
file_name_without_qt_prefix = project_file_name[2:]
|
|
|
|
|
|
|
|
# Qt::Declarative
|
|
|
|
qt_lib = map_qt_library(file_name_without_qt_prefix)
|
|
|
|
|
|
|
|
# Found a mapping, adjust name.
|
|
|
|
if qt_lib != file_name_without_qt_prefix:
|
|
|
|
# QtDeclarative
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
qt_lib = re.sub(r":", r"", qt_lib)
|
2019-09-09 08:52:27 +00:00
|
|
|
|
|
|
|
# Declarative
|
|
|
|
qt_lib_no_prefix = qt_lib[2:]
|
|
|
|
else:
|
|
|
|
qt_lib += "_FIXME"
|
|
|
|
qt_lib_no_prefix = qt_lib
|
|
|
|
|
2019-09-20 11:43:26 +00:00
|
|
|
header = dedent(
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
f"""\
|
|
|
|
cmake_minimum_required(VERSION {cmake_version_string})
|
2019-09-09 08:52:27 +00:00
|
|
|
|
2020-04-28 15:46:21 +00:00
|
|
|
include(.cmake.conf)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
project({qt_lib}
|
2020-04-28 15:46:21 +00:00
|
|
|
VERSION "${{QT_REPO_MODULE_VERSION}}"
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
DESCRIPTION "Qt {qt_lib_no_prefix} Libraries"
|
|
|
|
HOMEPAGE_URL "https://qt.io/"
|
|
|
|
LANGUAGES CXX C
|
|
|
|
)
|
2019-09-09 08:52:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
find_package(Qt6 ${{PROJECT_VERSION}} CONFIG REQUIRED COMPONENTS BuildInternals Core SET_ME_TO_SOMETHING_USEFUL)
|
|
|
|
find_package(Qt6 ${{PROJECT_VERSION}} CONFIG OPTIONAL_COMPONENTS SET_ME_TO_SOMETHING_USEFUL)
|
2019-09-20 11:43:26 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
build_repo = dedent(
|
2022-02-24 10:31:10 +00:00
|
|
|
"""\
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
qt_build_repo()
|
|
|
|
"""
|
|
|
|
)
|
2019-09-09 08:52:27 +00:00
|
|
|
|
2019-09-20 11:43:26 +00:00
|
|
|
cm_fh.write(f"{header}{expand_project_requirements(scope)}{build_repo}")
|
2019-09-09 08:52:27 +00:00
|
|
|
|
|
|
|
|
2020-04-28 15:46:21 +00:00
|
|
|
def create_top_level_cmake_conf():
|
|
|
|
conf_file_name = ".cmake.conf"
|
|
|
|
try:
|
2020-07-30 13:50:22 +00:00
|
|
|
with open(conf_file_name, "x") as file:
|
2022-01-28 05:58:37 +00:00
|
|
|
file.write('set(QT_REPO_MODULE_VERSION "6.4.0")\n')
|
2020-07-30 13:56:37 +00:00
|
|
|
except FileExistsError:
|
2020-04-28 15:46:21 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def find_top_level_repo_project_file(project_file_path: str = "") -> Optional[str]:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_dir = os.path.dirname(qmake_or_cmake_conf_path)
|
2019-09-09 08:52:27 +00:00
|
|
|
|
|
|
|
# Hope to a programming god that there's only one .pro file at the
|
|
|
|
# top level directory of repository.
|
2021-09-22 15:34:00 +00:00
|
|
|
glob_result = glob.glob(os.path.join(qmake_or_cmake_dir, "*.pro"))
|
2019-09-09 08:52:27 +00:00
|
|
|
if len(glob_result) > 0:
|
|
|
|
return glob_result[0]
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def handle_top_level_repo_tests_project(scope: Scope, cm_fh: IO[str]):
|
2019-09-22 16:28:01 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
content = dedent(
|
2022-02-24 10:31:10 +00:00
|
|
|
"""\
|
2019-11-01 10:48:23 +00:00
|
|
|
if(QT_BUILD_STANDALONE_TESTS)
|
|
|
|
# Add qt_find_package calls for extra dependencies that need to be found when building
|
|
|
|
# the standalone tests here.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
endif()
|
2019-09-22 16:28:01 +00:00
|
|
|
qt_build_tests()
|
|
|
|
"""
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2019-09-09 08:52:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"{content}")
|
2019-09-09 08:52:27 +00:00
|
|
|
|
|
|
|
|
2019-09-21 18:09:36 +00:00
|
|
|
def write_regular_cmake_target_scope_section(
|
|
|
|
scope: Scope, cm_fh: IO[str], indent: int = 0, skip_sources: bool = False
|
|
|
|
):
|
2019-09-21 16:02:54 +00:00
|
|
|
if not skip_sources:
|
|
|
|
target_sources = "target_sources(${PROJECT_NAME} PUBLIC"
|
|
|
|
write_all_source_file_lists(cm_fh, scope, target_sources, indent=indent, footer=")")
|
|
|
|
|
|
|
|
write_include_paths(
|
2019-09-21 18:09:36 +00:00
|
|
|
cm_fh,
|
|
|
|
scope,
|
2022-02-24 10:31:10 +00:00
|
|
|
"target_include_directories(${{PROJECT_NAME}} PUBLIC",
|
2019-09-21 18:09:36 +00:00
|
|
|
indent=indent,
|
|
|
|
footer=")",
|
2019-09-21 16:02:54 +00:00
|
|
|
)
|
|
|
|
write_defines(
|
2019-09-21 18:09:36 +00:00
|
|
|
cm_fh,
|
|
|
|
scope,
|
2022-02-24 10:31:10 +00:00
|
|
|
"target_compile_definitions(${{PROJECT_NAME}} PUBLIC",
|
2019-09-21 18:09:36 +00:00
|
|
|
indent=indent,
|
|
|
|
footer=")",
|
2019-09-21 16:02:54 +00:00
|
|
|
)
|
|
|
|
(public_libs, private_libs) = extract_cmake_libraries(scope)
|
|
|
|
write_list(
|
|
|
|
cm_fh,
|
|
|
|
private_libs,
|
|
|
|
"",
|
|
|
|
indent=indent,
|
2022-02-24 10:31:10 +00:00
|
|
|
header="target_link_libraries(${{PROJECT_NAME}} PRIVATE\n",
|
2019-09-21 16:02:54 +00:00
|
|
|
footer=")",
|
|
|
|
)
|
|
|
|
write_list(
|
|
|
|
cm_fh,
|
|
|
|
public_libs,
|
|
|
|
"",
|
|
|
|
indent=indent,
|
2022-02-24 10:31:10 +00:00
|
|
|
header="target_link_libraries(${{PROJECT_NAME}} PUBLIC\n",
|
2019-09-21 16:02:54 +00:00
|
|
|
footer=")",
|
|
|
|
)
|
|
|
|
write_compile_options(
|
2022-02-24 10:31:10 +00:00
|
|
|
cm_fh, scope, "target_compile_options(${{PROJECT_NAME}}", indent=indent, footer=")"
|
2019-09-21 16:02:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def handle_config_test_project(scope: Scope, cm_fh: IO[str]):
|
|
|
|
project_name = os.path.splitext(os.path.basename(scope.file_absolute_path))[0]
|
|
|
|
content = (
|
2021-09-22 13:11:47 +00:00
|
|
|
f"cmake_minimum_required(VERSION 3.16)\n"
|
2020-04-02 08:33:04 +00:00
|
|
|
f"project(config_test_{project_name} LANGUAGES C CXX)\n"
|
|
|
|
"""
|
2021-10-05 09:09:07 +00:00
|
|
|
if(DEFINED QT_CONFIG_COMPILE_TEST_CMAKE_SYSTEM_PREFIX_PATH)
|
|
|
|
set(CMAKE_SYSTEM_PREFIX_PATH "${QT_CONFIG_COMPILE_TEST_CMAKE_SYSTEM_PREFIX_PATH}")
|
|
|
|
endif()
|
|
|
|
if(DEFINED QT_CONFIG_COMPILE_TEST_CMAKE_SYSTEM_FRAMEWORK_PATH)
|
|
|
|
set(CMAKE_SYSTEM_FRAMEWORK_PATH "${QT_CONFIG_COMPILE_TEST_CMAKE_SYSTEM_FRAMEWORK_PATH}")
|
|
|
|
endif()
|
|
|
|
|
2020-04-02 08:33:04 +00:00
|
|
|
foreach(p ${QT_CONFIG_COMPILE_TEST_PACKAGES})
|
|
|
|
find_package(${p})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(QT_CONFIG_COMPILE_TEST_LIBRARIES)
|
|
|
|
link_libraries(${QT_CONFIG_COMPILE_TEST_LIBRARIES})
|
|
|
|
endif()
|
2020-04-09 07:59:35 +00:00
|
|
|
if(QT_CONFIG_COMPILE_TEST_LIBRARY_TARGETS)
|
|
|
|
foreach(lib ${QT_CONFIG_COMPILE_TEST_LIBRARY_TARGETS})
|
|
|
|
if(TARGET ${lib})
|
|
|
|
link_libraries(${lib})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2020-04-02 08:33:04 +00:00
|
|
|
"""
|
2019-09-21 16:02:54 +00:00
|
|
|
)
|
|
|
|
cm_fh.write(f"{content}\n")
|
|
|
|
|
|
|
|
# Remove default QT libs.
|
|
|
|
scope._append_operation("QT", RemoveOperation(["core", "gui"]))
|
|
|
|
|
2022-02-24 10:31:10 +00:00
|
|
|
add_target = "add_executable(${{PROJECT_NAME}}"
|
2019-09-21 16:02:54 +00:00
|
|
|
|
|
|
|
temp_buffer = io.StringIO()
|
|
|
|
write_all_source_file_lists(temp_buffer, scope, add_target, indent=0)
|
|
|
|
buffer_value = temp_buffer.getvalue()
|
|
|
|
|
|
|
|
if buffer_value:
|
|
|
|
cm_fh.write(buffer_value)
|
|
|
|
else:
|
|
|
|
cm_fh.write(add_target)
|
|
|
|
cm_fh.write(")\n")
|
|
|
|
|
|
|
|
indent = 0
|
|
|
|
write_regular_cmake_target_scope_section(scope, cm_fh, indent, skip_sources=True)
|
|
|
|
|
|
|
|
recursive_evaluate_scope(scope)
|
|
|
|
scopes = flatten_scopes(scope)
|
|
|
|
scopes = merge_scopes(scopes)
|
|
|
|
|
|
|
|
assert len(scopes)
|
|
|
|
assert scopes[0].total_condition == "ON"
|
|
|
|
|
|
|
|
for c in scopes[1:]:
|
|
|
|
extend_scope_io_string = io.StringIO()
|
2019-09-21 18:09:36 +00:00
|
|
|
write_regular_cmake_target_scope_section(c, extend_scope_io_string, indent=indent + 1)
|
2019-09-21 16:02:54 +00:00
|
|
|
extend_string = extend_scope_io_string.getvalue()
|
|
|
|
|
|
|
|
if extend_string:
|
2019-10-07 10:22:04 +00:00
|
|
|
assert c.total_condition, "Cannot write if with empty condition"
|
2019-09-21 16:02:54 +00:00
|
|
|
extend_scope = (
|
|
|
|
f"\nif({map_to_cmake_condition(c.total_condition)})\n"
|
|
|
|
f"{extend_string}"
|
|
|
|
f"endif()\n"
|
|
|
|
)
|
|
|
|
cm_fh.write(extend_scope)
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
def cmakeify_scope(
|
2022-03-04 14:49:02 +00:00
|
|
|
scope: Scope,
|
|
|
|
cm_fh: IO[str],
|
|
|
|
*,
|
|
|
|
indent: int = 0,
|
|
|
|
is_example: bool = False,
|
|
|
|
is_user_project: bool = False,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) -> None:
|
2019-01-29 09:18:21 +00:00
|
|
|
template = scope.TEMPLATE
|
2019-09-09 08:52:27 +00:00
|
|
|
|
2022-03-04 14:49:02 +00:00
|
|
|
if is_user_project:
|
|
|
|
if template == "subdirs":
|
|
|
|
handle_subdir(scope, cm_fh, indent=indent, is_example=True, is_user_project=True)
|
|
|
|
elif template in ("app", "lib"):
|
|
|
|
handle_app_or_lib(scope, cm_fh, indent=indent, is_example=True, is_user_project=True)
|
2018-10-24 13:20:27 +00:00
|
|
|
else:
|
2022-03-04 14:49:02 +00:00
|
|
|
temp_buffer = io.StringIO()
|
|
|
|
|
|
|
|
# Handle top level repo project in a special way.
|
|
|
|
if is_top_level_repo_project(scope.file_absolute_path):
|
|
|
|
create_top_level_cmake_conf()
|
|
|
|
handle_top_level_repo_project(scope, temp_buffer)
|
|
|
|
# Same for top-level tests.
|
|
|
|
elif is_top_level_repo_tests_project(scope.file_absolute_path):
|
|
|
|
handle_top_level_repo_tests_project(scope, temp_buffer)
|
|
|
|
elif is_config_test_project(scope.file_absolute_path):
|
|
|
|
handle_config_test_project(scope, temp_buffer)
|
|
|
|
elif template == "subdirs":
|
|
|
|
handle_subdir(scope, temp_buffer, indent=indent, is_example=is_example)
|
|
|
|
elif template in ("app", "lib"):
|
|
|
|
handle_app_or_lib(scope, temp_buffer, indent=indent, is_example=is_example)
|
|
|
|
else:
|
|
|
|
print(f" XXXX: {scope.file}: Template type {template} not yet supported.")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2022-03-04 14:49:02 +00:00
|
|
|
buffer_value = temp_buffer.getvalue()
|
2019-09-09 08:52:27 +00:00
|
|
|
|
2022-03-04 14:49:02 +00:00
|
|
|
if is_top_level_repo_examples_project(scope.file_absolute_path):
|
|
|
|
# Wrap top level examples project with some commands which
|
|
|
|
# are necessary to build examples as part of the overall
|
|
|
|
# build.
|
|
|
|
buffer_value = f"qt_examples_build_begin()\n\n{buffer_value}\nqt_examples_build_end()\n"
|
2019-09-09 08:52:27 +00:00
|
|
|
|
2022-03-04 14:49:02 +00:00
|
|
|
cm_fh.write(buffer_value)
|
2019-09-09 08:52:27 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2022-03-04 14:49:02 +00:00
|
|
|
def generate_new_cmakelists(
|
|
|
|
scope: Scope, *, is_example: bool = False, is_user_project: bool = True, debug: bool = False
|
|
|
|
) -> None:
|
2019-11-11 17:47:28 +00:00
|
|
|
if debug:
|
|
|
|
print("Generating CMakeLists.gen.txt")
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
with open(scope.generated_cmake_lists_path, "w") as cm_fh:
|
2019-01-29 09:18:21 +00:00
|
|
|
assert scope.file
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
cm_fh.write(f"# Generated from {os.path.basename(scope.file)}.\n\n")
|
2019-09-09 12:16:26 +00:00
|
|
|
|
|
|
|
is_example_heuristic = is_example_project(scope.file_absolute_path)
|
|
|
|
final_is_example_decision = is_example or is_example_heuristic
|
2022-03-04 14:49:02 +00:00
|
|
|
cmakeify_scope(
|
|
|
|
scope, cm_fh, is_example=final_is_example_decision, is_user_project=is_user_project
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
|
2018-12-21 11:13:38 +00:00
|
|
|
def do_include(scope: Scope, *, debug: bool = False) -> None:
|
2019-01-29 09:18:21 +00:00
|
|
|
for c in scope.children:
|
2019-01-17 16:14:19 +00:00
|
|
|
do_include(c)
|
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
for include_index, include_file in enumerate(scope.get_files("_INCLUDED", is_include=True)):
|
2018-12-21 11:13:38 +00:00
|
|
|
if not include_file:
|
|
|
|
continue
|
2020-03-19 11:47:41 +00:00
|
|
|
# Ignore selfcover.pri as this generates too many incompatible flags
|
|
|
|
# need to be removed with special cases
|
|
|
|
if include_file.endswith("selfcover.pri"):
|
|
|
|
continue
|
2020-03-11 14:34:27 +00:00
|
|
|
if include_file.startswith("${QT_SOURCE_TREE}"):
|
|
|
|
root_source_dir = get_top_level_repo_project_path(scope.file_absolute_path)
|
|
|
|
include_file = include_file.replace("${QT_SOURCE_TREE}", root_source_dir)
|
2018-10-24 13:20:27 +00:00
|
|
|
if not os.path.isfile(include_file):
|
2019-11-11 17:56:47 +00:00
|
|
|
generated_config_pri_pattern = re.compile(r"qt.+?-config\.pri$")
|
|
|
|
match_result = re.search(generated_config_pri_pattern, include_file)
|
|
|
|
if not match_result:
|
|
|
|
print(f" XXXX: Failed to include {include_file}.")
|
2018-10-24 13:20:27 +00:00
|
|
|
continue
|
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
include_op = scope._get_operation_at_index("_INCLUDED", include_index)
|
|
|
|
include_line_no = include_op._line_no
|
|
|
|
|
|
|
|
include_result, project_file_content = parseProFile(include_file, debug=debug)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
include_scope = Scope.FromDict(
|
2019-11-08 14:42:35 +00:00
|
|
|
None,
|
|
|
|
include_file,
|
|
|
|
include_result.asDict().get("statements"),
|
|
|
|
"",
|
|
|
|
scope.basedir,
|
|
|
|
project_file_content=project_file_content,
|
|
|
|
parent_include_line_no=include_line_no,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
) # This scope will be merged into scope!
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
do_include(include_scope)
|
|
|
|
|
|
|
|
scope.merge(include_scope)
|
|
|
|
|
|
|
|
|
2019-11-11 17:47:28 +00:00
|
|
|
def copy_generated_file_to_final_location(
|
2020-04-03 15:38:24 +00:00
|
|
|
scope: Scope, output_file: str, keep_temporary_files=False, debug: bool = False
|
2019-11-11 17:47:28 +00:00
|
|
|
) -> None:
|
|
|
|
if debug:
|
2020-04-03 15:38:24 +00:00
|
|
|
print(f"Copying {scope.generated_cmake_lists_path} to {output_file}")
|
|
|
|
|
|
|
|
base_dir = os.path.dirname(output_file)
|
|
|
|
base_dir_abs = os.path.realpath(base_dir)
|
|
|
|
os.makedirs(base_dir_abs, exist_ok=True)
|
|
|
|
|
|
|
|
copyfile(scope.generated_cmake_lists_path, output_file)
|
2019-05-04 11:08:19 +00:00
|
|
|
if not keep_temporary_files:
|
|
|
|
os.remove(scope.generated_cmake_lists_path)
|
|
|
|
|
|
|
|
|
2019-10-08 09:57:27 +00:00
|
|
|
def cmake_project_has_skip_marker(project_file_path: str = "") -> bool:
|
|
|
|
dir_path = os.path.dirname(project_file_path)
|
|
|
|
cmake_project_path = os.path.join(dir_path, "CMakeLists.txt")
|
|
|
|
if not os.path.exists(cmake_project_path):
|
|
|
|
return False
|
|
|
|
|
|
|
|
with open(cmake_project_path, "r") as file_fd:
|
|
|
|
contents = file_fd.read()
|
|
|
|
|
|
|
|
if "# special case skip regeneration" in contents:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def should_convert_project(project_file_path: str = "", ignore_skip_marker: bool = False) -> bool:
|
2021-09-22 15:34:00 +00:00
|
|
|
qmake_or_cmake_conf_path = find_qmake_or_cmake_conf(project_file_path)
|
|
|
|
qmake_or_cmake_conf_dir_path = os.path.dirname(qmake_or_cmake_conf_path)
|
2019-09-09 12:29:12 +00:00
|
|
|
|
2021-09-22 15:34:00 +00:00
|
|
|
project_relative_path = os.path.relpath(project_file_path, qmake_or_cmake_conf_dir_path)
|
2019-09-09 12:29:12 +00:00
|
|
|
|
|
|
|
# Skip cmake auto tests, they should not be converted.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if project_relative_path.startswith("tests/auto/cmake"):
|
2019-09-09 12:29:12 +00:00
|
|
|
return False
|
2019-09-21 15:41:20 +00:00
|
|
|
if project_relative_path.startswith("tests/auto/installed_cmake"):
|
|
|
|
return False
|
2019-09-09 12:29:12 +00:00
|
|
|
|
|
|
|
# Skip qmake testdata projects.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if project_relative_path.startswith("tests/auto/tools/qmake/testdata"):
|
2019-09-09 12:29:12 +00:00
|
|
|
return False
|
|
|
|
|
2020-04-03 09:16:14 +00:00
|
|
|
# Skip doc snippets.
|
|
|
|
if fnmatch.fnmatch(project_relative_path, "src/*/doc/snippets/*"):
|
|
|
|
return False
|
|
|
|
|
2019-09-21 16:02:54 +00:00
|
|
|
# Skip certain config tests.
|
|
|
|
config_tests = [
|
|
|
|
# Relative to qtbase/config.tests
|
|
|
|
"arch/arch.pro",
|
|
|
|
"avx512/avx512.pro",
|
|
|
|
"stl/stl.pro",
|
|
|
|
"verifyspec/verifyspec.pro",
|
|
|
|
"x86_simd/x86_simd.pro",
|
|
|
|
# Relative to repo src dir
|
|
|
|
"config.tests/hostcompiler/hostcompiler.pro",
|
|
|
|
]
|
|
|
|
skip_certain_tests = any(project_relative_path.startswith(c) for c in config_tests)
|
|
|
|
if skip_certain_tests:
|
|
|
|
return False
|
|
|
|
|
2019-10-08 09:57:27 +00:00
|
|
|
# Skip if CMakeLists.txt in the same path as project_file_path has a
|
|
|
|
# special skip marker.
|
|
|
|
if not ignore_skip_marker and cmake_project_has_skip_marker(project_file_path):
|
|
|
|
return False
|
|
|
|
|
2019-09-09 12:29:12 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
|
2019-11-11 18:31:31 +00:00
|
|
|
def should_convert_project_after_parsing(
|
|
|
|
file_scope: Scope, skip_subdirs_project: bool = False
|
|
|
|
) -> bool:
|
|
|
|
template = file_scope.TEMPLATE
|
|
|
|
if template == "subdirs" and skip_subdirs_project:
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
def main() -> None:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
# Be sure of proper Python version
|
|
|
|
assert sys.version_info >= (3, 7)
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
args = _parse_commandline()
|
|
|
|
|
2018-11-01 14:55:19 +00:00
|
|
|
debug_parsing = args.debug_parser or args.debug
|
2019-10-07 13:28:05 +00:00
|
|
|
if args.skip_condition_cache:
|
|
|
|
set_condition_simplified_cache_enabled(False)
|
2018-11-01 14:55:19 +00:00
|
|
|
|
2019-05-07 14:46:28 +00:00
|
|
|
backup_current_dir = os.getcwd()
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
for file in args.files:
|
2019-05-07 14:46:28 +00:00
|
|
|
new_current_dir = os.path.dirname(file)
|
|
|
|
file_relative_path = os.path.basename(file)
|
2019-05-08 11:14:37 +00:00
|
|
|
if new_current_dir:
|
|
|
|
os.chdir(new_current_dir)
|
2019-05-07 14:46:28 +00:00
|
|
|
|
2019-09-11 07:13:19 +00:00
|
|
|
project_file_absolute_path = os.path.abspath(file_relative_path)
|
2019-10-08 09:57:27 +00:00
|
|
|
if not should_convert_project(project_file_absolute_path, args.ignore_skip_marker):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print(f'Skipping conversion of project: "{project_file_absolute_path}"')
|
2019-09-09 12:29:12 +00:00
|
|
|
continue
|
|
|
|
|
2019-11-08 14:42:35 +00:00
|
|
|
parseresult, project_file_content = parseProFile(file_relative_path, debug=debug_parsing)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-11-13 13:03:20 +00:00
|
|
|
# If CMake api version is given on command line, that means the
|
|
|
|
# user wants to force use that api version.
|
|
|
|
global cmake_api_version
|
|
|
|
if args.api_version:
|
|
|
|
cmake_api_version = args.api_version
|
|
|
|
else:
|
|
|
|
# Otherwise detect the api version in the old CMakeLists.txt
|
|
|
|
# if it exsists.
|
|
|
|
detected_cmake_api_version = detect_cmake_api_version_used_in_file_content(
|
|
|
|
file_relative_path
|
|
|
|
)
|
|
|
|
if detected_cmake_api_version:
|
|
|
|
cmake_api_version = detected_cmake_api_version
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
if args.debug_parse_result or args.debug:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print("\n\n#### Parser result:")
|
2018-10-24 13:20:27 +00:00
|
|
|
print(parseresult)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print("\n#### End of parser result.\n")
|
2018-10-24 13:20:27 +00:00
|
|
|
if args.debug_parse_dictionary or args.debug:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print("\n\n####Parser result dictionary:")
|
2018-10-24 13:20:27 +00:00
|
|
|
print(parseresult.asDict())
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print("\n#### End of parser result dictionary.\n")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
file_scope = Scope.FromDict(
|
2019-11-08 14:42:35 +00:00
|
|
|
None,
|
|
|
|
file_relative_path,
|
|
|
|
parseresult.asDict().get("statements"),
|
|
|
|
project_file_content=project_file_content,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
if args.debug_pro_structure or args.debug:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print("\n\n#### .pro/.pri file structure:")
|
2019-05-08 14:45:25 +00:00
|
|
|
file_scope.dump()
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print("\n#### End of .pro/.pri file structure.\n")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2018-11-01 14:55:19 +00:00
|
|
|
do_include(file_scope, debug=debug_parsing)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
if args.debug_full_pro_structure or args.debug:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print("\n\n#### Full .pro/.pri file structure:")
|
2019-05-08 14:45:25 +00:00
|
|
|
file_scope.dump()
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
print("\n#### End of full .pro/.pri file structure.\n")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-11-11 18:31:31 +00:00
|
|
|
if not should_convert_project_after_parsing(file_scope, args.skip_subdirs_project):
|
|
|
|
print(f'Skipping conversion of project: "{project_file_absolute_path}"')
|
|
|
|
continue
|
|
|
|
|
2022-03-04 14:49:02 +00:00
|
|
|
generate_new_cmakelists(
|
|
|
|
file_scope,
|
|
|
|
is_example=args.is_example,
|
|
|
|
is_user_project=args.is_user_project,
|
|
|
|
debug=args.debug,
|
|
|
|
)
|
2019-05-04 11:08:19 +00:00
|
|
|
|
|
|
|
copy_generated_file = True
|
2020-04-03 15:38:24 +00:00
|
|
|
|
|
|
|
output_file = file_scope.original_cmake_lists_path
|
|
|
|
if args.output_file:
|
|
|
|
output_file = args.output_file
|
|
|
|
|
2019-05-04 11:08:19 +00:00
|
|
|
if not args.skip_special_case_preservation:
|
|
|
|
debug_special_case = args.debug_special_case_preservation or args.debug
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
handler = SpecialCaseHandler(
|
2020-04-03 15:38:24 +00:00
|
|
|
output_file,
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
file_scope.generated_cmake_lists_path,
|
|
|
|
file_scope.basedir,
|
|
|
|
keep_temporary_files=args.keep_temporary_files,
|
|
|
|
debug=debug_special_case,
|
|
|
|
)
|
2019-05-04 11:08:19 +00:00
|
|
|
|
|
|
|
copy_generated_file = handler.handle_special_cases()
|
|
|
|
|
|
|
|
if copy_generated_file:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
copy_generated_file_to_final_location(
|
2020-04-03 15:38:24 +00:00
|
|
|
file_scope, output_file, keep_temporary_files=args.keep_temporary_files
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
)
|
2019-05-07 14:46:28 +00:00
|
|
|
os.chdir(backup_current_dir)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
if __name__ == "__main__":
|
2018-10-24 13:20:27 +00:00
|
|
|
main()
|