Skip to content

Commit c8739a5

Browse files
Restructuring the code to make a more coherent ROOT component (#2)
1 parent 8572608 commit c8739a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4834
-35490
lines changed

.clang-format

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
# BasedOnStyle: LLVM
22
AccessModifierOffset: -3
33
AlignAfterOpenBracket: Align
4-
AlignConsecutiveAssignments: false
4+
AlignConsecutiveAssignments: None
55
# This would be nice to have but seems to also (mis)align function parameters
6-
AlignConsecutiveDeclarations: false
7-
AlignEscapedNewlinesLeft: true
6+
AlignConsecutiveDeclarations: None
7+
AlignEscapedNewlines: Left
88
AlignOperands: true
99
AlignTrailingComments: true
1010
AllowAllParametersOfDeclarationOnNextLine: true
11-
AllowShortBlocksOnASingleLine: false
11+
AllowShortBlocksOnASingleLine: Never
1212
AllowShortCaseLabelsOnASingleLine: true
13+
AllowShortEnumsOnASingleLine: false
1314
AllowShortFunctionsOnASingleLine: Inline
14-
AllowShortIfStatementsOnASingleLine: true
15-
AllowShortLoopsOnASingleLine: true
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
1617
# This option is "deprecated and is retained for backwards compatibility."
1718
# AlwaysBreakAfterDefinitionReturnType: None
1819
AlwaysBreakAfterReturnType: None
1920
AlwaysBreakBeforeMultilineStrings: false
20-
AlwaysBreakTemplateDeclarations: true
21+
AlwaysBreakTemplateDeclarations: Yes
2122
BinPackArguments: true
2223
BinPackParameters: true
2324
BraceWrapping:
2425
AfterClass: false
25-
AfterControlStatement: false
26+
AfterControlStatement: Never
2627
AfterEnum: false
2728
AfterFunction: true
2829
AfterNamespace: false
@@ -32,33 +33,20 @@ BraceWrapping:
3233
BeforeCatch: false
3334
BeforeElse: false
3435
IndentBraces: false
35-
BreakBeforeBinaryOperators: false
36+
BreakBeforeBinaryOperators: None
3637
BreakBeforeBraces: Custom
3738
BreakBeforeTernaryOperators: true
3839
BreakConstructorInitializersBeforeComma: false
3940
ColumnLimit: 120
4041
CommentPragmas: '^ IWYU pragma:'
41-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
42+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
4243
ConstructorInitializerIndentWidth: 3
4344
ContinuationIndentWidth: 3
4445
Cpp11BracedListStyle: true
4546
DerivePointerAlignment: false
4647
DisableFormat: false
4748
ExperimentalAutoDetectBinPacking: false
4849
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
49-
IncludeCategories:
50-
- Regex: '^("|<)T'
51-
Priority: 4
52-
- Regex: '^("|<)ROOT/'
53-
Priority: 5
54-
- Regex: '^<.*\.h>'
55-
Priority: 1
56-
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
57-
Priority: 2
58-
- Regex: '^(<|"(gtest|isl|json)/)'
59-
Priority: 3
60-
- Regex: '.*'
61-
Priority: 6
6250
IndentCaseLabels: false
6351
IndentWidth: 3
6452
IndentWrappedFunctionNames: false
@@ -75,12 +63,14 @@ PenaltyBreakComment: 300
7563
PenaltyBreakFirstLessLess: 120
7664
PenaltyBreakString: 1000
7765
PenaltyExcessCharacter: 1000000
78-
PenaltyReturnTypeOnItsOwnLine: 60000
66+
PenaltyReturnTypeOnItsOwnLine: 10
7967
PointerAlignment: Right
80-
ReflowComments: true
81-
SortIncludes: false
68+
ReflowComments: true
69+
SortIncludes: Never
8270
SpaceAfterCStyleCast: false
8371
SpaceBeforeAssignmentOperators: true
72+
# You want this : enable it if you have https://reviews.llvm.org/D32525
73+
# SpaceBeforeColon: false
8474
SpaceBeforeParens: ControlStatements
8575
SpaceInEmptyParentheses: false
8676
SpacesBeforeTrailingComments: 1
@@ -89,6 +79,24 @@ SpacesInContainerLiterals: true
8979
SpacesInCStyleCastParentheses: false
9080
SpacesInParentheses: false
9181
SpacesInSquareBrackets: false
92-
Standard: Cpp11
82+
Standard: c++17
9383
TabWidth: 3
9484
UseTab: Never
85+
86+
# Order alphabetically and by generality the included header files.
87+
IncludeCategories:
88+
- Regex: '^"[^/]+\"'
89+
Priority: 10
90+
- Regex: '^("|<)T'
91+
Priority: 12
92+
- Regex: '^"ROOT/'
93+
Priority: 15
94+
- Regex: '^"cling/'
95+
Priority: 20
96+
- Regex: '^"clang/'
97+
Priority: 30
98+
- Regex: '^"llvm/'
99+
Priority: 40
100+
- Regex: '^<'
101+
Priority: 50
102+

.clang-tidy

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Checks: >
2+
-*,
3+
bugprone-*,
4+
clang-diagnostic-*,
5+
clang-analyzer-*,
6+
cppcoreguidelines-*,
7+
llvm-*,
8+
misc-*,
9+
modernize-*,
10+
performance-*,
11+
portability-*,
12+
readability-*,
13+
-bugprone-narrowing-conversions,
14+
-bugprone-easily-swappable-parameters,
15+
-bugprone-implicit-widening-of-multiplication-result,
16+
-bugprone-unchecked-optional-access,
17+
-misc-const-correctness,
18+
-misc-unused-parameters,
19+
-misc-non-private-member-variables-in-classes,
20+
-misc-no-recursion,
21+
-misc-use-anonymous-namespace,
22+
-modernize-return-braced-init-list,
23+
-modernize-use-trailing-return-type,
24+
-readability-braces-around-statements,
25+
-readability-identifier-length,
26+
-readability-magic-numbers,
27+
-readability-named-parameter,
28+
-readability-function-cognitive-complexity,
29+
-readability-implicit-bool-conversion,
30+
-cppcoreguidelines-avoid-magic-numbers,
31+
-clang-analyzer-cplusplus.NewDeleteLeaks,
32+
33+
CheckOptions:
34+
- key: readability-identifier-naming.ClassCase
35+
value: aNy_CasE
36+
- key: readability-identifier-naming.FunctionCase
37+
value: aNy_CasE
38+
- key: readability-identifier-naming.MemberCase
39+
value: aNy_CasE
40+
- key: readability-identifier-naming.PrivateMemberPrefix
41+
value: 'm_'
42+
- key: readability-identifier-naming.ProtectedMemberPrefix
43+
value: 'm_'
44+
- key: readability-identifier-naming.PublicMemberPrefix
45+
value: ''
46+
- key: readability-identifier-naming.ParameterCase
47+
value: aNy_CasE
48+
- key: readability-identifier-naming.UnionCase
49+
value: CamelCase
50+
- key: readability-identifier-naming.VariableCase
51+
value: aNy_CasE
52+
- key: readability-identifier-naming.IgnoreMainLikeFunctions
53+
value: 1
54+
- key: readability-implicit-bool-conversion.AllowPointerConditions
55+
value: 1
56+
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
57+
value: 1
58+
- key: readability-magic-numbers.IgnoredIntegerValues
59+
value: 4;8;16;
60+
- key: bugprone-argument-comment.CommentNullPtrs
61+
value: 1
62+
- key: bugprone-argument-comment.CommentBoolLiterals
63+
value: 1
64+
- key: bugprone-argument-comment.StrictMode
65+
value: 1
66+
- key: bugprone-argument-comment.CommentIntegerLiterals
67+
value: 1
68+
- key: bugprone-argument-comment.CommentUserDefinedLiterals
69+
value: 1
70+
- key: bugprone-argument-comment.CommentStringLiterals
71+
value: 1
72+
- key: bugprone-argument-comment.CommentFloatLiterals
73+
value: 1
74+
- key: bugprone-argument-comment.CommentCharacterLiterals
75+
value: 1
76+

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ tmp/
1717
*.bk
1818
*.rootix
1919
*.sam
20+
build/
21+
cmake-build-*/
22+
Build/
23+
BUILD/
24+
Testing/
25+
.vscode/
26+
docs/html/
27+
docs/latex/
28+
html/

CMakeLists.txt

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,65 @@
11
cmake_minimum_required(VERSION 3.16)
2+
project(ramtools VERSION 1.0.0 LANGUAGES CXX)
23

3-
project(ramtools LANGUAGES CXX)
4+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
45

56
set(CMAKE_CXX_STANDARD 17)
67
set(CMAKE_CXX_STANDARD_REQUIRED ON)
78
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
89

9-
find_package(ROOT 6.26 REQUIRED
10-
COMPONENTS Core RIO Tree ROOTNTuple)
10+
option(RAMTOOLS_BUILD_TESTS "Build unit tests" ON)
11+
option(RAMTOOLS_BUILD_BENCHMARKS "Build benchmarks" ON)
12+
option(RAMTOOLS_BUILD_TOOLS "Build tools" ON)
1113

12-
set(RNTUPLE_LIBS ROOT::ROOTNTuple ROOT::ROOTNTupleUtil)
14+
set(ROOT_MIN_VERSION 6.26)
15+
find_package(ROOT ${ROOT_MIN_VERSION} REQUIRED COMPONENTS Core RIO Tree ROOTNTuple ROOTNTupleUtil)
1316

1417
include(${ROOT_USE_FILE})
1518

16-
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/rntuple)
19+
include(GNUInstallDirs)
20+
set(CMAKE_INSTALL_LIBDIR lib)
21+
set(CMAKE_INSTALL_INCLUDEDIR include)
1722

