Warning, /sdk/codevis/doc/build_linux.md is written in an unsupported language. File is not indexed.

0001 ## Linux build
0002 
0003 ### Easy Build using kdesrc-build
0004 
0005 We use `kdesrc-build` in order to speed up and automate the build process,
0006 downloading the needed libraries, and building the ones we need in a multitude of linux distributions.
0007 If you have never used `kdesrc-build` before, it's quite simple, and this is the startup point:
0008 
0009 clone the repository, or install from your package manager the `kdesrc-build` tool, the repository can be found in `https://invent.kde.org/sdk/kdesrc-build/`
0010 
0011 Run `kdesrc-build --initial-setup` to install the necessary packages for your linux distribution. Even if you already have `kdesrc-build`, you are encouraged to run `--initial-setup` often, to install newer dependencies that are added to the list from time to time, running this again will not override your configuration file.
0012 
0013 Open and edit `~/.config/kdesrc-buildrc` to your liking, specially the `kdedir`, `source-dir` and `build-dir` packages.
0014 
0015 run `kdesrc-build codevis`
0016 This will:
0017     - Download the sources from the KDE infrastructure, on `source-dir`
0018     - Configure the sources for building
0019     - Build the sources into a compiled binary on `build-dir`
0020     - Install the compiled binary into `kdedir`
0021 
0022 After you build the software for the first time with kdesrc-build, you can load the source on any IDE, and point the build folder to `$build-dir/codevis`, the IDE should pickup the `CMakeCache.txt` and the `compile_commands.json` and you can go from there.
0023 
0024 ### Building natively on Ubuntu 20.10
0025 
0026 First install the dependencies:
0027 ```
0028 apt-get update && apt-get install \
0029     build-essential \
0030     clang \
0031     clang-tools-13 \
0032     llvm-dev \
0033     cmake \
0034     git \
0035     lcov \
0036     libclang-13-dev \
0037     libqt5core5a \
0038     qtbase5-dev \
0039     qtwebengine5-dev \
0040     libsqlite3-dev \
0041     sqlite3 \
0042     catch2 \
0043     extra-cmake-modules \
0044     libclang-dev \
0045     libqt5svg5-dev \
0046     libkf5config-dev \
0047     libkf5texteditor-dev \
0048     python3-dev \
0049 ```
0050 
0051 Build and test the project
0052 ```
0053 cd $PROJECT_PATH
0054 git submodule init
0055 git submodule update --recursive
0056 mkdir build
0057 cd build
0058 cmake ..
0059 make -j$(nproc)
0060 make test
0061 ```
0062 
0063 The GUI executable is at `build/desktopapp/codevis_desktop`.
0064 
0065 ### Building using the docker images
0066 
0067 To build inside of docker use
0068 
0069 ```
0070 export DOCKER_BUILDKIT=1
0071 cd $PROJECT_PATH
0072 docker build --target build-qt -t ctlvt/build-qt .
0073 ```
0074 
0075 The build is located in `$PROJECT_PATH/build`.
0076 
0077 Unless your host machine is running very similar library versions to the docker
0078 container, the built binaries will not be very useful: this is mostly good for
0079 CI. Use appimage to create re-distributable binaries.
0080 
0081 To get files out of the docker image we need to start a container then copy files
0082 out of it
0083 
0084 In one terminal emulator:
0085 ```
0086 docker run -it --name "lvtbuild" ctlvt/build-qt
0087 ```
0088 
0089 In another:
0090 ```
0091 docker cp lvtbuild:$PROJECT_PATH/build path/to/destination
0092 ```
0093 
0094 ### Appimage
0095 
0096 There is a handy docker image to build an appimage package. Build it using
0097 ```
0098 export DOCKER_BUILDKIT=1
0099 docker pull debian:buster
0100 cd $PROJECT_PATH
0101 docker build --target appimage -t ctlvt/appimage .
0102 ```
0103 
0104 To output the appimage to the directory `/foo`, run
0105 ```
0106 docker run -v /foo:/tmp/lvt-appimage ctlvt/appimage
0107 ```
0108 
0109 It is very important to build the appimage using the docker container and not by
0110 running the appimage build script nativly because appimage does not bundle glibc.
0111 glibc is forwards but not backwards compatible so the appimage has to be built
0112 to the oldest libc practically available.
0113 
0114 The appimage is the most useful way to distribute Linux executables.
0115 
0116 ### Centos 7
0117 
0118 There's a Docker script that builds the tool natively on Centos 7, The script is
0119 slow because it needs to compile llvm, qt and cmake beforehand.
0120 Invoke the script from the toplevel source directory:
0121 
0122 ```
0123 $ docker build -f packaging/centos7/Dockerfile . --progress=plain
0124 ```
0125 
0126 Invoking it from the toplevel directory is needed so that Docker can access
0127 the source files of this project while building it.
0128 
0129 # Code coverage
0130 
0131 ```
0132 cmake -DENABLE_CODE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug ..
0133 cmake --build . -j$(nproc)
0134 ctest . -j$(nproc)
0135 make coverage
0136 ```