Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nadult committed Nov 25, 2023
1 parent 699f621 commit 3cfd7f1
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ AllowShortFunctionsOnASingleLine: All
NamespaceIndentation: Inner
SpaceBeforeParens: Never
FixNamespaceComments: false
Standard: Cpp11
Standard: Latest
IndentRequires: true
BreakBeforeConceptDeclarations: false
BreakBeforeTernaryOperators: false

#RequiresClausePosition: OwnLine
#IndentRequiresClause: true

DeriveLineEnding: false
UseCRLF: false
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: build

on:
push:
pull_request:
workflow_run:
# Use a workflow as a trigger of scheduled builds. Forked repositories can disable scheduled builds by disabling
# "scheduled" workflow, while maintaining ability to perform local CI builds.
workflows:
- scheduled
branches:
- main
- test_actions
types:
- requested

jobs:
cpp-formatting-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

- name: Install Dependencies
run: |
git submodule update --init
- name: Check formatting
run: |
python tools/format.py
57 changes: 57 additions & 0 deletions tools/format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3

import argparse, os, subprocess, shutil

# if ! command -v clang-format &> /dev/null ; then
# echo "clang-format is not available. Please install version 14 "
# echo "and make sure that it is accessible from PATH."
# exit
# fi

# cfversion=`clang-format --version | grep -Eo '[0-9]+' | head -1`
# if [ "$cfversion" != "14" ]; then
# echo "Warning: Invalid clang-format version: ${cfversion} (should be 14)"
# fi

# clang-format -i *.cc *.h boxpack/*.cc boxpack/*.h


def verify_clang_format():
if shutil.which('clang-format') is None:
print('clang-format is missing')
exit(1)
result = subprocess.run(['clang-format', '--version'], stdout=subprocess.PIPE)
tokens = result.stdout.decode("utf-8").split()
while len(tokens) > 0 and tokens[0] != 'clang-format':
tokens.pop(0)
if result.returncode != 0 or len(tokens) < 3 or tokens[0] != 'clang-format' or tokens[1] != 'version':
print('error while checking clang-format version')
exit(1)
version = tokens[2].split('.', 2)
print(f"clang-format version: {version[0]}.{version[1]}.{version[2]}")


def format_cpp(check: bool):
print("meh")


def main():
parser = argparse.ArgumentParser(
prog='libfwk-format',
description='Tool for code formatting and format verification',
)
parser.add_argument('-c', '--check', action='store_true')
args = parser.parse_args()

libfwk_path = os.path.join(__file__, '..')

if args.check:
print('Checking mode')
else:
print('Formatting mode')

verify_clang_format()


if __name__ == "__main__":
main()

0 comments on commit 3cfd7f1

Please sign in to comment.