Skip to content
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

Included headers changes after running include-what-you-use tool #1503

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4740c7e
Introduce a Dockerfile dedicated to include-what-you-use tool build a…
fspindle Nov 7, 2024
d1448b3
Modify core module to satisfy IWYU
fspindle Nov 7, 2024
620bd31
Fix build on c++98
fspindle Nov 7, 2024
393585e
Fix build on ubuntu 12.04 ci
fspindle Nov 7, 2024
77dcf51
Add missing header detected on nix ci
fspindle Nov 7, 2024
35f2281
Modify io module to satisfy IWYU
fspindle Nov 7, 2024
4fa95eb
Simplify eigen includes
fspindle Nov 7, 2024
413ee06
Fix /usr/include/linux/ppdev.h:30:8: error: previous definition of ‘s…
fspindle Nov 7, 2024
454c887
Add missing vpMatrixException header
fspindle Nov 7, 2024
65c2392
Fix io module build on ubuntu 12.04 ci
fspindle Nov 7, 2024
308824a
More fixes in core tests
fspindle Nov 7, 2024
d1eb535
Introduce changes in visual_features module
fspindle Nov 7, 2024
ab514e5
Introduce fixes in vision module
fspindle Nov 7, 2024
cc74691
Introduce fixes in me module
fspindle Nov 7, 2024
d78e1ad
Introduce fixes in blob module
fspindle Nov 7, 2024
acbb963
Introduce fixes in detection module
fspindle Nov 7, 2024
9eccfe3
Introduce fixes in ar module
fspindle Nov 7, 2024
9d3ecaa
Introduce fixes in sensor module
fspindle Nov 7, 2024
5867bf9
Fixes to build on ubuntu 12.04
fspindle Nov 7, 2024
ebcfcae
Remove useless code introduced for debug
fspindle Nov 7, 2024
9c13688
Fix build when visp namespace is enabled
fspindle Nov 7, 2024
953d237
Trigger new build
fspindle Nov 7, 2024
f65fb95
Trigger new build after fixing visp_sample
fspindle Nov 8, 2024
a0bb711
Include initializer_list header only when c++11
fspindle Nov 8, 2024
bf30407
Fix to include json.hpp only when VISP_HAVE_NLOHMANN_JSON is defined
fspindle Nov 8, 2024
ff7a165
Fix build on UWP arch
fspindle Nov 8, 2024
64408b6
Add script to measure build time
fspindle Nov 12, 2024
94fe282
Introduce more fixes detected by IWYU
fspindle Nov 12, 2024
3335621
Add missing header detected on ci
fspindle Nov 12, 2024
7a67971
Fix build under windows ci
fspindle Nov 12, 2024
795478f
Fix build under windows ci
fspindle Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Visual Servoing Platform
Resume of the change log

Copyright (C) 2005 - 2023 by Inria. All rights reserved.
Copyright (C) 2005 - 2024 by Inria. All rights reserved.
https://visp.inria.fr

ViSP 3.x.x (Version in development)
Expand Down
8 changes: 6 additions & 2 deletions apps/calibration/visp-compute-chessboard-poses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@

#include <visp3/core/vpConfig.h>

#if defined(VISP_HAVE_OPENCV)
#include <opencv2/opencv_modules.hpp> // for HAVE_OPENCV_IMGCODECS, HAVE...
#endif

#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_CALIB3D) && defined(VISP_HAVE_PUGIXML)

#include <opencv2/calib3d/calib3d.hpp>
Expand Down Expand Up @@ -228,7 +232,7 @@ int main(int argc, const char **argv)
#elif defined(VISP_HAVE_GTK)
display = new vpDisplayGTK(I);
#endif
}
}
#endif

std::vector<vpPoint> corners_pts;
Expand Down Expand Up @@ -339,7 +343,7 @@ int main(int argc, const char **argv)
}
}
#endif
}
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e.getMessage() << std::endl;
}
Expand Down
159 changes: 159 additions & 0 deletions ci/docker/ubuntu-24.04-IWYU/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
FROM ubuntu:24.04

