Skip to content

Commit 9aaf61c

Browse files
kszucskou
authored andcommitted
ARROW-8459: [Dev][Archery] Use a more recent cmake-format
- [x] bump cmake-format's version to the latest one - [x] port `run-cmake-format.py` script to archery - [x] support `archery lint --cmake-format` format checks without reformatting the files in-place - [x] support `archery lint --cmake-format --fix` for actually reformat the files - [x] reformat the cmake files I assume we may need tune the options a little bit, so feel free to experiment with the values defined in `cmake-format.py` then re-run `archery-lint --cmake-format --fix`. The `cmakelang` package also provides a `cmake-lint` command which we could experiment with in the future. Closes #10571 from kszucs/update-cmake-format Authored-by: Krisztián Szűcs <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 8113c37 commit 9aaf61c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1300
-1493
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# include explicitly
2828
!ci/**
2929
!c_glib/Gemfile
30-
!dev/archery/requirements*.txt
30+
!dev/archery/setup.py
3131
!python/requirements*.txt
3232
!python/manylinux1/**
3333
!python/manylinux2010/**

.pre-commit-config.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ repos:
2929
entry: bash -c "git archive HEAD --prefix=apache-arrow/ --output=arrow-src.tar && ./dev/release/run-rat.sh arrow-src.tar"
3030
always_run: true
3131
pass_filenames: false
32-
- id: cmake-format
33-
name: CMake Format
34-
language: python
35-
entry: python run-cmake-format.py
36-
types: [cmake]
37-
additional_dependencies:
38-
- cmake_format==0.5.2
3932
- id: hadolint
4033
name: Docker Format
4134
language: docker_image

ci/docker/linux-apt-lint.dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,8 @@ RUN arrow/ci/scripts/install_iwyu.sh /tmp/iwyu /usr/local ${clang_tools}
4949
RUN ln -s /usr/bin/python3 /usr/local/bin/python && \
5050
ln -s /usr/bin/pip3 /usr/local/bin/pip
5151

52-
COPY dev/archery/requirements.txt \
53-
dev/archery/requirements-lint.txt \
54-
/arrow/dev/archery/
55-
RUN pip install \
56-
-r arrow/dev/archery/requirements.txt \
57-
-r arrow/dev/archery/requirements-lint.txt
52+
COPY dev/archery/setup.py /arrow/dev/archery/
53+
RUN pip install -e arrow/dev/archery[lint]
5854

5955
ENV LC_ALL=C.UTF-8 \
6056
LANG=C.UTF-8

cmake-format.py

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,61 @@
1616
# under the License.
1717

1818
# cmake-format configuration file
19-
# Use run-cmake-format.py to reformat all cmake files in the source tree
19+
# Use `archery lint --cmake-format --fix` to reformat all cmake files in the
20+
# source tree
2021

21-
# How wide to allow formatted cmake files
22-
line_width = 90
22+
# -----------------------------
23+
# Options affecting formatting.
24+
# -----------------------------
25+
with section("format"):
26+
# How wide to allow formatted cmake files
27+
line_width = 90
2328

24-
# How many spaces to tab for indent
25-
tab_size = 2
29+
# How many spaces to tab for indent
30+
tab_size = 2
2631

27-
# If arglists are longer than this, break them always
28-
max_subargs_per_line = 4
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
2935

30-
# If true, separate flow control names from their parentheses with a space
31-
separate_ctrl_name_with_space = False
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
3242

33-
# If true, separate function names from parentheses with a space
34-
separate_fn_name_with_space = False
43+
# If true, separate flow control names from their parentheses with a space
44+
separate_ctrl_name_with_space = False
3545

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
46+
# If true, separate function names from parentheses with a space
47+
separate_fn_name_with_space = False
3948

40-
# What style line endings to use in the output.
41-
line_ending = 'unix'
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
4252

43-
# Format command names consistently as 'lower' or 'upper' case
44-
command_case = 'lower'
53+
# What style line endings to use in the output.
54+
line_ending = 'unix'
4555

46-
# Format keywords consistently as 'lower' or 'upper' case
47-
keyword_case = 'unchanged'
56+
# Format command names consistently as 'lower' or 'upper' case
57+
command_case = 'lower'
4858

49-
# enable comment markup parsing and reflow
50-
enable_markup = False
59+
# Format keywords consistently as 'lower' or 'upper' case
60+
keyword_case = 'unchanged'
5161

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
62+
# ------------------------------------------------
63+
# Options affecting comment reflow and formatting.
64+
# ------------------------------------------------
65+
with section("markup"):
66+
# enable comment markup parsing and reflow
67+
enable_markup = False
5668

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
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+
# matchesthis (regex) pattern. Default is `None` (disabled).
76+
literal_comment_pattern = None

cpp/CMakeLists.txt

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" ARROW_BASE_VERSION "${ARROW_VERSI
5353

5454
# if no build build type is specified, default to release builds
5555
if(NOT DEFINED CMAKE_BUILD_TYPE)
56-
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build.")
56+
set(CMAKE_BUILD_TYPE
57+
Release
58+
CACHE STRING "Choose the type of build.")
5759
endif()
5860
string(TOLOWER ${CMAKE_BUILD_TYPE} LOWERCASE_BUILD_TYPE)
5961
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
@@ -117,18 +119,15 @@ set(ARROW_LLVM_VERSIONS
117119
"8"
118120
"7")
119121
list(GET ARROW_LLVM_VERSIONS 0 ARROW_LLVM_VERSION_PRIMARY)
120-
string(REGEX
121-
REPLACE "^([0-9]+)(\\..+)?" "\\1" ARROW_LLVM_VERSION_PRIMARY_MAJOR
122-
"${ARROW_LLVM_VERSION_PRIMARY}")
122+
string(REGEX REPLACE "^([0-9]+)(\\..+)?" "\\1" ARROW_LLVM_VERSION_PRIMARY_MAJOR
123+
"${ARROW_LLVM_VERSION_PRIMARY}")
123124

124125
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../.env ARROW_ENV)
125126
string(REGEX MATCH "CLANG_TOOLS=[^\n]+" ARROW_ENV_CLANG_TOOLS_VERSION "${ARROW_ENV}")
126-
string(REGEX
127-
REPLACE "^CLANG_TOOLS=" "" ARROW_CLANG_TOOLS_VERSION
128-
"${ARROW_ENV_CLANG_TOOLS_VERSION}")
129-
string(REGEX
130-
REPLACE "^([0-9]+)(\\..+)?" "\\1" ARROW_CLANG_TOOLS_VERSION_MAJOR
131-
"${ARROW_CLANG_TOOLS_VERSION}")
127+
string(REGEX REPLACE "^CLANG_TOOLS=" "" ARROW_CLANG_TOOLS_VERSION
128+
"${ARROW_ENV_CLANG_TOOLS_VERSION}")
129+
string(REGEX REPLACE "^([0-9]+)(\\..+)?" "\\1" ARROW_CLANG_TOOLS_VERSION_MAJOR
130+
"${ARROW_CLANG_TOOLS_VERSION}")
132131

133132
if(APPLE)
134133
find_program(BREW_BIN brew)
@@ -163,7 +162,9 @@ endif()
163162

164163
find_package(ClangTools)
165164
find_package(InferTools)
166-
if("$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}" STREQUAL "1" OR CLANG_TIDY_FOUND OR INFER_FOUND)
165+
if("$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}" STREQUAL "1"
166+
OR CLANG_TIDY_FOUND
167+
OR INFER_FOUND)
167168
# Generate a Clang compile_commands.json "compilation database" file for use
168169
# with various development tools, such as Vim's YouCompleteMe plugin.
169170
# See http://clang.llvm.org/docs/JSONCompilationDatabase.html
@@ -226,7 +227,9 @@ if(NOT LINT_EXCLUSIONS_FILE)
226227
set(LINT_EXCLUSIONS_FILE ${BUILD_SUPPORT_DIR}/lint_exclusions.txt)
227228
endif()
228229

229-
find_program(CPPLINT_BIN NAMES cpplint cpplint.py HINTS ${BUILD_SUPPORT_DIR})
230+
find_program(CPPLINT_BIN
231+
NAMES cpplint cpplint.py
232+
HINTS ${BUILD_SUPPORT_DIR})
230233
message(STATUS "Found cpplint executable at ${CPPLINT_BIN}")
231234

232235
add_custom_target(lint
@@ -271,7 +274,7 @@ if(${CLANG_FORMAT_FOUND})
271274
endif()
272275

273276
add_custom_target(lint_cpp_cli ${PYTHON_EXECUTABLE} ${BUILD_SUPPORT_DIR}/lint_cpp_cli.py
274-
${CMAKE_CURRENT_SOURCE_DIR}/src)
277+
${CMAKE_CURRENT_SOURCE_DIR}/src)
275278

276279
if(ARROW_LINT_ONLY)
277280
message("ARROW_LINT_ONLY was specified, this is only a partial build directory")
@@ -469,10 +472,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
469472
if(NOT APPLE)
470473
set(MORE_ARGS "-T")
471474
endif()
472-
execute_process(COMMAND ln
473-
${MORE_ARGS}
474-
-sf
475-
${BUILD_OUTPUT_ROOT_DIRECTORY}
475+
execute_process(COMMAND ln ${MORE_ARGS} -sf ${BUILD_OUTPUT_ROOT_DIRECTORY}
476476
${CMAKE_CURRENT_BINARY_DIR}/build/latest)
477477
else()
478478
set(BUILD_OUTPUT_ROOT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SUBDIR_NAME}/")
@@ -550,12 +550,9 @@ include_directories(src/generated)
550550
#
551551
if(PARQUET_BUILD_SHARED)
552552
set_target_properties(arrow_shared
553-
PROPERTIES C_VISIBILITY_PRESET
554-
hidden
555-
CXX_VISIBILITY_PRESET
556-
hidden
557-
VISIBILITY_INLINES_HIDDEN
558-
1)
553+
PROPERTIES C_VISIBILITY_PRESET hidden
554+
CXX_VISIBILITY_PRESET hidden
555+
VISIBILITY_INLINES_HIDDEN 1)
559556
endif()
560557

561558
#
@@ -599,7 +596,9 @@ endif(UNIX)
599596
# "make cscope" target
600597
#
601598
if(UNIX)
602-
add_custom_target(cscope find ${CMAKE_CURRENT_SOURCE_DIR}
599+
add_custom_target(cscope
600+
find
601+
${CMAKE_CURRENT_SOURCE_DIR}
603602
(-name
604603
\\*.cc
605604
-or
@@ -636,23 +635,14 @@ endif(UNIX)
636635
637636
if(${INFER_FOUND})
638637
# runs infer capture
639-
add_custom_target(infer
640-
${BUILD_SUPPORT_DIR}/run-infer.sh
641-
${INFER_BIN}
642-
${CMAKE_BINARY_DIR}/compile_commands.json
643-
1)
638+
add_custom_target(infer ${BUILD_SUPPORT_DIR}/run-infer.sh ${INFER_BIN}
639+
${CMAKE_BINARY_DIR}/compile_commands.json 1)
644640
# runs infer analyze
645-
add_custom_target(infer-analyze
646-
${BUILD_SUPPORT_DIR}/run-infer.sh
647-
${INFER_BIN}
648-
${CMAKE_BINARY_DIR}/compile_commands.json
649-
2)
641+
add_custom_target(infer-analyze ${BUILD_SUPPORT_DIR}/run-infer.sh ${INFER_BIN}
642+
${CMAKE_BINARY_DIR}/compile_commands.json 2)
650643
# runs infer report
651-
add_custom_target(infer-report
652-
${BUILD_SUPPORT_DIR}/run-infer.sh
653-
${INFER_BIN}
654-
${CMAKE_BINARY_DIR}/compile_commands.json
655-
3)
644+
add_custom_target(infer-report ${BUILD_SUPPORT_DIR}/run-infer.sh ${INFER_BIN}
645+
${CMAKE_BINARY_DIR}/compile_commands.json 3)
656646
endif()
657647
658648
#
@@ -721,7 +711,7 @@ if(ARROW_ORC)
721711
list(APPEND ARROW_STATIC_LINK_LIBS orc::liborc ${ARROW_PROTOBUF_LIBPROTOBUF})
722712
if(ORC_SOURCE STREQUAL "SYSTEM")
723713
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS orc::liborc
724-
${ARROW_PROTOBUF_LIBPROTOBUF})
714+
${ARROW_PROTOBUF_LIBPROTOBUF})
725715
endif()
726716
endif()
727717
@@ -916,8 +906,7 @@ endif()
916906
917907
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE.txt
918908
${CMAKE_CURRENT_SOURCE_DIR}/../NOTICE.txt
919-
${CMAKE_CURRENT_SOURCE_DIR}/README.md
920-
DESTINATION "${ARROW_DOC_DIR}")
909+
${CMAKE_CURRENT_SOURCE_DIR}/README.md DESTINATION "${ARROW_DOC_DIR}")
921910
922911
#
923912
# Validate and print out Arrow configuration options

0 commit comments

Comments
 (0)