Skip to content

Commit

Permalink
style: added .clang-format (#371)
Browse files Browse the repository at this point in the history
- added .clang-format
- find . -name "*.c" -or -name "*.h" | xargs sed -e 's#/\* \*INDENT-ON\* \*/#/\* clang-format on \*/#g' -e 's#/\* \*INDENT-OFF\* \*/#/\* clang-format off \*/#g' -i
- find . -name "*.c" -or -name "*.h" | xargs clang-format-11 -i
- substituted hack/checkstyle.sh with simpler call to clang-format-11 in Makefile
- removed .dir-locals.el as it is likely to be wrong now
- fixed ci checkstyle to use clang-format
  • Loading branch information
demo-exe authored Jan 4, 2024
1 parent ed8738b commit f3b6ee7
Show file tree
Hide file tree
Showing 49 changed files with 12,379 additions and 12,992 deletions.
49 changes: 49 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# based on https://github.com/FDio/vpp/blob/f3b0004f8a5de433bf8a601a7e21c7f73b321cee/.clang-format
# Minimal clang-format version is 11

BasedOnStyle: GNU
UseTab: Never
SpaceAfterCStyleCast: true
SortIncludes: false
AlignConsecutiveMacros: true
BreakBeforeTernaryOperators: false
BreakBeforeBinaryOperators: None
ContinuationIndentWidth: 2

ForEachMacros:
- 'clib_bitmap_foreach'
- 'pool_foreach'
- 'pool_foreach_index'
- 'pool_foreach_pointer'
- 'vec_foreach'
- 'vec_foreach_backwards'
- 'vec_foreach_index'
- 'vec_foreach_index_backwards'
- 'vec_foreach_pointer'
- 'vlib_foreach_rx_tx'
- 'foreach_int'
- 'foreach_pointer'
- 'foreach_vlib_main'
- 'foreach_set_bit_index'
- 'foreach_vlib_frame_bitmap_set_bit_index'
- 'FOREACH_ARRAY_ELT'
- 'RTE_ETH_FOREACH_DEV'
- 'foreach_vnet_dev_rx_queue_runtime'
- 'foreach_vnet_dev_counter'
- 'foreach_vnet_dev_port_rx_queue'
- 'foreach_vnet_dev_port_tx_queue'
- 'foreach_vnet_dev_port'
- 'foreach_vnet_dev_args'
- 'foreach_vnet_dev_port_args'

StatementMacros:
- 'CLIB_MULTIARCH_FN'
- 'VLIB_NODE_FN'
- 'VNET_DEV_NODE_FN'
- 'VNET_DEVICE_CLASS_TX_FN'
- '__clib_section'
- '__clib_aligned'

WhitespaceSensitiveMacros:
- 'WARN_ON'
- 'WARN_OFF'
7 changes: 0 additions & 7 deletions .dir-locals.el

This file was deleted.

7 changes: 3 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ jobs:
password: ${{ secrets.CUR_REGISTRY_PASSWORD }}
- name: Checkout
uses: actions/checkout@v2
with:
# the checkstyle script needs a bit of git history
fetch-depth: 2
- name: Check the code style
run: make checkstyle
uses: jidicula/[email protected]
with:
clang-format-version: '11'

integration:
runs-on: ["self-hosted", "hugepages"]
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ version:
rm -f "$${ver_tmp}"; \
fi

# TODO: checktyle shouldn't require VPP checkout but presently it's
# needed for getting the build image tag
checkstyle:
SKIP_VPP_SOURCE_CHECK=1 hack/buildenv.sh hack/checkstyle.sh
find . -name "*.c" -or -name "*.h" | xargs clang-format-11 -n --Werror

ci-build: version
hack/ci-build.sh
Expand Down
155 changes: 0 additions & 155 deletions hack/checkstyle.sh

This file was deleted.

Loading

0 comments on commit f3b6ee7

Please sign in to comment.