Skip to content

Commit

Permalink
Update Thrift to version 0.16 (Ericsson#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
LoremIPsummer authored and wbqpk3 committed Jul 8, 2024
1 parent 66c1fc7 commit a7b3234
Show file tree
Hide file tree
Showing 32 changed files with 1,803 additions and 84 deletions.
17 changes: 17 additions & 0 deletions .github/scripts/ubuntu-20.04/compile_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Compile dependencies that cannot be acquired via the official repositories

mkdir -p ${INSTALL_PATH}

## Compile Thrift
tar -xvf ${DOWNLOAD_PATH}/thrift-0.16.0.tar.gz
cd thrift-0.16.0
./configure --prefix=${INSTALL_PATH}/thrift --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 \
--without-java --without-swift

make install -j $(nproc)
23 changes: 23 additions & 0 deletions .github/scripts/ubuntu-20.04/download_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Download installers for compiled dependencies

mkdir -p ${DOWNLOAD_PATH}

## Thrift 0.16

wget -O ${DOWNLOAD_PATH}/thrift-0.16.0.tar.gz "http://archive.apache.org/dist/thrift/0.16.0/thrift-0.16.0.tar.gz"

# Calculate hash of dependencies for Github Cache Action

dependencies_to_hash=("thrift-0.16.0.tar.gz")

concatenated_hashes=""
for file in "${dependencies_to_hash[@]}"; do
file_hash=$(md5sum "${DOWNLOAD_PATH}/${file}" | awk '{print $1}')
concatenated_hashes="${concatenated_hashes}${file_hash}"
done

hash_value=$(echo -n "$concatenated_hashes" | md5sum | awk '{print $1}')

## Save said hash

echo "compile-hash-key=${hash_value}" >> $GITHUB_OUTPUT
4 changes: 4 additions & 0 deletions .github/scripts/ubuntu-20.04/postcompile_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Post compilation configuration for building (environmental variables, library location settings etc..)

echo "${INSTALL_PATH}/thrift/bin" >> $GITHUB_PATH
echo "CMAKE_PREFIX_PATH=${INSTALL_PATH}/thrift:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# Install required packages for CodeCompass build
sudo apt-get install -y git cmake make g++ libboost-all-dev llvm-11-dev clang-11 \
libclang-11-dev odb libodb-dev thrift-compiler libthrift-dev default-jdk libssl-dev \
libclang-11-dev odb libodb-dev default-jdk libssl-dev \
libgraphviz-dev libmagic-dev libgit2-dev ctags doxygen libgtest-dev npm libldap2-dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Install required packages for CodeCompass runtime
sudo apt-get install -y git cmake make g++ graphviz \
libboost-filesystem1.71.0 libboost-log1.71.0 libboost-program-options1.71.0 \
libllvm11 clang-11 libclang1-11 libthrift-0.13.0 default-jre libssl1.1 libmagic1 \
libllvm11 clang-11 libclang1-11 default-jre libssl1.1 libmagic1 \
libgit2-28 ctags googletest libldap-2.4-2
83 changes: 74 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on: [push, pull_request, workflow_dispatch]

env:
BUILD_TYPE: Debug
## For locally compiled dependencies
INSTALL_PATH: ${{github.workspace}}/dependencies/install
## Temp directory for installers of the downloaded dependencies
DOWNLOAD_PATH: ${{github.workspace}}/dependencies/download

permissions: read-all

Expand All @@ -20,6 +24,9 @@ jobs:
fail-fast: false

runs-on: ${{ matrix.os }}
outputs:
has-compiled-dependencies: ${{ steps.compilation-flag.outputs.has-compiled-dependencies }}
compile-hash-key: ${{ steps.download-compile-dependencies.outputs.compile-hash-key }}

services:
# Label used to access the service container
Expand All @@ -45,10 +52,56 @@ jobs:
run: sudo apt-get update

- name: Install required packages for build
run: ./.github/scripts/setup_build_${{matrix.os}}.sh
run: ./.github/scripts/${{ matrix.os }}/setup_build.sh

- name: Set has-compiled-dependencies flag
id: compilation-flag
run: |
if [ -f ./.github/scripts/${{ matrix.os }}/compile_build.sh ]; then
echo "has-compiled-dependencies=true" >> "$GITHUB_OUTPUT"
else
echo "has-compiled-dependencies=false" >> "$GITHUB_OUTPUT"
fi
- name: Download installers for compiled dependencies
if: steps.compilation-flag.outputs.has-compiled-dependencies == 'true'
id: download-compile-dependencies
run: |
chmod +x ./.github/scripts/${{ matrix.os }}/download_build.sh
./.github/scripts/${{ matrix.os }}/download_build.sh
- name: Restore compiled dependencies
if: steps.compilation-flag.outputs.has-compiled-dependencies == 'true'
id: restore-compiled-dependencies
uses: actions/cache/restore@v3
with:
path: ${{ env.INSTALL_PATH }}
key: ${{ matrix.os }}-compile-install-${{steps.download-compile-dependencies.outputs.compile-hash-key}}

- name: Compile dependencies
if: steps.restore-compiled-dependencies.outputs.cache-hit != 'true' && steps.compilation-flag.outputs.has-compiled-dependencies == 'true'
run: |
chmod +x ./.github/scripts/${{ matrix.os }}/compile_build.sh
./.github/scripts/${{ matrix.os }}/compile_build.sh
- name: Post compilation configuration (build)
if: steps.compilation-flag.outputs.has-compiled-dependencies == 'true'
run: |
if [ -f ./.github/scripts/${{ matrix.os }}/postcompile_build.sh ]; then
chmod +x ./.github/scripts/${{ matrix.os }}/postcompile_build.sh
./.github/scripts/${{ matrix.os }}/postcompile_build.sh
fi
- name: Save dependencies
if: steps.restore-compiled-dependencies.outputs.cache-hit != 'true' && steps.compilation-flag.outputs.has-compiled-dependencies == 'true'
id: save-compiled-dependencies
uses: actions/cache/save@v3
with:
path: ${{ env.INSTALL_PATH }}
key: ${{ matrix.os }}-compile-install-${{steps.download-compile-dependencies.outputs.compile-hash-key}}

- name: Install database packages
run: ./.github/scripts/setup_${{matrix.db}}_${{matrix.os}}.sh
run: ./.github/scripts/${{ matrix.os }}/setup_${{matrix.db}}.sh

- name: Install GoogleTest
run: |
Expand Down Expand Up @@ -79,8 +132,7 @@ jobs:
- name: Configure CMake
working-directory: ${{github.workspace}}
run:
cmake -E make_directory $HOME/cc-build
run: cmake -E make_directory $HOME/cc-build

- name: Run CMake
run: >
Expand Down Expand Up @@ -128,7 +180,6 @@ jobs:
name: codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime
path: ${{github.workspace}}/artifacts/codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime.zip


## PARSING JOBS
parse:
needs: build
Expand Down Expand Up @@ -166,10 +217,26 @@ jobs:

# We need build dependencies for CodeCompass, as it will parsed as well
- name: Install required packages for build
run: ./.github/scripts/setup_build_${{matrix.os}}.sh
run: ./.github/scripts/${{ matrix.os }}/setup_build.sh

- name: Install database packages
run: ./.github/scripts/setup_${{matrix.db}}_${{matrix.os}}.sh
run: ./.github/scripts/${{ matrix.os }}/setup_${{matrix.db}}.sh

- name: Restore compiled dependencies
if: needs.build.outputs.has-compiled-dependencies == 'true'
id: restore-compiled-dependencies
uses: actions/cache/restore@v3
with:
path: ${{ env.INSTALL_PATH }}
key: ${{ matrix.os }}-compile-install-${{needs.build.outputs.compile-hash-key}}

- name: Post compilation configuration (runtime)
if: needs.build.outputs.has-compiled-dependencies == 'true'
run: |
if [ -f ./.github/scripts/${{ matrix.os }}/postcompile_runtime.sh ]; then
chmod +x ./.github/scripts/${{ matrix.os }}/postcompile_runtime.sh
./.github/scripts/${{ matrix.os }}/postcompile_runtime.sh
fi
- name: Download CodeCompass binaries
uses: actions/download-artifact@v2
Expand Down Expand Up @@ -241,7 +308,6 @@ jobs:
cd $HOME/cc-install/bin
./CodeCompass_parser -d $PROJ_XERCES_CONNSTRING -w $HOME/$DIR_WS/ -n "Xerces-C" -i $HOME/xerces-c -i $HOME/build_xerces-c/compile_commands.json -j $(nproc)
## DOCKER IMAGE JOB
docker:
needs: parse
Expand All @@ -253,7 +319,6 @@ jobs:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}


