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

Add clang-format support for the experimental c/cpp plugin #15395

Merged
merged 9 commits into from
May 12, 2022

Conversation

sureshjoshi
Copy link
Member

@sureshjoshi sureshjoshi commented May 11, 2022

This PR builds off of the recently added experimental C/C++ targets, by adding the clang-format code formatter.

clang-format with --style=file argument looks for the closest parent directory with a .clang-format or _clang-format configuration file, for each input file. This provides support for multiple .clang-format configuration files in a project hierarchy.

If --style=file is used, but no .clang-format file is found, then the --fallback-style=WebKit takes precedence.

In lieu of pulling executables from various sources, or building the llvm codebase, this PR uses the clang-format Python package.

(Closes issue #15377)

[ci skip-rust]
[ci skip-build-wheels]

- Updated to 2.13.x
- Removed explicit LintTargetRequests
- Replaced `cpp` targets with `cc`

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@sureshjoshi
Copy link
Member Author

Tests coming tomorrow!

@sureshjoshi
Copy link
Member Author

Also, I need to spend some time looking at the command line arguments, I just put in some sane placeholders for now.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
- Added `args` option to command-line Pants

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
- Also testing configuration

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
…e pre-commit

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@sureshjoshi sureshjoshi changed the title [WIP] Add clang-format support for the experimental c/cpp plugin Add clang-format support for the experimental c/cpp plugin May 12, 2022
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Sweet! Thanks so much!

@tdyas
Copy link
Contributor

tdyas commented May 12, 2022

In lieu of pulling executables from various sources, or building the llvm codebase, this PR uses the clang-format Python package.

Regarding software supply chain management, the help message for the Subsystem should disclose where the binaries come from, i.e. add a link to the PyPi project. Eventually, it would be good to build the binary from scratch or from an official source, although today is not that day since Pants doesn't currently have any C/C++ compile infrastructure (but of course that will come as we work on this C/C++ backend).

@sureshjoshi
Copy link
Member Author

Regarding software supply chain management, the help message for the Subsystem should disclose where the binaries come from, i.e. add a link to the PyPi project. Eventually, it would be good to build the binary from scratch or from an official source, although today is not that day since Pants doesn't currently have any C/C++ compile infrastructure (but of course that will come as we work on this C/C++ backend).

Good point - I actually thought I did put it in help, but turns out it was only in this PR description.

- Added documentation pointing to PyPi
- Replaced boilerplate with helper to_pex_request()

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Huzzah! Thanks!

@Eric-Arellano Eric-Arellano enabled auto-merge (squash) May 12, 2022 18:36
@Eric-Arellano Eric-Arellano merged commit ac0973d into pantsbuild:main May 12, 2022
@sureshjoshi sureshjoshi deleted the 15377-clang-format-plugin branch May 12, 2022 20:15
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.

None yet

4 participants