Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add windows support #119

Merged
merged 5 commits into from
May 20, 2024
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
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.bazelrc.absl
15 changes: 15 additions & 0 deletions .bazelrc.absl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# In order to support both Unixen and Windows, different styles of compiler
# flags must be used.
#
# This .bazelrc file specifies different compiler flags for Linux/Darwin versus
# Windows.
#
# This bazelrc defines the `DD_USE_ABSEIL_FOR_ENVOY` preprocessor macro, and so
# the resulting library will use `absl::string_view` and `absl::optional`
# instead of their standard (`std`) equivalents.

build --enable_platform_specific_config

build:linux --cxxopt='-std=c++17' --cxxopt='-Wall' --cxxopt='-Wextra' --cxxopt='-pedantic' --cxxopt='-DDD_USE_ABSEIL_FOR_ENVOY'
build:macos --cxxopt='-std=c++17' --cxxopt='-Wall' --cxxopt='-Wextra' --cxxopt='-pedantic' --cxxopt='-DDD_USE_ABSEIL_FOR_ENVOY'
build:windows --cxxopt='/std:c++17' --cxxopt='/DDD_USE_ABSEIL_FOR_ENVOY' --linkopt='ws2_32.lib'
15 changes: 15 additions & 0 deletions .bazelrc.std
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# In order to support both Unixen and Windows, different styles of compiler
# flags must be used.
#
# This .bazelrc file specifies different compiler flags for Linux/Darwin versus
# Windows.
#
# This bazelrc does _not_ define the `DD_USE_ABSEIL_FOR_ENVOY` preprocessor
# macro, and so the resulting library will use `std::string_view` and
# `std::optional` instead of their Abseil equivalents.

build --enable_platform_specific_config

build:linux --cxxopt='-std=c++17' --cxxopt='-Wall' --cxxopt='-Wextra' --cxxopt='-pedantic'
build:macos --cxxopt='-std=c++17' --cxxopt='-Wall' --cxxopt='-Wextra' --cxxopt='-pedantic'
build:windows --cxxopt='/std:c++17' --linkopt='ws2_32.lib'
80 changes: 71 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,65 @@ jobs:
type: string
arch:
type: string
bazelrc:
type: string
executor: docker-<< parameters.arch >>
environment:
MAKE_JOB_COUNT: 8
steps:
- checkout
- run: bin/with-toolchain << parameters.toolchain >> bazelisk build --jobs $MAKE_JOB_COUNT dd_trace_cpp
- run: bin/with-toolchain << parameters.toolchain >> bazelisk --bazelrc=<< parameters.bazelrc >> build --jobs $MAKE_JOB_COUNT dd_trace_cpp

test-cmake:
build-and-test-windows-bazel:
parameters:
toolchain:
# `bazelrc` is the path to the .bazelrc file to use in the build/test.
# The repository has two flavors: one that uses Abseil types (for use with
# Envoy), and one that uses std types.
bazelrc:
type: string
machine:
image: "windows-server-2022-gui:current"
resource_class: windows.medium
shell: powershell.exe -ExecutionPolicy Bypass
environment:
MAKE_JOB_COUNT: 4
steps:
- checkout
- run: choco install -y bazelisk
- run: bazelisk.exe --bazelrc=<< parameters.bazelrc >> build --jobs $env:MAKE_JOB_COUNT dd_trace_cpp

build-and-test-windows-cmake:
parameters:
arch:
type: string
sanitize:
machine:
image: "windows-server-2022-gui:current"
shell: powershell.exe -ExecutionPolicy Bypass
resource_class: "windows.large"
environment:
MAKE_JOB_COUNT: 8
steps:
- checkout
- run:
name: Install dependencies
command: |
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
choco install -y ninja
- run:
name: Building
command: |
& 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\Tools\\Launch-VsDevShell.ps1' -arch << parameters.arch >>
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DDD_TRACE_BUILD_TESTING=1 -G Ninja .
cmake --build build -j $env:MAKE_JOB_COUNT -v
- run:
name: Testing
command: |
& 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\Tools\\Launch-VsDevShell.ps1' -arch << parameters.arch >>
.\build\test\tests.exe

build-and-test-cmake:
parameters:
toolchain:
type: string
arch:
type: string
Expand All @@ -55,7 +102,7 @@ jobs:
ASAN_OPTIONS: alloc_dealloc_mismatch=0
steps:
- checkout
- run: bin/with-toolchain << parameters.toolchain >> cmake . -B .build -DBUILD_TESTING=1 -DSANITIZE=<< parameters.sanitize >>
- run: bin/with-toolchain << parameters.toolchain >> cmake . -B .build -DCMAKE_BUILD_TYPE=Debug -DDD_TRACE_BUILD_TESTING=1
- run: cmake --build .build -j ${MAKE_JOB_COUNT} -v
- run: cd .build && test/tests

Expand Down Expand Up @@ -127,19 +174,34 @@ workflows:
jobs:
- format
- shellcheck
- test-cmake:
- build-and-test-cmake:
matrix:
parameters:
toolchain: ["gnu", "llvm"]
sanitize: ["on", "off"]
arch: ["amd64", "arm64"]
- build-bazel:
matrix:
parameters:
arch: ["amd64", "arm64"]
toolchain: ["gnu", "llvm"]
- coverage
arch: ["amd64", "arm64"]
bazelrc: [".bazelrc.absl", ".bazelrc.std"]
- build-and-test-windows-cmake:
matrix:
parameters:
arch: ["amd64"]
- build-and-test-windows-bazel:
matrix:
parameters:
bazelrc: [".bazelrc.absl", ".bazelrc.std"]
- coverage:
requires:
- build-and-test-cmake
- system-tests:
requires:
- build-bazel
- build-and-test-cmake
- build-and-test-windows-bazel
- build-and-test-windows-cmake
filters:
branches:
only:
Expand Down
8 changes: 0 additions & 8 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ cc_library(
"src/datadog/version.h",
"src/datadog/w3c_propagation.h",
],
copts = [
"-Wall",
"-Wextra",
"-Werror",
"-pedantic",
"-std=c++17",
"-DDD_USE_ABSEIL_FOR_ENVOY",
],
strip_include_prefix = "src/",
visibility = ["//visibility:public"],
deps = [
Expand Down
Loading
Loading