Skip to content

Commit 751a691

Browse files
authored
pre-commit: keep sorted lists in order (#9024)
1 parent 4b6ed82 commit 751a691

19 files changed

Lines changed: 168 additions & 106 deletions

File tree

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
# keep-sorted start skip_lines=10
23
Checks: >
34
*,
45
-abseil-*,
@@ -159,6 +160,7 @@ Checks: >
159160
-readability-use-anyofallof,
160161
-readability-use-concise-preprocessor-directives,
161162
-readability-use-std-min-max,
163+
# keep-sorted end
162164
WarningsAsErrors: '*'
163165
HeaderFilterRegex: '.*'
164166
ExcludeHeaderFilterRegex: '\.fbs\.h|common/cmdline\.h|/mini_\w*\.h'

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ repos:
6767
hooks:
6868
- id: gitleaks
6969

70+
- repo: https://github.com/google/keep-sorted
71+
rev: v0.8.0
72+
hooks:
73+
- id: keep-sorted
74+
args: [
75+
--default-options,
76+
"allow_yaml_lists=yes case=yes group=yes order=asc remove_duplicates=yes sticky_comments=no"
77+
]
78+
7079
- repo: https://github.com/hukkin/mdformat
7180
rev: 1.0.0
7281
hooks:

Makefile

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ HEXAGON_RUNTIME_LIBS = \
440440
$(HEXAGON_RUNTIME_LIBS_DIR)/v65/libhalide_hexagon_remote_skel.so \
441441
$(HEXAGON_RUNTIME_LIBS_DIR)/v65/signed_by_debug/libhalide_hexagon_remote_skel.so
442442

443-
# Keep this list sorted in alphabetical order.
443+
# keep-sorted start skip_lines=1 case=no
444444
SOURCE_FILES = \
445445
AbstractGenerator.cpp \
446446
AddAtomicMutex.cpp \
@@ -456,15 +456,15 @@ SOURCE_FILES = \
456456
AsyncProducers.cpp \
457457
AutoScheduleUtils.cpp \
458458
BoundaryConditions.cpp \
459+
BoundConstantExtentLoops.cpp \
459460
Bounds.cpp \
460461
BoundsInference.cpp \
461-
BoundConstantExtentLoops.cpp \
462462
BoundSmallAllocations.cpp \
463463
Buffer.cpp \
464464
Callable.cpp \
465465
CanonicalizeGPUVars.cpp \
466-
Closure.cpp \
467466
ClampUnsafeAccesses.cpp \
467+
Closure.cpp \
468468
CodeGen_ARM.cpp \
469469
CodeGen_C.cpp \
470470
CodeGen_D3D12Compute_Dev.cpp \
@@ -474,12 +474,12 @@ SOURCE_FILES = \
474474
CodeGen_LLVM.cpp \
475475
CodeGen_Metal_Dev.cpp \
476476
CodeGen_OpenCL_Dev.cpp \
477-
CodeGen_Vulkan_Dev.cpp \
478477
CodeGen_Posix.cpp \
479478
CodeGen_PowerPC.cpp \
480479
CodeGen_PTX_Dev.cpp \
481480
CodeGen_PyTorch.cpp \
482481
CodeGen_RISCV.cpp \
482+
CodeGen_Vulkan_Dev.cpp \
483483
CodeGen_WebAssembly.cpp \
484484
CodeGen_WebGPU_Dev.cpp \
485485
CodeGen_X86.cpp \
@@ -580,7 +580,6 @@ SOURCE_FILES = \
580580
Simplify_And.cpp \
581581
Simplify_Call.cpp \
582582
Simplify_Cast.cpp \
583-
Simplify_Reinterpret.cpp \
584583
Simplify_Div.cpp \
585584
Simplify_EQ.cpp \
586585
Simplify_Exprs.cpp \
@@ -592,6 +591,7 @@ SOURCE_FILES = \
592591
Simplify_Mul.cpp \
593592
Simplify_Not.cpp \
594593
Simplify_Or.cpp \
594+
Simplify_Reinterpret.cpp \
595595
Simplify_Select.cpp \
596596
Simplify_Shuffle.cpp \
597597
Simplify_Stmts.cpp \
@@ -626,6 +626,7 @@ SOURCE_FILES = \
626626
VectorizeLoops.cpp \
627627
WasmExecutor.cpp \
628628
WrapCalls.cpp
629+
# keep-sorted end
629630

630631
C_TEMPLATE_FILES = \
631632
CodeGen_C_prologue \
@@ -639,7 +640,7 @@ HTML_TEMPLATE_FILES = \
639640
# The externally-visible header files that go into making Halide.h.
640641
# Don't include anything here that includes llvm headers.
641642
# Also *don't* include anything that's only used internally (eg SpirvIR.h).
642-
# Keep this list sorted in alphabetical order.
643+
# keep-sorted start skip_lines=1 case=no
643644
HEADER_FILES = \
644645
AbstractGenerator.h \
645646
AddAtomicMutex.h \
@@ -655,9 +656,9 @@ HEADER_FILES = \
655656
AsyncProducers.h \
656657
AutoScheduleUtils.h \
657658
BoundaryConditions.h \
659+
BoundConstantExtentLoops.h \
658660
Bounds.h \
659661
BoundsInference.h \
660-
BoundConstantExtentLoops.h \
661662
BoundSmallAllocations.h \
662663
Buffer.h \
663664
Callable.h \
@@ -671,17 +672,17 @@ HEADER_FILES = \
671672
CodeGen_LLVM.h \
672673
CodeGen_Metal_Dev.h \
673674
CodeGen_OpenCL_Dev.h \
674-
CodeGen_Vulkan_Dev.h \
675675
CodeGen_Posix.h \
676676
CodeGen_PTX_Dev.h \
677677
CodeGen_PyTorch.h \
678678
CodeGen_Targets.h \
679+
CodeGen_Vulkan_Dev.h \
679680
CodeGen_WebGPU_Dev.h \
680681
CompilerLogger.h \
681682
ConciseCasts.h \
682-
CPlusPlusMangle.h \
683683
ConstantBounds.h \
684684
ConstantInterval.h \
685+
CPlusPlusMangle.h \
685686
CSE.h \
686687
Debug.h \
687688
DebugArguments.h \
@@ -734,7 +735,6 @@ HEADER_FILES = \
734735
IROperator.h \
735736
IRPrinter.h \
736737
IRVisitor.h \
737-
WasmExecutor.h \
738738
JITModule.h \
739739
Lambda.h \
740740
Lerp.h \
@@ -767,8 +767,8 @@ HEADER_FILES = \
767767
PythonExtensionGen.h \
768768
Qualify.h \
769769
Random.h \
770-
Realization.h \
771770
RDom.h \
771+
Realization.h \
772772
RealizationOrder.h \
773773
RebaseLoopsToZero.h \
774774
Reduction.h \
@@ -811,11 +811,14 @@ HEADER_FILES = \
811811
Util.h \
812812
Var.h \
813813
VectorizeLoops.h \
814+
WasmExecutor.h \
814815
WrapCalls.h
816+
# keep-sorted end
815817

816818
OBJECTS = $(SOURCE_FILES:%.cpp=$(BUILD_DIR)/%.o)
817819
HEADERS = $(HEADER_FILES:%.h=$(SRC_DIR)/%.h)
818820

821+
# keep-sorted start skip_lines=1
819822
RUNTIME_CPP_COMPONENTS = \
820823
aarch64_cpu_features \
821824
alignment_128 \
@@ -895,6 +898,7 @@ RUNTIME_CPP_COMPONENTS = \
895898
to_string \
896899
trace_helper \
897900
tracing \
901+
vulkan \
898902
wasm_cpu_features \
899903
webgpu_dawn \
900904
webgpu_emscripten \
@@ -912,9 +916,10 @@ RUNTIME_CPP_COMPONENTS = \
912916
windows_vulkan \
913917
windows_yield \
914918
write_debug_image \
915-
vulkan \
916919
x86_cpu_features \
920+
# keep-sorted end
917921

922+
# keep-sorted start skip_lines=1
918923
RUNTIME_LL_COMPONENTS = \
919924
aarch64 \
920925
arm \
@@ -931,6 +936,7 @@ RUNTIME_LL_COMPONENTS = \
931936
x86_avx2 \
932937
x86_avx512 \
933938
x86_sse41
939+
# keep-sorted end
934940

935941
RUNTIME_EXPORTED_INCLUDES = $(INCLUDE_DIR)/HalideRuntime.h \
936942
$(INCLUDE_DIR)/HalideRuntimeD3D12Compute.h \

apps/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ if (Halide_TARGET MATCHES "wasm")
2828
return()
2929
endif()
3030

31-
# add_app(HelloAndroid) # TODO(#5374): missing CMake build
32-
# add_app(HelloAndroidCamera2) # TODO(#5374): missing CMake build
33-
# add_app(HelloPyTorch) # TODO(#5374): missing CMake build
34-
# add_app(HelloiOS) # TODO(#5374): missing CMake build
31+
# keep-sorted start case=no ignore_prefixes=#
3532
# add_app(auto_viz) # TODO(#5374): missing CMake build
3633
add_app(bgu)
3734
add_app(bilateral_grid)
@@ -45,6 +42,11 @@ add_app(depthwise_separable_conv)
4542
add_app(fft)
4643
add_app(hannk)
4744
add_app(harris)
45+
# add_app(HelloAndroid) # TODO(#5374): missing CMake build
46+
# add_app(HelloAndroidCamera2) # TODO(#5374): missing CMake build
47+
add_app(HelloBaremetal)
48+
# add_app(HelloiOS) # TODO(#5374): missing CMake build
49+
# add_app(HelloPyTorch) # TODO(#5374): missing CMake build
4850
add_app(hexagon_benchmarks)
4951
# add_app(hexagon_dma) # TODO(#5374): missing CMake build
5052
add_app(hist)
@@ -64,4 +66,4 @@ add_app(resize)
6466
add_app(stencil_chain)
6567
add_app(unsharp)
6668
add_app(wavelet)
67-
add_app(HelloBaremetal)
69+
# keep-sorted end

apps/hannk/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ endif ()
117117
# Tests
118118

119119
set(TEST_FILES
120+
# keep-sorted start
120121
inception_v2_224_quant/000.DEPTHWISE_CONV_2D.tflite
121122
inception_v4_299_quant/000.CONV_2D.tflite
122123
inception_v4_299_quant/001.CONV_2D.tflite
@@ -235,6 +236,7 @@ set(TEST_FILES
235236
mobilenet_v2_1.0_224_quant/059.DEPTHWISE_CONV_2D.tflite
236237
mobilenet_v2_1.0_224_quant/062.AVERAGE_POOL_2D.tflite
237238
mobilenet_v2_1.0_224_quant/064.RESHAPE.tflite
239+
# keep-sorted end
238240
)
239241
list(TRANSFORM TEST_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/test/")
240242

apps/hannk/interpreter/ops.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,7 @@ void UpsampleChannelsOp::execute() {
18871887
}; \
18881888
}
18891889

1890+
// keep-sorted start
18901891
ACCEPT_AND_MUTATE_IMPL(BinaryOp)
18911892
ACCEPT_AND_MUTATE_IMPL(ConcatenationOp)
18921893
ACCEPT_AND_MUTATE_IMPL(ConvOp)
@@ -1896,16 +1897,17 @@ ACCEPT_AND_MUTATE_IMPL(GatherOp)
18961897
ACCEPT_AND_MUTATE_IMPL(L2NormalizationOp)
18971898
ACCEPT_AND_MUTATE_IMPL(PadOp)
18981899
ACCEPT_AND_MUTATE_IMPL(Pool2DOp)
1900+
ACCEPT_AND_MUTATE_IMPL(ReductionOp)
1901+
ACCEPT_AND_MUTATE_IMPL(ReshapeOp)
18991902
ACCEPT_AND_MUTATE_IMPL(ShapeOp)
19001903
ACCEPT_AND_MUTATE_IMPL(SoftmaxOp)
19011904
ACCEPT_AND_MUTATE_IMPL(SpaceDepthOp)
19021905
ACCEPT_AND_MUTATE_IMPL(SplitOp)
1903-
ACCEPT_AND_MUTATE_IMPL(ReductionOp)
1904-
ACCEPT_AND_MUTATE_IMPL(ReshapeOp)
19051906
ACCEPT_AND_MUTATE_IMPL(TileConvFilterOp)
19061907
ACCEPT_AND_MUTATE_IMPL(TransposeOp)
1907-
ACCEPT_AND_MUTATE_IMPL(UpsampleChannelsOp)
19081908
ACCEPT_AND_MUTATE_IMPL(UnaryOp)
1909+
ACCEPT_AND_MUTATE_IMPL(UpsampleChannelsOp)
1910+
// keep-sorted end
19091911

19101912
ACCEPT_AND_MUTATE_IMPL(OpGroup)
19111913

cmake/HalideGeneratorHelpers.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ function(_Halide_library_from_generator TARGET)
174174

175175
## "hash table" of extra outputs to extensions
176176
# Keep in sync with Module.cpp
177+
# keep-sorted start ignore_prefixes=#
177178
set(assembly_extension ".s")
178179
set(bitcode_extension ".bc")
179180
# set(c_header_extension ".h") # handled specially
@@ -195,6 +196,7 @@ function(_Halide_library_from_generator TARGET)
195196
# set(static_library_extension (is_windows_coff ? ".lib" : ".a")) # handled specially
196197
set(stmt_extension ".stmt")
197198
set(stmt_html_extension ".stmt.html")
199+
# keep-sorted end
198200

199201
## Validate TYPE
200202
if (NOT ARG_TYPE MATCHES "^(c_source|static_library|object)$")
@@ -452,6 +454,7 @@ function(add_halide_library TARGET)
452454
# - `object` is selected for CMake-target-compile
453455
# - `static_library` is selected for cross-compile
454456
set(extra_output_names
457+
# keep-sorted start
455458
ASSEMBLY
456459
BITCODE
457460
COMPILER_LOG
@@ -469,6 +472,7 @@ function(add_halide_library TARGET)
469472
SCHEDULE
470473
STMT
471474
STMT_HTML
475+
# keep-sorted end
472476
)
473477

474478
##

doc/CodeStyleCMake.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ that every `.c` and `.cpp` appears in the `CMakeLists.txt` file _on its own
197197
line_, possibly as a comment. This is to avoid globbing and also to ensure that
198198
added files are not missed.
199199

200-
For most test types, it should be as simple as adding to the existing lists,
201-
which must remain in alphabetical order. Generator tests are trickier, but
202-
following the existing examples is a safe way to go.
200+
For most test types, it should be as simple as adding to the existing lists.
201+
Generator tests are trickier, but following the existing examples is a safe way
202+
to go.
203203

204204
# Adding apps
205205

python_bindings/test/correctness/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_library(the_sort_function MODULE the_sort_function.c)
77
target_link_libraries(the_sort_function PRIVATE Halide::Runtime)
88

99
set(tests
10+
# keep-sorted start
1011
addconstant_test.py
1112
atomics.py
1213
autodiff.py
@@ -32,6 +33,7 @@ set(tests
3233
type.py
3334
user_context_test.py
3435
var.py
36+
# keep-sorted end
3537
)
3638

3739
set(PY_GENERATORS "${CMAKE_CURRENT_SOURCE_DIR}/../generators")

python_bindings/tutorial/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ if (Halide_TARGET MATCHES "webgpu")
44
endif ()
55

66
set(tests
7+
# keep-sorted start
78
lesson_01_basics.py
89
lesson_02_input_image.py
910
lesson_03_debugging_1.py
@@ -19,6 +20,7 @@ set(tests
1920
lesson_12_using_the_gpu.py
2021
lesson_13_tuples.py
2122
lesson_14_types.py
23+
# keep-sorted end
2224
)
2325

2426
set(PYPATH_lesson_10_aot_compilation_run "$<TARGET_FILE_DIR:lesson_10_halide>")

0 commit comments

Comments
 (0)