Skip to content

Commit f68e8c0

Browse files
committed
Use consistent indent style throughout
Until now we've had multiple styles throught the project. This doesn't buy us anything for contributors as each source file might be different - totally negating the point of having a clang-format style in the first place - indeed I started debugging clang-format since it was apparently not formatting my adapter code as 4 spaces after my editor had loaded the editconfig file specifying 4 spaces. I wasted an hour on that! Here we codify everything as LLVM style, which seems to be used by the majority of the project. We also bump the clang-format version requirement to v18.1 to align with dpc++.
1 parent 222e4b1 commit f68e8c0

File tree

13 files changed

+18
-44
lines changed

13 files changed

+18
-44
lines changed

.clang-format

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
---
22
Language: Cpp
33
BasedOnStyle: LLVM
4-
IndentWidth: 4
5-
InsertBraces: true
6-
ReflowComments: false
74
...

.editorconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
[*]
22
indent_style = space
3+
indent_size = 2
4+
5+
[*.py]
36
indent_size = 4
47

5-
[.github/workflows/*.yml]
6-
indent_size = 2
8+
[scripts/core/*]
9+
indent_size = 4
10+
11+
[CMakeLists.txt]
12+
indent_size = 4
13+
14+
[*.cmake]
15+
indent_size = 4

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ endif()
236236

237237
# Check if clang-format (in correct version) is available for Cpp code formatting.
238238
if(UR_FORMAT_CPP_STYLE)
239-
find_program(CLANG_FORMAT NAMES clang-format-15 clang-format-15.0 clang-format)
239+
find_program(CLANG_FORMAT NAMES clang-format-18 clang-format-18.1 clang-format)
240240

241241
if(CLANG_FORMAT)
242242
get_program_version_major_minor(${CLANG_FORMAT} CLANG_FORMAT_VERSION)
243243
message(STATUS "Found clang-format: ${CLANG_FORMAT} (version: ${CLANG_FORMAT_VERSION})")
244244

245-
set(CLANG_FORMAT_REQUIRED "15.0")
245+
set(CLANG_FORMAT_REQUIRED "18.1")
246246
if(NOT (CLANG_FORMAT_VERSION VERSION_EQUAL CLANG_FORMAT_REQUIRED))
247247
message(FATAL_ERROR "required clang-format version is ${CLANG_FORMAT_REQUIRED}")
248248
endif()

REQUIREMENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
## API and Library Requirements
44

55
### API Namespace
6-
* API’s will clearly define the functionality
7-
* API’s will use a consistent style within the library
8-
* APIs will not allow namespace collision when multiple libraries are linked in the same user application
6+
* APIs will clearly define the functionality
7+
* APIs will use a consistent style within the library
8+
* APIs will not allow namespace collision when multiple libraries are linked in the same user application
99
* API will be consistent across libraries included in the product
1010
* Will not allow namespace collision when multiple libraries are linked in the same user application
1111
* Exceptions:

include/.clang-format

Lines changed: 0 additions & 8 deletions
This file was deleted.

scripts/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def jsonRead(path):
129129
def jsonWrite(path, data):
130130
try:
131131
with open(path, 'w') as fout:
132-
fout.write(json.dumps(data, indent=4, sort_keys=True))
132+
fout.write(json.dumps(data, indent=2, sort_keys=True))
133133
except:
134134
print("error: unable to write %s"%path)
135135

source/adapters/cuda/.clang-format

Lines changed: 0 additions & 4 deletions
This file was deleted.

source/adapters/hip/.clang-format

Lines changed: 0 additions & 4 deletions
This file was deleted.

source/adapters/level_zero/.clang-format

Lines changed: 0 additions & 4 deletions
This file was deleted.

source/adapters/native_cpu/.clang-format

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)