ARG DEBIAN_FRONTEND=noninteractive
ARG USER_UID=1001
ENV TZ=Europe/Paris

## Update aptitude with default packages
RUN apt-get update \
&& apt-get install -y \
cmake \
cmake-curses-gui \
curl \
gedit \
gdb \
git \
iputils-ping \
locales \
locate \
lsb-release \
mercurial \
nano \
net-tools \
python3 \
python3-dev \
python3-pip \
python3-dbg \
python3-empy \
python3-numpy \
python3-pip \
python3-psutil \
python3-venv \
software-properties-common \
sudo \
tzdata \
vim \
wget \
&& apt-get clean
# build-essential \

# Update aptitude with recommended ViSP 3rd parties
RUN apt-get update \
&& apt-get install -y \
libdc1394-dev \
libeigen3-dev \
liblapack-dev \
libopencv-dev \
libv4l-dev \
libx11-dev \
libzbar-dev \
nlohmann-json3-dev \
&& apt-get clean

# Update aptitude with other optional ViSP 3rd parties
RUN apt-get update \
&& apt-get install -y \
libcoin-dev \
libdmtx-dev \
libgsl-dev \
libjpeg-turbo8-dev \
libpng-dev \
libogre-1.9-dev \
libois-dev \
libpcl-dev \
&& apt-get clean

RUN apt-get update \
&& apt-get install -y \
libedit-dev \
&& apt-get clean

# Set Locale
RUN locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
export LANG=en_US.UTF-8

ENV USERNAME vispci

RUN useradd -U --uid $USER_UID -ms /bin/bash ${USERNAME} \
&& echo "${USERNAME}:${USERNAME}" | chpasswd \
&& adduser ${USERNAME} sudo \
&& echo "$USERNAME ALL=NOPASSWD: ALL" >> /etc/sudoers.d/${USERNAME} \
&& adduser ${USERNAME} video

# Commands below are now run as normal user
USER ${USERNAME}

# When running a container start in the home folder
WORKDIR /home/$USERNAME

# Some apps don't show controls without this
ENV QT_X11_NO_MITSHM 1

# Install visp-images
RUN mkdir -p ${HOME}/visp-ws \
&& cd ${HOME}/visp-ws \
&& git clone https://github.com/lagadic/visp-images.git \
&& echo "export VISP_WS=${HOME}/visp-ws" >> ${HOME}/.bashrc \
&& echo "export VISP_INPUT_IMAGE_PATH=${HOME}/visp-ws/visp-images" >> ${HOME}/.bashrc

# Get IWYU
RUN cd ${HOME}/visp-ws \
&& mkdir -p 3rdparty \
&& cd 3rdparty \
&& git clone https://github.com/include-what-you-use/include-what-you-use.git

# Build llvm + clang + include-what-you-use
RUN cd ${HOME}/visp-ws \
&& mkdir -p 3rdparty \
&& cd 3rdparty \
&& git clone --depth=1 https://github.com/llvm/llvm-project.git \
&& cd llvm-project \
&& mkdir build \
&& cd build \
&& cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release -DLLVM_EXTERNAL_PROJECTS=iwyu -DLLVM_EXTERNAL_IWYU_SOURCE_DIR=/home/vispci/visp-ws/3rdparty/include-what-you-use ../llvm \
&& make -j4 \
&& sudo make install

# Build and install Panda3D from source
RUN cd ${HOME}/visp-ws \
&& mkdir -p 3rdparty \
&& cd 3rdparty \
&& git clone https://github.com/panda3d/panda3d \
&& cd panda3d \
&& python3 makepanda/makepanda.py --everything --installer --no-egl --no-gles --no-gles2 --no-opencv --threads 4 \
&& sudo dpkg -i panda3d*.deb \
&& echo "export Panda3D_DIR=${HOME}/visp-ws/3rdparty/panda3d" >> ~/.bashrc \
&& . ~/.bashrc

