Skip to content

Commit 89217c8

Browse files
authored
apacheGH-520: [CI] Add cmake-format to pre-commit (apache#521)
Fixes apacheGH-520. The configuration file is borrowed from apache/arrow.
1 parent 4f9b452 commit 89217c8

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.cmake-format.py

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# cmake-format configuration file
19+
# Use `archery lint --cmake-format --fix` to reformat all cmake files in the
20+
# source tree
21+
22+
# -----------------------------
23+
# Options affecting formatting.
24+
# -----------------------------
25+
with section("format"):
26+
# How wide to allow formatted cmake files
27+
line_width = 90
28+
29+
# How many spaces to tab for indent
30+
tab_size = 2
31+
32+
# If a positional argument group contains more than this many arguments,
33+
# then force it to a vertical layout.
34+
max_pargs_hwrap = 4
35+
36+
# If the statement spelling length (including space and parenthesis) is
37+
# smaller than this amount, then force reject nested layouts.
38+
# This value only comes into play when considering whether or not to nest
39+
# arguments below their parent. If the number of characters in the parent
40+
# is less than this value, we will not nest.
41+
min_prefix_chars = 32
42+
43+
# If true, separate flow control names from their parentheses with a space
44+
separate_ctrl_name_with_space = False
45+
46+
# If true, separate function names from parentheses with a space
47+
separate_fn_name_with_space = False
48+
49+
# If a statement is wrapped to more than one line, than dangle the closing
50+
# parenthesis on it's own line
51+
dangle_parens = False
52+
53+
# What style line endings to use in the output.
54+
line_ending = 'unix'
55+
56+
# Format command names consistently as 'lower' or 'upper' case
57+
command_case = 'lower'
58+
59+
# Format keywords consistently as 'lower' or 'upper' case
60+
keyword_case = 'unchanged'
61+
62+
# ------------------------------------------------
63+
# Options affecting comment reflow and formatting.
64+
# ------------------------------------------------
65+
with section("markup"):
66+
# enable comment markup parsing and reflow
67+
enable_markup = False
68+
69+
# If comment markup is enabled, don't reflow the first comment block in
70+
# eachlistfile. Use this to preserve formatting of your
71+
# copyright/licensestatements.
72+
first_comment_is_literal = True
73+
74+
# If comment markup is enabled, don't reflow any comment block which
75+
# matches this (regex) pattern. Default is `None` (disabled).
76+
literal_comment_pattern = None

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
# under the License.
1717

1818
repos:
19+
- repo: https://github.com/cheshirekow/cmake-format-precommit
20+
rev: v0.6.13
21+
hooks:
22+
- id: cmake-format
1923
- repo: https://github.com/pre-commit/pre-commit-hooks
2024
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # v5.0.0
2125
hooks:

0 commit comments

Comments
 (0)