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

Update clang-format to newer version (8) #72

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
14 changes: 8 additions & 6 deletions etc/scripts/check_format.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright 2018, Intel Corporation
# Copyright 2018-2019, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -35,7 +35,7 @@
Check involves applying clang-format and checking format of test designs
documentation comments located above test fixture macros.

Requires clang-format in version 3.9 installed on the system.
Requires clang-format in version 8 installed in the system.
"""

import sys
Expand All @@ -49,6 +49,7 @@
DESIGN_EXTENSIONS = ('.cc',)
CPP_EXTENSIONS = ('.c', '.cc', '.cpp', '.h', '.tpp', '.hpp')
CLANG_FORMAT_BIN = ''
REQUIRED_VERSION = str(8)


def format_file(filepath):
Expand Down Expand Up @@ -129,19 +130,20 @@ def check_prerequisites():

CLANG_FORMAT_BIN = find_clang_format()
if not CLANG_FORMAT_BIN:
sys.exit('No clang-format in version 3.9 found.')
sys.exit('No clang-format in version ' + REQUIRED_VERSION + ' found.')


def find_clang_format():
"""Find clang-format binary with appropriate version on system."""

returncode, out = check_utils.run('clang-format --version', shell=True)
if returncode == 0 and b'version 3.9' in out:
if returncode == 0 and 'version ' + REQUIRED_VERSION in str(out):
return 'clang-format'

returncode, _ = check_utils.run('clang-format-3.9 --version', shell=True)
alternative_binary = 'clang-format-' + REQUIRED_VERSION
returncode, _ = check_utils.run(alternative_binary + ' --version', shell=True)
if returncode == 0:
return 'clang-format-3.9'
return alternative_binary

return ''

Expand Down
4 changes: 2 additions & 2 deletions style-format.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2018, Intel Corporation
# Copyright 2018-2019, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -45,7 +45,7 @@ execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/etc/scripts/che
ERROR_QUIET)

if ("${PREREQUISITES_CHECK_ERROR}" GREATER "0")
message(WARNING "code-format.py prerequisites check failed - code style and formatting is disabled\nclang-format 3.9 is required")
message(WARNING "code-format.py prerequisites check failed - code style and formatting is disabled. clang-format 8 is required")
return()
endif ()

Expand Down