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
|
|
|
|
|
|
|
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
|
2019-09-09 08:52:27 +00:00
|
|
|
import glob
|
2019-09-17 08:39:13 +00:00
|
|
|
import collections
|
|
|
|
|
|
|
|
try:
|
|
|
|
collectionsAbc = collections.abc
|
|
|
|
except AttributeError:
|
|
|
|
collectionsAbc = collections
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
import pyparsing as pp
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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
|
|
|
|
from itertools import chain
|
2019-05-04 11:08:19 +00:00
|
|
|
from shutil import copyfile
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 sympy.logic import simplify_logic, And, Or, Not
|
|
|
|
from sympy.core.sympify import SympifyError
|
|
|
|
from typing import List, Optional, Dict, Set, IO, Union, Mapping, Any, Callable, FrozenSet, Tuple
|
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,
|
|
|
|
)
|
|
|
|
from helper import _set_up_py_parsing_nicer_debug_output
|
|
|
|
|
|
|
|
_set_up_py_parsing_nicer_debug_output(pp)
|
2019-05-04 11:08:19 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-09-09 08:52:27 +00:00
|
|
|
cmake_version_string = "3.15.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
|
|
|
|
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.",
|
|
|
|
epilog="Requirements: pip install sympy pyparsing",
|
|
|
|
)
|
|
|
|
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",
|
|
|
|
help="Treat the input .pro file as an example.",
|
|
|
|
)
|
|
|
|
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.",
|
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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:
|
2019-09-09 08:52:27 +00:00
|
|
|
qmake_conf_path = find_qmake_conf(project_file_path)
|
|
|
|
qmake_conf_dir_path = os.path.dirname(qmake_conf_path)
|
|
|
|
project_dir_path = os.path.dirname(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
|
|
|
return qmake_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:
|
2019-09-09 08:52:27 +00:00
|
|
|
qmake_conf_path = find_qmake_conf(project_file_path)
|
|
|
|
qmake_conf_dir_path = os.path.dirname(qmake_conf_path)
|
|
|
|
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 (
|
|
|
|
qmake_conf_dir_path == normalized_maybe_same_level_dir_path and project_dir_name == "tests"
|
|
|
|
)
|
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:
|
2019-09-09 08:52:27 +00:00
|
|
|
qmake_conf_path = find_qmake_conf(project_file_path)
|
|
|
|
qmake_conf_dir_path = os.path.dirname(qmake_conf_path)
|
|
|
|
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 (
|
|
|
|
qmake_conf_dir_path == normalized_maybe_same_level_dir_path
|
|
|
|
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:
|
2019-09-09 12:16:26 +00:00
|
|
|
qmake_conf_path = find_qmake_conf(project_file_path)
|
|
|
|
qmake_conf_dir_path = os.path.dirname(qmake_conf_path)
|
|
|
|
|
|
|
|
project_relative_path = os.path.relpath(project_file_path, qmake_conf_dir_path)
|
|
|
|
# If the project file is found in a subdir called 'examples'
|
|
|
|
# relative to the repo source dir, then it must be an 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
|
|
|
return project_relative_path.startswith("examples")
|
2019-09-09 12:16: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
|
|
|
def find_qmake_conf(project_file_path: str = "") -> Optional[str]:
|
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(
|
|
|
|
f"Warning: could not find .qmake.conf file, given path is not an "
|
|
|
|
f"absolute path: {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
|
|
|
return None
|
|
|
|
|
|
|
|
cwd = os.path.dirname(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
|
|
|
file_name = ".qmake.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
|
|
|
|
|
|
|
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:
|
|
|
|
cwd = os.path.dirname(cwd)
|
|
|
|
|
|
|
|
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 process_qrc_file(
|
|
|
|
target: str,
|
|
|
|
filepath: str,
|
|
|
|
base_dir: str = "",
|
|
|
|
project_file_path: str = "",
|
|
|
|
skip_qtquick_compiler: bool = False,
|
|
|
|
retain_qtquick_compiler: bool = False,
|
|
|
|
is_example: bool = False,
|
|
|
|
) -> str:
|
|
|
|
assert target
|
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:
|
|
|
|
qmake_conf = find_qmake_conf(project_file_path)
|
|
|
|
|
|
|
|
if qmake_conf:
|
|
|
|
qt_source_tree = os.path.dirname(qmake_conf)
|
|
|
|
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.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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_parent_path = dir_name.startswith("..")
|
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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 = ""
|
2019-03-07 10:06:23 +00:00
|
|
|
|
|
|
|
resource_count = 0
|
|
|
|
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"
|
|
|
|
lang = resource.get("lang", "")
|
|
|
|
prefix = resource.get("prefix", "/")
|
|
|
|
if not prefix.startswith("/"):
|
|
|
|
prefix = "/" + prefix
|
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
|
|
|
full_resource_name = resource_name + (str(resource_count) if resource_count > 0 else "")
|
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
|
|
|
files: Dict[str, str] = {}
|
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", "")
|
2019-08-06 12:51:04 +00:00
|
|
|
# In cases where examples use shared resources, we set the alias
|
|
|
|
# too the same name of the file, or the applications won't be
|
|
|
|
# be able to locate the resource
|
|
|
|
if not alias and is_parent_path:
|
|
|
|
alias = path
|
2019-03-07 10:06:23 +00:00
|
|
|
files[path] = 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
|
|
|
output += write_add_qt_resource_call(
|
|
|
|
target,
|
|
|
|
full_resource_name,
|
|
|
|
prefix,
|
|
|
|
base_dir,
|
|
|
|
lang,
|
|
|
|
files,
|
|
|
|
skip_qtquick_compiler,
|
|
|
|
retain_qtquick_compiler,
|
|
|
|
is_example,
|
|
|
|
)
|
2019-03-07 10:06:23 +00:00
|
|
|
resource_count += 1
|
|
|
|
|
|
|
|
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,
|
|
|
|
resource_name: str,
|
|
|
|
prefix: Optional[str],
|
|
|
|
base_dir: Optional[str],
|
|
|
|
lang: Optional[str],
|
|
|
|
files: Dict[str, str],
|
|
|
|
skip_qtquick_compiler: bool,
|
|
|
|
retain_qtquick_compiler: bool,
|
|
|
|
is_example: bool,
|
|
|
|
) -> str:
|
|
|
|
output = ""
|
2019-08-09 12:15:42 +00:00
|
|
|
|
|
|
|
sorted_files = sorted(files.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
|
|
|
assert sorted_files
|
2019-08-09 12:15:42 +00:00
|
|
|
|
|
|
|
for source in sorted_files:
|
|
|
|
alias = files[source]
|
|
|
|
if alias:
|
2019-09-11 08:13:06 +00:00
|
|
|
full_source = posixpath.join(base_dir, 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
|
|
|
output += (
|
|
|
|
f'set_source_files_properties("{full_source}"\n'
|
|
|
|
f' PROPERTIES QT_RESOURCE_ALIAS "{alias}"\n)\n'
|
|
|
|
)
|
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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 = "\n ".join(sorted_files)
|
|
|
|
output += f"set({resource_name}_resource_files\n {file_list}\n)\n\n"
|
|
|
|
file_list = f"${{{resource_name}_resource_files}}"
|
2019-08-09 12:15:42 +00:00
|
|
|
if 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
|
|
|
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
|
|
|
|
|
|
|
if retain_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
|
|
|
output += (
|
|
|
|
f"set_source_files_properties(${{{resource_name}_resource_files}}"
|
|
|
|
"PROPERTIES QT_RETAIN_QUICKCOMPILER 1)\n\n"
|
|
|
|
)
|
2019-08-09 12:15:42 +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
|
|
|
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'
|
|
|
|
add_resource_command = ""
|
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:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
add_resource_command = "add_qt_resource"
|
|
|
|
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:
|
|
|
|
def __init__(self, file_path: str, type_name: str):
|
|
|
|
self.file_path = file_path
|
|
|
|
self.version = ""
|
|
|
|
self.type_name = type_name
|
|
|
|
self.internal = False
|
|
|
|
self.singleton = False
|
|
|
|
|
|
|
|
|
|
|
|
class QmlDir:
|
|
|
|
def __init__(self):
|
|
|
|
self.module = ""
|
|
|
|
self.plugin_name = ""
|
|
|
|
self.plugin_path = ""
|
|
|
|
self.classname = ""
|
|
|
|
self.imports = [] # typing.List[str]
|
|
|
|
self.type_names = {} # typing.Dict[str, QmlDirFileInfo]
|
|
|
|
self.type_infos = [] # typing.List[str]
|
|
|
|
self.depends = [] # typing.List[[str,str]]
|
|
|
|
self.designer_supported = False
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
str = "module: {}\n".format(self.module)
|
|
|
|
str += "plugin: {} {}\n".format(self.plugin_name, self.plugin_path)
|
|
|
|
str += "classname: {}\n".format(self.classname)
|
|
|
|
str += "type_infos:{}\n".format(" \n".join(self.type_infos))
|
|
|
|
str += "imports:{}\n".format(" \n".join(self.imports))
|
|
|
|
str += "dependends: \n"
|
|
|
|
for dep in self.depends:
|
|
|
|
str += " {} {}\n".format(dep[0], dep[1])
|
|
|
|
str += "designer supported: {}\n".format(self.designer_supported)
|
|
|
|
str += "type_names:\n"
|
|
|
|
for key in self.type_names:
|
|
|
|
file_info = self.type_names[key]
|
|
|
|
str += " type:{} version:{} path:{} internal:{} singleton:{}\n".format(
|
|
|
|
file_info.type_name,
|
|
|
|
file_info.version,
|
|
|
|
file_info.type_name,
|
|
|
|
file_info.file_path,
|
|
|
|
file_info.internal,
|
|
|
|
file_info.singleton,
|
|
|
|
)
|
|
|
|
return str
|
|
|
|
|
|
|
|
def get_or_create_file_info(self, path: str, type_name: str) -> QmlDirFileInfo:
|
|
|
|
if not path in self.type_names:
|
|
|
|
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)
|
|
|
|
qmldir_file.version = version
|
|
|
|
qmldir_file.type_name = type_name
|
|
|
|
qmldir_file.path = path
|
|
|
|
return qmldir_file
|
|
|
|
|
|
|
|
def from_file(self, path: str):
|
|
|
|
f = open(path, "r")
|
|
|
|
if not f:
|
|
|
|
raise RuntimeError("Failed to open qmldir file at: {}".format(str))
|
|
|
|
for line in f:
|
|
|
|
if line.startswith("#"):
|
|
|
|
continue
|
|
|
|
line = line.strip().replace("\n", "")
|
|
|
|
if len(line) == 0:
|
|
|
|
continue
|
|
|
|
|
|
|
|
entries = line.split(" ")
|
|
|
|
if len(entries) == 0:
|
|
|
|
raise RuntimeError("Unexpected QmlDir file line entry")
|
|
|
|
if entries[0] == "module":
|
|
|
|
self.module = entries[1]
|
|
|
|
elif entries[0] == "[singleton]":
|
|
|
|
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]
|
|
|
|
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":
|
|
|
|
self.imports.append(entries[1])
|
|
|
|
elif len(entries) == 3:
|
|
|
|
self.handle_file(entries[0], entries[1], entries[2])
|
|
|
|
else:
|
|
|
|
raise RuntimeError("Uhandled qmldir entry {}".format(line))
|
|
|
|
|
|
|
|
|
2019-02-13 11:24:14 +00:00
|
|
|
def fixup_linecontinuation(contents: str) -> str:
|
2019-05-23 13:57:59 +00:00
|
|
|
# Remove all line continuations, aka a backslash followed by
|
|
|
|
# a newline character with an arbitrary amount of whitespace
|
|
|
|
# between the backslash and the newline.
|
|
|
|
# This greatly simplifies the qmake parsing grammar.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
contents = re.sub(r"([^\t ])\\[ \t]*\n", "\\1 ", contents)
|
|
|
|
contents = re.sub(r"\\[ \t]*\n", "", contents)
|
2019-02-13 11:24:14 +00:00
|
|
|
return contents
|
|
|
|
|
|
|
|
|
2019-05-17 16:31:19 +00:00
|
|
|
def fixup_comments(contents: str) -> str:
|
|
|
|
# Get rid of completely commented out lines.
|
|
|
|
# So any line which starts with a '#' char and ends with a new line
|
|
|
|
# will be replaced by a single new line.
|
|
|
|
#
|
|
|
|
# This is needed because qmake syntax is weird. In a multi line
|
|
|
|
# assignment (separated by backslashes and newlines aka
|
|
|
|
# # \\\n ), if any of the lines are completely commented out, in
|
|
|
|
# principle the assignment should fail.
|
|
|
|
#
|
|
|
|
# It should fail because you would have a new line separating
|
|
|
|
# the previous value from the next value, and the next value would
|
|
|
|
# not be interpreted as a value, but as a new token / operation.
|
|
|
|
# qmake is lenient though, and accepts that, so we need to take
|
|
|
|
# care of it as well, as if the commented line didn't exist in the
|
|
|
|
# first place.
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
contents = re.sub(r"\n#[^\n]*?\n", "\n", contents, re.DOTALL)
|
2019-05-17 16:31:19 +00:00
|
|
|
return contents
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2019-09-17 08:39:13 +00:00
|
|
|
def flatten_list(l):
|
|
|
|
""" Flattens an irregular nested list into a simple list."""
|
|
|
|
for el in l:
|
|
|
|
if isinstance(el, collectionsAbc.Iterable) and not isinstance(el, (str, bytes)):
|
|
|
|
yield from flatten_list(el)
|
|
|
|
else:
|
|
|
|
yield el
|
|
|
|
|
|
|
|
|
2019-08-08 11:21:23 +00:00
|
|
|
def handle_function_value(group: pp.ParseResults):
|
|
|
|
function_name = group[0]
|
|
|
|
function_args = 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 function_name == "qtLibraryTarget":
|
2019-08-08 11:21:23 +00:00
|
|
|
if len(function_args) > 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
|
|
|
raise RuntimeError(
|
|
|
|
"Don't know what to with more than one function argument "
|
|
|
|
"for $$qtLibraryTarget()."
|
|
|
|
)
|
2019-08-08 11:21:23 +00:00
|
|
|
return str(function_args[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 function_name == "quote":
|
2019-08-08 11:21:23 +00:00
|
|
|
# Do nothing, just return a string result
|
|
|
|
return str(group)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 function_name == "files":
|
2019-09-03 13:25:55 +00:00
|
|
|
if len(function_args) > 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
|
|
|
raise RuntimeError(
|
|
|
|
"Don't know what to with more than one function argument for $$files()."
|
|
|
|
)
|
2019-09-03 13:25:55 +00:00
|
|
|
return str(function_args[0])
|
|
|
|
|
2019-09-17 08:39:13 +00:00
|
|
|
if isinstance(function_args, pp.ParseResults):
|
|
|
|
function_args = list(flatten_list(function_args.asList()))
|
|
|
|
|
2019-08-15 11:09:55 +00:00
|
|
|
# Return the whole expression as a 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
|
|
|
if function_name in [
|
|
|
|
"join",
|
|
|
|
"files",
|
|
|
|
"cmakeRelativePath",
|
|
|
|
"shell_quote",
|
|
|
|
"shadowed",
|
|
|
|
"cmakeTargetPath",
|
|
|
|
"shell_path",
|
|
|
|
"cmakeProcessLibs",
|
|
|
|
"cmakeTargetPaths",
|
|
|
|
"cmakePortablePaths",
|
|
|
|
"escape_expand",
|
|
|
|
"member",
|
|
|
|
]:
|
|
|
|
return f"join({''.join(function_args)})"
|
2019-09-03 13:25:55 +00:00
|
|
|
|
2019-08-08 11:21:23 +00:00
|
|
|
|
2018-12-20 15:15:10 +00:00
|
|
|
class 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 __init__(self, value: Union[List[str], str]):
|
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)]
|
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(
|
|
|
|
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
|
|
|
|
) -> 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(
|
|
|
|
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
|
|
|
|
) -> List[str]:
|
2019-03-28 12:54:56 +00:00
|
|
|
return input + 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
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
|
|
|
|
) -> List[str]:
|
2018-12-20 15:15:10 +00:00
|
|
|
result = input
|
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
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
|
|
|
|
) -> 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:
|
|
|
|
values += input
|
|
|
|
|
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):
|
|
|
|
def __init__(self, value):
|
|
|
|
super().__init__(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 process(
|
|
|
|
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
|
|
|
|
) -> List[str]:
|
2018-12-20 15:15:10 +00:00
|
|
|
input_set = set(input)
|
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:
|
|
|
|
for v in input:
|
|
|
|
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-03-26 13:12:09 +00:00
|
|
|
if v not in input_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-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],
|
|
|
|
file: Optional[str] = None,
|
|
|
|
condition: str = "",
|
|
|
|
base_dir: str = "",
|
|
|
|
operations: Union[Mapping[str, List[Operation]], None] = None,
|
|
|
|
) -> None:
|
2019-08-01 14:01:22 +00:00
|
|
|
if operations is None:
|
|
|
|
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}"])],
|
|
|
|
"QT_BUILD_TREE": [SetOperation(["${PROJECT_BUILD_DIR}"])],
|
2019-08-01 14:01:22 +00:00
|
|
|
}
|
|
|
|
|
2019-07-04 12:48:32 +00:00
|
|
|
self._operations = 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
|
|
|
|
if file:
|
|
|
|
self._currentdir = os.path.dirname(file)
|
|
|
|
if not self._currentdir:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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._currentdir = "."
|
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
|
2018-10-24 13:20:27 +00:00
|
|
|
self._file = file
|
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
|
|
|
self._file_absolute_path = os.path.abspath(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]
|
|
|
|
self._visited_keys = set() # type: Set[str]
|
|
|
|
self._total_condition = None # type: Optional[str]
|
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
|
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
|
|
|
|
|
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
|
|
|
|
|
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(
|
|
|
|
parent_scope: Optional["Scope"], file: str, statements, cond: str = "", base_dir: str = ""
|
|
|
|
) -> Scope:
|
2019-01-24 15:01:17 +00:00
|
|
|
scope = Scope(parent_scope=parent_scope, file=file, condition=cond, base_dir=base_dir)
|
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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 == "=":
|
2018-12-20 15:15:10 +00:00
|
|
|
scope._append_operation(key, SetOperation(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
|
|
|
elif operation == "-=":
|
2018-12-20 15:15:10 +00:00
|
|
|
scope._append_operation(key, RemoveOperation(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
|
|
|
elif operation == "+=":
|
2018-12-20 15:15:10 +00:00
|
|
|
scope._append_operation(key, AddOperation(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
|
|
|
elif operation == "*=":
|
2018-12-20 15:15:10 +00:00
|
|
|
scope._append_operation(key, UniqueAddOperation(value))
|
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:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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("_INCLUDED", UniqueAddOperation(included))
|
2018-10-24 13:20:27 +00:00
|
|
|
continue
|
|
|
|
|
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)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 dump_structure(self, *, type: str = "ROOT", indent: int = 0) -> None:
|
|
|
|
print(f"{spaces(indent)}{type}: {self}")
|
2019-03-28 12:54:56 +00:00
|
|
|
for i in 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
|
|
|
i.dump_structure(type="INCL", indent=indent + 1)
|
2019-03-28 12:54:56 +00:00
|
|
|
for i in 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
|
|
|
i.dump_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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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-04-12 09:45:43 +00:00
|
|
|
# Inherrit values from above:
|
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-03-28 12:54:56 +00:00
|
|
|
if 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 op_transformer(files):
|
|
|
|
return transformer(self, files)
|
|
|
|
|
2019-03-28 12:54:56 +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
|
|
|
|
|
|
|
def op_transformer(files):
|
|
|
|
return files
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2018-12-20 15:15:10 +00:00
|
|
|
for op in self._operations.get(key, []):
|
2019-04-11 15:06:01 +00:00
|
|
|
result = op.process(key, result, op_transformer)
|
2019-03-28 12:54:56 +00:00
|
|
|
|
|
|
|
for ic in self._included_children:
|
|
|
|
result = list(ic._evalOps(key, transformer, result))
|
|
|
|
|
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:
|
|
|
|
relative_path = os.path.relpath(self.currentdir, self.basedir)
|
2019-05-29 07:57: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
|
|
|
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
|
|
|
|
2019-07-15 13:38:47 +00:00
|
|
|
return self._evalOps(key, None, [], 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
|
|
|
|
assert len(v) == 1
|
|
|
|
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
|
|
|
|
def _replace_env_var_value(value: Any) -> str:
|
|
|
|
if not isinstance(value, str):
|
|
|
|
return value
|
|
|
|
|
|
|
|
pattern = re.compile(r"\$\$\(?([A-Za-z_][A-Za-z0-9_]*)\)?")
|
|
|
|
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().
|
|
|
|
result_list = []
|
|
|
|
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 ""
|
|
|
|
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-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
|
|
|
|
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
|
|
|
|
|
|
|
class QmakeParser:
|
|
|
|
def __init__(self, *, debug: bool = False) -> None:
|
2019-05-23 13:20:41 +00:00
|
|
|
self.debug = debug
|
|
|
|
self._Grammar = self._generate_grammar()
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-05-23 13:20:41 +00:00
|
|
|
def _generate_grammar(self):
|
2018-10-24 13:20:27 +00:00
|
|
|
# Define grammar:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
pp.ParserElement.setDefaultWhitespaceChars(" \t")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-05-23 13:20:41 +00:00
|
|
|
def add_element(name: str, value: pp.ParserElement):
|
|
|
|
nonlocal self
|
|
|
|
if self.debug:
|
|
|
|
value.setName(name)
|
|
|
|
value.setDebug()
|
|
|
|
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
|
|
|
EOL = add_element("EOL", pp.Suppress(pp.LineEnd()))
|
|
|
|
Else = add_element("Else", pp.Keyword("else"))
|
|
|
|
Identifier = add_element(
|
|
|
|
"Identifier", pp.Word(f"{pp.alphas}_", bodyChars=pp.alphanums + "_-./")
|
|
|
|
)
|
|
|
|
BracedValue = add_element(
|
|
|
|
"BracedValue",
|
|
|
|
pp.nestedExpr(
|
|
|
|
ignoreExpr=pp.quotedString
|
|
|
|
| pp.QuotedString(
|
|
|
|
quoteChar="$(", endQuoteChar=")", escQuote="\\", unquoteResults=False
|
|
|
|
)
|
|
|
|
).setParseAction(lambda s, l, t: ["(", *t[0], ")"]),
|
|
|
|
)
|
|
|
|
|
|
|
|
Substitution = add_element(
|
|
|
|
"Substitution",
|
|
|
|
pp.Combine(
|
|
|
|
pp.Literal("$")
|
|
|
|
+ (
|
|
|
|
(
|
|
|
|
(pp.Literal("$") + Identifier + pp.Optional(pp.nestedExpr()))
|
|
|
|
| (pp.Literal("(") + Identifier + pp.Literal(")"))
|
|
|
|
| (pp.Literal("{") + Identifier + pp.Literal("}"))
|
|
|
|
| (
|
|
|
|
pp.Literal("$")
|
|
|
|
+ pp.Literal("{")
|
2019-08-08 11:21:23 +00:00
|
|
|
+ Identifier
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
+ pp.Optional(pp.nestedExpr())
|
|
|
|
+ pp.Literal("}")
|
|
|
|
)
|
|
|
|
| (pp.Literal("$") + pp.Literal("[") + Identifier + pp.Literal("]"))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
)
|
|
|
|
LiteralValuePart = add_element(
|
|
|
|
"LiteralValuePart", pp.Word(pp.printables, excludeChars="$#{}()")
|
|
|
|
)
|
|
|
|
SubstitutionValue = add_element(
|
|
|
|
"SubstitutionValue",
|
|
|
|
pp.Combine(pp.OneOrMore(Substitution | LiteralValuePart | pp.Literal("$"))),
|
|
|
|
)
|
|
|
|
FunctionValue = add_element(
|
|
|
|
"FunctionValue",
|
|
|
|
pp.Group(
|
|
|
|
pp.Suppress(pp.Literal("$") + pp.Literal("$"))
|
|
|
|
+ Identifier
|
|
|
|
+ pp.nestedExpr() # .setParseAction(lambda s, l, t: ['(', *t[0], ')'])
|
|
|
|
).setParseAction(lambda s, l, t: handle_function_value(*t)),
|
|
|
|
)
|
|
|
|
Value = add_element(
|
|
|
|
"Value",
|
|
|
|
pp.NotAny(Else | pp.Literal("}") | EOL)
|
|
|
|
+ (
|
|
|
|
pp.QuotedString(quoteChar='"', escChar="\\")
|
|
|
|
| FunctionValue
|
|
|
|
| SubstitutionValue
|
|
|
|
| BracedValue
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
Values = add_element("Values", pp.ZeroOrMore(Value)("value"))
|
|
|
|
|
|
|
|
Op = add_element(
|
|
|
|
"OP", pp.Literal("=") | pp.Literal("-=") | pp.Literal("+=") | pp.Literal("*=")
|
|
|
|
)
|
|
|
|
|
|
|
|
Key = add_element("Key", Identifier)
|
|
|
|
|
|
|
|
Operation = add_element("Operation", Key("key") + Op("operation") + Values("value"))
|
|
|
|
CallArgs = add_element("CallArgs", pp.nestedExpr())
|
2019-03-28 12:25:04 +00:00
|
|
|
|
|
|
|
def parse_call_args(results):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
out = ""
|
2019-03-28 12:25:04 +00:00
|
|
|
for item in chain(*results):
|
|
|
|
if isinstance(item, str):
|
|
|
|
out += item
|
|
|
|
else:
|
|
|
|
out += "(" + parse_call_args(item) + ")"
|
|
|
|
return out
|
|
|
|
|
|
|
|
CallArgs.setParseAction(parse_call_args)
|
2019-05-23 13:20: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
|
|
|
Load = add_element("Load", pp.Keyword("load") + CallArgs("loaded"))
|
|
|
|
Include = add_element("Include", pp.Keyword("include") + CallArgs("included"))
|
|
|
|
Option = add_element("Option", pp.Keyword("option") + CallArgs("option"))
|
2019-05-23 13:20:41 +00:00
|
|
|
|
|
|
|
# ignore the whole thing...
|
|
|
|
DefineTestDefinition = add_element(
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"DefineTestDefinition",
|
|
|
|
pp.Suppress(
|
|
|
|
pp.Keyword("defineTest")
|
|
|
|
+ CallArgs
|
|
|
|
+ pp.nestedExpr(opener="{", closer="}", ignoreExpr=pp.LineEnd())
|
|
|
|
),
|
|
|
|
)
|
2019-05-23 13:20:41 +00:00
|
|
|
|
|
|
|
# ignore the whole thing...
|
|
|
|
ForLoop = add_element(
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"ForLoop",
|
|
|
|
pp.Suppress(
|
|
|
|
pp.Keyword("for")
|
|
|
|
+ CallArgs
|
|
|
|
+ pp.nestedExpr(opener="{", closer="}", ignoreExpr=pp.LineEnd())
|
|
|
|
),
|
|
|
|
)
|
2019-05-23 13:20:41 +00:00
|
|
|
|
|
|
|
# ignore the whole thing...
|
|
|
|
ForLoopSingleLine = add_element(
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"ForLoopSingleLine",
|
|
|
|
pp.Suppress(pp.Keyword("for") + CallArgs + pp.Literal(":") + pp.SkipTo(EOL)),
|
|
|
|
)
|
2019-05-23 13:20:41 +00:00
|
|
|
|
|
|
|
# ignore the whole thing...
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
FunctionCall = add_element("FunctionCall", pp.Suppress(Identifier + pp.nestedExpr()))
|
|
|
|
|
|
|
|
Scope = add_element("Scope", pp.Forward())
|
|
|
|
|
|
|
|
Statement = add_element(
|
|
|
|
"Statement",
|
|
|
|
pp.Group(
|
|
|
|
Load
|
|
|
|
| Include
|
|
|
|
| Option
|
|
|
|
| ForLoop
|
|
|
|
| ForLoopSingleLine
|
|
|
|
| DefineTestDefinition
|
|
|
|
| FunctionCall
|
|
|
|
| Operation
|
|
|
|
),
|
|
|
|
)
|
|
|
|
StatementLine = add_element("StatementLine", Statement + (EOL | pp.FollowedBy("}")))
|
|
|
|
StatementGroup = add_element(
|
|
|
|
"StatementGroup", pp.ZeroOrMore(StatementLine | Scope | pp.Suppress(EOL))
|
|
|
|
)
|
|
|
|
|
|
|
|
Block = add_element(
|
|
|
|
"Block",
|
|
|
|
pp.Suppress("{")
|
|
|
|
+ pp.Optional(EOL)
|
|
|
|
+ StatementGroup
|
|
|
|
+ pp.Optional(EOL)
|
|
|
|
+ pp.Suppress("}")
|
|
|
|
+ pp.Optional(EOL),
|
|
|
|
)
|
|
|
|
|
|
|
|
ConditionEnd = add_element(
|
|
|
|
"ConditionEnd",
|
|
|
|
pp.FollowedBy(
|
|
|
|
(pp.Optional(pp.White()) + (pp.Literal(":") | pp.Literal("{") | pp.Literal("|")))
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
ConditionPart1 = add_element(
|
|
|
|
"ConditionPart1", (pp.Optional("!") + Identifier + pp.Optional(BracedValue))
|
|
|
|
)
|
|
|
|
ConditionPart2 = add_element("ConditionPart2", pp.CharsNotIn("#{}|:=\\\n"))
|
2019-05-23 13:20:41 +00:00
|
|
|
ConditionPart = add_element(
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"ConditionPart", (ConditionPart1 ^ ConditionPart2) + ConditionEnd
|
|
|
|
)
|
2019-05-23 13:20: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
|
|
|
ConditionOp = add_element("ConditionOp", pp.Literal("|") ^ pp.Literal(":"))
|
|
|
|
ConditionWhiteSpace = add_element(
|
|
|
|
"ConditionWhiteSpace", pp.Suppress(pp.Optional(pp.White(" ")))
|
|
|
|
)
|
2019-05-23 13:20: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
|
|
|
ConditionRepeated = add_element(
|
|
|
|
"ConditionRepeated", pp.ZeroOrMore(ConditionOp + ConditionWhiteSpace + ConditionPart)
|
|
|
|
)
|
2019-05-23 13:20: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
|
|
|
Condition = add_element("Condition", pp.Combine(ConditionPart + ConditionRepeated))
|
|
|
|
Condition.setParseAction(lambda x: " ".join(x).strip().replace(":", " && ").strip(" && "))
|
2019-02-11 17:02:22 +00:00
|
|
|
|
2019-05-23 09:53:41 +00:00
|
|
|
# Weird thing like write_file(a)|error() where error() is the alternative condition
|
|
|
|
# which happens to be a function call. In this case there is no scope, but our code expects
|
|
|
|
# a scope with a list of statements, so create a fake empty statement.
|
2019-05-23 13:20:41 +00:00
|
|
|
ConditionEndingInFunctionCall = add_element(
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
"ConditionEndingInFunctionCall",
|
|
|
|
pp.Suppress(ConditionOp)
|
|
|
|
+ FunctionCall
|
|
|
|
+ pp.Empty().setParseAction(lambda x: [[]]).setResultsName("statements"),
|
|
|
|
)
|
|
|
|
|
|
|
|
SingleLineScope = add_element(
|
|
|
|
"SingleLineScope",
|
|
|
|
pp.Suppress(pp.Literal(":")) + pp.Group(Block | (Statement + EOL))("statements"),
|
|
|
|
)
|
|
|
|
MultiLineScope = add_element("MultiLineScope", Block("statements"))
|
|
|
|
|
|
|
|
SingleLineElse = add_element(
|
|
|
|
"SingleLineElse",
|
|
|
|
pp.Suppress(pp.Literal(":")) + (Scope | Block | (Statement + pp.Optional(EOL))),
|
|
|
|
)
|
|
|
|
MultiLineElse = add_element("MultiLineElse", Block)
|
|
|
|
ElseBranch = add_element("ElseBranch", pp.Suppress(Else) + (SingleLineElse | MultiLineElse))
|
2019-05-23 13:20:41 +00:00
|
|
|
|
|
|
|
# Scope is already add_element'ed in the forward declaration above.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 <<= pp.Group(
|
|
|
|
Condition("condition")
|
|
|
|
+ (SingleLineScope | MultiLineScope | ConditionEndingInFunctionCall)
|
|
|
|
+ pp.Optional(ElseBranch)("else_statements")
|
|
|
|
)
|
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
|
|
|
Grammar = StatementGroup("statements")
|
2019-05-17 16:31:19 +00:00
|
|
|
Grammar.ignore(pp.pythonStyleComment())
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
return Grammar
|
|
|
|
|
|
|
|
def parseFile(self, 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
|
|
|
print(f'Parsing "{file}"...')
|
2018-10-24 13:20:27 +00:00
|
|
|
try:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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(file, "r") as file_fd:
|
2019-02-13 11:24:14 +00:00
|
|
|
contents = file_fd.read()
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
# old_contents = contents
|
2019-05-17 16:31:19 +00:00
|
|
|
contents = fixup_comments(contents)
|
2019-06-06 08:31:03 +00:00
|
|
|
contents = fixup_linecontinuation(contents)
|
2019-02-13 11:24:14 +00:00
|
|
|
result = self._Grammar.parseString(contents, parseAll=True)
|
2018-10-24 13:20:27 +00:00
|
|
|
except pp.ParseException as pe:
|
|
|
|
print(pe.line)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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"{' ' * (pe.col-1)}^")
|
2018-10-24 13:20:27 +00:00
|
|
|
print(pe)
|
|
|
|
raise pe
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def parseProFile(file: str, *, debug=False):
|
|
|
|
parser = QmakeParser(debug=debug)
|
|
|
|
return parser.parseFile(file)
|
|
|
|
|
|
|
|
|
|
|
|
def map_condition(condition: str) -> str:
|
2019-05-29 15:39:56 +00:00
|
|
|
# Some hardcoded cases that are too bothersome to generalize.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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\)\?\)",
|
|
|
|
r"QT_FEATURE_opengl OR QT_FEATURE_opengles2 OR QT_FEATURE_opengles3",
|
|
|
|
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)
|
2019-05-29 15:39:56 +00:00
|
|
|
|
2019-06-03 15:42:43 +00:00
|
|
|
def gcc_version_handler(match_obj: re.Match):
|
|
|
|
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)
|
|
|
|
|
|
|
|
# TODO: the current if(...) replacement makes the parentheses
|
|
|
|
# unbalanced when there are nested expressions.
|
|
|
|
# Need to fix this either with pypi regex recursive regexps,
|
|
|
|
# using pyparsing, or some other proper means of handling
|
|
|
|
# balanced parentheses.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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"\bif\s*\((.*?)\)", r"\1", condition)
|
|
|
|
|
|
|
|
condition = re.sub(r"\bisEmpty\s*\((.*?)\)", r"\1_ISEMPTY", condition)
|
|
|
|
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)
|
|
|
|
|
|
|
|
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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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))
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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_name.startswith("system_") and is_known_3rd_party_library(
|
|
|
|
feature_name[7:]
|
|
|
|
):
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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(
|
|
|
|
scope: Scope, cm_fh: IO[str], *, indent: int = 0, is_example: bool = False
|
|
|
|
) -> 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,
|
|
|
|
current_conditions: FrozenSet[str] = None,
|
|
|
|
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:
|
|
|
|
subdir_result = 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(
|
|
|
|
scope, sd, subdir_result.asDict().get("statements"), "", scope.basedir
|
|
|
|
)
|
2019-08-08 07:52:36 +00:00
|
|
|
|
|
|
|
do_include(subdir_scope)
|
|
|
|
cmakeify_scope(subdir_scope, cm_fh, indent=indent, is_example=is_example)
|
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.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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
|
|
|
|
handle_subdir_helper(
|
|
|
|
c,
|
|
|
|
cm_fh,
|
|
|
|
indent=indent + 1,
|
|
|
|
is_example=is_example,
|
|
|
|
current_conditions=frozenset((*current_conditions, child_condition)),
|
|
|
|
)
|
2019-08-01 17:14:58 +00:00
|
|
|
|
|
|
|
def group_and_print_sub_dirs(indent: int = 0):
|
|
|
|
# Simplify conditions, and group
|
|
|
|
# subdirectories with the same conditions.
|
|
|
|
grouped_sub_dirs = {}
|
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
|
|
|
|
condition_simplified = simplify_condition(condition_str)
|
|
|
|
condition_key = condition_simplified
|
|
|
|
|
|
|
|
sub_dir_list_by_key = grouped_sub_dirs.get(condition_key, [])
|
|
|
|
sub_dir_list_by_key.append(subdir_name)
|
|
|
|
grouped_sub_dirs[condition_key] = sub_dir_list_by_key
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
current_conditions = frozenset()
|
|
|
|
|
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
|
|
|
|
)
|
2019-08-01 17:14:58 +00:00
|
|
|
group_and_print_sub_dirs(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
|
|
|
|
|
|
|
|
dir = os.path.dirname(s)
|
|
|
|
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-09-11 08:13:06 +00:00
|
|
|
sort_name = posixpath.join(dir, 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
|
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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_libraries_to_cmake(libraries: List[str], known_libraries: Set[str]) -> List[str]:
|
|
|
|
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:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 = f"${{FW{lib}}}"
|
|
|
|
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(
|
|
|
|
scope: Scope, *, known_libraries: Set[str] = set()
|
|
|
|
) -> Tuple[List[str], List[str]]:
|
|
|
|
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
|
|
|
# Qt public libs: These may include FooPrivate in which case we get
|
|
|
|
# a private dependency on FooPrivate as well as a public dependency on Foo
|
|
|
|
for lib in scope.expand(key):
|
|
|
|
mapped_lib = map_qt_library(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 mapped_lib.endswith("Private"):
|
2019-05-09 08:02:37 +00:00
|
|
|
private_dependencies.append(mapped_lib)
|
|
|
|
public_dependencies.append(mapped_lib[:-7])
|
|
|
|
else:
|
|
|
|
public_dependencies.append(mapped_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
|
|
|
return (
|
|
|
|
_map_libraries_to_cmake(public_dependencies, known_libraries),
|
|
|
|
_map_libraries_to_cmake(private_dependencies, known_libraries),
|
|
|
|
)
|
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-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):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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}{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-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,
|
|
|
|
["SOURCES", "HEADERS", "OBJECTIVE_SOURCES", "NO_PCH_SOURCES", "FORMS"] + extra_keys,
|
|
|
|
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
|
|
|
|
]
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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_include_paths(
|
|
|
|
cm_fh: IO[str], scope: Scope, cmake_parameter: str, *, indent: int = 0, footer: str = ""
|
|
|
|
):
|
|
|
|
includes = [i.rstrip("/") or ("/") for i in scope.get_files("INCLUDEPATH")]
|
2019-05-07 09:27:33 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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(
|
|
|
|
cm_fh: IO[str], scope: Scope, *, indent: int = 0, known_libraries: Set[str] = set()
|
|
|
|
):
|
|
|
|
public_dependencies, private_dependencies = extract_cmake_libraries(
|
|
|
|
scope, known_libraries=known_libraries
|
|
|
|
)
|
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
|
|
|
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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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_sources_section(cm_fh: IO[str], scope: Scope, *, indent: int = 0, 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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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
|
|
|
|
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",
|
|
|
|
"TARGET",
|
|
|
|
"QMAKE_DOCS",
|
|
|
|
"QT_SOURCE_TREE",
|
|
|
|
"QT_BUILD_TREE",
|
|
|
|
"TRACEPOINT_PROVIDER",
|
|
|
|
}:
|
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
|
|
|
|
|
|
|
|
|
2019-01-23 15:40:23 +00:00
|
|
|
def _iterate_expr_tree(expr, op, matches):
|
|
|
|
assert expr.func == op
|
|
|
|
keepers = ()
|
|
|
|
for arg in expr.args:
|
|
|
|
if arg in matches:
|
|
|
|
matches = tuple(x for x in matches if x != arg)
|
|
|
|
elif arg == op:
|
|
|
|
(matches, extra_keepers) = _iterate_expr_tree(arg, op, matches)
|
|
|
|
keepers = (*keepers, *extra_keepers)
|
|
|
|
else:
|
|
|
|
keepers = (*keepers, arg)
|
2019-02-12 23:15:15 +00:00
|
|
|
return matches, keepers
|
2019-01-23 15:40:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
def _simplify_expressions(expr, op, matches, replacement):
|
2019-02-12 23:15:15 +00:00
|
|
|
for arg in expr.args:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
expr = expr.subs(arg, _simplify_expressions(arg, op, matches, replacement))
|
2019-01-23 15:40:23 +00:00
|
|
|
|
|
|
|
if expr.func == op:
|
|
|
|
(to_match, keepers) = tuple(_iterate_expr_tree(expr, op, matches))
|
|
|
|
if len(to_match) == 0:
|
|
|
|
# build expression with keepers and replacement:
|
|
|
|
if keepers:
|
|
|
|
start = replacement
|
|
|
|
current_expr = None
|
|
|
|
last_expr = keepers[-1]
|
|
|
|
for repl_arg in keepers[:-1]:
|
|
|
|
current_expr = op(start, repl_arg)
|
|
|
|
start = current_expr
|
|
|
|
top_expr = op(start, last_expr)
|
|
|
|
else:
|
|
|
|
top_expr = replacement
|
|
|
|
|
|
|
|
expr = expr.subs(expr, top_expr)
|
|
|
|
|
|
|
|
return expr
|
|
|
|
|
|
|
|
|
|
|
|
def _simplify_flavors_in_condition(base: str, flavors, expr):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
""" Simplify conditions based on the knownledge of which flavors
|
|
|
|
belong to which OS. """
|
2019-01-23 15:40:23 +00:00
|
|
|
base_expr = simplify_logic(base)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
false_expr = simplify_logic("false")
|
2019-01-23 15:40:23 +00:00
|
|
|
for flavor in flavors:
|
|
|
|
flavor_expr = simplify_logic(flavor)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
expr = _simplify_expressions(expr, And, (base_expr, flavor_expr), flavor_expr)
|
|
|
|
expr = _simplify_expressions(expr, Or, (base_expr, flavor_expr), base_expr)
|
|
|
|
expr = _simplify_expressions(expr, And, (Not(base_expr), flavor_expr), false_expr)
|
2019-01-23 15:40:23 +00:00
|
|
|
return expr
|
|
|
|
|
|
|
|
|
2019-02-12 23:15:15 +00:00
|
|
|
def _simplify_os_families(expr, family_members, other_family_members):
|
|
|
|
for family in family_members:
|
|
|
|
for other in other_family_members:
|
|
|
|
if other in family_members:
|
|
|
|
continue # skip those in the sub-family
|
|
|
|
|
|
|
|
f_expr = simplify_logic(family)
|
|
|
|
o_expr = simplify_logic(other)
|
|
|
|
|
|
|
|
expr = _simplify_expressions(expr, And, (f_expr, Not(o_expr)), f_expr)
|
|
|
|
expr = _simplify_expressions(expr, And, (Not(f_expr), o_expr), o_expr)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
expr = _simplify_expressions(expr, And, (f_expr, o_expr), simplify_logic("false"))
|
2019-02-12 23:15:15 +00:00
|
|
|
return expr
|
|
|
|
|
|
|
|
|
2019-01-23 15:40:23 +00:00
|
|
|
def _recursive_simplify(expr):
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
""" Simplify the expression as much as possible based on
|
|
|
|
domain knowledge. """
|
2019-01-23 15:40:23 +00:00
|
|
|
input_expr = expr
|
|
|
|
|
|
|
|
# Simplify even further, based on domain knowledge:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
# windowses = ('WIN32', 'WINRT')
|
|
|
|
apples = ("APPLE_OSX", "APPLE_UIKIT", "APPLE_IOS", "APPLE_TVOS", "APPLE_WATCHOS")
|
|
|
|
bsds = ("FREEBSD", "OPENBSD", "NETBSD")
|
|
|
|
androids = ("ANDROID", "ANDROID_EMBEDDED")
|
|
|
|
unixes = (
|
|
|
|
"APPLE",
|
|
|
|
*apples,
|
|
|
|
"BSD",
|
|
|
|
*bsds,
|
|
|
|
"LINUX",
|
|
|
|
*androids,
|
|
|
|
"HAIKU",
|
|
|
|
"INTEGRITY",
|
|
|
|
"VXWORKS",
|
|
|
|
"QNX",
|
|
|
|
"WASM",
|
|
|
|
)
|
|
|
|
|
|
|
|
unix_expr = simplify_logic("UNIX")
|
|
|
|
win_expr = simplify_logic("WIN32")
|
|
|
|
false_expr = simplify_logic("false")
|
|
|
|
true_expr = simplify_logic("true")
|
2019-01-23 15:40:23 +00:00
|
|
|
|
|
|
|
expr = expr.subs(Not(unix_expr), win_expr) # NOT UNIX -> WIN32
|
|
|
|
expr = expr.subs(Not(win_expr), unix_expr) # NOT WIN32 -> UNIX
|
|
|
|
|
|
|
|
# UNIX [OR foo ]OR WIN32 -> ON [OR foo]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
expr = _simplify_expressions(expr, Or, (unix_expr, win_expr), true_expr)
|
2019-01-23 15:40:23 +00:00
|
|
|
# UNIX [AND foo ]AND WIN32 -> OFF [AND foo]
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
expr = _simplify_expressions(expr, And, (unix_expr, win_expr), false_expr)
|
2019-01-23 15:40: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
|
|
|
expr = _simplify_flavors_in_condition("WIN32", ("WINRT",), expr)
|
|
|
|
expr = _simplify_flavors_in_condition("APPLE", apples, expr)
|
|
|
|
expr = _simplify_flavors_in_condition("BSD", bsds, expr)
|
|
|
|
expr = _simplify_flavors_in_condition("UNIX", unixes, expr)
|
|
|
|
expr = _simplify_flavors_in_condition("ANDROID", ("ANDROID_EMBEDDED",), expr)
|
2019-01-23 15:40:23 +00:00
|
|
|
|
2019-02-12 23:15:15 +00:00
|
|
|
# Simplify families of OSes against other families:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
expr = _simplify_os_families(expr, ("WIN32", "WINRT"), unixes)
|
2019-02-12 23:15:15 +00:00
|
|
|
expr = _simplify_os_families(expr, androids, unixes)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
expr = _simplify_os_families(expr, ("BSD", *bsds), unixes)
|
2019-02-12 23:15:15 +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 family in ("HAIKU", "QNX", "INTEGRITY", "LINUX", "VXWORKS"):
|
2019-02-12 23:15:15 +00:00
|
|
|
expr = _simplify_os_families(expr, (family,), unixes)
|
|
|
|
|
2019-01-23 15:40:23 +00:00
|
|
|
# Now simplify further:
|
|
|
|
expr = simplify_logic(expr)
|
|
|
|
|
|
|
|
while expr != input_expr:
|
|
|
|
input_expr = expr
|
|
|
|
expr = _recursive_simplify(expr)
|
|
|
|
|
|
|
|
return expr
|
|
|
|
|
|
|
|
|
|
|
|
def simplify_condition(condition: str) -> str:
|
|
|
|
input_condition = condition.strip()
|
|
|
|
|
|
|
|
# Map to sympy syntax:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 = " " + input_condition + " "
|
|
|
|
condition = condition.replace("(", " ( ")
|
|
|
|
condition = condition.replace(")", " ) ")
|
2019-01-23 15:40: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
|
|
|
tmp = ""
|
2019-01-23 15:40:23 +00:00
|
|
|
while tmp != condition:
|
|
|
|
tmp = 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 = condition.replace(" NOT ", " ~ ")
|
|
|
|
condition = condition.replace(" AND ", " & ")
|
|
|
|
condition = condition.replace(" OR ", " | ")
|
|
|
|
condition = condition.replace(" ON ", " true ")
|
|
|
|
condition = condition.replace(" OFF ", " false ")
|
2019-08-27 17:15:36 +00:00
|
|
|
# Replace dashes with a token
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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("-", "_dash_")
|
2019-01-23 15:40:23 +00:00
|
|
|
|
2019-08-01 15:30:26 +00:00
|
|
|
# SymPy chokes on expressions that contain two tokens one next to
|
|
|
|
# the other delimited by a space, which are not an operation.
|
|
|
|
# So a CMake condition like "TARGET Foo::Bar" fails the whole
|
|
|
|
# expression simplifying process.
|
|
|
|
# Turn these conditions into a single token so that SymPy can parse
|
|
|
|
# the expression, and thus simplify it.
|
|
|
|
# Do this by replacing and keeping a map of conditions to single
|
|
|
|
# token symbols.
|
2019-08-27 17:15:36 +00:00
|
|
|
# Support both target names without double colons, and with double
|
|
|
|
# colons.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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"(TARGET [a-zA-Z]+(?:::[a-zA-Z]+)?)")
|
2019-08-01 15:30:26 +00:00
|
|
|
target_symbol_mapping = {}
|
|
|
|
all_target_conditions = re.findall(pattern, condition)
|
|
|
|
for target_condition in all_target_conditions:
|
|
|
|
# Replace spaces and colons with underscores.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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_condition_symbol_name = re.sub("[ :]", "_", target_condition)
|
2019-08-01 15:30:26 +00:00
|
|
|
target_symbol_mapping[target_condition_symbol_name] = target_condition
|
|
|
|
condition = re.sub(target_condition, target_condition_symbol_name, condition)
|
|
|
|
|
2019-01-23 15:40:23 +00:00
|
|
|
try:
|
|
|
|
# Generate and simplify condition using sympy:
|
|
|
|
condition_expr = simplify_logic(condition)
|
|
|
|
condition = str(_recursive_simplify(condition_expr))
|
|
|
|
|
2019-08-01 15:30:26 +00:00
|
|
|
# Restore the target conditions.
|
|
|
|
for symbol_name in target_symbol_mapping:
|
|
|
|
condition = re.sub(symbol_name, target_symbol_mapping[symbol_name], condition)
|
|
|
|
|
2019-01-23 15:40:23 +00:00
|
|
|
# Map back to CMake syntax:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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")
|
|
|
|
condition = condition.replace("True", "ON")
|
|
|
|
condition = condition.replace("False", "OFF")
|
|
|
|
condition = condition.replace("_dash_", "-")
|
|
|
|
except (SympifyError, TypeError):
|
2019-01-23 15:40:23 +00:00
|
|
|
# sympy did not like our input, so leave this condition alone:
|
|
|
|
condition = input_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
|
|
|
return condition or "ON"
|
2019-01-23 15:40: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
|
|
|
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-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
|
|
|
|
|
|
|
|
|
|
|
def write_resources(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0, is_example=False):
|
|
|
|
# vpath = scope.expand('VPATH')
|
2019-03-07 10:06:23 +00:00
|
|
|
|
|
|
|
# Handle QRC files by turning them into add_qt_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
|
|
|
resources = scope.get_files("RESOURCES")
|
|
|
|
qtquickcompiler_skipped = scope.get_files("QTQUICK_COMPILER_SKIPPED_RESOURCES")
|
|
|
|
qtquickcompiler_retained = scope.get_files("QTQUICK_COMPILER_RETAINED_RESOURCES")
|
|
|
|
qrc_output = ""
|
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
|
2019-08-12 14:31:30 +00:00
|
|
|
retain_qtquick_compiler = r in qtquickcompiler_retained
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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"):
|
|
|
|
qrc_output += process_qrc_file(
|
|
|
|
target,
|
|
|
|
r,
|
|
|
|
scope.basedir,
|
|
|
|
scope.file_absolute_path,
|
|
|
|
skip_qtquick_compiler,
|
|
|
|
retain_qtquick_compiler,
|
|
|
|
is_example,
|
|
|
|
)
|
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:
|
|
|
|
immediate_prefix = scope.get(r + ".prefix")
|
|
|
|
if immediate_prefix:
|
|
|
|
immediate_prefix = immediate_prefix[0]
|
|
|
|
else:
|
|
|
|
immediate_prefix = "/"
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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_base = scope.get(f"{r}.base")
|
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}"
|
|
|
|
qrc_output += write_add_qt_resource_call(
|
|
|
|
target,
|
|
|
|
immediate_name,
|
|
|
|
immediate_prefix,
|
|
|
|
immediate_base,
|
|
|
|
immediate_lang,
|
|
|
|
immediate_files,
|
|
|
|
skip_qtquick_compiler,
|
|
|
|
retain_qtquick_compiler,
|
|
|
|
is_example,
|
|
|
|
)
|
2019-08-09 12:15:42 +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 "*" in r:
|
2019-09-03 13:25:55 +00:00
|
|
|
global resource_file_expansion_counter
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 = r.replace('"', "")
|
|
|
|
|
|
|
|
qrc_output += 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()
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
standalone_files.append(
|
|
|
|
f"${{resource_glob_{resource_file_expansion_counter}}}"
|
|
|
|
)
|
2019-09-03 13:25:55 +00:00
|
|
|
resource_file_expansion_counter += 1
|
|
|
|
else:
|
|
|
|
# stadalone source file properties need to be set as they
|
|
|
|
# are parsed.
|
|
|
|
if 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
|
|
|
qrc_output += 'set_source_files_properties(f"{r}" PROPERTIES QT_SKIP_QUICKCOMPILER 1)\n\n'
|
2019-09-03 13:25:55 +00:00
|
|
|
|
|
|
|
if retain_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
|
|
|
qrc_output += 'set_source_files_properties(f"{r}" PROPERTIES QT_RETAIN_QUICKCOMPILER 1)\n\n'
|
2019-09-03 13:25:55 +00:00
|
|
|
standalone_files.append(r)
|
2019-08-09 12:15:42 +00:00
|
|
|
|
|
|
|
if standalone_files:
|
|
|
|
name = "qmake_immediate"
|
|
|
|
prefix = "/"
|
|
|
|
base = None
|
|
|
|
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
|
|
|
files = {f: "" for f in standalone_files}
|
2019-08-09 12:15:42 +00:00
|
|
|
skip_qtquick_compiler = 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
|
|
|
qrc_output += write_add_qt_resource_call(
|
|
|
|
target,
|
|
|
|
name,
|
|
|
|
prefix,
|
|
|
|
base,
|
|
|
|
lang,
|
|
|
|
files,
|
|
|
|
skip_qtquick_compiler=False,
|
|
|
|
retain_qtquick_compiler=False,
|
|
|
|
is_example=is_example,
|
|
|
|
)
|
2019-03-07 10:06:23 +00:00
|
|
|
|
|
|
|
if qrc_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
|
|
|
cm_fh.write("\n# Resources:\n")
|
|
|
|
for line in qrc_output.split("\n"):
|
|
|
|
cm_fh.write(f"{' ' * indent}{line}\n")
|
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
|
|
|
def write_extend_target(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
|
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()
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 = (
|
|
|
|
f"\n{ind}extend_target({target} CONDITION"
|
|
|
|
f" {map_to_cmake_condition(scope.total_condition)}\n"
|
|
|
|
f"{extend_qt_string}{ind})\n"
|
|
|
|
)
|
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-03-07 10:06:23 +00:00
|
|
|
write_resources(cm_fh, target, scope, 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
|
|
|
|
|
|
|
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:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
known_scopes = {} # type: Mapping[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-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(
|
|
|
|
cm_fh,
|
|
|
|
scope,
|
|
|
|
"SOURCES",
|
|
|
|
[f"{SIMD}_HEADERS", f"{SIMD}_SOURCES", f"{SIMD}_C_SOURCES", f"{SIMD}_ASM"],
|
|
|
|
indent,
|
|
|
|
header=f"add_qt_simd_part({target} SIMD {simd}\n",
|
|
|
|
footer=")\n\n",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
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-06-24 12:54:40 +00:00
|
|
|
|
|
|
|
has_no_values = True
|
|
|
|
for key in keys:
|
|
|
|
value = scope.get(key)
|
|
|
|
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")
|
|
|
|
|
|
|
|
|
|
|
|
def write_main_part(
|
|
|
|
cm_fh: IO[str],
|
|
|
|
name: str,
|
|
|
|
typename: str,
|
|
|
|
cmake_function: str,
|
|
|
|
scope: Scope,
|
|
|
|
*,
|
|
|
|
extra_lines: List[str] = [],
|
|
|
|
indent: int = 0,
|
|
|
|
extra_keys: List[str],
|
|
|
|
**kwargs: Any,
|
|
|
|
):
|
2019-01-24 15:01:17 +00:00
|
|
|
# Evaluate total condition of all scopes:
|
|
|
|
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
|
|
|
is_qml_plugin = any("qml_plugin" == s for s in scope.get("_LOADED"))
|
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
|
|
|
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)
|
|
|
|
|
|
|
|
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":
|
|
|
|
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
|
|
|
|
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:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 destdir.startswith("./") or destdir.startswith("../"):
|
|
|
|
destdir = "${CMAKE_CURRENT_BINARY_DIR}/" + destdir
|
|
|
|
extra_lines.append(f'OUTPUT_DIRECTORY "{destdir}"')
|
2019-08-07 12:45: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
|
|
|
cm_fh.write(f"{spaces(indent)}{cmake_function}({name}\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
|
|
|
|
2019-03-07 10:06:23 +00:00
|
|
|
write_resources(cm_fh, name, scope, indent)
|
|
|
|
|
2019-03-11 14:09:33 +00:00
|
|
|
write_simd_part(cm_fh, name, scope, indent)
|
|
|
|
|
2019-06-24 12:54:40 +00:00
|
|
|
write_android_part(cm_fh, name, scopes[0], indent)
|
|
|
|
|
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-01-22 13:20:47 +00:00
|
|
|
write_extend_target(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
|
|
|
|
|
|
|
def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
2019-01-29 09:18:21 +00:00
|
|
|
module_name = scope.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
|
|
|
if not module_name.startswith("Qt"):
|
|
|
|
print(f"XXXXXX Module name {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
|
|
|
|
|
|
|
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"):
|
|
|
|
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")
|
|
|
|
if "header_module" in scope.get("CONFIG"):
|
|
|
|
extra.append("HEADER_MODULE")
|
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
|
|
|
|
2019-09-18 07:27:22 +00:00
|
|
|
target_name = module_name[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
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
target_name,
|
|
|
|
"Module",
|
|
|
|
"add_qt_module",
|
|
|
|
scope,
|
|
|
|
extra_lines=extra,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries={},
|
|
|
|
extra_keys=[],
|
|
|
|
)
|
|
|
|
|
|
|
|
if "qt_tracepoints" in scope.get("CONFIG"):
|
|
|
|
tracepoints = scope.get_files("TRACEPOINT_PROVIDER")
|
|
|
|
cm_fh.write(
|
|
|
|
f"\n\n{spaces(indent)}qt_create_tracepoints({module_name[2:]} {' '.join(tracepoints)})\n"
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-09-18 07:27:22 +00:00
|
|
|
return target_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_tool(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
2019-01-29 09:18:21 +00:00
|
|
|
tool_name = scope.TARGET
|
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
|
|
|
extra = ["BOOTSTRAP"] if "force_bootstrap" in scope.get("CONFIG") else []
|
2019-03-01 12:32: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
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
tool_name,
|
|
|
|
"Tool",
|
|
|
|
"add_qt_tool",
|
|
|
|
scope,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries={"Qt::Core"},
|
|
|
|
extra_lines=extra,
|
|
|
|
extra_keys=["CONFIG"],
|
|
|
|
)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-09-18 07:27:22 +00:00
|
|
|
return tool_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_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}"')
|
|
|
|
|
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
test_name,
|
|
|
|
"Test",
|
|
|
|
"add_qt_test",
|
|
|
|
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
|
|
|
|
|
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_binary(cm_fh: IO[str], scope: Scope, gui: bool = False, *, indent: int = 0) -> None:
|
2019-01-29 09:18:21 +00:00
|
|
|
binary_name = scope.TARGET
|
2018-10-24 13:20:27 +00:00
|
|
|
assert binary_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
|
|
|
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 []
|
|
|
|
cmake_function_call = "add_qt_executable"
|
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"
|
|
|
|
cmake_function_call = "add_qt_test_helper"
|
2019-03-18 18:15:22 +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("target.path")
|
2019-03-18 18:15:22 +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
|
|
|
target_path = target_path.replace("$$[QT_INSTALL_EXAMPLES]", "${INSTALL_EXAMPLESDIR}")
|
|
|
|
extra.append(f'OUTPUT_DIRECTORY "{target_path}"')
|
|
|
|
if "target" in scope.get("INSTALLS"):
|
|
|
|
extra.append(f'INSTALL_DIRECTORY "{target_path}"')
|
|
|
|
|
|
|
|
write_main_part(
|
|
|
|
cm_fh,
|
|
|
|
binary_name,
|
|
|
|
"Binary",
|
|
|
|
cmake_function_call,
|
|
|
|
scope,
|
|
|
|
extra_lines=extra,
|
|
|
|
indent=indent,
|
|
|
|
known_libraries={"Qt::Core"},
|
|
|
|
extra_keys=["target.path", "INSTALLS"],
|
|
|
|
)
|
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(
|
|
|
|
cm_fh: IO[str], public_libs: List[str], private_libs: List[str], *, indent: int = 0
|
|
|
|
):
|
|
|
|
packages = [] # type: List[LibraryMapping]
|
2019-05-09 08:59:13 +00:00
|
|
|
all_libs = public_libs + private_libs
|
|
|
|
|
|
|
|
for l in all_libs:
|
|
|
|
info = find_library_info_for_target(l)
|
|
|
|
if info and info not in packages:
|
|
|
|
packages.append(info)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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-05-09 08:59:13 +00:00
|
|
|
|
|
|
|
for p in packages:
|
|
|
|
cm_fh.write(generate_find_package_info(p, use_qt_find_package=False, indent=indent))
|
|
|
|
|
|
|
|
if packages:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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-09-03 12:32:43 +00:00
|
|
|
def write_example(
|
|
|
|
cm_fh: IO[str], scope: Scope, gui: bool = False, *, indent: int = 0, is_plugin: bool = False
|
|
|
|
) -> str:
|
2019-05-07 09:27:33 +00:00
|
|
|
binary_name = scope.TARGET
|
|
|
|
assert binary_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
|
|
|
cm_fh.write(
|
|
|
|
"cmake_minimum_required(VERSION 3.14)\n"
|
|
|
|
f"project({binary_name} LANGUAGES CXX)\n\n"
|
|
|
|
"set(CMAKE_INCLUDE_CURRENT_DIR ON)\n\n"
|
|
|
|
"set(CMAKE_AUTOMOC ON)\n"
|
|
|
|
"set(CMAKE_AUTORCC ON)\n"
|
|
|
|
"set(CMAKE_AUTOUIC ON)\n\n"
|
|
|
|
'set(INSTALL_EXAMPLEDIR "examples")\n\n'
|
|
|
|
)
|
2019-05-07 09:27:33 +00:00
|
|
|
|
2019-05-09 08:59:13 +00:00
|
|
|
(public_libs, private_libs) = extract_cmake_libraries(scope)
|
|
|
|
write_find_package_section(cm_fh, public_libs, private_libs, indent=indent)
|
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
add_target = ""
|
|
|
|
|
|
|
|
qmldir = None
|
|
|
|
if is_plugin:
|
|
|
|
if "qml" in scope.get("QT"):
|
|
|
|
# Get the uri from the destination directory
|
|
|
|
dest_dir = scope.expandString("DESTDIR")
|
|
|
|
if not dest_dir:
|
|
|
|
dest_dir = "${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
else:
|
|
|
|
uri = os.path.basename(dest_dir)
|
|
|
|
dest_dir = "${CMAKE_CURRENT_BINARY_DIR}/" + dest_dir
|
2019-05-07 09:27:33 +00:00
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
add_target = f"qt6_add_qml_module({binary_name}\n"
|
|
|
|
add_target += f' OUTPUT_DIRECTORY "{dest_dir}"\n'
|
|
|
|
add_target += " VERSION 1.0\n"
|
|
|
|
add_target += ' URI "{}"\n'.format(uri)
|
|
|
|
|
|
|
|
qmldir_file_path = scope.get_files("qmldir.files")
|
|
|
|
if qmldir_file_path:
|
|
|
|
qmldir_file_path = os.path.join(os.getcwd(), qmldir_file_path[0])
|
|
|
|
else:
|
|
|
|
qmldir_file_path = os.path.join(os.getcwd(), "qmldir")
|
|
|
|
|
|
|
|
if os.path.exists(qmldir_file_path):
|
|
|
|
qml_dir = QmlDir()
|
|
|
|
qml_dir.from_file(qmldir_file_path)
|
|
|
|
if qml_dir.designer_supported:
|
|
|
|
add_target += " DESIGNER_SUPPORTED\n"
|
|
|
|
if len(qml_dir.classname) != 0:
|
|
|
|
add_target += f" CLASSNAME {qml_dir.classname}\n"
|
|
|
|
if len(qml_dir.imports) != 0:
|
|
|
|
add_target += " IMPORTS\n{}".format(" \n".join(qml_dir.imports))
|
|
|
|
if len(qml_dir.depends) != 0:
|
|
|
|
add_target += " DEPENDENCIES\n"
|
|
|
|
for dep in qml_dir.depends:
|
|
|
|
add_target += f" {dep[0]}/{dep[1]}\n"
|
|
|
|
|
|
|
|
add_target += " INSTALL_LOCATION ${INSTALL_EXAMPLEDIR}\n)\n\n"
|
|
|
|
add_target += f"target_sources({binary_name} PRIVATE"
|
|
|
|
else:
|
|
|
|
add_target = f"add_library({binary_name} MODULE"
|
|
|
|
|
|
|
|
else:
|
|
|
|
add_target = f'add_{"qt_gui_" if gui else ""}executable({binary_name}'
|
|
|
|
|
|
|
|
write_all_source_file_lists(cm_fh, scope, add_target, indent=0)
|
2019-05-07 09:27:33 +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(")\n")
|
|
|
|
|
|
|
|
write_include_paths(
|
|
|
|
cm_fh, scope, f"target_include_directories({binary_name} PUBLIC", indent=0, footer=")"
|
|
|
|
)
|
|
|
|
write_defines(
|
2019-09-03 12:32:43 +00:00
|
|
|
cm_fh,
|
|
|
|
scope,
|
|
|
|
"target_compile_definitions({} PUBLIC".format(binary_name),
|
|
|
|
indent=0,
|
|
|
|
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
|
|
|
)
|
|
|
|
write_list(
|
|
|
|
cm_fh,
|
|
|
|
private_libs,
|
|
|
|
"",
|
|
|
|
indent=indent,
|
2019-09-03 12:32:43 +00:00
|
|
|
header="target_link_libraries({} PRIVATE\n".format(binary_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
|
|
|
footer=")",
|
|
|
|
)
|
|
|
|
write_list(
|
|
|
|
cm_fh,
|
|
|
|
public_libs,
|
|
|
|
"",
|
|
|
|
indent=indent,
|
2019-09-03 12:32:43 +00:00
|
|
|
header="target_link_libraries({} PUBLIC\n".format(binary_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
|
|
|
footer=")",
|
|
|
|
)
|
|
|
|
write_compile_options(
|
2019-09-03 12:32:43 +00:00
|
|
|
cm_fh, scope, "target_compile_options({}".format(binary_name), indent=0, 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
|
|
|
)
|
|
|
|
|
|
|
|
write_resources(cm_fh, binary_name, scope, indent=indent, is_example=True)
|
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
if qmldir:
|
|
|
|
write_qml_plugin_epilogue(cm_fh, binary_name, scope, qmldir, 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
|
|
|
cm_fh.write(
|
2019-09-03 12:32:43 +00:00
|
|
|
"\ninstall(TARGETS {}\n".format(binary_name)
|
|
|
|
+ ' RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"\n'
|
|
|
|
+ ' BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"\n'
|
|
|
|
+ ' LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"\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-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:
|
2019-01-29 09:18:21 +00:00
|
|
|
plugin_name = scope.TARGET
|
2018-10-24 13:20:27 +00:00
|
|
|
assert plugin_name
|
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
extra = []
|
|
|
|
|
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")
|
|
|
|
is_qml_plugin = any("qml_plugin" == s for s in scope.get("_LOADED"))
|
|
|
|
plugin_function_name = "add_qt_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:
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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_function_name = "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-05-03 14:03:15 +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
|
|
|
plugin_class_name = scope.get_string("PLUGIN_CLASS_NAME")
|
2019-05-03 14:03:15 +00:00
|
|
|
if plugin_class_name:
|
2019-09-03 12:32:43 +00:00
|
|
|
extra.append("CLASS_NAME {}".format(plugin_class_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
|
|
|
|
|
|
|
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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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-03 12:32:43 +00:00
|
|
|
extra_lines: typing.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
|
|
|
indent: int = 0,
|
2019-09-03 12:32:43 +00:00
|
|
|
**kwargs: typing.Any,
|
|
|
|
) -> QmlDir:
|
2019-06-05 11:39:41 +00:00
|
|
|
# Collect other args if available
|
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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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_version = scope.get_string("IMPORT_VERSION")
|
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
|
|
|
import_version = import_version.replace(
|
|
|
|
"$$QT_MINOR_VERSION", "${CMAKE_PROJECT_VERSION_MINOR}"
|
|
|
|
)
|
|
|
|
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-09-03 12:32:43 +00:00
|
|
|
qmldir_file_path = os.path.join(os.getcwd(), "qmldir")
|
|
|
|
if os.path.exists(qmldir_file_path):
|
|
|
|
qml_dir = QmlDir()
|
|
|
|
qml_dir.from_file(qmldir_file_path)
|
|
|
|
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.imports) != 0:
|
|
|
|
extra_lines.append("IMPORTS\n {}".format("\n ".join(qml_dir.imports)))
|
|
|
|
if len(qml_dir.depends) != 0:
|
|
|
|
extra_lines.append("DEPENDENCIES")
|
|
|
|
for dep in qml_dir.depends:
|
|
|
|
extra_lines.append(f" {dep[0]}/{dep[1]}")
|
|
|
|
|
|
|
|
return qml_dir
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
2019-08-01 13:43:36 +00:00
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
def write_qml_plugin_epilogue(
|
|
|
|
cm_fh: typing.IO[str], target: str, scope: Scope, qmldir: QmlDir, indent: int = 0
|
|
|
|
):
|
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-03 12:32:43 +00:00
|
|
|
qml_files_quoted = ['"{}"'.format(f) for f 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
|
|
|
|
|
|
|
cm_fh.write(
|
2019-09-03 12:32:43 +00:00
|
|
|
"\n{}set(qml_files\n{}{}\n)\n".format(
|
|
|
|
indent_0, indent_1, "\n{}".format(indent_1).join(qml_files_quoted)
|
|
|
|
)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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]
|
|
|
|
cm_fh.write(
|
|
|
|
"{}set_source_files_properties({} PROPERTIES\n".format(indent_0, qml_file)
|
|
|
|
)
|
|
|
|
cm_fh.write(
|
|
|
|
'{}QT_QML_SOURCE_VERSION "{}"\n'.format(indent_1, qmldir_file_info.version)
|
|
|
|
)
|
|
|
|
# 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
|
|
|
|
):
|
|
|
|
cm_fh.write(
|
|
|
|
"{}QT_QML_SOURCE_TYPENAME {}\n".format(indent_1, qmldir_file_info.type_name)
|
|
|
|
)
|
|
|
|
cm_fh.write("{}QT_QML_SOURCE_INSTALL TRUE\n".format(indent_1))
|
|
|
|
if qmldir_file_info.singleton:
|
|
|
|
cm_fh.write("{}QT_QML_SINGLETON_TYPE TRUE\n".format(indent_1))
|
|
|
|
if qmldir_file_info.internal:
|
|
|
|
cm_fh.write("{}QT_QML_INTERNAL_TYPE TRUE\n".format(indent_1))
|
|
|
|
cm_fh.write("{})\n".format(indent_0))
|
|
|
|
|
|
|
|
cm_fh.write(
|
|
|
|
"\n{}qt6_target_qml_files({}\n{}FILES\n{}${{qml_files}}\n)\n".format(
|
|
|
|
indent_0, target, indent_1, spaces(indent + 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
|
|
|
|
|
|
|
|
|
|
|
def handle_app_or_lib(
|
|
|
|
scope: Scope, cm_fh: IO[str], *, indent: int = 0, is_example: bool = False
|
|
|
|
) -> None:
|
|
|
|
assert scope.TEMPLATE in ("app", "lib")
|
|
|
|
|
|
|
|
config = scope.get("CONFIG")
|
|
|
|
is_lib = scope.TEMPLATE == "lib"
|
|
|
|
is_qml_plugin = any("qml_plugin" == s for s in scope.get("_LOADED"))
|
|
|
|
is_plugin = (
|
|
|
|
any("qt_plugin" == s for s in scope.get("_LOADED")) or is_qml_plugin or "plugin" in config
|
|
|
|
)
|
2019-09-18 07:27:22 +00:00
|
|
|
target = ""
|
2019-09-03 12:32:43 +00:00
|
|
|
gui = all(
|
|
|
|
val not in config for val in ["console", "cmdline"]
|
|
|
|
) and "testlib" not in scope.expand("QT")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-09-03 12:32:43 +00:00
|
|
|
if is_example:
|
|
|
|
target = write_example(cm_fh, scope, gui, indent=indent, is_plugin=is_plugin)
|
|
|
|
elif is_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)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 is_lib or "qt_module" in scope.get("_LOADED"):
|
2019-08-07 12:25:50 +00:00
|
|
|
assert not is_example
|
2019-09-18 07:27:22 +00:00
|
|
|
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
|
2019-09-18 07:27:22 +00:00
|
|
|
target = write_tool(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
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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)
|
|
|
|
write_source_file_list(
|
2019-09-19 07:34:46 +00:00
|
|
|
cm_fh, scope, "", ["QMAKE_DOCS"], indent, header=f"add_qt_docs({target}\n", 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
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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(
|
|
|
|
f"""\
|
|
|
|
cmake_minimum_required(VERSION {cmake_version_string})
|
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
|
|
|
project({qt_lib}
|
|
|
|
VERSION 6.0.0
|
|
|
|
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)
|
|
|
|
qt_build_repo()
|
|
|
|
"""
|
|
|
|
)
|
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
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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]:
|
2019-09-09 08:52:27 +00:00
|
|
|
qmake_conf_path = find_qmake_conf(project_file_path)
|
|
|
|
qmake_dir = os.path.dirname(qmake_conf_path)
|
|
|
|
|
|
|
|
# Hope to a programming god that there's only one .pro file at the
|
|
|
|
# top level directory of repository.
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `except` for sympy (SympifyError, TypeError)
Change-Id: Ie05f754e7d8ee4bf427117c58e0eb1b903202933
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-16 22:11:17 +00:00
|
|
|
glob_result = glob.glob(os.path.join(qmake_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-09 08:52:27 +00:00
|
|
|
top_level_project_path = find_top_level_repo_project_file(scope.file_absolute_path)
|
|
|
|
if top_level_project_path:
|
|
|
|
# qtdeclarative
|
|
|
|
file_name = os.path.splitext(os.path.basename(top_level_project_path))[0]
|
|
|
|
|
|
|
|
# declarative
|
|
|
|
file_name_without_qt = file_name[2:]
|
|
|
|
|
|
|
|
# Qt::Declarative
|
|
|
|
qt_lib = map_qt_library(file_name_without_qt)
|
|
|
|
|
|
|
|
# Found a mapping, adjust name.
|
|
|
|
if qt_lib != file_name_without_qt:
|
|
|
|
# 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) + "Tests"
|
2019-09-09 08:52:27 +00:00
|
|
|
else:
|
|
|
|
qt_lib += "Tests_FIXME"
|
|
|
|
else:
|
|
|
|
qt_lib = "Tests_FIXME"
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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(
|
|
|
|
f"""\
|
|
|
|
if(NOT TARGET Qt::Test)
|
|
|
|
cmake_minimum_required(VERSION {cmake_version_string})
|
|
|
|
project({qt_lib} VERSION 6.0.0 LANGUAGES C CXX)
|
|
|
|
find_package(Qt6 ${{PROJECT_VERSION}} REQUIRED COMPONENTS BuildInternals Core SET_ME_TO_SOMETHING_USEFUL)
|
|
|
|
find_package(Qt6 ${{PROJECT_VERSION}} OPTIONAL_COMPONENTS SET_ME_TO_SOMETHING_USEFUL)
|
|
|
|
qt_set_up_standalone_tests_build()
|
|
|
|
endif()
|
|
|
|
qt_build_tests()"""
|
|
|
|
)
|
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
|
|
|
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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(
|
|
|
|
scope: Scope, cm_fh: IO[str], *, indent: int = 0, is_example: bool = False
|
|
|
|
) -> None:
|
2019-01-29 09:18:21 +00:00
|
|
|
template = scope.TEMPLATE
|
2019-09-09 08:52:27 +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):
|
|
|
|
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)
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 template == "subdirs":
|
2019-09-09 08:52:27 +00:00
|
|
|
handle_subdir(scope, temp_buffer, indent=indent, 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
|
|
|
elif template in ("app", "lib"):
|
2019-09-09 08:52:27 +00:00
|
|
|
handle_app_or_lib(scope, temp_buffer, indent=indent, is_example=is_example)
|
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" XXXX: {scope.file}: Template type {template} not yet supported.")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-09-09 08:52:27 +00:00
|
|
|
buffer_value = temp_buffer.getvalue()
|
|
|
|
|
|
|
|
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.
|
2019-09-18 13:22:34 +00:00
|
|
|
buffer_value = f"\nqt_examples_build_begin()\n\n{buffer_value}\nqt_examples_build_end()"
|
2019-09-09 08:52:27 +00:00
|
|
|
|
|
|
|
cm_fh.write(buffer_value)
|
|
|
|
|
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 generate_new_cmakelists(scope: Scope, *, is_example: bool = False) -> None:
|
|
|
|
print("Generating CMakeLists.gen.txt")
|
|
|
|
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
|
|
|
|
cmakeify_scope(scope, cm_fh, is_example=final_is_example_decision)
|
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)
|
|
|
|
|
Improve styling of util/cmake scripts
flake8 was used to evaluate the file, with a couple of exeptions:
E501,E266,W503
black was used to reformat the code automatically
The changes were:
* Added a README that explains how to use pipenv and pip,
* Remove unnecessary return statements,
* Remove '\' from the end of the lines,
* Use f-strings (>= 3.6) since we are requiring Python 3.7,
* Commenting unused variables,
* Adding assert when Python >= 3.7 is not being used,
* Wrapping long lines to 100 (Qt Style),
* Re-factoring some lines,
* Re-ordering imports,
* Naming `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 include_file in scope.get_files("_INCLUDED", is_include=True):
|
2018-12-21 11:13:38 +00:00
|
|
|
if not include_file:
|
|
|
|
continue
|
2018-10-24 13:20:27 +00:00
|
|
|
if not os.path.isfile(include_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
|
|
|
print(f" XXXX: Failed to include {include_file}.")
|
2018-10-24 13:20:27 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
include_result = 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(
|
|
|
|
None, include_file, include_result.asDict().get("statements"), "", scope.basedir
|
|
|
|
) # This scope will be merged into scope!
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
do_include(include_scope)
|
|
|
|
|
|
|
|
scope.merge(include_scope)
|
|
|
|
|
|
|
|
|
2019-05-04 11:08:19 +00:00
|
|
|
def copy_generated_file_to_final_location(scope: Scope, keep_temporary_files=False) -> 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
|
|
|
print(f"Copying {scope.generated_cmake_lists_path} to {scope.original_cmake_lists_path}")
|
2019-05-04 11:08:19 +00:00
|
|
|
copyfile(scope.generated_cmake_lists_path, scope.original_cmake_lists_path)
|
|
|
|
if not keep_temporary_files:
|
|
|
|
os.remove(scope.generated_cmake_lists_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 should_convert_project(project_file_path: str = "") -> bool:
|
2019-09-09 12:29:12 +00:00
|
|
|
qmake_conf_path = find_qmake_conf(project_file_path)
|
|
|
|
qmake_conf_dir_path = os.path.dirname(qmake_conf_path)
|
|
|
|
|
|
|
|
project_relative_path = os.path.relpath(project_file_path, qmake_conf_dir_path)
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
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-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-09-09 12:29:12 +00:00
|
|
|
if not should_convert_project(project_file_absolute_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(f'Skipping conversion of project: "{project_file_absolute_path}"')
|
2019-09-09 12:29:12 +00:00
|
|
|
continue
|
|
|
|
|
2019-05-07 14:46:28 +00:00
|
|
|
parseresult = parseProFile(file_relative_path, debug=debug_parsing)
|
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(
|
|
|
|
None, file_relative_path, parseresult.asDict().get("statements")
|
|
|
|
)
|
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-05-04 11:08:19 +00:00
|
|
|
generate_new_cmakelists(file_scope, is_example=args.is_example)
|
|
|
|
|
|
|
|
copy_generated_file = True
|
|
|
|
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(
|
|
|
|
file_scope.original_cmake_lists_path,
|
|
|
|
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(
|
|
|
|
file_scope, keep_temporary_files=args.keep_temporary_files
|
|
|
|
)
|
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()
|