Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ install:
$env:CMAKE_INCLUDE_PATH = "eigen-eigen-67e894c6cd8f;$env:CMAKE_INCLUDE_PATH"
build_script:
- cmake -G "%CMAKE_GENERATOR%" -A "%CMAKE_ARCH%"
-DPYBIND11_CPP_STANDARD=/std:c++14
-DCMAKE_CXX_STANDARD=14
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DCMAKE_SUPPRESS_REGENERATION=1
Expand Down
73 changes: 73 additions & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
parse:
Copy link
Member

Choose a reason for hiding this comment

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

First time I heard about .cmake-format, that's neat! One related question: we're beginning to "clog up" the root directory with many dot-files related to CI infrastructure. Can we move them to '.github' as well?

Copy link
Collaborator Author

@henryiii henryiii Jul 30, 2020

Choose a reason for hiding this comment

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

Putting them in .github is probably a bad idea, as the files in there have special meanings for GitHub - like .github/CONTRIBUTING.md, issue templates, pull request templates, actions, workflows, etc. But this one could go anywhere, such as in tools. The problem is that if you try to run cmake-format from the command line, it will pick this up only if it's in the main folder. However, I would expect this and all the other formatters to only be run by pre-commit, so that's not a big deal. The .pre-commit-config.yaml file needs to be in the main folder. I rather think the .clang-format file will need to be in the main folder (IIRC, -style=file is the parameter you run, which doesn't include a path).

These are all just dot files, so they only make the main GitHub page longer (which is still a little irritating, but a common issue, especially for Python).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(My general rule is that I always use the default name/location if something expects it, so tools "just work" if someone tries to run them; but if there's not special meaning to a name/path, I put it in a folder to keep the page clean)

additional_commands:
pybind11_add_module:
flags:
- THIN_LTO
- MODULE
- SHARED
- NO_EXTRAS
- EXCLUDE_FROM_ALL
- SYSTEM

format:
line_width: 99
tab_size: 2

# If an argument group contains more than this many sub-groups
# (parg or kwarg groups) then force it to a vertical layout.
max_subgroups_hwrap: 2

# If a positional argument group contains more than this many
# arguments, then force it to a vertical layout.
max_pargs_hwrap: 6

# If a cmdline positional group consumes more than this many
# lines without nesting, then invalidate the layout (and nest)
max_rows_cmdline: 2
separate_ctrl_name_with_space: false
separate_fn_name_with_space: false
dangle_parens: false

# If the trailing parenthesis must be 'dangled' on its on
# 'line, then align it to this reference: `prefix`: the start'
# 'of the statement, `prefix-indent`: the start of the'
# 'statement, plus one indentation level, `child`: align to'
# the column of the arguments
dangle_align: prefix
# If the statement spelling length (including space and
# parenthesis) is smaller than this amount, then force reject
# nested layouts.
min_prefix_chars: 4

# If the statement spelling length (including space and
# parenthesis) is larger than the tab width by more than this
# amount, then force reject un-nested layouts.
max_prefix_chars: 10

# If a candidate layout is wrapped horizontally but it exceeds
# this many lines, then reject the layout.
max_lines_hwrap: 2

line_ending: unix

# Format command names consistently as 'lower' or 'upper' case
command_case: canonical

# Format keywords consistently as 'lower' or 'upper' case
# unchanged is valid too
keyword_case: 'upper'

# A list of command names which should always be wrapped
always_wrap: []

# If true, the argument lists which are known to be sortable
# will be sorted lexicographically
enable_sort: true

# If true, the parsers may infer whether or not an argument
# list is sortable (without annotation).
autosort: false

# Causes a few issues - can be solved later, possibly.
markup:
enable_markup: false
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ jobs:
- name: Configure C++11
shell: bash
run: >
cmake --version &&
cmake -S . -B build
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
Expand All @@ -107,10 +106,10 @@ jobs:
run: cmake --build build -j 2

- name: Python tests C++11
run: cmake --build build --target pytest -j 2 -v
run: cmake --build build --target pytest -j 2

- name: C++11 tests
run: cmake --build build --target cpptest -j 2 -v
run: cmake --build build --target cpptest -j 2

- name: Interface test C++11
run: cmake --build build --target test_cmake_build
Expand All @@ -119,7 +118,7 @@ jobs:
shell: bash
run: >
cmake -S . -B build2
-DPYBIND17_WERROR=ON
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DDOWNLOAD_EIGEN=ON
-DCMAKE_CXX_STANDARD=${{ matrix.max-cxx-std }}
Expand Down Expand Up @@ -163,7 +162,6 @@ jobs:
- name: Configure
shell: bash
run: >
cmake --version &&
cmake -S . -B build
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
Expand Down Expand Up @@ -210,7 +208,6 @@ jobs:
- name: Configure
shell: bash
run: >
cmake --version &&
cmake -S . -B build
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
Expand Down Expand Up @@ -256,7 +253,6 @@ jobs:
- name: Configure
shell: bash
run: >
cmake --version &&
cmake -S . -B build
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,31 @@ jobs:

- name: Make build directories
run: |
mkdir build2.8
mkdir build3.7
mkdir build3.11
mkdir build3.18

- name: Setup CMake 2.8
- name: Setup CMake 3.7
uses: jwlawson/[email protected]
with:
cmake-version: 2.8
cmake-version: 3.7

- name: Configure 2.8
working-directory: build2.8
- name: Configure 3.7
working-directory: build3.7
run: >
cmake --version &&
cmake ..
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)")

- name: Setup CMake 3.7
- name: Setup CMake 3.11
uses: jwlawson/[email protected]
with:
cmake-version: 3.7
cmake-version: 3.11

- name: Configure 3.7
working-directory: build3.7
- name: Configure 3.11
working-directory: build3.11
run: >
cmake --version &&
cmake ..
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
Expand All @@ -74,7 +72,6 @@ jobs:
- name: Configure 3.18
working-directory: build3.18
run: >
cmake --version &&
cmake ..
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ repos:
additional_dependencies: [flake8-bugbear, pep8-naming]
exclude: ^(docs/.*|tools/.*)$

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
- id: cmake-format
additional_dependencies: [pyyaml]

- repo: local
hooks:
- id: check-style
Expand Down
Loading