Skip to content

Commit e49ed8b

Browse files
authored
Initial ALF implemention
Tested: * Register read/write * SWT sequence Not tested: * SCA sequence Not implemented: * IC
1 parent db321f6 commit e49ed8b

30 files changed

+3844
-0
lines changed

.clang-format

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
BasedOnStyle: Google
2+
AccessModifierOffset: -1
3+
AlignEscapedNewlinesLeft: true
4+
AlignTrailingComments: true
5+
AllowAllParametersOfDeclarationOnNextLine: false
6+
AllowShortFunctionsOnASingleLine: true
7+
AllowShortIfStatementsOnASingleLine: false
8+
AllowShortLoopsOnASingleLine: false
9+
#AlwaysBreakBeforeMultilineStrings: true
10+
AlwaysBreakTemplateDeclarations: true
11+
BinPackParameters: true
12+
BreakBeforeBinaryOperators: false
13+
BreakBeforeBraces: Linux
14+
BreakBeforeTernaryOperators: true
15+
BreakConstructorInitializersBeforeComma: false
16+
ColumnLimit: 0
17+
CommentPragmas: '^ IWYU pragma:'
18+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
19+
ConstructorInitializerIndentWidth: 2
20+
ContinuationIndentWidth: 2
21+
Cpp11BracedListStyle: false
22+
DerivePointerBinding: false
23+
ExperimentalAutoDetectBinPacking: false
24+
IndentCaseLabels: true
25+
IndentFunctionDeclarationAfterType: true
26+
IndentWidth: 2
27+
# It is broken on windows. Breaks all #include "header.h"
28+
Language: Cpp
29+
MaxEmptyLinesToKeep: 1
30+
KeepEmptyLinesAtTheStartOfBlocks: true
31+
NamespaceIndentation: None
32+
ObjCSpaceAfterProperty: false
33+
ObjCSpaceBeforeProtocolList: false
34+
PenaltyBreakBeforeFirstCallParameter: 1
35+
PenaltyBreakComment: 300
36+
PenaltyBreakFirstLessLess: 120
37+
PenaltyBreakString: 1000
38+
PenaltyExcessCharacter: 1000000
39+
PenaltyReturnTypeOnItsOwnLine: 200
40+
SortIncludes: false
41+
SpaceBeforeAssignmentOperators: true
42+
SpaceBeforeParens: ControlStatements
43+
SpaceInEmptyParentheses: false
44+
SpacesBeforeTrailingComments: 1
45+
SpacesInAngles: false
46+
SpacesInContainerLiterals: true
47+
SpacesInCStyleCastParentheses: false
48+
SpacesInParentheses: false
49+
Standard: Cpp11
50+
TabWidth: 2
51+
UseTab: Never

.clang-tidy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CheckOptions:
2+
- key: CheckPathRegex
3+
value: '.*/ALF/.*'

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build
2+
.idea
3+
.project
4+
.cproject
5+
cmake-build-*
6+
*.swp
7+
*.swo
8+
*.pyc

