Skip to content

Commit 26645df

Browse files
Created Option for Linters only
1 parent 4f52d3e commit 26645df

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

.github/workflows/ci-lint.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ jobs:
2424
submodules: recursive
2525
- uses: actions/setup-python@v5
2626

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

33-
- name: Build (Ubuntu 22.04)
30+
- name: Configure CMake for lint-only build
3431
run: |
35-
tools/ci-build.sh
32+
mkdir -p build && cd build
33+
cmake .. -DCMAKE_LINT_ONLY=ON
3634
3735
- name: Run cpplint on C/C++ files.
3836
run: cmake --build build --target cpplint
@@ -43,4 +41,4 @@ jobs:
4341
- name: Run black and isort on Python files.
4442
run: |
4543
cmake --build build --target black
46-
cmake --build build --target isort
44+
cmake --build build --target isort

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ OPTION (ENABLE_UNIFIED_COMPILATION "Enable CMAKE_UNITY_BUILD" OFF)
7474
# Enable DumpPipe pass output
7575
OPTION(ENABLE_DUMP_PIPE "Enable DumpPipe pass output" ON)
7676

77+
option(CMAKE_LINT_ONLY "Only run linting/formatting targets without building p4c" OFF)
78+
79+
if(CMAKE_LINT_ONLY)
80+
include(cmake/Linters.cmake)
81+
82+
# Add the existing linting targets here using the functions
83+
add_cpplint_target()
84+
add_clang_format_target() # (if defined inside Linters.cmake)
85+
add_cpplint_target()
86+
add_black_target()
87+
88+
# Stop here, no further targets
89+
return()
90+
endif()
91+
92+
7793
set (P4C_DRIVER_NAME "p4c" CACHE STRING "Customize the name of the driver script")
7894

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

0 commit comments

Comments
 (0)