## TARBALL JOB
tarball:
needs: parse
Expand Down
8 changes: 4 additions & 4 deletions .gitlab/build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ fi
##########

cd $PACKAGES_DIR
wget --no-verbose --no-clobber http://archive.apache.org/dist/thrift/0.13.0/thrift-0.13.0.tar.gz
tar -xf thrift-0.13.0.tar.gz
cd thrift-0.13.0
wget --no-verbose --no-clobber http://archive.apache.org/dist/thrift/0.16.0/thrift-0.16.0.tar.gz
tar -xf thrift-0.16.0.tar.gz
cd thrift-0.16.0

CXXFLAGS="$CXXFLAGS -I$DEPS_INSTALL_RUNTIME_DIR/boost-install/include" \
LDFLAGS="$LDFLAGS -Wl,-rpath-link,$DEPS_INSTALL_RUNTIME_DIR/openssl-install/lib" \
Expand All @@ -338,7 +338,7 @@ LDFLAGS="$LDFLAGS -Wl,-rpath-link,$DEPS_INSTALL_RUNTIME_DIR/openssl-install/lib"
--without-python

make install --quiet --jobs $(nproc)
rm -f $PACKAGES_DIR/thrift-0.13.0.tar.gz
rm -f $PACKAGES_DIR/thrift-0.16.0.tar.gz

