-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a231bb
commit ca40c9b
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
from setup import get_build_dir | ||
import subprocess | ||
import os | ||
import re | ||
from common import setup_common as setup | ||
|
||
# ------ | ||
# CHECKS | ||
# ------ | ||
|
||
issueFound = False | ||
|
||
def FAIL(message, line, path): | ||
print("Offending file:", path) | ||
print("Line:", line) | ||
print(message) | ||
print() | ||
global issueFound | ||
issueFound = True | ||
|
||
def CHECK(cond, line, message, path): | ||
if not cond(line): | ||
FAIL(message, line, path) | ||
return True | ||
return False | ||
|
||
|
||
# Common | ||
|
||
|
||
# Header files | ||
|
||
|
||
# Source files | ||
|
||
|
||
# ----- | ||
# UTILS | ||
# ----- | ||
|
||
def check_source(c, path): | ||
return | ||
|
||
def check_header(c, path): | ||
return | ||
|
||
def check_file(file_str): | ||
file = open(file_str, mode="r") | ||
content = file.read() | ||
file.close() | ||
|
||
if file_str.endswith('.h'): | ||
check_header(content, file_str) | ||
elif file_str.endswith('.cpp'): | ||
check_source(content, file_str) | ||
else: | ||
FAIL("Must only contain .h and .cpp files!", "NOT APPLICABLE", file_str) | ||
|
||
|
||
project_root = setup.ROOT | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
'check-format.py', description="Verify additional formatting options next to clang-format and clang-tidy") | ||
parser.add_argument('--verbose', action='store_true', | ||
help="Give verbose output") | ||
args = parser.parse_args() | ||
|
||
for dir in [project_root/'lib'/'al', project_root/'src']: | ||
for root, _, files in os.walk(dir): | ||
for file in files: | ||
file_path = os.path.join(root, file) | ||
file_str = str(file_path) | ||
check_file(file_str) | ||
|
||
if issueFound: | ||
exit(1) | ||
else: | ||
print("No issues found!") | ||
|
||
if __name__ == "__main__": | ||
main() |