Skip to content
Snippets Groups Projects
Commit 0f66152d authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Adrien Béraud
Browse files

build.py: allow initialization without installing pre-commit hook

Gitlab: #1219
Change-Id: I5a2e2099d6ad1b551e2d744ffbf800b79c36a821
parent 24a0a384
Branches
Tags
No related merge requests found
...@@ -329,7 +329,7 @@ def run_init(args): ...@@ -329,7 +329,7 @@ def run_init(args):
# The client submodule has QML files, so we need to run qmlformat on it, # The client submodule has QML files, so we need to run qmlformat on it,
# and thus need to supply the Qt path. # and thus need to supply the Qt path.
execute_script([f'{format_script} --install {client_hooks_dir}' execute_script([f'{format_script} --install {client_hooks_dir}'
f' --qt {args.qt}' if args.qt else ''], f' --qt {args.qt}'],
{"path": client_hooks_dir}) {"path": client_hooks_dir})
# The daemon submodule has no QML files, so we don't need to run # The daemon submodule has no QML files, so we don't need to run
......
...@@ -22,7 +22,7 @@ import shutil ...@@ -22,7 +22,7 @@ import shutil
from platform import uname from platform import uname
CFVERSION = "9" CFVERSION = "9"
CLANGFORMAT = "" CLANGFORMAT = None
QMLFORMAT = None QMLFORMAT = None
...@@ -138,27 +138,29 @@ def main(): ...@@ -138,27 +138,29 @@ def main():
args = parser.parse_args() args = parser.parse_args()
if args.type in ["cpp", "both"]: if args.type in ["cpp", "both"]:
if not command_exists("clang-format-" + CFVERSION): if command_exists("clang-format-" + CFVERSION):
if not command_exists("clang-format"):
print("Required version of clang-format not found")
sys.exit(1)
else:
CLANGFORMAT = "clang-format"
else:
CLANGFORMAT = "clang-format-" + CFVERSION CLANGFORMAT = "clang-format-" + CFVERSION
elif command_exists("clang-format"):
CLANGFORMAT = "clang-format"
if CLANGFORMAT is not None:
print("Using source formatter: " + CLANGFORMAT) print("Using source formatter: " + CLANGFORMAT)
else:
print("clang-format not found. can't format source files")
if args.qt is not None and args.type in ["qml", "both"]: if args.qt is not None and args.type in ["qml", "both"]:
global QMLFORMAT # pylint: disable=global-statement global QMLFORMAT # pylint: disable=global-statement
QMLFORMAT = find_qmlformat(args.qt) QMLFORMAT = find_qmlformat(args.qt)
if QMLFORMAT is not None: if QMLFORMAT is not None:
print("Using qmlformatter: " + QMLFORMAT) print("Using qmlformatter: " + QMLFORMAT)
else: else:
print("No qmlformat found, can't format QML files") print("qmlformat not found, can't format QML files")
if args.install: if args.install:
if CLANGFORMAT is not None or QMLFORMAT is not None:
install_hook(args.install, args.qt) install_hook(args.install, args.qt)
else:
print("No formatters found, skipping hook install")
sys.exit(0) sys.exit(0)
src_files = get_files([".cpp", ".cxx", ".cc", ".h", ".hpp"], src_files = get_files([".cpp", ".cxx", ".cc", ".h", ".hpp"],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment