Skip to content

Commit a1ec50b

Browse files
committed
Initial commit
0 parents  commit a1ec50b

File tree

17 files changed

+3762
-0
lines changed

17 files changed

+3762
-0
lines changed

.clang-format

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
BasedOnStyle: Google
2+
IndentWidth: 4
3+
ColumnLimit: 100

.devcontainer/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM ubuntu:latest
2+
3+
RUN apt-get update && apt-get install -y \
4+
build-essential \
5+
cmake \
6+
git \
7+
clang \
8+
lldb \
9+
gdb \
10+
&& rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
3+
{
4+
"name": "C++",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
8+
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
// "features": {},
11+
12+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
13+
// "forwardPorts": [],
14+
15+
// Use 'postCreateCommand' to run commands after the container is created.
16+
// "postCreateCommand": "gcc -v",
17+
18+
// Configure tool-specific properties.
19+
"customizations": {
20+
"vscode": {
21+
"extensions": [
22+
"ms-vscode.cpptools",
23+
"ms-vscode.cmake-tools"
24+
]
25+
}
26+
}
27+
28+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
29+
// "remoteUser": "root"
30+
}

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto eol=lf
2+
*.{cmd,[cC][mM][dD]} text eol=crlf
3+
*.{bat,[bB][aA][tT]} text eol=crlf

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
permissions:
3+
contents: write
4+
5+
on:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Create build environment
16+
run: cmake -E make_directory build
17+
18+
- name: Configure
19+
working-directory: build/
20+
run: cmake $GITHUB_WORKSPACE
21+
22+
- name: Package source code
23+
working-directory: build/
24+
run: cmake --build . --target Traits_package
25+
26+
- name: Add packaged source code to release
27+
uses: svenstaro/upload-release-action@v2
28+
with:
29+
repo_token: ${{ secrets.GITHUB_TOKEN }}
30+
file: build/Traits-src.zip
31+
tag: ${{ github.ref }}

.github/workflows/tests.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: tests on all platforms
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: true
15+
16+
matrix:
17+
os: [ubuntu-latest, windows-latest, macos-latest]
18+
build_type: [Debug, Release]
19+
c_compiler: [gcc, clang, cl]
20+
include:
21+
- os: windows-latest
22+
c_compiler: cl
23+
cpp_compiler: cl
24+
- os: ubuntu-latest
25+
c_compiler: gcc
26+
cpp_compiler: g++
27+
- os: ubuntu-latest
28+
c_compiler: clang
29+
cpp_compiler: clang++
30+
- os: macos-latest
31+
c_compiler: clang
32+
cpp_compiler: clang++
33+
exclude:
34+
- os: windows-latest
35+
c_compiler: gcc
36+
- os: windows-latest
37+
c_compiler: clang
38+
- os: ubuntu-latest
39+
c_compiler: cl
40+
- os: macos-latest
41+
c_compiler: cl
42+
- os: macos-latest
43+
c_compiler: gcc
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Set reusable strings
49+
id: strings
50+
shell: bash
51+
run: |
52+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
53+
54+
- name: Configure CMake
55+
run: >
56+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
57+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
58+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
59+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
60+
-S ${{ github.workspace }}
61+
62+
- name: Build
63+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
64+
65+
- name: Test
66+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
67+
run: ctest --output-on-failure --build-config ${{ matrix.build_type }}
68+
69+
lint:
70+
runs-on: ubuntu-latest
71+
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- name: Check formatting
76+
run: |
77+
find examples include tests -name '*.cpp' -o -name '*.h' |
78+
xargs clang-format -style=file -i # --dry-run --Werror

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Directories
2+
.vs
3+
build
4+
out
5+
6+
# Prerequisites
7+
*.d
8+
9+
# Compiled Object files
10+
*.slo
11+
*.lo
12+
*.o
13+
*.obj
14+
15+
# Precompiled Headers
16+
*.gch
17+
*.pch
18+
19+
# Compiled Dynamic libraries
20+
*.so
21+
*.dylib
22+
*.dll
23+
24+
# Compiled Static libraries
25+
*.lai
26+
*.la
27+
*.a
28+
*.lib
29+
30+
# Executables
31+
*.exe
32+
*.out
33+
*.app

CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
cmake_policy(VERSION 3.24)
3+
4+
project(Traits VERSION 0.0.1 LANGUAGES CXX)
5+
6+
set(CMAKE_CXX_STANDARD 20)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
9+
add_library(traits INTERFACE)
10+
add_library(Traits::traits ALIAS traits)
11+
target_compile_features(traits INTERFACE cxx_std_20)
12+
target_include_directories(traits INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")
13+
14+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
15+
16+
option (TRAITS_BUILD_TESTS "whether or not tests should be built" ON)
17+
18+
if(TRAITS_BUILD_TESTS)
19+
enable_testing()
20+
add_subdirectory(tests)
21+
endif()
22+
23+
set(package_files examples/ include/ tests/ CMakeLists.txt LICENSE README.md)
24+
add_custom_command(
25+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip
26+
COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip --format=zip -- ${package_files}
27+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
28+
DEPENDS ${package_files}
29+
)
30+
add_custom_target(${PROJECT_NAME}_package DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip)
31+
32+
endif()

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2024, Volume Graphics GmbH
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)