# Build and install YARP from source
RUN sudo apt-get install -y \
libeigen3-dev \
libace-dev \
libedit-dev \
libsqlite3-dev \
libtinyxml-dev \
&& cd ${HOME}/visp-ws \
&& mkdir -p 3rdparty \
&& cd 3rdparty \
&& git clone https://github.com/robotology/ycm-cmake-modules \
&& cd ycm-cmake-modules \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make -j4 \
&& sudo make install \
&& cd ${HOME}/visp-ws/3rdparty \
&& git clone https://github.com/robotology/yarp.git \
&& cd yarp \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make -j4 \
&& sudo make install

# Create visp build folder
RUN cd ${HOME}/visp-ws \
&& mkdir visp-build

CMD ["/bin/bash"]
86 changes: 86 additions & 0 deletions ci/docker/ubuntu-24.04-IWYU/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Docker dedicated to IWYU tool

Include-What-You-Use [IWYU](https://include-what-you-use.org/) is a tool for use with clang to analyze
#includes in C and C++ source files. This docker file contains the receipt to build clang with support of IWYU tool
that can be used to analyse ViSP c++ includes.

## Build docker image from Dockerfile

- We suppose here that you already installed docker.
If this is not the case, follow instructions provided for [Ubuntu](https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-docker.html#install_docker_engine_ubuntu) or [MacOS](https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-docker.html#install_docker_engine_mac).

- Get ViSP source code
```
$ cd $VISP_WS/
$ git clone https://github.com/lagadic/visp
```

- Build docker image from Dockerfile running the following:
```
$ cd $VISP_WS/visp/ci/docker/ubuntu-24.04-IWYU
$ docker build -t vispci/vispci:ubuntu-24.04-IWYU .
```

## Start the container

### On Ubuntu host

- On your computer running Ubuntu, allow access to the X11 server
```
$ xhost +local:docker
non-network local connections being added to access control list
```
- Run your Docker container. The following command connects to the ubuntu-24.04-IWYU Docker container.
```
$ docker run --rm -it --network=host --privileged \
--env=DISPLAY \
--env=QT_X11_NO_MITSHM=1 \
--volume=/tmp/.X11-unix:/tmp/.X11-unix:rw \
--volume=/dev:/dev \
--volume=$VISP_WS/visp:/home/vispci/visp-ws/visp \
vispci/vispci:ubuntu-24.04-IWYU
vispci@6c8d67579659:~$ pwd
/home/vispci
```
- Build ViSP with IWYU support
```
vispci@6c8d67579659:~$ cd ~/visp-ws/visp-build
vispci@6c8d67579659:~$ CC="clang" CXX="clang++" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use ../visp
vispci@6c8d67579659:~$ make -j4 visp_modules > ../visp/iwyu.log 2>&1
```

### On MacOS host

- Get your MacOS computer IP address
```
$ IP=$(/usr/sbin/ipconfig getifaddr en0)
$ echo $IP
$ 192.168.1.18
```
- Allow connections from MacOS to XQuartz
```
$ xhost + "$IP"
192.168.1.18 being added to access control list
```
- Run your Docker container. The following command connects to the ubuntu-24.04-IWYU Docker container.
```
$ docker run --rm -it --network=host --privileged \
--env=DISPLAY="${IP}:0" \
--env=QT_X11_NO_MITSHM=1 \
--volume=/tmp/.X11-unix:/tmp/.X11-unix:rw \
--volume=/dev:/dev \
--volume=$VISP_WS/visp:/home/vispci/visp-ws/visp \
vispci/vispci:ubuntu-24.04-IWYU
vispci@6c8d67579659:~$ pwd
/home/vispci
```
- Build ViSP with IWYU support
```
vispci@6c8d67579659:~$ cd ~/visp-ws/visp-build
vispci@6c8d67579659:~$ CC="clang" CXX="clang++" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use ../visp
vispci@6c8d67579659:~$ make -j4 visp_modules > ../visp/iwyu.log 2>&1
```

# Analyse IWYU logs

IWYU logs are available either on your host in `$VISP_WS/visp/iwyu.log` or in your docker container in `/home/vispci/visp-ws/visp/iwyu.log`.
10 changes: 10 additions & 0 deletions ci/docker/ubuntu-24.04-IWYU/script-build-time.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rm -rf visp-build-time
mkdir visp-build-time && cd visp-build-time
cmake ../visp -DBUILD_JAVA=OFF -DENABLE_AVX=ON

SECONDS=0
# make -j12
time make -j4
duration=$SECONDS
echo ""
echo "$((duration / 60)) minutes and $((duration % 60)) seconds elapsed."
3 changes: 3 additions & 0 deletions demo/wireframe-simulator/servoSimu4Points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
#include <visp3/visual_features/vpFeaturePoint.h>
#include <visp3/vs/vpServo.h>

#if defined(VISP_HAVE_OPENCV)
#include <opencv2/opencv_modules.hpp> // for HAVE_OPENCV_IMGCODECS, HAVE...
#endif
#define GETOPTARGS "dhp"

#if defined(VISP_HAVE_DISPLAY) && (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
Expand Down
3 changes: 3 additions & 0 deletions demo/wireframe-simulator/servoSimuCylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
#include <visp3/visual_features/vpFeatureBuilder.h>
#include <visp3/vs/vpServo.h>

#if defined(VISP_HAVE_OPENCV)
#include <opencv2/opencv_modules.hpp> // for HAVE_OPENCV_IMGCODECS, HAVE...
#endif
#define GETOPTARGS "dhp"

#if defined(VISP_HAVE_DISPLAY) && (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
Expand Down
3 changes: 3 additions & 0 deletions demo/wireframe-simulator/servoSimuSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
#include <visp3/visual_features/vpFeatureBuilder.h>
#include <visp3/visual_features/vpGenericFeature.h>
#include <visp3/vs/vpServo.h>
#if defined(VISP_HAVE_OPENCV)
#include <opencv2/opencv_modules.hpp> // for HAVE_OPENCV_IMGCODECS, HAVE...
#endif

#define GETOPTARGS "dhp"

Expand Down
5 changes: 4 additions & 1 deletion example/calibration/calibrate-camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

#include <visp3/core/vpConfig.h>

#if defined(VISP_HAVE_OPENCV)
#include <opencv2/opencv_modules.hpp> // for HAVE_OPENCV_IMGCODECS, HAVE...
#endif
#if (VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_CALIB3D) && defined(HAVE_OPENCV_HIGHGUI) && \
defined(HAVE_OPENCV_IMGPROC) && defined(VISP_HAVE_PUGIXML)

Expand Down Expand Up @@ -683,5 +686,5 @@ int main()
std::cout << "pugixml built-in 3rdparty is requested to run the calibration." << std::endl;
#endif
return EXIT_SUCCESS;
}
}
#endif
5 changes: 4 additions & 1 deletion example/device/display/displayOpenCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpDebug.h>

#if defined(VISP_HAVE_OPENCV)
#include <opencv2/opencv_modules.hpp> // for HAVE_OPENCV_IMGCODECS, HAVE...
#endif
#if defined(HAVE_OPENCV_HIGHGUI)

#include <visp3/core/vpImage.h>
Expand Down Expand Up @@ -463,5 +466,5 @@ int main()
std::cout << "Tip:" << std::endl;
std::cout << "- Install OpenCV, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
}
}
#endif
6 changes: 2 additions & 4 deletions example/tracking/mbtEdgeKltTracking.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/****************************************************************************
*
/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
*
Expand Down Expand Up @@ -30,8 +29,7 @@
*
* Description:
* Example of Hybrid Tracking of MBT and MBT KTL.
*
*****************************************************************************/
*/

/*!
\example mbtEdgeKltTracking.cpp
Expand Down
Loading
Loading