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
80 changes: 80 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# SPDX-License-Identifier: MIT
name: Build

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
build-posix:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends cmake ninja-build g++

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
set -euo pipefail
brew install cmake ninja

- name: Configure
run: |
set -euo pipefail
cmake -S . -B build -G Ninja \
-DCORETRACE_LOGGER_BUILD_TESTS=ON \
-DCORETRACE_LOGGER_BUILD_EXAMPLES=ON

- name: Build
run: |
set -euo pipefail
cmake --build build

- name: Test
run: |
set -euo pipefail
ctest --test-dir build --output-on-failure

build-windows:
name: Build on Windows
runs-on: windows-2022

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
cmake -S . -B build-win -G "Visual Studio 17 2022" -A x64 `
-DCORETRACE_LOGGER_BUILD_TESTS=ON `
-DCORETRACE_LOGGER_BUILD_EXAMPLES=ON

- name: Build
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
cmake --build build-win --config Release

- name: Test
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
ctest --test-dir build-win -C Release --output-on-failure
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ find_package(Threads REQUIRED)

### Library ###

add_library(coretrace_logger STATIC src/logger.cpp)
set(CORETRACE_LOGGER_SOURCES src/logger.cpp)
if(WIN32)
list(APPEND CORETRACE_LOGGER_SOURCES src/logger_windows.cpp)
else()
list(APPEND CORETRACE_LOGGER_SOURCES src/logger_posix.cpp)
endif()

add_library(coretrace_logger STATIC ${CORETRACE_LOGGER_SOURCES})

target_include_directories(coretrace_logger
PUBLIC
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,19 @@ target_link_libraries(my_target PRIVATE coretrace::logger)

## Requirements

- C++20 compiler (Clang 16+, GCC 13+, AppleClang 15+)
- POSIX (Linux, macOS) for `write(2)`, `pthread`, `clock_gettime`
- C++20 compiler (Clang 16+, GCC 13+, AppleClang 15+, Visual Studio/MSVC)
- Linux, macOS, or Windows

## Windows build

Native Windows builds work with Visual Studio 2022 and CMake:

```powershell
cmake -S . -B build-win -G "Visual Studio 17 2022" -A x64 `
-DCORETRACE_LOGGER_BUILD_TESTS=ON
cmake --build build-win --config Release
ctest --test-dir build-win -C Release --output-on-failure
```

## API reference

Expand Down
2 changes: 1 addition & 1 deletion scripts/check-license-compliance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [ -f "${WORKFLOW_FILE}" ]; then
fi
fi

spdx_output="$(git -C "${REPO_ROOT}" grep -n "SPDX-License-Identifier:" -- . 2>/dev/null || true)"
spdx_output="$(git -C "${REPO_ROOT}" grep -n -E "^[[:space:]]*(#|//|/\*)[[:space:]]*SPDX-License-Identifier:" -- . 2>/dev/null || true)"

if [ -n "${spdx_output}" ]; then
mismatches=()
Expand Down
Loading
Loading