diff options
-rw-r--r-- | SConstruct | 5 | ||||
-rw-r--r-- | src/third_party/SConscript | 27 | ||||
-rw-r--r-- | src/third_party/kms-message/SConscript | 48 | ||||
-rwxr-xr-x | src/third_party/scripts/kms_message_get_sources.sh | 67 | ||||
-rw-r--r-- | src/third_party/shim_kms_message.cpp | 3 |
5 files changed, 150 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct index 830b0116f1a..dfce870e17e 100644 --- a/SConstruct +++ b/SConstruct @@ -400,6 +400,11 @@ add_option('use-system-mongo-c', type='choice', ) +add_option('use-system-kms-message', + help='use system version of kms-message library', + nargs=0, +) + add_option('use-system-all', help='use all system libraries', nargs=0, diff --git a/src/third_party/SConscript b/src/third_party/SConscript index 3858e7360ba..7fc1f4f57fb 100644 --- a/src/third_party/SConscript +++ b/src/third_party/SConscript @@ -133,6 +133,12 @@ if not use_system_version_of_library('icu'): '#/src/third_party/icu4c' + icuSuffix + '/source/i18n'], } +if not use_system_version_of_library('kms-message'): + thirdPartyEnvironmentModifications['kms-message'] = { + 'CPPPATH' : ['#/src/third_party/kms-message/src'], + 'CPPDEFINES' :['KMS_MSG_STATIC'] + } + def injectThirdParty(thisEnv, libraries=[], parts=[]): libraries = thisEnv.Flatten([libraries]) parts = thisEnv.Flatten([parts]) @@ -526,3 +532,24 @@ icuEnv.Library( source=[ 'shim_icu.cpp', ]) + +if use_system_version_of_library("kms-message"): + kmsEnv = env.Clone( + SYSLIBDEPS=[ + env['LIBDEPS_KMS-MESSAGE_SYSLIBDEP'], + ]) +else: + kmsEnv = env.Clone() + kmsEnv.InjectThirdParty(libraries=['kms-message']) + kmsEnv.SConscript('kms-message/SConscript', exports={ 'env' : kmsEnv }) + kmsEnv = kmsEnv.Clone( + LIBDEPS_INTERFACE=[ + 'kms-message/kms-message', + ]) + +kmsEnv.Library( + target="shim_kms_message", + source=[ + 'shim_kms_message.cpp', + ]) + diff --git a/src/third_party/kms-message/SConscript b/src/third_party/kms-message/SConscript new file mode 100644 index 00000000000..85dee6fc012 --- /dev/null +++ b/src/third_party/kms-message/SConscript @@ -0,0 +1,48 @@ +# -*- mode: python; -*- +Import("env") + +env = env.Clone() + +def removeIfPresent(lst, item): + try: + lst.remove(item) + except ValueError: + pass + +for to_remove in ['-Werror', "-Wsign-compare","-Wall","-Werror=unused-result"]: + removeIfPresent(env['CCFLAGS'], to_remove) + removeIfPresent(env['CFLAGS'], to_remove) + +env.Append(CPPDEFINES=['KMS_MSG_STATIC']) + +additional_sources = [] + +if env.TargetOSIs('windows'): + additional_sources.append(['src/kms_crypto_windows.c']) + # Disable warnings about deprecated functions + env.Append(CFLAGS=['/wd4996']) +elif env.TargetOSIs('darwin'): + additional_sources.append(['src/kms_crypto_apple.c']) +else: + additional_sources.append(['src/kms_crypto_openssl.c']) + +env.Library( + target="kms-message", + source=[ + 'src/hexlify.c', + 'src/kms_b64.c', + 'src/kms_decrypt_request.c', + 'src/kms_encrypt_request.c', + 'src/kms_kv_list.c', + 'src/kms_message.c', + 'src/kms_request.c', + 'src/kms_request_opt.c', + 'src/kms_request_str.c', + 'src/kms_response.c', + 'src/kms_response_parser.c', + 'src/sort.c', + ] + additional_sources, + LIBDEPS_TAGS=[ + 'init-no-global-side-effects', + ], +) diff --git a/src/third_party/scripts/kms_message_get_sources.sh b/src/third_party/scripts/kms_message_get_sources.sh new file mode 100755 index 00000000000..04579ca0edf --- /dev/null +++ b/src/third_party/scripts/kms_message_get_sources.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# This script downloads and imports a revision of kms-message. +# It can be run on Linux, Mac OS X or Windows WSL. +# Actual integration into the build system is not done by this script. +# +# Turn on strict error checking, like perl use 'strict' +set -xeuo pipefail +IFS=$'\n\t' + +if [ "$#" -ne 0 ]; then + echo "This script does not take any arguments" + exit 1 +fi + +GIT_EXE=git +if grep -q Microsoft /proc/version; then + GIT_EXE=git.exe +fi + +NAME=kms-message +REVISION=8d91fa28cf179be591f595ca6611f74443357fdb + +if grep -q Microsoft /proc/version; then + SRC_ROOT=$(wslpath -u $(powershell.exe -Command "Get-ChildItem Env:TEMP | Get-Content | Write-Host")) + SRC_ROOT+="$(mktemp -u /$NAME.XXXXXX)" + mkdir -p $SRC_ROOT +else + SRC_ROOT=$(mktemp -d /tmp/$NAME.XXXXXX) +fi +trap "rm -rf $SRC_ROOT" EXIT + + +SRC=${SRC_ROOT}/${NAME} +CLONE_DEST=$SRC +if grep -q Microsoft /proc/version; then + CLONE_DEST=$(wslpath -m $SRC) +fi +DEST_DIR=$($GIT_EXE rev-parse --show-toplevel)/src/third_party/$NAME + +echo "dest: $DEST_DIR" + +if [ ! -d $SRC ]; then + $GIT_EXE clone https://github.com/mongodb-labs/kms-message $CLONE_DEST + + pushd $SRC + $GIT_EXE checkout $REVISION + popd +fi + +test -d $DEST_DIR/$NAME && rm -r $DEST_DIR/$NAME +mkdir -p $DEST_DIR/$NAME + +stuff_to_remove=( +aws-sig-v4-test-suite +CMakeLists.txt +cmake +README.rst +test +) + +for file in "${stuff_to_remove[@]}" ; do + rm -rf "$SRC/$file" +done + +cp -r $SRC/* $DEST_DIR + + diff --git a/src/third_party/shim_kms_message.cpp b/src/third_party/shim_kms_message.cpp new file mode 100644 index 00000000000..ce3aa6bb123 --- /dev/null +++ b/src/third_party/shim_kms_message.cpp @@ -0,0 +1,3 @@ +// This file intentionally blank. shim_kms_message.cpp is part of the +// third_party/kms_message library, which is just a placeholder for forwarding +// library dependencies. |