CMakeLists.txt

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
####################################
2+
# General project definition
3+
####################################
4+
5+
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.2 FATAL_ERROR)
6+
7+
# Set cmake policy by version: https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html
8+
if(${CMAKE_VERSION} VERSION_LESS 3.12)
9+
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
10+
else()
11+
cmake_policy(VERSION 3.12)
12+
endif()
13+
14+
# Define project
15+
project(ALF
16+
VERSION 0.0.1
17+
DESCRIPTION "O2 ALF"
18+
LANGUAGES CXX
19+
)
20+
21+
# Documentation dir
22+
# add_subdirectory(doc)
23+
24+
# Add compiler flags for warnings and debug symbols
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra")
26+
27+
# Set fPIC for all targets
28+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
29+
30+
# Set CMAKE_INSTALL_LIBDIR explicitly to lib (to avoid lib64 on CC7)
31+
set(CMAKE_INSTALL_LIBDIR lib)
32+
33+
# Set the default build type to "RelWithDebInfo"
34+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
35+
set(CMAKE_BUILD_TYPE "RelWithDebInfo"
36+
CACHE
37+
STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Coverage."
38+
FORCE
39+
)
40+
endif()
41+
42+
43+
####################################
44+
# Dependencies
45+
####################################
46+
47+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
48+
49+
find_package(Common REQUIRED)
50+
find_package(InfoLogger REQUIRED)
51+
find_package(ReadoutCard REQUIRED)
52+
find_package(DIM REQUIRED)
53+
54+
####################################
55+
# Module, library and executable definition
56+
####################################
57+
58+
add_library(ALF OBJECT
59+
src/AlfServer.cxx
60+
src/DimServices/DimServices.cxx
61+
src/DimServices/ServiceNames.cxx
62+
src/Sca/Sca.cxx
63+
src/Swt/Swt.cxx
64+
src/Swt/SwtWord.cxx
65+
)
66+
67+
target_include_directories(ALF
68+
PUBLIC
69+
${Common_INCLUDE_DIRS}
70+
${InfoLogger_INCLUDE_DIRS}
71+
${ReadoutCard_INCLUDE_DIRS}
72+
PRIVATE
73+
${CMAKE_CURRENT_SOURCE_DIR}/src
74+
)
75+
76+
# Link targets
77+
target_link_libraries(ALF
78+
PUBLIC
79+
AliceO2::Common
80+
AliceO2::InfoLogger
81+
AliceO2::ReadoutCard
82+
dim::dim
83+
)
84+
85+
# Use C++17
86+
target_compile_features(ALF PUBLIC cxx_std_17)
87+
88+
89+
####################################
90+
# Executables
91+
####################################
92+
93+
set(EXE_SRCS
94+
ProgramAlf.cxx
95+
ProgramAlfClient.cxx
96+
)
97+
98+
set(EXE_NAMES
99+
o2-alf
100+
o2-alf-client
101+
)
102+
103+
list(LENGTH EXE_SRCS count)
104+
math(EXPR count "${count}-1")
105+
foreach(i RANGE ${count})
106+
list(GET EXE_SRCS ${i} src)
107+
list(GET EXE_NAMES ${i} name)
108+
add_executable(${name} apps/${src})
109+
target_include_directories(${name}
110+
PRIVATE
111+
${CMAKE_CURRENT_SOURCE_DIR}/src
112+
)
113+
target_link_libraries(${name}
114+
PRIVATE
115+
ALF
116+
)
117+
endforeach()
118+
119+
120+
####################################
121+
# Install
122+
####################################
123+
124+
include(GNUInstallDirs)
125+
126+
# Build targets with install rpath on Mac to dramatically speed up installation
127+
# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
128+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
129+
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
130+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
131+
if("${isSystemDir}" STREQUAL "-1")
132+
set(CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
133+
endif()
134+
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
135+
endif()
136+
unset(isSystemDir)
137+
138+
# Install library and executables
139+
install(TARGETS ALF ${EXE_NAMES}
140+
EXPORT ALFTargets
141+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
142+
)
143+
144+
# Create version file
145+
include(CMakePackageConfigHelpers)
146+
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/cmake/ALFConfigVersion.cmake"
147+
VERSION ${PACKAGE_VERSION}
148+
COMPATIBILITY AnyNewerVersion
149+
)
150+
151+
# Install headers # NO PUBLIC HEADERS
152+
# install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ALF DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
153+
154+
# Export targets
155+
install(EXPORT ALFTargets
156+
FILE
157+
ALFTargets.cmake
158+
NAMESPACE
159+
AliceO2::
160+
DESTINATION
161+
${CMAKE_INSTALL_LIBDIR}/cmake/ALF
162+
)
163+
164+
# Configure and install Config files
165+
configure_package_config_file(
166+
cmake/ALFConfig.cmake.in cmake/ALFConfig.cmake
167+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ALF"
168+
PATH_VARS CMAKE_INSTALL_PREFIX
169+
)
170+
171+
install(
172+
FILES
173+
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ALFConfig.cmake"
174+
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ALFConfigVersion.cmake"
175+
DESTINATION
176+
${CMAKE_INSTALL_LIBDIR}/cmake/ALF
177+
)

0 commit comments

Comments
 (0)