p4c icon indicating copy to clipboard operation
p4c copied to clipboard

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

Open fruffy opened this issue 11 months ago • 5 comments

Currently CMake breaks if you do not have certain dependencies (flex, bison, boost, etc) installed. It would be nice to run our formatters independently.

fruffy avatar Mar 15 '24 14:03 fruffy

Hello, I am going to working on this issue

zhonniks avatar Mar 18 '24 17:03 zhonniks

@fruffy if i want to extract formatters into a separate directory or module, may i add only clang-format and cmake-format scripts ? It is a bit complicated to find all used formatters, directory will include documentation how to use it Screenshot 2024-03-20 at 6 07 52 PM is it okay?

zhonniks avatar Mar 20 '24 13:03 zhonniks

This should be possible to do only in CMake. The reason why is that each back end may add its own clang-format files. We used to have code set up like this but it turned out to be too inflexible.

We have a linter file where everything is set up: https://github.com/p4lang/p4c/blob/71d79c8dccd9fc78af52379868f20f5c45e69774/cmake/Linters.cmake#L1

Private extensions may call add_clang_format_files to add their own files to the list.

fruffy avatar Mar 20 '24 13:03 fruffy

Also do not worry about creating a dedicated folder structure. We already have all the formatters and configs available, the only changes required are to the CMake script. We could add an option "CMAKE_LINT_ONLY" to the main CMakeLists.txt file where it does not check for certain dependencies.

fruffy avatar Mar 20 '24 13:03 fruffy

added PR #4552 should i add conditional checks? In order to handle the dependencies based on whether CMAKE_LINT_ONLY is enabled or not: if(NOT CMAKE_LINT_ONLY) find_package(FLEX REQUIRED) find_package(BISON REQUIRED) find_package(Boost REQUIRED) endif()

or an option "CMAKE_LINT_ONLY" is enough?

But it looks like the failures are coming from eBPF back end tests, is it because some dependencies are missing?

zhonniks avatar Mar 20 '24 19:03 zhonniks