diff options
Diffstat (limited to 'src/jaegertracing/jaeger-client-cpp/scripts')
8 files changed, 381 insertions, 0 deletions
diff --git a/src/jaegertracing/jaeger-client-cpp/scripts/build-plugin.sh b/src/jaegertracing/jaeger-client-cpp/scripts/build-plugin.sh new file mode 100755 index 000000000..192c824d0 --- /dev/null +++ b/src/jaegertracing/jaeger-client-cpp/scripts/build-plugin.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e + +function main() { + local project_dir + project_dir="$(git rev-parse --show-toplevel)" + + mkdir -p build + cd build + export CFLAGS="$CFLAGS -march=x86-64" + export CXXFLAGS="$CXXFLAGS -march=x86-64" + + cat <<EOF > export.map +{ + global: + OpenTracingMakeTracerFactory; + local: *; +}; +EOF + + cmake -DCMAKE_BUILD_TYPE=Release \ + -DJAEGERTRACING_PLUGIN=ON \ + -DBUILD_TESTING=ON \ + -DHUNTER_CONFIGURATION_TYPES=Release \ + .. + make -j3 + mv libjaegertracing_plugin.so /libjaegertracing_plugin.so + ./DynamicallyLoadTracerTest /libjaegertracing_plugin.so +} + +main diff --git a/src/jaegertracing/jaeger-client-cpp/scripts/build.sh b/src/jaegertracing/jaeger-client-cpp/scripts/build.sh new file mode 100755 index 000000000..e12e11c97 --- /dev/null +++ b/src/jaegertracing/jaeger-client-cpp/scripts/build.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Based on https://github.com/codecov/example-cpp11-cmake/blob/master/run_build.sh. + +set -e + +RED='\033[0;31m' +BLUE='\033[0;34m' +NO_COLOR='\033[0m' +GREEN='\033[0;32m' + +function info() { + echo -e "${GREEN}$1${NO_COLOR}" +} + +function working() { + echo -e "${BLUE}$1${NO_COLOR}" +} + +function main() { + local project_dir + project_dir=$(git rev-parse --show-toplevel) + cd "$project_dir" + + mkdir -p build + cd build + cmake ${CMAKE_OPTIONS} .. + make -j3 UnitTest + info "Running tests..." + ./UnitTest + working "All tests compiled and passed" + + set -x + if ! [[ "${CMAKE_OPTIONS}" =~ "-DJAEGERTRACING_BUILD_CROSSDOCK=ON" ]]; then + exit 0 + fi + make crossdock-fresh +} + +main diff --git a/src/jaegertracing/jaeger-client-cpp/scripts/clang-format.sh b/src/jaegertracing/jaeger-client-cpp/scripts/clang-format.sh new file mode 100755 index 000000000..3f1a43830 --- /dev/null +++ b/src/jaegertracing/jaeger-client-cpp/scripts/clang-format.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +function main() { + local project_dir + project_dir=$(git rev-parse --show-toplevel) + cd "$project_dir" || exit 1 + + local srcs + srcs=$(git ls-files src crossdock | + grep -E -v 'thrift-gen' | + grep -E '\.(cpp|h)$') + + local cmd + for src in $srcs; do + cmd="clang-format -i $src" + echo "$cmd" + eval "$cmd" + done +} + +main diff --git a/src/jaegertracing/jaeger-client-cpp/scripts/clang-tidy.sh b/src/jaegertracing/jaeger-client-cpp/scripts/clang-tidy.sh new file mode 100755 index 000000000..2946db95c --- /dev/null +++ b/src/jaegertracing/jaeger-client-cpp/scripts/clang-tidy.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +function main() { + local project_dir + project_dir=$(git rev-parse --show-toplevel) + cd "$project_dir" || exit 1 + + local srcs + srcs=$(git ls-files src crossdock | + grep -E -v 'thrift-gen|Test\.cpp' | + grep -E '\.cpp$') + + local cmd + for src in $srcs; do + cmd="clang-tidy -p=build" + cmd+=" -checks=\"-clang-diagnostic-unused-command-line-argument\" " + cmd+=" $src" + echo "$cmd" + eval "$cmd" + done +} + +main diff --git a/src/jaegertracing/jaeger-client-cpp/scripts/thrift-gen.patch b/src/jaegertracing/jaeger-client-cpp/scripts/thrift-gen.patch new file mode 100644 index 000000000..aa484888e --- /dev/null +++ b/src/jaegertracing/jaeger-client-cpp/scripts/thrift-gen.patch @@ -0,0 +1,115 @@ +diff --git a/src/jaegertracing/thrift-gen/tracetest_types.cpp b/src/jaegertracing/thrift-gen/tracetest_types.cpp +index cb7199e..ceb7a20 100644 +--- a/src/jaegertracing/thrift-gen/tracetest_types.cpp ++++ b/src/jaegertracing/thrift-gen/tracetest_types.cpp +@@ -60,7 +60,7 @@ void Downstream::__set_transport(const Transport::type val) { + this->transport = val; + } + +-void Downstream::__set_downstream(const Downstream& val) { ++void Downstream::__set_downstream(const std::shared_ptr<Downstream>& val) { + this->downstream = val; + __isset.downstream = true; + } +@@ -141,7 +141,7 @@ uint32_t Downstream::read(::apache::thrift::protocol::TProtocol* iprot) { + break; + case 6: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { +- xfer += this->downstream.read(iprot); ++ xfer += this->downstream->read(iprot); + this->__isset.downstream = true; + } else { + xfer += iprot->skip(ftype); +@@ -196,7 +196,7 @@ uint32_t Downstream::write(::apache::thrift::protocol::TProtocol* oprot) const { + + if (this->__isset.downstream) { + xfer += oprot->writeFieldBegin("downstream", ::apache::thrift::protocol::T_STRUCT, 6); +- xfer += this->downstream.write(oprot); ++ xfer += this->downstream->write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); +@@ -672,7 +672,7 @@ void TraceResponse::__set_span(const ObservedSpan& val) { + __isset.span = true; + } + +-void TraceResponse::__set_downstream(const TraceResponse& val) { ++void TraceResponse::__set_downstream(const std::shared_ptr<TraceResponse>& val) { + this->downstream = val; + __isset.downstream = true; + } +@@ -719,7 +719,7 @@ uint32_t TraceResponse::read(::apache::thrift::protocol::TProtocol* iprot) { + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { +- xfer += this->downstream.read(iprot); ++ xfer += this->downstream->read(iprot); + this->__isset.downstream = true; + } else { + xfer += iprot->skip(ftype); +@@ -759,7 +759,7 @@ uint32_t TraceResponse::write(::apache::thrift::protocol::TProtocol* oprot) cons + } + if (this->__isset.downstream) { + xfer += oprot->writeFieldBegin("downstream", ::apache::thrift::protocol::T_STRUCT, 2); +- xfer += this->downstream.write(oprot); ++ xfer += this->downstream->write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldBegin("notImplementedError", ::apache::thrift::protocol::T_STRING, 3); +diff --git a/src/jaegertracing/thrift-gen/tracetest_types.h b/src/jaegertracing/thrift-gen/tracetest_types.h +index 5a0e6c9..a44f3a3 100644 +--- a/src/jaegertracing/thrift-gen/tracetest_types.h ++++ b/src/jaegertracing/thrift-gen/tracetest_types.h +@@ -61,7 +61,7 @@ class Downstream : public virtual ::apache::thrift::TBase { + std::string host; + std::string port; + Transport::type transport; +- Downstream downstream; ++ std::shared_ptr<Downstream> downstream; + + _Downstream__isset __isset; + +@@ -75,7 +75,7 @@ class Downstream : public virtual ::apache::thrift::TBase { + + void __set_transport(const Transport::type val); + +- void __set_downstream(const Downstream& val); ++ void __set_downstream(const std::shared_ptr<Downstream>& val); + + bool operator == (const Downstream & rhs) const + { +@@ -91,7 +91,7 @@ class Downstream : public virtual ::apache::thrift::TBase { + return false; + if (__isset.downstream != rhs.__isset.downstream) + return false; +- else if (__isset.downstream && !(downstream == rhs.downstream)) ++ else if (__isset.downstream && !(*downstream == *rhs.downstream)) + return false; + return true; + } +@@ -273,14 +273,14 @@ class TraceResponse : public virtual ::apache::thrift::TBase { + + virtual ~TraceResponse() throw(); + ObservedSpan span; +- TraceResponse downstream; ++ std::shared_ptr<TraceResponse> downstream; + std::string notImplementedError; + + _TraceResponse__isset __isset; + + void __set_span(const ObservedSpan& val); + +- void __set_downstream(const TraceResponse& val); ++ void __set_downstream(const std::shared_ptr<TraceResponse>& val); + + void __set_notImplementedError(const std::string& val); + +@@ -292,7 +292,7 @@ class TraceResponse : public virtual ::apache::thrift::TBase { + return false; + if (__isset.downstream != rhs.__isset.downstream) + return false; +- else if (__isset.downstream && !(downstream == rhs.downstream)) ++ else if (__isset.downstream && !(*downstream == *rhs.downstream)) + return false; + if (!(notImplementedError == rhs.notImplementedError)) + return false; diff --git a/src/jaegertracing/jaeger-client-cpp/scripts/update-license.py b/src/jaegertracing/jaeger-client-cpp/scripts/update-license.py new file mode 100644 index 000000000..bd51168d0 --- /dev/null +++ b/src/jaegertracing/jaeger-client-cpp/scripts/update-license.py @@ -0,0 +1,100 @@ +from __future__ import ( + absolute_import, print_function, division, unicode_literals +) + +import logging +import re +import sys +from datetime import datetime + +logging.basicConfig(level=logging.DEBUG) +logger = logging.getLogger(__name__) + +CURRENT_YEAR = datetime.today().year + +LICENSE_BLOB = """Copyright (c) %d Uber Technologies, Inc. + +Licensed 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.""" % CURRENT_YEAR + + +def comment_block(license_blob): + lines = ['/*\n'] + lines += [(' * ' + l).rstrip() + '\n' + for l in license_blob.split('\n')] + lines.append(' */\n') + return lines + + +LICENSE_BLOB_LINES_CPP = comment_block(LICENSE_BLOB) + +COPYRIGHT_RE = re.compile(r'Copyright \(c\) (\d+)', re.I) + + +def update_cpp_license(name, force=False): + with open(name) as f: + orig_lines = list(f) + lines = list(orig_lines) + + found = False + changed = False + for i, line in enumerate(lines[:5]): + m = COPYRIGHT_RE.search(line) + if not m: + continue + + found = True + year = int(m.group(1)) + if year == CURRENT_YEAR: + break + + new_line = COPYRIGHT_RE.sub('Copyright (c) %d' % CURRENT_YEAR, line) + assert line != new_line, ('Could not change year in: %s' % line) + lines[i] = new_line + changed = True + break + + if not found: + if 'Code generated by' in lines[0]: + lines[1:1] = ['\n'] + LICENSE_BLOB_LINES_CPP + else: + lines[0:0] = LICENSE_BLOB_LINES_CPP + ['\n'] + changed = True + + if changed: + with open(name, 'w') as f: + for line in lines: + f.write(line) + print(name) + + +def main(): + if len(sys.argv) == 1: + print('USAGE: %s FILE ...' % sys.argv[0]) + sys.exit(1) + + for name in sys.argv[1:]: + if name.endswith('.cpp') or \ + name.endswith('.h') or \ + name.endswith('.h.in'): + try: + update_cpp_license(name) + except Exception as error: + logger.error('Failed to process file %s', name) + logger.exception(error) + raise error + else: + raise NotImplementedError('Unsupported file type: %s' % name) + + +if __name__ == "__main__": + main() diff --git a/src/jaegertracing/jaeger-client-cpp/scripts/update-licenses.sh b/src/jaegertracing/jaeger-client-cpp/scripts/update-licenses.sh new file mode 100755 index 000000000..e912743ca --- /dev/null +++ b/src/jaegertracing/jaeger-client-cpp/scripts/update-licenses.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +python scripts/update-license.py $(git ls-files "*\.cpp" "*\.h" | + grep -v thrift-gen | + grep -v tracetest) \ + src/jaegertracing/Constants.h.in diff --git a/src/jaegertracing/jaeger-client-cpp/scripts/upload-coverage.sh b/src/jaegertracing/jaeger-client-cpp/scripts/upload-coverage.sh new file mode 100755 index 000000000..a31da5772 --- /dev/null +++ b/src/jaegertracing/jaeger-client-cpp/scripts/upload-coverage.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Copyright (c) 2018 Uber Technologies, Inc. +# +# Licensed 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. + +set -e + +function main() { + set -x + if ! [[ "${CMAKE_OPTIONS}" =~ "-DJAEGERTRACING_COVERAGE=ON" ]]; then + exit 0 + fi + unset -x + + local project_dir + project_dir=$(git rev-parse --show-toplevel) + cd "$project_dir" || exit 1 + + local gcov_tool + case "$CC" in + gcc*) gcov_tool=${CC/gcc/gcov} + ;; + *) gcov_tool="$project_dir/scripts/llvm-gcov.sh" + ;; + esac + find build -name '*.gcno' -exec "$gcov_tool" {} \; + bash <(curl -s https://codecov.io/bash) || \ + echo "Codecov did not collect coverage reports" +} + +main |