Skip to content

Commit

Permalink
Initial (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
improbable-til authored Jul 3, 2020
1 parent 75a1c51 commit e13db9e
Show file tree
Hide file tree
Showing 102 changed files with 13,303 additions and 1 deletion.
102 changes: 102 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# general build options
build --compilation_mode=dbg
build --verbose_failures
build --experimental_strict_action_env
build --experimental_guard_against_concurrent_changes
# This causes bazel to pass --config=windows/macos/linux automatically for us.
build --enable_platform_specific_config
# We enable the nocopts flag because it's used in the OpenSSL rules
build --noincompatible_disable_nocopts
# Enable symlinking of runfiles on all platforms (including Windows, where it's disable by default).
build --enable_runfiles --build_runfile_links
# Avoids downloading any remote build outputs to the local machine, except the ones required by local actions.
# Commenting out for now as it may be causing builds to flake.
#build --remote_download_minimal

# general test options - note that test inherits from build, so these are in addition to the ones
# above
test --test_output=errors

build:release --compilation_mode=opt

build:ci --keep_going
build:ci --announce_rc

#build:linux --copt="-O1"
#build:linux --copt="-march=skylake"
build:linux --copt="-fvisibility=hidden"
build:linux --copt="-fno-omit-frame-pointer" # for friendlier stack traces
build:linux --copt="-Wno-error"
build:linux --copt="-mavx"
build:linux --cxxopt="-std=c++17"
build:linux --linkopt="-lm"
build:linux --linkopt="-latomic"
build:linux --linkopt="-ldl"

build:linux-release --config=release
build:linux-release --config=linux
build:linux-release --copt="-O3"

build:macos --copt="-fvisibility=hidden"
build:macos --copt="-Wno-error"
build:macos --cxxopt="-std=c++17"

build:windows --cxxopt="/std:c++17"
# Disables wingdi.h, which avoids defining a macro called ERROR.
build:windows --cxxopt="/DNOGDI"
build:windows --features=static_link_msvcrt
# We fix the temp directory, as otherwise it is different across different Windows BK agents, which causes
# the remote cache to never be hit due to differing build graph hashes.
build:windows --action_env TMP=C:/Windows/Temp
build:windows --action_env TEMP=C:/Windows/Temp

# Config for when tests are running in a "slow" environment such as Valgrind or TSan
build:slow-tests --copt="-DIMPROBABLE_SLOW_TEST"

# Valgrind config.
build:valgrind-memcheck --config=slow-tests
test:valgrind-memcheck --run_under=//tools/runners/sanitizers/valgrind-memcheck

# Sanitizer configs; for an overview of the sanitizers, see https://github.com/google/sanitizers/wiki
# For more specific information on sanitizers:
# - https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
# - https://clang.llvm.org/docs/AddressSanitizer.html
# - https://clang.llvm.org/docs/ThreadSanitizer.html
build:base-sanitizer --copt="-fno-omit-frame-pointer" # for friendlier stack traces
build:base-sanitiser -strip=never

build:asan --config=base-sanitizer
build:asan --copt="-O1"
build:asan --copt="-fno-optimize-sibling-calls"
build:asan --copt="-fsanitize=address"
build:asan --linkopt="-fsanitize=address"
test:asan --test_env="ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-9/bin/llvm-symbolizer"
test:asan --run_under=//tools/runners/sanitizers/asan

build:tsan --config=base-sanitizer
build:tsan --config=slow-tests
build:tsan --copt="-O1"
build:tsan --copt="-fno-optimize-sibling-calls"
build:tsan --copt="-fsanitize=thread"
build:tsan --linkopt="-fsanitize=thread"
#test:tsan --test_env="TSAN_SYMBOLIZER_PATH=/usr/lib/llvm-9/bin/llvm-symbolizer"
test:tsan --run_under=//tools/runners/sanitizers/tsan

build:ubsan --config=base-sanitizer
build:ubsan --copt="-O1"
build:ubsan --copt="-fsanitize=undefined"
build:ubsan --copt="-fno-sanitize-recover=all"
# Since Bazel uses clang instead of clang++, enabling -fsanitize=vptr would
# require extra linkopts that cause segmentation faults on pure C code.
build:ubsan --copt="-fno-sanitize=function"
build:ubsan --linkopt="-fsanitize=undefined"
build:ubsan --linkopt="-lubsan"
test:ubsan --run_under=//tools/runners/sanitizers/ubsan

# MSAN is disabled for now, as there are false positives and we can't suppress them easily.
#build:msan --config=base-sanitizer
#build:msan --copt="-fsanitize=memory"
#build:msan --linkopt="-fsanitize=memory"
#test:msan --run_under=//tools/runners/sanitizers/msan

build:lint --define linting_only=true
158 changes: 158 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<improbable'
Priority: 2
- Regex: '^<spdlog/sinks/'
Priority: 4
- Regex: '^<.*\.(h|hpp)>'
Priority: 3
- Regex: '^<.*>'
Priority: 5
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 1
PenaltyBreakBeforeFirstCallParameter: 10
PenaltyBreakComment: 400
PenaltyBreakFirstLessLess: 200
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000000
PointerAlignment: Left
RawStringFormats:
- Language: TextProto
Delimiters:
- 'pb'
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
---
Language: Proto
BasedOnStyle: Google
ColumnLimit: 100
---
Language: Java
BasedOnStyle: Google
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakAfterJavaFieldAnnotations: true
BreakStringLiterals: true
ColumnLimit: 120
ContinuationIndentWidth: 4
ExperimentalAutoDetectBinPacking: false
...
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.*
!.bazelrc
!.clang-format
!.gitignore
bazel-*
!bazel-*.sh
compile_commands.json
perf.data*
build

54 changes: 54 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package(default_visibility = ["//visibility:public"])

# Platform configuration definitions for select()

config_setting(
name = "linux",
constraint_values = ["@bazel_tools//platforms:linux"],
)

config_setting(
name = "macos",
constraint_values = ["@bazel_tools//platforms:osx"],
)

config_setting(
name = "windows",
constraint_values = ["@bazel_tools//platforms:windows"],
)

config_setting(
name = "windows_debug",
constraint_values = ["@bazel_tools//platforms:windows"],
values = {
"compilation_mode": "dbg",
},
)

config_setting(
name = "windows_release",
constraint_values = ["@bazel_tools//platforms:windows"],
values = {
"compilation_mode": "opt",
},
)

# Buildifier

sh_binary(
name = "buildifier",
srcs = select(
{
":linux": ["@buildifier_linux//file"],
":macos": ["@buildifier_macos//file"],
":windows": ["@buildifier_windows//file"],
},
),
)

# Aspect-based clang-format

filegroup(
name = "dot_clang_format",
srcs = [".clang-format"],
)
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

## 0.1.0 - 2020-07-02
### Added
- Initial version.

### Changed
- Everything.

### Removed
- Nothing.

### Fixed
- Nothing.


[Unreleased]: https://github.com/improbable-eng/phtree-cpp/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/improbable-eng/phtree-cpp/compare/v0.1.0...v1.0.0
[0.2.0]: https://github.com/improbable-eng/phtree-cpp/compare/v0.1.0...v0.2.0
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.14)

# set the project name
project(PH_Tree_Main VERSION 0.1.0
DESCRIPTION "PH-Tree C++"
LANGUAGES CXX)

# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -O3")

add_subdirectory(phtree)
add_subdirectory(examples)
Loading

0 comments on commit e13db9e

Please sign in to comment.