Skip to content

cmake: add FORMATTING_ONLY option to run formatters without build deps#5554

Open
Vineet1101 wants to merge 3 commits intop4lang:mainfrom
Vineet1101:feature/formatting-only-option
Open

cmake: add FORMATTING_ONLY option to run formatters without build deps#5554
Vineet1101 wants to merge 3 commits intop4lang:mainfrom
Vineet1101:feature/formatting-only-option

Conversation

@Vineet1101
Copy link
Contributor

Add a new FORMATTING_ONLY CMake option that skips all build dependencies (flex, bison, boost, protobuf, etc.) and only configures the formatting/linting targets (clang-format, cpplint, black, isort).

This allows contributors to run code formatters without needing to install the full P4C toolchain:

cmake -B build -DFORMATTING_ONLY=ON
cmake --build build --target clang-format

Fixes: #4534

@fruffy fruffy added the infrastructure Topics related to code style and build and test infrastructure. label Mar 20, 2026
@fruffy
Copy link
Collaborator

fruffy commented Mar 20, 2026

To validate that this works as intended you should enable this option for our linter workflow here: https://github.com/p4lang/p4c/blob/main/.github/workflows/ci-lint.yaml

Add a new FORMATTING_ONLY CMake option that skips all build
dependencies (flex, bison, boost, protobuf, etc.) and only configures
the formatting/linting targets (clang-format, cpplint, black, isort).

This allows contributors to run code formatters without needing to
install the full P4C toolchain:

    cmake -B build -DFORMATTING_ONLY=ON
    cmake --build build --target clang-format

Fixes: p4lang#4534
Signed-off-by: Vineet1101 <vineetgoel692@gmail.com>
Signed-off-by: Vineet1101 <vineetgoel692@gmail.com>
@Vineet1101 Vineet1101 force-pushed the feature/formatting-only-option branch 2 times, most recently from 536785b to b1d8f7e Compare March 21, 2026 09:02
@Vineet1101
Copy link
Contributor Author

To validate that this works as intended you should enable this option for our linter workflow here: https://github.com/p4lang/p4c/blob/main/.github/workflows/ci-lint.yaml

done

@fruffy
Copy link
Collaborator

fruffy commented Mar 21, 2026

To validate that this works as intended you should enable this option for our linter workflow here: https://github.com/p4lang/p4c/blob/main/.github/workflows/ci-lint.yaml

done

Great, now if you check the build log here: https://github.com/p4lang/p4c/actions/runs/23376288633/job/68008761360?pr=5554

You can see that we still install PI and BMv2, but we do not actually need them for the linter. Hopefully, once we get rid of these two, the linter run should be very quick.

This disables BMv2, eBPF, and P4TC installation to speed up the linter job as they are not needed.

Signed-off-by: Vineet1101 <vineetgoel692@gmail.com>
@Vineet1101
Copy link
Contributor Author

To validate that this works as intended you should enable this option for our linter workflow here: https://github.com/p4lang/p4c/blob/main/.github/workflows/ci-lint.yaml

done

Great, now if you check the build log here: https://github.com/p4lang/p4c/actions/runs/23376288633/job/68008761360?pr=5554

You can see that we still install PI and BMv2, but we do not actually need them for the linter. Hopefully, once we get rid of these two, the linter run should be very quick.

This is also done. This time the linter took only 3 mins, previously it took around 13mins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Topics related to code style and build and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

It should be possible to run the formatters without needing to install all P4C dependencies

2 participants