diff --git a/README.md b/README.md index b5d3dc46c0..fc5dd23e62 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,8 @@ openairinterface5g ├── openair3 : Layer 3 (3GPP LTE Rel-10 S1AP/GTP, NR Rel-15 NGAP/GTP) ├── openshift : OpenShift helm charts for some deployment options of OAI ├── radio : Drivers for various radios such as USRP, AW2S, RFsim, 7.2 FHI, ... -└── targets : Some configuration files; only historical relevance, and might be deleted in the future +├── targets : Some configuration files; only historical relevance, and might be deleted in the future +└── tools : Tools for use by the developers/ci machines: code analysis and formatting ``` # How to get support from the OAI Community # diff --git a/doc/README.md b/doc/README.md index 7f57a24eb0..ba7e5fbd12 100644 --- a/doc/README.md +++ b/doc/README.md @@ -115,3 +115,8 @@ The other SDRs (AW2S, LimeSDR, ...) have no READMEs. - [UnitTests.md](./UnitTests.md) explains the unit testing setup - [TESTBenches.md](./TESTBenches.md) lists the CI setup and links to pipelines + +# Developer tools + +- [formatting](../tools/formatting/README.md) is a clang-format error detection tool +- [iwyu](../tools/iwyu/README.md) is a tool to detect `#include` errors diff --git a/tools/iwyu/README.md b/tools/iwyu/README.md new file mode 100644 index 0000000000..30b573747a --- /dev/null +++ b/tools/iwyu/README.md @@ -0,0 +1,23 @@ +# Overview + +IWYU - [include what you use](https://github.com/include-what-you-use/include-what-you-use) +is a tool that can detect and correct C/C++ include errors + +# Usage + +``` +TARGET= docker compose up +``` + +Automatically apply suggestions: + +``` +TARGET= docker compose run iwyu | tee suggestions +cat suggestions | python3 ~/include-what-you-use/fix_includes.py +``` + +Apply only removal suggestions + +``` +cat suggestions | grep "should add these line\|The full include-list\|should remove these lines\|^-" | python3 ~/include-what-you-use/fix_includes.py +``` diff --git a/tools/iwyu/docker-compose.yaml b/tools/iwyu/docker-compose.yaml new file mode 100644 index 0000000000..de8dab6b73 --- /dev/null +++ b/tools/iwyu/docker-compose.yaml @@ -0,0 +1,39 @@ +services: + iwyu: + image: iwyu + build: + dockerfile_inline: | + FROM ran-base + ENV DEBIAN_FRONTEND=noninteractive + RUN apt update && \ + apt install -y wget gnupg && \ + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ + echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" > /etc/apt/sources.list.d/llvm.list && \ + apt update + RUN apt install -y \ + git \ + cmake \ + build-essential \ + clang-14 \ + libclang-14-dev \ + ninja-build \ + libyaml-cpp-dev + WORKDIR /iwyu/ + RUN git clone https://github.com/include-what-you-use/include-what-you-use.git + RUN cd /iwyu/include-what-you-use && \ + git checkout origin/clang_14 && \ + mkdir build && cd build && \ + cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc ../ -G "Unix Makefiles" && \ + make + RUN apt clean && rm -rf /var/lib/apt/lists/* + volumes: + - ../../:/code/ + command: + bash -c "git config --global --add safe.directory /code && \ + mkdir -p iwyu-bin && cd iwyu-bin && \ + cmake \ + -DCMAKE_C_INCLUDE_WHAT_YOU_USE=/iwyu/include-what-you-use/build/bin/include-what-you-use \ + -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=/iwyu/include-what-you-use/build/bin/include-what-you-use \ + /code/ \ + -GNinja && \ + cmake --build . --target $TARGET"