Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only fail qmlformat stage if Qt >= 5.15 is used #3929

Merged
merged 4 commits into from
Jun 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions tools/qmlformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@
import re

QMLFORMAT_MISSING_MESSAGE = """
qmlformat is not installed or not in your $PATH. It is included in Qt 5.15
and later. If that Qt version is not available on your system, please
use the SKIP environment variable when committing:
$ SKIP=qmlformat git commit
qmlformat is not installed or not in your $PATH, please install.
"""


def main(argv=None):
qmlformat_executable = shutil.which("qmlformat")
if not qmlformat_executable:
# verify if qmlformat is available on this machine
moc_executable = shutil.which("moc")
if moc_executable:
moc_version = subprocess.check_output(
(moc_executable, "-v")
).strip()
v = re.search("moc ([0-9]*)\\.([0-9]*)\\.[0-9]*", str(moc_version))
if v:
version = (int(v.group(1)), int(v.group(2)))
if version < (5, 15):
# Succeed if a Qt Version < 5.15 is used without qmlformat
return 0
print(QMLFORMAT_MISSING_MESSAGE.strip(), file=sys.stderr)
return 1

Expand Down