Skip to content

Add cplint workflow support for minimal lint-only builds #5225

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 6 additions & 8 deletions .github/workflows/ci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ jobs:
submodules: recursive
- uses: actions/setup-python@v5

- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: apply-linters-${{ runner.os }}
max-size: 1000M
- name: Install Python requirements
run: pip3 install -r requirements.txt

- name: Build (Ubuntu 22.04)
- name: Configure CMake for lint-only build
run: |
tools/ci-build.sh
mkdir -p build && cd build
cmake .. -DCMAKE_LINT_ONLY=ON

- name: Run cpplint on C/C++ files.
run: cmake --build build --target cpplint
Expand All @@ -43,4 +41,4 @@ jobs:
- name: Run black and isort on Python files.
run: |
cmake --build build --target black
cmake --build build --target isort
cmake --build build --target isort
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ OPTION (ENABLE_UNIFIED_COMPILATION "Enable CMAKE_UNITY_BUILD" OFF)
# Enable DumpPipe pass output
OPTION(ENABLE_DUMP_PIPE "Enable DumpPipe pass output" ON)

option(CMAKE_LINT_ONLY "Only run linting/formatting targets without building p4c" OFF)

if(CMAKE_LINT_ONLY)
include(cmake/Linters.cmake)

# Add the existing linting targets here using the functions
add_cpplint_target()
add_clang_format_target() # (if defined inside Linters.cmake)
add_cpplint_target()
add_black_target()

# Stop here, no further targets
return()
endif()


set (P4C_DRIVER_NAME "p4c" CACHE STRING "Customize the name of the driver script")

set(MAX_LOGGING_LEVEL 10 CACHE STRING "Control the maximum logging level for -T logs")
Expand Down
Loading