########
# Java #
Expand Down
2 changes: 1 addition & 1 deletion Functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ function(join _values _glue _output)
string (REGEX REPLACE "([^\\]|^);" "\\1${_glue}" _tmpStr "${_values}")
string (REGEX REPLACE "[\\](.)" "\\1" _tmpStr "${_tmpStr}") #fixes escaping
set (${_output} "${_tmpStr}" PARENT_SCOPE)
endfunction(join)
endfunction(join)
16 changes: 8 additions & 8 deletions doc/deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ known issues.
```bash
sudo apt install git cmake make g++ libboost-all-dev \
llvm-11-dev clang-11 libclang-11-dev \
odb libodb-dev thrift-compiler libthrift-dev \
odb libodb-dev \
default-jdk libssl-dev libgraphviz-dev libmagic-dev libgit2-dev ctags doxygen \
libldap2-dev libgtest-dev
```
Expand All @@ -65,7 +65,7 @@ sudo apt install git cmake make g++ libboost-all-dev \
```bash
sudo apt install git cmake make g++ libboost-all-dev \
llvm-11-dev clang-11 libclang-11-dev \
gcc-11-plugin-dev \
gcc-11-plugin-dev thrift-compiler libthrift-dev \
default-jdk libssl-dev libgraphviz-dev libmagic-dev libgit2-dev exuberant-ctags doxygen \
libldap2-dev libgtest-dev
```
Expand Down Expand Up @@ -157,11 +157,11 @@ time (depending on the machine one is using).
> **Note:** now you may delete the *Build2* toolchain installed in the
> `<build2_install_dir>` folder, if you do not need any longer.
### Thrift (for Ubuntu 22.04)
### Thrift (for Ubuntu 20.04)
CodeCompass needs [Thrift](https://thrift.apache.org/) which provides Remote
Procedure Call (RPC) between the server and the client. A suitable version of
Thrift is, unfortunately, not part of the official Ubuntu repositories for
this version (only a newer version is available), so you should download and
this version (only an older version is available), so you should download and
build from source.

Thrift can generate stubs for many programming languages. The configure
Expand All @@ -180,10 +180,10 @@ 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
wget "http://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=thrift/0.16.0/thrift-0.16.0.tar.gz" \
-O thrift-0.16.0.tar.gz
tar -xvf ./thrift-0.16.0.tar.gz
cd thrift-0.16.0

./configure --prefix=<thrift_install_dir> --silent --without-python \
--enable-libtool-lock --enable-tutorial=no --enable-tests=no \
Expand Down
Binary file removed lib/java/libthrift-0.13.0.jar
Binary file not shown.
Binary file added lib/java/libthrift-0.16.0.jar
Binary file not shown.
6 changes: 0 additions & 6 deletions plugins/cpp_metrics/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ include_directories(SYSTEM

add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppmetrics_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppmetrics_constants.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppmetrics_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppmetrics_types.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/CppMetricsService.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/CppMetricsService.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp
Expand All @@ -26,8 +22,6 @@ add_custom_command(
"Generating Thrift for cppmetrics.thrift")

add_library(cppmetricsthrift STATIC
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppmetrics_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppmetrics_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/CppMetricsService.cpp)

target_compile_options(cppmetricsthrift PUBLIC -fPIC)
Expand Down
3 changes: 0 additions & 3 deletions plugins/cpp_reparse/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ add_definitions(${LLVM_DEFINITIONS})

add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppreparse_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppreparse_constants.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppreparse_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppreparse_types.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/CppReparseService.cpp
Expand All @@ -42,7 +40,6 @@ add_custom_command(
"Generating Thrift for cppreparse.thrift")

add_library(cppreparsethrift STATIC
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppreparse_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/cppreparse_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/CppReparseService.cpp)

Expand Down
6 changes: 0 additions & 6 deletions plugins/dummy/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ include_directories(SYSTEM

add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/dummy_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/dummy_constants.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/dummy_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/dummy_types.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/DummyService.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/DummyService.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp
Expand All @@ -26,8 +22,6 @@ add_custom_command(
"Generating Thrift for dummy.thrift")

add_library(dummythrift STATIC
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/dummy_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/dummy_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/DummyService.cpp)

target_compile_options(dummythrift PUBLIC -fPIC)
Expand Down
3 changes: 0 additions & 3 deletions plugins/git/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ include_directories(SYSTEM

add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/git_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/git_constants.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/git_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/git_types.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/GitService.cpp
Expand All @@ -31,7 +29,6 @@ add_custom_command(
"Generating Thrift for git.thrift")

add_library(gitthrift STATIC
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/git_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/git_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/GitService.cpp)

Expand Down
3 changes: 0 additions & 3 deletions plugins/metrics/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ include_directories(SYSTEM

add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/metrics_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/metrics_constants.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/metrics_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/metrics_types.h
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/MetricsService.cpp
Expand All @@ -30,7 +28,6 @@ add_custom_command(
"Generating Thrift for metrics.thrift")

add_library(metricsthrift STATIC
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/metrics_constants.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/metrics_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/gen-cpp/MetricsService.cpp)

Expand Down
Loading

0 comments on commit a7b3234

Please sign in to comment.