Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-8459: [Dev][Archery] Use a more recent cmake-format #10571

Closed
wants to merge 8 commits into from

Conversation

kszucs
Copy link
Member

@kszucs kszucs commented Jun 22, 2021

  • bump cmake-format's version to the latest one
  • port run-cmake-format.py script to archery
  • support archery lint --cmake-format format checks without reformatting the files in-place
  • support archery lint --cmake-format --fix for actually reformat the files
  • 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.

@kszucs kszucs requested review from pitrou and kou June 22, 2021 13:43
@github-actions
Copy link

"AVX2"
"AVX512"
"MAX")
define_option_string(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can alter this tabulation behavior using https://cmake-format.readthedocs.io/en/latest/configopts.html#min-prefix-chars

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try 32 or something?
I don't expect formatter so much but I want to reduce diff to look history easily later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm going to try formatting with min-prefix-chars=32

def __init__(self, cmake_format_bin):
self.bin = cmake_format_bin

# TODO(kszucs): check cmake_format version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you can do it in this PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, it seems done already below. Perhaps just remove this TODO?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thanks for spotting that!

'go/**/CMakeLists.txt',
'java/**/CMakeLists.txt',
'matlab/**/CMakeLists.txt',
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have cmake files in python as well, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those haven't been checked earlier either https://github.com/apache/arrow/blob/master/run-cmake-format.py#L29
I think we could simply use a global pattern with an exclusion list rather.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have only python/CMakeLists.txt in python/.
python/cmake_modules/ is a symbolic link to cpp/cmake_modules/.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added python/CMakeLists.txt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see.

'cpp/cmake_modules/FindPythonLibsNew.cmake',
'cpp/cmake_modules/UseCython.cmake',
'cpp/src/arrow/util/config.h.cmake',
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know the reasons for these exclusions?

Copy link
Member Author

@kszucs kszucs Jun 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ported from the previous script, I assume these files are vendored or generated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpp/cmake_modules/*.cmake in the list are imported CMake files: #9045 (comment)

We can't use cmake-format for cpp/src/arrow/util/config.h.cmake because it's not valid CMake file. It has @...@ to replace variables by CMake.

Comment on lines +71 to +73
LLVMAlt
REQUIRED_VARS # The first variable is used for display.
LLVM_PACKAGE_VERSION CLANG_EXECUTABLE LLVM_FOUND LLVM_LINK_EXECUTABLE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LLVMAlt
REQUIRED_VARS # The first variable is used for display.
LLVM_PACKAGE_VERSION CLANG_EXECUTABLE LLVM_FOUND LLVM_LINK_EXECUTABLE)
LLVMAlt
# The first variable is used for display.
REQUIRED_VARS LLVM_PACKAGE_VERSION CLANG_EXECUTABLE LLVM_FOUND LLVM_LINK_EXECUTABLE)

Comment on lines +454 to +458
Arrow
REQUIRED_VARS # The first required variable is shown
# in the found message. So this list is
# not sorted alphabetically.
ARROW_INCLUDE_DIR ARROW_LIB_DIR ARROW_FULL_SO_VERSION ARROW_SO_VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Arrow
REQUIRED_VARS # The first required variable is shown
# in the found message. So this list is
# not sorted alphabetically.
ARROW_INCLUDE_DIR ARROW_LIB_DIR ARROW_FULL_SO_VERSION ARROW_SO_VERSION
Arrow
# The first required variable is shown in the found message. So this list is
# not sorted alphabetically.
REQUIRED_VARS ARROW_INCLUDE_DIR ARROW_LIB_DIR ARROW_FULL_SO_VERSION ARROW_SO_VERSION

'go/**/CMakeLists.txt',
'java/**/CMakeLists.txt',
'matlab/**/CMakeLists.txt',
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have only python/CMakeLists.txt in python/.
python/cmake_modules/ is a symbolic link to cpp/cmake_modules/.

'cpp/cmake_modules/FindPythonLibsNew.cmake',
'cpp/cmake_modules/UseCython.cmake',
'cpp/src/arrow/util/config.h.cmake',
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpp/cmake_modules/*.cmake in the list are imported CMake files: #9045 (comment)

We can't use cmake-format for cpp/src/arrow/util/config.h.cmake because it's not valid CMake file. It has @...@ to replace variables by CMake.

"AVX2"
"AVX512"
"MAX")
define_option_string(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try 32 or something?
I don't expect formatter so much but I want to reduce diff to look history easily later.

@kszucs
Copy link
Member Author

kszucs commented Jun 23, 2021

@kou updated the formatting with min-prefix-chars=32, please take a look again.

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Thanks. It looks good with min-prefix-chars=32.

.pre-commit-config.yaml Show resolved Hide resolved
'go/**/CMakeLists.txt',
'java/**/CMakeLists.txt',
'matlab/**/CMakeLists.txt',
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see.

@kou kou closed this in 9aaf61c Jun 23, 2021
kou added a commit to kou/arrow that referenced this pull request Sep 9, 2021
kou added a commit to kou/arrow that referenced this pull request Sep 9, 2021
kou added a commit to kou/arrow that referenced this pull request Sep 9, 2021
kou added a commit to kou/arrow that referenced this pull request Sep 9, 2021
kou added a commit that referenced this pull request Sep 10, 2021
This is a follow-up of #10571 / ARROW-8459 .

Closes #11112 from kou/github-actions-autotune

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
ViniciusSouzaRoque pushed a commit to s1mbi0se/arrow that referenced this pull request Oct 20, 2021
This is a follow-up of apache#10571 / ARROW-8459 .

Closes apache#11112 from kou/github-actions-autotune

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants