Skip to content

Commit

Permalink
Merge branch 'main' into rlamb/common-persistent-store
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Oct 24, 2023
2 parents d3730a8 + 17668f9 commit 8f92208
Show file tree
Hide file tree
Showing 89 changed files with 1,084 additions and 483 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
BasedOnStyle: Chromium
IndentWidth: 4
QualifierAlignment: Right
NamespaceIndentation: None
...
8 changes: 6 additions & 2 deletions .github/ISSUE_TEMPLATE/client-sdk--bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ assignees: ''
A clear and concise description of what you expected to happen.

**Logs**
If applicable, add any log output related to your problem.
If applicable, add any log output related to your problem.
To get more logs from the SDK, change the log level using environment variable `LD_LOG_LEVEL`. For example:
```
LD_LOG_LEVEL=debug ./your-application
```

**SDK version**
The version of this SDK that you are using.

**Language version, developer tools**
For instance, Go 1.11 or Ruby 2.5.3. If you are using a language that requires a separate compiler, such as C, please include the name and version of the compiler too.
For instance, C++17 or C11. If you are using a language that requires a separate compiler, such as C, please include the name and version of the compiler too.

**OS/platform**
For instance, Ubuntu 16.04, Windows 10, or Android 4.0.3. If your code is running in a browser, please also include the browser type and version.
Expand Down
21 changes: 17 additions & 4 deletions .github/actions/sdk-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,25 @@ runs:
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Upgrade OpenSSL
if: runner.os == 'Windows'
shell: bash
run: |
choco upgrade openssl --no-progress
- name: Determine OpenSSL Installation Directory
if: runner.os == 'Windows'
shell: bash
run: |
if [ -d "C:\Program Files\OpenSSL-Win64" ]; then
echo "OPENSSL_ROOT_DIR=C:\Program Files\OpenSSL-Win64" >> "$GITHUB_ENV"
else
echo "OPENSSL_ROOT_DIR=C:\Program Files\OpenSSL" >> "$GITHUB_ENV"
fi
- name: Build Windows Artifacts
if: runner.os == 'Windows'
shell: bash
env:
OPENSSL_ROOT_DIR: 'C:\Program Files\OpenSSL'
OPENSSL_ROOT_DIR: ${{ env.OPENSSL_ROOT_DIR }}
BOOST_LIBRARY_DIR: 'C:\local\boost_1_81_0\lib64-msvc-14.3'
BOOST_LIBRARYDIR: 'C:\local\boost_1_81_0\lib64-msvc-14.3'
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
Expand Down Expand Up @@ -155,9 +169,8 @@ runs:
if: runner.os == 'macOS'
shell: bash
run: |
brew link --overwrite [email protected]
echo "OPENSSL_ROOT_DIR=$(brew --prefix [email protected])" >> "$GITHUB_ENV"
export OPENSSL_ROOT_DIR=$(brew --prefix [email protected])
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)" >> "$GITHUB_ENV"
export OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)
./scripts/build-release.sh ${{ inputs.sdk_cmake_target }}
env:
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
paths-ignore:
- '**.md' #Do not need to run CI for markdown changes.
pull_request:
branches: [ main, server-side ]
branches: [ main ]
paths-ignore:
- '**.md'

Expand All @@ -16,21 +16,20 @@ jobs:
env:
# Port the test service (implemented in this repo) should bind to.
TEST_SERVICE_PORT: 8123
TEST_SERVICE_BINARY: ./build/contract-tests/client-contract-tests/client-tests
TEST_SERVICE_BINARY: ./build/contract-tests/sdk-contract-tests/sdk-tests
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/ci
with:
cmake_target: client-tests
cmake_target: sdk-tests
run_tests: false
- name: 'Launch test service as background task'
run: $TEST_SERVICE_BINARY $TEST_SERVICE_PORT 2>&1 &
- uses: ./.github/actions/contract-tests
with:
# Inform the test harness of test service's port.
test_service_port: ${{ env.TEST_SERVICE_PORT }}
extra_params: '-skip-from ./contract-tests/client-contract-tests/test-suppressions.txt'
build-test-client:
build-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand All @@ -41,10 +40,9 @@ jobs:
runs-on: macos-12
steps:
- run: |
brew link --overwrite [email protected]
echo "OPENSSL_ROOT_DIR=$(brew --prefix [email protected])" >> "$GITHUB_ENV"
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)" >> "$GITHUB_ENV"
# For debugging
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@1.1)"
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)"
- uses: actions/checkout@v3
- uses: ./.github/actions/ci
env:
Expand All @@ -55,11 +53,23 @@ jobs:
build-test-client-windows:
runs-on: windows-2022
steps:
- name: Upgrade OpenSSL
shell: bash
run: |
choco upgrade openssl --no-progress
- name: Determine OpenSSL Installation Directory
shell: bash
run: |
if [ -d "C:\Program Files\OpenSSL-Win64" ]; then
echo "OPENSSL_ROOT_DIR=C:\Program Files\OpenSSL-Win64" >> "$GITHUB_ENV"
else
echo "OPENSSL_ROOT_DIR=C:\Program Files\OpenSSL" >> "$GITHUB_ENV"
fi
- uses: actions/checkout@v3
- uses: ilammy/msvc-dev-cmd@v1
- uses: ./.github/actions/ci
env:
OPENSSL_ROOT_DIR: 'C:\Program Files\OpenSSL'
OPENSSL_ROOT_DIR: ${{ env.OPENSSL_ROOT_DIR }}
BOOST_LIBRARY_DIR: 'C:\local\boost_1_81_0\lib64-msvc-14.3'
BOOST_LIBRARYDIR: 'C:\local\boost_1_81_0\lib64-msvc-14.3'
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/manual-publish-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
type: choice
options:
- libs/client-sdk
- libs/server-sdk
name: Publish Documentation
jobs:
build-publish:
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/manual-sdk-release-artifacts.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Checks out the tag, builds release builds, and attaches them to the release for the tag.
# If you need to change build scripts, then update the tag to include the modifications.
# NOTE: This workflow uses sdk-release/action.yml @ the tag specified in the workflow_dispatch input.
on:
workflow_dispatch:
inputs:
Expand All @@ -13,6 +14,7 @@ on:
type: choice
options:
- libs/client-sdk:launchdarkly-cpp-client
- libs/server-sdk:launchdarkly-cpp-server

name: Publish SDK Artifacts

Expand Down Expand Up @@ -55,18 +57,18 @@ jobs:
sdk_path: ${{ needs.split-input.outputs.sdk_path}}
sdk_cmake_target: ${{ needs.split-input.outputs.sdk_cmake_target}}
release-sdk-provenance:
needs: ['release-sdk']
needs: [ 'release-sdk' ]
strategy:
matrix:
# Generates a combined attestation for each platform
os: [ linux, windows, macos ]
permissions:
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.release-sdk.outputs[format('hashes-{0}', matrix.os)] }}"
upload-assets: true
upload-assets: true
upload-tag-name: ${{ inputs.tag }}
provenance-name: ${{ format('{0}-multiple-provenance.intoto.jsonl', matrix.os) }}
21 changes: 16 additions & 5 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ jobs:
runs-on: macos-12
steps:
- run: |
brew link --overwrite [email protected]
echo "OPENSSL_ROOT_DIR=$(brew --prefix [email protected])" >> "$GITHUB_ENV"
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)" >> "$GITHUB_ENV"
# For debugging
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@1.1)"
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)"
- uses: actions/checkout@v3
- uses: ./.github/actions/ci
env:
Expand All @@ -55,14 +54,26 @@ jobs:
build-test-server-windows:
runs-on: windows-2022
steps:
- name: Upgrade OpenSSL
shell: bash
run: |
choco upgrade openssl --no-progress
- name: Determine OpenSSL Installation Directory
shell: bash
run: |
if [ -d "C:\Program Files\OpenSSL-Win64" ]; then
echo "OPENSSL_ROOT_DIR=C:\Program Files\OpenSSL-Win64" >> "$GITHUB_ENV"
else
echo "OPENSSL_ROOT_DIR=C:\Program Files\OpenSSL" >> "$GITHUB_ENV"
fi
- uses: actions/checkout@v3
- uses: ilammy/msvc-dev-cmd@v1
- uses: ./.github/actions/ci
env:
OPENSSL_ROOT_DIR: 'C:\Program Files\OpenSSL'
OPENSSL_ROOT_DIR: ${{ env.OPENSSL_ROOT_DIR }}
BOOST_LIBRARY_DIR: 'C:\local\boost_1_81_0\lib64-msvc-14.3'
BOOST_LIBRARYDIR: 'C:\local\boost_1_81_0\lib64-msvc-14.3'
with:
cmake_target: launchdarkly-cpp-server
cmake_target: launchdarkly-cpp-client
platform_version: 2022
toolset: msvc
9 changes: 5 additions & 4 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"libs/client-sdk": "3.0.8",
"libs/server-sent-events": "0.1.3",
"libs/common": "0.3.6",
"libs/internal": "0.1.9"
"libs/client-sdk": "3.2.1",
"libs/server-sdk": "0.1.0",
"libs/server-sent-events": "0.2.0",
"libs/common": "0.5.0",
"libs/internal": "0.3.0"
}
100 changes: 74 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Required for Apple Silicon support.
cmake_minimum_required(VERSION 3.19)
include(CMakeDependentOption)

