Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
timblechmann committed Nov 26, 2023
0 parents commit 58dc748
Show file tree
Hide file tree
Showing 12 changed files with 1,477 additions and 0 deletions.
171 changes: 171 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
Checks: >
-*,
clang-diagnostic-*,
clang-analyzer-*,
boost-*,
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-bad-signal-to-kill-thread,
bugprone-bool-pointer-implicit-conversion,
bugprone-branch-clone,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
bugprone-exception-escape,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-forwarding-reference-overload,
bugprone-inaccurate-erase,
bugprone-incorrect-roundings,
bugprone-infinite-loop,
bugprone-integer-division,
bugprone-lambda-function-name,
bugprone-macro-*,
bugprone-misplaced-*,
bugprone-move-forwarding-reference,
bugprone-multiple-statement-macro,
bugprone-narrowing-conversions,
bugprone-no-escape,
bugprone-not-null-terminated-result,
bugprone-parent-virtual-call,
bugprone-posix-return,
bugprone-redundant-branch-condition,
bugprone-reserved-identifier,
bugprone-signal-handler,
bugprone-signed-char-misuse,
bugprone-sizeof-*,
bugprone-spuriously-wake-up-functions,
bugprone-string-*,
bugprone-suspicious-*,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unhandled-*,
bugprone-unused-*,
bugprone-use-after-move,
bugprone-virtual-near-miss,
clang-*,
concurrency-*,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-slicing,
google-default-arguments,
google-explicit-constructor,
google-global-names-in-headers,
google-objc-*,
google-readability-avoid-underscore-in-googletest-name,
google-runtime-operator,
google-upgrade-googletest-case,
hicpp-static-assert,
hicpp-undelegated-constructor,
hicpp-use-emplace,
hicpp-use-equals-*,
hicpp-use-noexcept,
hicpp-use-nullptr,
llvm-namespace-comment,
misc-definitions-in-headers,
misc-misplaced-const,
misc-new-delete-overloads,
misc-no-recursion,
misc-non-copyable-objects,
misc-redundant-expression,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
misc-unused-parameters,
misc-unused-using-decls,
modernize-avoid-bind,
modernize-concat-nested-namespaces,
modernize-deprecated-ios-base-aliases,
modernize-loop-convert,
modernize-make-*,
modernize-pass-by-value,
modernize-raw-string-literal,
modernize-redundant-void-arg,
modernize-shrink-to-fit,
modernize-unary-static-assert,
modernize-use-bool-literals,
modernize-use-default-member-init,
modernize-use-emplace,
modernize-use-equals-*,
modernize-use-noexcept,
modernize-use-nullptr,
modernize-use-override,
modernize-use-transparent-functors,
modernize-use-uncaught-exceptions,
performance-*,
portability-*,
readability-avoid-const-params-in-decls,
readability-const-return-type,
readability-container-size-empty,
readability-convert-member-functions-to-static,
readability-delete-null-pointer,
readability-else-after-return,
readability-function-*,
-readability-function-size,
readability-identifier-naming,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-misleading-indentation,
readability-misplaced-array-index,
readability-non-const-parameter,
readability-qualified-auto,
readability-redundant-control-flow,
readability-redundant-declaration,
readability-redundant-function-ptr-dereference,
readability-redundant-member-init,
readability-redundant-preprocessor,
readability-redundant-smartptr-get,
readability-redundant-string-*,
readability-simplify-*,
readability-static-*,
readability-string-compare,
readability-suspicious-call-argument,
readability-uniqueptr-delete-release,
readability-use-anyofallof,
zircon-*
CheckOptions:
- key: llvm-else-after-return.WarnOnConditionVariables
value: 'false'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-use-override.IgnoreDestructors
value: 'true'
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
value: 'false'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: 'false'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: 'true'
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: 'true'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: llvm-qualified-auto.AddConstToQualified
value: 'false'
- key: llvm-else-after-return.WarnOnUnfixable
value: 'false'
- key: readability-function-cognitive-complexity.IgnoreMacros
value: 'true'
- key: bugprone-signed-char-misuse.CharTypdefsToIgnore
value: 'int8_t;std::int8_t'
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CMake Build and Test

on:
push:
branches:
- master
- develop
- githubactions*
- feature/**
- fix/**
- pr/**
jobs:
build-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]

steps:
- uses: actions/checkout@v2

- name: Setup CMake
uses: actions/setup-cmake@v3
with:
cmake-version: '3.18.2'

- name: Configure CMake
run: cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=cmake/conan_provider.cmake

- name: Build
run: cmake --build build

- name: Test
run: ctest --build build --target test
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-shebang-scripts-are-executable
- id: mixed-line-ending
args: [--fix=auto]


- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.4
hooks:
- id: clang-format
types_or: [c++, c, cuda]
55 changes: 55 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.25)

project(nova_symbol VERSION 0.1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)

########################################################################################################################

add_custom_target(nova_symbol_project_files SOURCES
.clang-tidy
.pre-commit-config.yaml
_clang-format
conanfile.txt
Readme.md
License.txt
.github/workflows/ci.yml
)
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS conanfile.txt)

########################################################################################################################

find_package(Boost)
find_package(Cityhash)
find_package(Catch2 CONFIG)

########################################################################################################################

set(Sources
inc/nova/symbol/symbol.hpp
src/nova/symbol/symbol.cpp
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Sources})

add_library(nova_symbol STATIC ${Sources})

target_include_directories(nova_symbol PUBLIC inc)
target_link_libraries(nova_symbol
PUBLIC Boost::headers
PRIVATE cityhash::cityhash)

########################################################################################################################

option(NOVA_SYMBOL_BUILD_TEST "Build unit tests" ON)

if (NOVA_SYMBOL_BUILD_TEST)
add_executable(nova_symbol_test test/symbol_test.cpp)

add_test(NAME nova_symbol_test COMMAND nova_symbol_test)

target_link_libraries(nova_symbol_test
PUBLIC Catch2::Catch2WithMain nova_symbol)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES test/symbol_test.cpp)
endif()
23 changes: 23 additions & 0 deletions License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (c) 2023 Tim Blechmann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---

As a non-binding request, please use this code responsibly and ethically.
20 changes: 20 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Nova symbol

Symbols are hashed strings:
* fast to copy (size of a pointer)
* fast to compare (comparing pointers)
* slow-ish to construct (require registration in hash table)
* no cross-dso support

# Dependencies
* C++20 (with pmr)
* Boost (for instrusive hash table)
* Cityhash (for string hashing)
* Catch2 (for unit tests)

# Building

Integrate Conan via
```
cmake -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=cmake/conan_provider.cmake
```
Loading

0 comments on commit 58dc748

Please sign in to comment.