Skip to content

Commit

Permalink
[thirdparty] add jwt-cpp to thirdparty build
Browse files Browse the repository at this point in the history
This is a header-only library implementing the JWT functionality.

This is the same library used by Impala for its JWT implementation, but
in Kudu we are using a snapshot which is close to 0.6.0-rc2 and contains
an extra changelist [2] to avoid patching jwt-cpp upstream source code.

[1] https://github.com/Thalhammer/jwt-cpp
[2] Thalhammer/jwt-cpp@97c8782

Change-Id: Idab887e1e0c44e9ebe6897defec8238c020cccbb
Reviewed-on: http://gerrit.cloudera.org:8080/18103
Reviewed-by: Andrew Wong <[email protected]>
Tested-by: Alexey Serbin <[email protected]>
  • Loading branch information
bbhavsar authored and alexeyserbin committed Jan 26, 2022
1 parent 10e3cec commit 6f3087b
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,10 @@ include_directories(SYSTEM ${OATPP_SWAGGER_INCLUDE_DIR})
ADD_THIRDPARTY_LIB(oatpp-swagger
STATIC_LIB "${OATPP_SWAGGER_STATIC_LIB}")

## jwt-cpp
find_package(JwtCpp REQUIRED)
include_directories(${JWT_CPP_INCLUDE_DIR})

## OpenSSL
##
## Version 1.0.0 or higher is required because we are using the following
Expand Down
29 changes: 29 additions & 0 deletions cmake_modules/FindJwtCpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Find jwt-cpp headers.
# This module defines:
# - JWT_CPP_INCLUDE_DIR, where to find jwt-cpp header files.
# - JwtCpp_FOUND, If false, do not try to use jwt-cpp.

find_path(JWT_CPP_INCLUDE_DIR jwt-cpp/jwt.h
DOC "Path to the jwt-cpp header file"
NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH)

find_package_handle_standard_args(JwtCpp REQUIRED_VARS
JWT_CPP_INCLUDE_DIR)
16 changes: 16 additions & 0 deletions thirdparty/build-definitions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1125,3 +1125,19 @@ build_oatpp_swagger(){
make -j$PARALLEL install
popd
}

build_jwt_cpp() {
JWT_CPP_BUILD_DIR=$TP_BUILD_DIR/$JWT_CPP_NAME$MODE_SUFFIX
mkdir -p $JWT_CPP_BUILD_DIR
pushd $JWT_CPP_BUILD_DIR
CFLAGS="$EXTRA_CFLAGS" \
CXXFLAGS="$EXTRA_CXXFLAGS $OPENSSL_CFLAGS" \
LDFLAGS="$EXTRA_LDFLAGS $OPENSSL_LDFLAGS" \
cmake \
-DCMAKE_BUILD_TYPE=release \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DJWT_BUILD_EXAMPLES=OFF \
$JWT_CPP_SOURCE
make -j$PARALLEL install
popd
}
5 changes: 5 additions & 0 deletions thirdparty/build-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ else
"ranger") F_RANGER=1 ;;
"oatpp") F_OATPP=1 ;;
"oatpp-swagger") F_OATPP_SWAGGER=1 ;;
"jwt-cpp") F_JWT_CPP=1;;
*) echo "Unknown module: $arg"; exit 1 ;;
esac
done
Expand Down Expand Up @@ -421,6 +422,10 @@ if [ -n "$F_UNINSTRUMENTED" -o -n "$F_OATPP_SWAGGER" ]; then
build_oatpp_swagger
fi

if [ -n "$F_UNINSTRUMENTED" -o -n "$F_JWT_CPP" ]; then
build_jwt_cpp
fi

restore_env

# If we're on macOS best to exit here, otherwise single dependency builds will try to
Expand Down
5 changes: 5 additions & 0 deletions thirdparty/download-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ fetch_and_patch \
$OATPP_SWAGGER_PATCHLEVEL \
"patch -p1 < $TP_DIR/patches/oatpp-swagger-remove-version-from-path.patch"

JWT_CPP_PATCHLEVEL=0
fetch_and_patch \
$JWT_CPP_NAME.tar.gz \
$JWT_CPP_SOURCE \
$JWT_CPP_PATCHLEVEL

echo "---------------"
echo "Thirdparty dependencies downloaded successfully"
5 changes: 5 additions & 0 deletions thirdparty/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,8 @@ OATPP_SOURCE=$TP_SOURCE_DIR/$OATPP_NAME
OATPP_SWAGGER_VERSION=1.2.5
OATPP_SWAGGER_NAME=oatpp-swagger-$OATPP_SWAGGER_VERSION
OATPP_SWAGGER_SOURCE=$TP_SOURCE_DIR/$OATPP_SWAGGER_NAME

JWT_CPP_VERSION=3bd600762a70faccc7ec1c2dacb999cba6c6ef5e
JWT_CPP=jwt-cpp
JWT_CPP_NAME=$JWT_CPP-$JWT_CPP_VERSION
JWT_CPP_SOURCE=$TP_SOURCE_DIR/$JWT_CPP_NAME

0 comments on commit 6f3087b

Please sign in to comment.