18-
ROOT_STANDARD_LIBRARY_PACKAGE(ramrecord
19-
SOURCES ramrecord.C
20-
HEADERS ramrecord.h
21-
LIBRARIES ROOT::Core ROOT::RIO ROOT::Tree
23+
ROOT_STANDARD_LIBRARY_PACKAGE(ramcore
24+
HEADERS
25+
inc/ttree/RAMRecord.h
26+
inc/ttree/Utils.h
27+
inc/ttree/CigarOps.h
28+
inc/rntuple/RAMNTupleRecord.h
29+
inc/ramcore/SamParser.h
30+
inc/ramcore/SamToTTree.h
31+
inc/ramcore/SamToNTuple.h
32+
SOURCES
33+
src/ttree/RAMRecord.cxx
34+
src/rntuple/RAMNTupleRecord.cxx
35+
src/ramcore/SamParser.cxx
36+
src/ramcore/SamToTTree.cxx
37+
src/ramcore/SamToNTuple.cxx
38+
LINKDEF
39+
inc/ttree/LinkDef.h
40+
DEPENDENCIES
41+
ROOT::Core
42+
ROOT::RIO
43+
ROOT::Tree
44+
ROOT::ROOTNTuple
45+
ROOT::ROOTNTupleUtil
46+
INSTALL_OPTIONS
47+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
2248
)
2349

24-
set(RAMTOOLS_ROOT_LIBS ROOT::Core ROOT::RIO ROOT::Tree)
25-
26-
ROOT_STANDARD_LIBRARY_PACKAGE(ramntuplerecord
27-
SOURCES rntuple/RAMntuplerecord.C
28-
HEADERS rntuple/RAMNTupleRecord.h
29-
LIBRARIES ROOT::Core ROOT::RIO ROOT::Tree ${RNTUPLE_LIBS}
50+
target_include_directories(ramcore
51+
PUBLIC
52+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
53+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
3054
)
3155

32-
ROOT_EXECUTABLE(samtoramntuple
33-
rntuple/samtoramntuple.C
34-
LIBRARIES ramntuplerecord ${RAMTOOLS_ROOT_LIBS} ${RNTUPLE_LIBS})
56+
install(DIRECTORY inc/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
3557

36-
include(CTest)
37-
file(GLOB RAMTESTS tests/test_*.C)
38-
foreach(testfile ${RAMTESTS})
39-
get_filename_component(testname ${testfile} NAME_WE)
40-
add_test(NAME ${testname}
41-
COMMAND root -l -b -q ${testfile}+)
42-
set_tests_properties(${testname} PROPERTIES WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
43-
endforeach()
58+
if(RAMTOOLS_BUILD_TOOLS)
59+
add_subdirectory(tools)
60+
endif()
4461

62+
if(RAMTOOLS_BUILD_TESTS)
63+
enable_testing()
64+
add_subdirectory(test)
65+
endif()

0 commit comments

Comments
 (0)