Skip to content

Commit 02df87e

Browse files
committed
github: Add instructions for Copilot
Add instructions for Copilot AI agent. Also include clang-format rules from Zephyr to help tools. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent a7c07a1 commit 02df87e

4 files changed

Lines changed: 667 additions & 0 deletions

File tree

.clang-format

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Zephyr RTOS clang-format rules
4+
#
5+
# Note: The list of ForEachMacros can be obtained using:
6+
#
7+
# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \
8+
# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \
9+
# | sort | uniq
10+
#
11+
# References:
12+
# - https://clang.llvm.org/docs/ClangFormatStyleOptions.html
13+
14+
---
15+
BasedOnStyle: LLVM
16+
AlignConsecutiveMacros: AcrossComments
17+
AllowShortBlocksOnASingleLine: Never
18+
AllowShortCaseLabelsOnASingleLine: false
19+
AllowShortEnumsOnASingleLine: false
20+
AllowShortFunctionsOnASingleLine: None
21+
AllowShortIfStatementsOnASingleLine: false
22+
AllowShortLoopsOnASingleLine: false
23+
AttributeMacros:
24+
- __aligned
25+
- __deprecated
26+
- __packed
27+
- __printf_like
28+
- __syscall
29+
- __syscall_always_inline
30+
- __subsystem
31+
BitFieldColonSpacing: After
32+
BreakBeforeBraces: Linux
33+
ColumnLimit: 100
34+
ConstructorInitializerIndentWidth: 8
35+
ContinuationIndentWidth: 8
36+
ForEachMacros:
37+
- 'ARRAY_FOR_EACH'
38+
- 'ARRAY_FOR_EACH_PTR'
39+
- 'FOR_EACH'
40+
- 'FOR_EACH_FIXED_ARG'
41+
- 'FOR_EACH_IDX'
42+
- 'FOR_EACH_IDX_FIXED_ARG'
43+
- 'FOR_EACH_NONEMPTY_TERM'
44+
- 'FOR_EACH_FIXED_ARG_NONEMPTY_TERM'
45+
- 'RB_FOR_EACH'
46+
- 'RB_FOR_EACH_CONTAINER'
47+
- 'SYS_DLIST_FOR_EACH_CONTAINER'
48+
- 'SYS_DLIST_FOR_EACH_CONTAINER_SAFE'
49+
- 'SYS_DLIST_FOR_EACH_NODE'
50+
- 'SYS_DLIST_FOR_EACH_NODE_SAFE'
51+
- 'SYS_SEM_LOCK'
52+
- 'SYS_SFLIST_FOR_EACH_CONTAINER'
53+
- 'SYS_SFLIST_FOR_EACH_CONTAINER_SAFE'
54+
- 'SYS_SFLIST_FOR_EACH_NODE'
55+
- 'SYS_SFLIST_FOR_EACH_NODE_SAFE'
56+
- 'SYS_SLIST_FOR_EACH_CONTAINER'
57+
- 'SYS_SLIST_FOR_EACH_CONTAINER_SAFE'
58+
- 'SYS_SLIST_FOR_EACH_NODE'
59+
- 'SYS_SLIST_FOR_EACH_NODE_SAFE'
60+
- '_WAIT_Q_FOR_EACH'
61+
- '_WAIT_Q_FOR_EACH_SAFE'
62+
- 'Z_FOR_EACH'
63+
- 'Z_FOR_EACH_ENGINE'
64+
- 'Z_FOR_EACH_EXEC'
65+
- 'Z_FOR_EACH_FIXED_ARG'
66+
- 'Z_FOR_EACH_FIXED_ARG_EXEC'
67+
- 'Z_FOR_EACH_IDX'
68+
- 'Z_FOR_EACH_IDX_EXEC'
69+
- 'Z_FOR_EACH_IDX_FIXED_ARG'
70+
- 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC'
71+
- 'Z_GENLIST_FOR_EACH_CONTAINER'
72+
- 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE'
73+
- 'Z_GENLIST_FOR_EACH_NODE'
74+
- 'Z_GENLIST_FOR_EACH_NODE_SAFE'
75+
- 'STRUCT_SECTION_FOREACH'
76+
- 'STRUCT_SECTION_FOREACH_ALTERNATE'
77+
- 'TYPE_SECTION_FOREACH'
78+
- 'K_SPINLOCK'
79+
- 'COAP_RESOURCE_FOREACH'
80+
- 'COAP_SERVICE_FOREACH'
81+
- 'COAP_SERVICE_FOREACH_RESOURCE'
82+
- 'HTTP_RESOURCE_FOREACH'
83+
- 'HTTP_SERVER_CONTENT_TYPE_FOREACH'
84+
- 'HTTP_SERVICE_FOREACH'
85+
- 'HTTP_SERVICE_FOREACH_RESOURCE'
86+
- 'I3C_BUS_FOR_EACH_I3CDEV'
87+
- 'I3C_BUS_FOR_EACH_I3CDEV_SAFE'
88+
- 'I3C_BUS_FOR_EACH_I2CDEV'
89+
- 'I3C_BUS_FOR_EACH_I2CDEV_SAFE'
90+
- 'MIN_HEAP_FOREACH'
91+
IfMacros:
92+
- 'CHECKIF'
93+
# Disabled for now, see bug https://github.com/zephyrproject-rtos/zephyr/issues/48520
94+
#IncludeBlocks: Regroup
95+
IncludeCategories:
96+
- Regex: '^".*\.h"$'
97+
Priority: 0
98+
- Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h>$'
99+
Priority: 1
100+
- Regex: '^\<zephyr/.*\.h\>$'
101+
Priority: 2
102+
- Regex: '.*'
103+
Priority: 3
104+
IndentCaseLabels: false
105+
IndentGotoLabels: false
106+
IndentWidth: 8
107+
InsertBraces: true
108+
InsertNewlineAtEOF: true
109+
SpaceBeforeInheritanceColon: False
110+
SpaceBeforeParens: ControlStatementsExceptControlMacros
111+
SortIncludes: Never
112+
UseTab: ForContinuationAndIndentation
113+
WhitespaceSensitiveMacros:
114+
- COND_CODE_0
115+
- COND_CODE_1
116+
- IF_DISABLED
117+
- IF_ENABLED
118+
- LISTIFY
119+
- STRINGIFY
120+
- Z_STRINGIFY
121+
- DT_FOREACH_PROP_ELEM_SEP

0 commit comments

Comments
 (0)