Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ ARG USER_GID=1000
ARG INSTALL_PACKAGES=

ARG CXX_STANDARD=17
ARG THIRD_PARTY_BUILD_TYPE=Release

ENV CXX_STANDARD=${CXX_STANDARD}
ENV THIRD_PARTY_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}

COPY ci /opt/ci

Expand Down Expand Up @@ -42,15 +44,16 @@ ENV USER_GID=${USER_GID}
ENV IS_CONTAINER_BUILD=true

COPY install /opt/install
COPY third_party_release /opt/third_party_release
COPY ./.devcontainer/customize_container.sh /tmp/opentelemetry_cpp/devcontainer/customize_container.sh
RUN /tmp/opentelemetry_cpp/devcontainer/customize_container.sh
RUN apt install -y npm && npm install -g markdownlint-cli@0.44.0

USER devuser

WORKDIR /workspaces/opentelemetry-cpp
RUN cd /opt && bash ci/install_thirdparty.sh --install-dir /home/devuser/third-party/install-stable --tags-file install/cmake/third_party_stable
ENV CMAKE_PREFIX_PATH=/home/devuser/third-party/install-stable
RUN cd /opt && bash ci/install_thirdparty.sh --install-dir /home/devuser/third-party/install --build-type ${THIRD_PARTY_BUILD_TYPE} --tags-file third_party_release
ENV CMAKE_PREFIX_PATH=/home/devuser/third-party/install

ENTRYPOINT []

Expand Down
50 changes: 43 additions & 7 deletions ci/install_thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
set -e

usage() {
echo "Usage: $0 --install-dir <path> [--tags-file <file>] [--packages \"<pkg1>;<pkg2>\"]"
echo "Usage: $0 --install-dir <path> [--tags-file <file>] [--packages \"<pkg1>;<pkg2>\"] [--build-type <type>]"
echo " --install-dir <path> Path where third-party packages will be installed (required)"
echo " --tags-file <file> File containing tags for third-party packages (optional)"
echo " --packages \"<pkg1>;<pkg2>;...\" Semicolon-separated list of packages to build (optional). Default installs all third-party packages."
echo " --build-type <type> Build type for third-party packages (optional). Valid: Debug|Release|RelWithDebInfo|MinSizeRel. Default: Release"
echo " -h, --help Show this help message"
}

THIRDPARTY_TAGS_FILE=""
THIRDPARTY_PACKAGES=""
SRC_DIR="$(pwd)"
THIRDPARTY_INSTALL_DIR=""
BUILD_TYPE=""

while [[ $# -gt 0 ]]; do
case $1 in
Expand Down Expand Up @@ -47,6 +49,15 @@ while [[ $# -gt 0 ]]; do
THIRDPARTY_PACKAGES="$2"
shift 2
;;
--build-type)
if [ -z "$2" ] || [[ "$2" == --* ]]; then
echo "Error: --build-type requires a value" >&2
usage
exit 1
fi
BUILD_TYPE="$2"
shift 2
;;
-h|--help)
usage
exit 0
Expand All @@ -69,20 +80,44 @@ if [ -z "${CXX_STANDARD}" ]; then
CXX_STANDARD=17
fi

if [[ "${BUILD_TYPE}" =~ ^(Debug|Release|RelWithDebInfo|MinSizeRel)$ ]]; then
CMAKE_BUILD_TYPE="${BUILD_TYPE}"
else
Comment thread
dbarker marked this conversation as resolved.
if [ -n "${BUILD_TYPE}" ]; then
echo "Warning: invalid --build-type '${BUILD_TYPE}', defaulting to Release" >&2
fi
CMAKE_BUILD_TYPE=Release
fi

THIRDPARTY_BUILD_DIR="/tmp/otel-cpp-third-party-build"
CMAKE_OPTIONS=(
"-DCMAKE_INSTALL_PREFIX=${THIRDPARTY_INSTALL_DIR}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DCMAKE_CXX_STANDARD=${CXX_STANDARD}"
"-DOTELCPP_THIRDPARTY_TAGS_FILE=${THIRDPARTY_TAGS_FILE}"
"-DOTELCPP_PROTO_PATH=${OTELCPP_PROTO_PATH}"
"-DOTELCPP_THIRDPARTY_INSTALL_LIST=${THIRDPARTY_PACKAGES}"
)
CMAKE_BUILD_ARGS=(--clean-first --parallel)

shopt -s nocasematch
if [[ "${OTELCPP_CMAKE_VERBOSE_BUILD:-OFF}" =~ ^(1|ON|TRUE|YES)$ ]]; then
CMAKE_BUILD_ARGS+=(--verbose)
fi
shopt -u nocasematch

if command -v ninja >/dev/null 2>&1; then
CMAKE_OPTIONS+=("-G" "Ninja")
fi

if [ -d "${THIRDPARTY_BUILD_DIR}" ]; then
rm -rf "${THIRDPARTY_BUILD_DIR}"
fi

cmake -S "${SRC_DIR}/install/cmake" -B "${THIRDPARTY_BUILD_DIR}" \
"-DCMAKE_INSTALL_PREFIX=${THIRDPARTY_INSTALL_DIR}" \
"-DCMAKE_CXX_STANDARD=${CXX_STANDARD}" \
"-DOTELCPP_THIRDPARTY_TAGS_FILE=${THIRDPARTY_TAGS_FILE}" \
"-DOTELCPP_PROTO_PATH=${OTELCPP_PROTO_PATH}" \
"-DOTELCPP_THIRDPARTY_INSTALL_LIST=${THIRDPARTY_PACKAGES}"
"${CMAKE_OPTIONS[@]}"

cmake --build "${THIRDPARTY_BUILD_DIR}" --clean-first -j"$(nproc)"
cmake --build "${THIRDPARTY_BUILD_DIR}" "${CMAKE_BUILD_ARGS[@]}"

if [ "${THIRDPARTY_INSTALL_DIR}" = "/usr/local" ]; then
ldconfig
Expand All @@ -92,4 +127,5 @@ echo "Third-party packages installed successfully."
echo "-- THIRDPARTY_INSTALL_DIR: ${THIRDPARTY_INSTALL_DIR}"
echo "-- THIRDPARTY_TAGS_FILE: ${THIRDPARTY_TAGS_FILE}"
echo "-- THIRDPARTY_PACKAGES: ${THIRDPARTY_PACKAGES:-all}"
echo "-- CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}"
echo "-- CXX_STANDARD: ${CXX_STANDARD}"
1 change: 1 addition & 0 deletions ci/setup_ci_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
set -e
apt-get update
apt-get install --no-install-recommends --no-install-suggests -y \
ninja-build \
build-essential \
ca-certificates \
wget \
Expand Down
1 change: 0 additions & 1 deletion third_party_release
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ opentelemetry-proto=v1.8.0
opentracing-cpp=v1.6.0
prometheus-cpp=v1.3.0
ryml=v0.10.0
vcpkg=2024.02.14
Loading