Skip to content

Commit

Permalink
Switched to odb 2.5 from 2.4 on Ubuntu 18.04 (Ericsson#385)
Browse files Browse the repository at this point in the history
Switched to odb 2.5 from 2.4, since the version 2.4 is currently broken.

Co-authored-by: Bendegúz Filyó <filyo.bendeguz@hallgato.ppke.hu>
Co-authored-by: Whisperity <whisperity@gmail.com>
Co-authored-by: Máté Cserép <mcserep@gmail.com>
  • Loading branch information
4 people authored May 29, 2020
1 parent ed26e0f commit 6c27226
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 61 deletions.
51 changes: 45 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
os: linux
sudo: require

language: cpp
language: generic

services:
- postgresql
Expand Down Expand Up @@ -52,23 +52,54 @@ services:
libboost-all-dev
llvm-7 llvm-7-dev clang-7 libclang-7-dev
default-jdk
odb libodb-dev
libodb-sqlite-dev libsqlite3-dev
libodb-pgsql-dev postgresql-server-dev-10
gcc-7-plugin-dev
libsqlite3-dev
postgresql-server-dev-10
libmagic-dev libgit2-dev ctags
libgraphviz-dev npm
libgtest-dev
libssl1.0-dev
byacc flex

.install_odb: &install_odb
|
if [ ! -f "$HOME/build2_install/bin/bpkg" ]; then
mkdir /tmp/build2src
cd /tmp/build2src
curl -sSfO https://download.build2.org/0.12.0/build2-install-0.12.0.sh
sh build2-install-0.12.0.sh --yes --trust yes "$HOME/build2_install/"
fi
export PATH=$PATH:$HOME/build2_install/bin/
if [ ! -f "$HOME/odb_install/bin/odb" ]; then
mkdir /tmp/odb_build
cd /tmp/odb_build
bpkg create --quiet --jobs $(nproc) cc \
config.cxx=g++ config.cc.coptions=-O3 \
config.bin.rpath="$HOME/odb_install/lib" config.install.root="$HOME/odb_install" \
config.install.sudo=sudo
bpkg add https://pkg.cppget.org/1/beta --trust-yes
bpkg fetch --trust-yes
bpkg build odb --yes
bpkg build libodb --yes
bpkg build libodb-sqlite --yes
bpkg build libodb-pgsql --yes
bpkg install --all --recursive
fi

.install_thrift: &install_thrift
|
if [ ! -f "$HOME/thrift_install/bin/thrift" ]; then
cd $HOME
wget -O thrift-0.13.0.tar.gz "http://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=thrift/0.13.0/thrift-0.13.0.tar.gz"
tar -xvf ./thrift-0.13.0.tar.gz
cd thrift-0.13.0
./configure --prefix=$HOME/thrift_install --without-python --without-php --without-ruby --without-nodejs --without-go --without-java
./configure --prefix=$HOME/thrift_install --without-python \
--enable-libtool-lock --enable-tutorial=no --enable-tests=no \
--with-libevent --with-zlib --without-nodejs --without-lua \
--without-ruby --without-csharp --without-erlang --without-perl \
--without-php --without-php_extension --without-dart \
--without-haskell --without-go --without-rs --without-haxe \
--without-dotnetcore --without-d --without-qt4 --without-qt5
make install
fi

Expand Down Expand Up @@ -110,6 +141,10 @@ before_script:
# LLVM/Clang test from package install
- /usr/bin/clang-7 --version
- /usr/bin/llvm-config-7 --version --has-rtti
# ODB
- export CMAKE_PREFIX_PATH=$HOME/odb_install:$CMAKE_PREFIX_PATH
- export PATH=$HOME/odb_install/bin:$PATH
- odb --version
# Thrift
- export CMAKE_PREFIX_PATH=$HOME/thrift_install:$CMAKE_PREFIX_PATH
- export PATH=$HOME/thrift_install/bin:$PATH
Expand Down Expand Up @@ -176,6 +211,7 @@ jobs:
install:
- sudo apt-get update -y
- *install_bionic
- *install_odb
- *install_thrift
- *install_gtest_bionic
script:
Expand All @@ -187,6 +223,7 @@ jobs:
install:
- sudo apt-get update -y
- *install_bionic
- *install_odb
- *install_thrift
- *install_gtest_bionic
script:
Expand All @@ -195,4 +232,6 @@ jobs:
cache:
directories:
- $HOME/thrift_install
- $HOME/gtest_install
- $HOME/gtest_install
- $HOME/build2_install
- $HOME/odb_install
6 changes: 3 additions & 3 deletions FindOdb.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
#
# https://github.com/BtbN/OdbCmake/blob/master/cmake/Modules/FindODB.cmake
# This module defines the following variables:
#
Expand All @@ -7,7 +7,7 @@
# odb generated headers.
#
# ODB_FOUND - All required components and the core library were found
# ODB_INCLUDR_DIRS - Combined list of all components include dirs
# ODB_INCLUDE_DIRS - Combined list of all components include dirs
# ODB_LIBRARIES - Combined list of all componenets libraries
#
# ODB_LIBODB_FOUND - Libodb core library was found
Expand Down Expand Up @@ -98,7 +98,7 @@ endif()
set(ODB_INCLUDE_DIRS ${ODB_LIBODB_INCLUDE_DIRS})
set(ODB_LIBRARIES ${ODB_LIBODB_LIBRARIES})

set(ODB_FIND_COMPONENTS "pgsql" "sqlite")
set(ODB_FIND_COMPONENTS "${DATABASE}")
foreach(component ${ODB_FIND_COMPONENTS})
find_odb_api(${component})
endforeach()
Expand Down
1 change: 1 addition & 0 deletions Functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function(add_odb_library _name)
target_compile_options(${_name} PUBLIC -Wno-unknown-pragmas -fPIC)
target_link_libraries(${_name} ${ODB_LIBRARIES})
target_include_directories(${_name} PUBLIC
${ODB_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/util/include
${CMAKE_SOURCE_DIR}/model/include
${CMAKE_CURRENT_SOURCE_DIR}/include
Expand Down
91 changes: 68 additions & 23 deletions doc/deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ be installed from the official repository of the given Linux distribution.
- **`cmake`** and **`make`**: For building CodeCompass.
- **`g++`**: For compiling CodeCompass. A version which supports C++14 features
is required. (Alternatively, you can compile with Clang.)
- **`gcc-X`, `gcc-X-plugin-dev`**: For building ODB.
- **`libboost-all-dev`**: Boost can be used during the development.
- **`llvm-7-dev`**, **`libclang-7-dev`**: C++ parser uses LLVM/Clang for
- **`llvm-7-dev`**, **`clang-7`**, **`libclang-7-dev`**: C++ parser uses LLVM/Clang for
parsing the source code.
- **`odb`**, **`libodb-dev`**: For persistence ODB can be used which is an
Object Relation Mapping (ORM) system.
Expand All @@ -26,8 +27,8 @@ be installed from the official repository of the given Linux distribution.
database system is used.
- **`default-jdk`**: For search parsing CodeCompass uses an indexer written in
Java.
- **`libssl-dev`**: OpenSSL libs are required by Thrift.
- **`libgraphviz-dev`**: GraphViz is used for generating diagram visualizaions.
- **`libssl-dev`** / **`libssl1.0-dev`**: OpenSSL libs are required by Thrift, and NodeJS.
- **`libgraphviz-dev`**: GraphViz is used for generating diagram visualizations.
- **`libmagic-dev`**: For detecting file types.
- **`libgit2-dev`**: For compiling Git plugin in CodeCompass.
- **`npm`** (and **`nodejs-legacy`** for Ubuntu 16.04): For handling
Expand Down Expand Up @@ -61,9 +62,9 @@ sudo apt-get install git cmake make g++ libboost-all-dev \
#### Ubuntu 18.04 LTS

```bash
sudo apt-get install git cmake make g++ libboost-all-dev \
llvm-7-dev libclang-7-dev odb libodb-dev \
default-jdk libssl-dev libgraphviz-dev libmagic-dev libgit2-dev ctags \
sudo apt install git cmake make g++ gcc-7-plugin-dev libboost-all-dev \
llvm-7-dev clang-7 libclang-7-dev \
default-jdk libssl1.0-dev libgraphviz-dev libmagic-dev libgit2-dev ctags \
libgtest-dev npm
```

Expand Down Expand Up @@ -91,36 +92,78 @@ by other processes which could, in extreme cases, make the system very hard or
impossible to recover. **Please do NOT add a `sudo` in front of any `make` or
other commands below, unless *explicitly* specified!**

### ODB (for Ubuntu 18.04)
ODB is an Object Relational Mapping tool, that is required by CodeCompass.
For Ubuntu 18.04, the official release of ODB conflicts with the official compiler (GNU G++ 7) of the distribution.
A newer version of ODB must be compiled manually.

The ODB installation uses the build2 build system.
(Build2 is not needed for CodeCompass so you may delete it right after the installation of ODB.)
```bash
wget https://download.build2.org/0.12.0/build2-install-0.12.0.sh
sh build2-install-0.12.0.sh --yes --trust yes "<build2_install_dir>"
```

Now, utilizing the *build2* toolchain, we can build the *odb* library. In the script below, we assume that ODB is built in the `<odb_build_dir>` directory and installed in the `<odb_install_dir>` directory.
```bash
export PATH="<build2_install_dir>/bin:$PATH"
# Configuring the build
cd <odb_build_dir>
bpkg create --quiet --jobs <number_of_threads> cc \
config.cxx=g++ \
config.cc.coptions=-O3 \
config.bin.rpath=<odb_install_dir>/lib \
config.install.root=<odb_install_dir>

# Getting the source
bpkg add https://pkg.cppget.org/1/beta --trust-yes
bpkg fetch --trust-yes

# Building odb
bpkg build odb --yes
bpkg build libodb --yes
bpkg build libodb-sqlite --yes
bpkg build libodb-pgsql --yes
bpkg install --all --recursive
```
Please take into consideration that the ODB installation can take up a long time (depending on the machine one is using),
but you can increase the used threads with the `--jobs` option.

> **Note:** now you may delete the *build2* toolchain installed in the `<build2_install_dir>` folder, if you do not need any longer.
### Thrift
CodeCompass needs [Thrift](https://thrift.apache.org/) which provides Remote
Procedure Call (RPC) between the server and the client. Thrift is not part of
the official Ubuntu 16.04 LTS and 18.04 LTS repositories, but you can download
it and build from source:

Thrift can generate stubs for many programming languages. The configure
script looks at the development environment and if it finds the environment
for a given language then it'll use it. For example in the previous step npm
was installed which requires NodeJS. If NodeJS can be found on your machine
then the corresponding stub will also compile. If you don't need it then you
can turn it off: `./configure --without-nodejs.`

In certain cases, installation may fail if development libraries for
languages are not installed on the target machine. E.g. if Python is
installed but the Python development headers are not, Thrift will unable to
install. Python, PHP and such other Thrift builds are NOT required by
CodeCompass, and can significantly increase compile time so it is advised to avoid using them if it's not necessary.

```bash
# Download and uncompress Thrift:
wget "http://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=thrift/0.13.0/thrift-0.13.0.tar.gz" \
-O thrift-0.13.0.tar.gz
tar -xvf ./thrift-0.13.0.tar.gz
cd thrift-0.13.0

# Ant is required for having Java support in Thrift.
sudo apt-get install ant

# Thrift can generate stubs for many programming languages. The configure
# script looks at the development environment and if it finds the environment
# for a given language then it'll use it. For example in the previous step npm
# was installed which requires NodeJS. If NodeJS can be found on your machine
# then the corresponding stub will also compile. If you don't need it then you
# can turn it off: ./configure --without-nodejs.
#
# In certain cases, installation may fail if development libraries for
# languages are not installed on the target machine. E.g. if Python is
# installed but the Python development headers are not, Thrift will unable to
# install. Python, PHP and such other Thrift builds are NOT required by
# CodeCompass.

./configure --prefix=<thrift_install_dir> --with-python=NO --with-php=NO
./configure --prefix=<thrift_install_dir> --silent --without-python \
--enable-libtool-lock --enable-tutorial=no --enable-tests=no \
--with-libevent --with-zlib --without-nodejs --without-lua \
--without-ruby --without-csharp --without-erlang --without-perl \
--without-php --without-php_extension --without-dart \
--without-haskell --without-go --without-rs --without-haxe \
--without-dotnetcore --without-d --without-qt4 --without-qt5

make install
```
Expand Down Expand Up @@ -169,7 +212,9 @@ be seen by CMake build system:
```bash
export GTEST_ROOT=<gtest_install_dir>
export CMAKE_PREFIX_PATH=<thrift_install_dir>:$CMAKE_PREFIX_PATH
export CMAKE_PREFIX_PATH=<odb_install_directory>:$CMAKE_PREFIX_PATH
export PATH=<thrift_install_dir>/bin:$PATH
export PATH=<odb_install_directory>/bin>:$PATH
```

Use the following instructions to build CodeCompass with CMake.
Expand Down
12 changes: 6 additions & 6 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ CodeCompass_parser \

As an experimental feature CodeCompass supports incremental parsing, updating an
existing database and project workspace by detecting the added, deleted and modified files.
Incremental parsing depends on that the build tooling generates a **complete** compilation database,
Incremental parsing depends on that the build tooling generates a **complete** compilation database,
therefore the build commands for only the modified files are not sufficient.
In case of CMake, using the result of the `CMAKE_EXPORT_COMPILE_COMMANDS=ON` argument, the
In case of CMake, using the result of the `CMAKE_EXPORT_COMPILE_COMMANDS=ON` argument, the
compilation database will always contain all files.
Currently the C++ and metrics parsers support incremental parsing, while other parsers
just execute a forced reparse.
Expand All @@ -171,20 +171,20 @@ In case the analyzed software project was significantly changed (e.g. as a resul
restructuring the project), dropping the workspace database and performing a full, clean
parse can yield results faster. This can be achieved by passing the `--force` (or `-f`)
command line option which can be specified for `CodeCompass_parser`. Another solution is
to set the `--incremental-threshold` option, which configures an upper threshold of change
for incremental parsing (in the percentage of changed files). Above the threshold a full,
to set the `--incremental-threshold` option, which configures an upper threshold of change
for incremental parsing (in the percentage of changed files). Above the threshold a full,
clean reparse is performed. The default value for this threshold is *10%*.

In order to review the changes detected by the incremental parser without performing any
action that would alter the workspace database or directory, the `--dry-run` command line
action that would alter the workspace database or directory, the `--dry-run` command line
option can be specified for `CodeCompass_parser`.

## 3. Start the web server
You can start the CodeCompass webserver with `CodeCompass_webserver` binary in
the CodeCompass installation directory.

```bash
CodeCompass_webserver -w <workdir> -p <port> -d <connection_string>
CodeCompass_webserver -w <workdir> -p <port>
```

- **Workspace**: This is a directory where the some parse results, and different
Expand Down
6 changes: 5 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ Table of Contents

## Build image from development
Build the development environment image. The tag name is important!
**It is very important to give this command from the top level directory of the
CodeCompass source.**

```
docker build -t codecompass-dev docker/dev
cd CodeCompass
docker build -t codecompass-dev --file docker/dev/Dockerfile .
```

## How to use docker to develop CodeCompass
Expand Down
Loading

0 comments on commit 6c27226

Please sign in to comment.