Skip to content

Commit fc7977a

Browse files
committed
ARROW-4363: [CI] [C++] Add CMake format checks
- Add a top-level script that reformats all known CMake files in the source tree - Add a lint step in Travis that checks CMake files are properly formatted Requires [cmake_format](https://github.com/cheshirekow/cmake_format) and Python 3. Author: Antoine Pitrou <antoine@python.org> Closes #3606 from pitrou/ARROW-4363-cmake-format and squashes the following commits: 762df29 <Antoine Pitrou> Add mention in cpp/README.md 9073af9 <Antoine Pitrou> ARROW-4363: Add CMake format checks
1 parent 4cf1c7a commit fc7977a

36 files changed

+1788
-1755
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ matrix:
5050
os: linux
5151
language: python
5252
python: "3.6"
53-
env:
54-
- ARROW_TRAVIS_CLANG_FORMAT=1
5553
before_script:
5654
# Always run RAT checks, in case another build in matrix breaks RAT
5755
- $TRAVIS_BUILD_DIR/ci/travis_release_audit.sh

ci/travis_lint.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@ set -ex
2323
export ARROW_TRAVIS_USE_TOOLCHAIN=0
2424
source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh
2525

26+
# CMake formatting check
27+
pip install cmake_format
28+
$TRAVIS_BUILD_DIR/run-cmake-format.py --check
29+
2630
# C++ code linting
2731
if [ "$ARROW_CI_CPP_AFFECTED" != "0" ]; then
2832
mkdir $ARROW_CPP_DIR/lint
2933
pushd $ARROW_CPP_DIR/lint
3034

3135
cmake .. -DARROW_ONLY_LINT=ON
3236
make lint
33-
34-
if [ "$ARROW_TRAVIS_CLANG_FORMAT" == "1" ]; then
35-
make check-format
36-
fi
37+
make check-format
3738

3839
python $ARROW_CPP_DIR/build-support/lint_cpp_cli.py $ARROW_CPP_DIR/src
3940

cmake-format.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 run-cmake-format.py to reformat all cmake files in the source tree
20+
21+
# How wide to allow formatted cmake files
22+
line_width = 90
23+
24+
# How many spaces to tab for indent
25+
tab_size = 2
26+
27+
# If arglists are longer than this, break them always
28+
max_subargs_per_line = 4
29+
30+
# If true, separate flow control names from their parentheses with a space
31+
separate_ctrl_name_with_space = False
32+
33+
# If true, separate function names from parentheses with a space
34+
separate_fn_name_with_space = False
35+
36+
# If a statement is wrapped to more than one line, than dangle the closing
37+
# parenthesis on it's own line
38+
dangle_parens = False
39+
40+
# What style line endings to use in the output.
41+
line_ending = 'unix'
42+
43+
# Format command names consistently as 'lower' or 'upper' case
44+
command_case = 'lower'
45+
46+
# Format keywords consistently as 'lower' or 'upper' case
47+
keyword_case = 'unchanged'
48+
49+
# enable comment markup parsing and reflow
50+
enable_markup = False
51+
52+
# If comment markup is enabled, don't reflow the first comment block in
53+
# eachlistfile. Use this to preserve formatting of your
54+
# copyright/licensestatements.
55+
first_comment_is_literal = False
56+
57+
# If comment markup is enabled, don't reflow any comment block which matchesthis
58+
# (regex) pattern. Default is `None` (disabled).
59+
literal_comment_pattern = None

0 commit comments

Comments
 (0)