project(
LaunchDarklyCPPSDKs
Expand All @@ -13,22 +14,62 @@ project(

include(GNUInstallDirs)

option(BUILD_TESTING "Top-level switch for testing. Turn off to disable unit and contract tests." ON)

option(LD_BUILD_SHARED_LIBS "Build the SDKs as shared libraries" OFF)

cmake_dependent_option(LD_BUILD_UNIT_TESTS
"Build the C++ unit tests."
ON # default to enabling unit tests
"BUILD_TESTING;NOT LD_BUILD_SHARED_LIBS" # only exposed if top-level switch is on, and also only when building
# static libs. This is because we have hidden visibility of symbols by default (to only expose our C API.)
OFF # otherwise, off
)

# If you want to run the unit tests with valgrind, then LD_TESTING_SANITIZERS must of OFF.
cmake_dependent_option(LD_TESTING_SANITIZERS
"Enable sanitizers for unit tests."
ON # default to enabling sanitizers
"LD_BUILD_UNIT_TESTS" # only expose if unit tests enabled..
OFF # otherwise, off
)

cmake_dependent_option(LD_BUILD_CONTRACT_TESTS
"Build contract test service."
OFF # default to disabling contract tests, since they require running a service
"BUILD_TESTING;NOT LD_BUILD_SHARED_LIBS" # only expose if top-level switch is on and using static libs, since C++ symbols needed would be hidden.
OFF # otherwise, off
)

# The general strategy is to produce a fat artifact containing all of our dependencies so users
# only have a single thing to link. We should support this either being a static or shared library.
# Because OpenSSL is a large, and security relevant dependency, we should have a separate option
# to link against that statically or dynamically.

option(LD_DYNAMIC_LINK_OPENSSL
"Dynamically link OpenSSL instead of building with static library"
OFF # default to linking OpenSSL statically
)

option(LD_BUILD_EXAMPLES "Build hello-world examples." ON)

# If using 'make' as the build system, CMake causes the 'install' target to have a dependency on 'all', meaning
# it will cause a full build. This disables that, allowing us to build piecemeal instead. This is useful
# so that we only need to build the client or server for a given release (if only the client or server were affected.)
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)

# All projects in this repo should share the same version of 3rd party depends.
# It's the only way to remain sane.
set(CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

option(BUILD_TESTING "Enable C++ unit tests." ON)

# If you want to run the unit tests with valgrind, then TESTING_SANITIZERS must of OFF.
option(TESTING_SANITIZERS "Enable sanitizers for unit tests." ON)

if (BUILD_TESTING)
if (LD_BUILD_UNIT_TESTS)
message(STATUS "LaunchDarkly: building unit tests")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
add_compile_definitions(LAUNCHDARKLY_USE_ASSERT)
if (TESTING_SANITIZERS)
if (LD_TESTING_SANITIZERS)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined -fsanitize=leak")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
Expand All @@ -53,14 +94,22 @@ if (BUILD_TESTING)
enable_testing()
endif ()

set(OPENSSL_USE_STATIC_LIBS ON)
set(OPENSSL_ROOT_DIR "/opt/homebrew/opt/[email protected]")
if (LD_DYNAMIC_LINK_OPENSSL)
message(STATUS "LaunchDarkly: searching for shared OpenSSL library")
set(OPENSSL_USE_STATIC_LIBS OFF)
else ()
message(STATUS "LaunchDarkly: searching for static OpenSSL library")
set(OPENSSL_USE_STATIC_LIBS ON)
endif ()

find_package(OpenSSL REQUIRED)
message(STATUS "LaunchDarkly: using OpenSSL v${OPENSSL_VERSION}")

# Even though the main SDK might be a static or shared lib, boost should always statically
# linked into the binary.
set(Boost_USE_STATIC_LIBS ON)

if (BUILD_SHARED_LIBS)
if (LD_BUILD_SHARED_LIBS)
# When building a shared library we hide all symbols
# aside from this we have specifically exported for the C-API.
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
Expand All @@ -72,26 +121,25 @@ set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.81 REQUIRED COMPONENTS json url coroutine)
message(STATUS "LaunchDarkly: using Boost v${Boost_VERSION}")

add_subdirectory(libs/client-sdk)
add_subdirectory(libs/server-sdk)

set(ORIGINAL_BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF)
include(${CMAKE_FILES}/certify.cmake)
add_subdirectory(vendor/foxy)

# Always build the common libraries as static libs.
# Common, internal, and server-sent-events are built as "object" libraries.
add_subdirectory(libs/common)
add_subdirectory(libs/internal)
add_subdirectory(libs/server-sent-events)

set(ORIGINAL_BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS}")

set(BUILD_TESTING OFF)
include(${CMAKE_FILES}/certify.cmake)
add_subdirectory(vendor/foxy)

set(BUILD_TESTING "${ORIGINAL_BUILD_TESTING}")
# Built as static or shared depending on LD_BUILD_SHARED_LIBS variable.
# This target "links" in common, internal, and sse as object libraries.
add_subdirectory(libs/client-sdk)
add_subdirectory(libs/server-sdk)

set(BUILD_SHARED_LIBS "${ORIGINAL_BUILD_SHARED_LIBS}")
if (LD_BUILD_CONTRACT_TESTS)
message(STATUS "LaunchDarkly: building contract tests")
add_subdirectory(contract-tests)
endif ()

add_subdirectory(contract-tests)
add_subdirectory(examples)
if (LD_BUILD_EXAMPLES)
message(STATUS "LaunchDarkly: building examples")
add_subdirectory(examples)
endif ()
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Repository Maintainers
* @launchdarkly/team-sdk
* @launchdarkly/team-sdk-c
Loading

0 comments on commit 8f92208

Please sign in to comment.