Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
zinccyy committed Dec 14, 2022
2 parents 8c384f9 + 247b4a9 commit 08a6c62
Show file tree
Hide file tree
Showing 190 changed files with 14,827 additions and 7,674 deletions.
181 changes: 165 additions & 16 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,17 +1,166 @@
Language : Cpp
BasedOnStyle: LLVM
BreakBeforeBraces : Linux
IndentWidth: 4
TabWidth : 4
UseTab : Always
ColumnLimit : 0
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: WebKit
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
StatementAttributeLikeMacros:
- Q_EMIT
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

SortIncludes: false
AllowShortIfStatementsOnASingleLine : false
AllowShortFunctionsOnASingleLine : Empty
AlwaysBreakAfterReturnType : None
AlignAfterOpenBracket : Align
AlignOperands : true
AlignTrailingComments : true
IndentCaseLabels : true
SpaceAfterCStyleCast : true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ build/
.vscode/
.clangd/
.test/
.cache/
compile_commands.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deps/uthash"]
path = deps/uthash
url = https://github.com/troydhanson/uthash
35 changes: 14 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0)
project(sysrepo-interfaces-plugins C)

include(CompileOptions.cmake)
Expand All @@ -8,42 +8,35 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

include_directories(
${CMAKE_SOURCE_DIR}/src/
${CMAKE_SOURCE_DIR}/deps/uthash/include/
)

# get sysrepo version
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} "--modversion" "sysrepo" OUTPUT_VARIABLE SYSREPO_VERSION)
if(SYSREPO_VERSION)
# strip new line from string
string(STRIP ${SYSREPO_VERSION} SYSREPO_VERSION)
if(${SYSREPO_VERSION} VERSION_LESS "1.0.0")
message(FATAL_ERROR "${PROJECT_NAME} requires at least libsysrepo verision 1.0.0")
endif()
endif()
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules")
find_package(SYSREPO REQUIRED)
find_package(LIBYANG REQUIRED)
find_package(SRPC REQUIRED)
find_package(NL REQUIRED)

include_directories(
${SYSREPO_INCLUDE_DIRS}
${LIBYANG_INCLUDE_DIRS}
${SRPC_INCLUDE_DIRS}
${NL_INCLUDE_DIRS}
)

option(INTERFACES_PLUGIN "Enable interfaces plugin" ON)
option(ROUTING_PLUGIN "Enable interfaces plugin" ON)
option(INTERFACES_PLUGIN "Enable interfaces plugin" OFF)
option(ROUTING_PLUGIN "Enable interfaces plugin" OFF)

if(INTERFACES_PLUGIN)
add_subdirectory(src/interfaces)
add_subdirectory(src/interfaces)
endif()

if(ROUTING_PLUGIN)
add_subdirectory(src/routing)
add_subdirectory(src/routing)
endif()

if(ENABLE_BUILD_TESTS)
find_package(CMOCKA REQUIRED)
include (CTest)
find_package(CMOCKA REQUIRED)
include(CTest)
include(tests/Tests.cmake)
endif()
32 changes: 32 additions & 0 deletions CMakeModules/FindAUGYANG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
if (AUGYANG_LIBRARIES)
# in cache already
set(AUGYANG_FOUND TRUE)
else(AUGYANG_LIBRARIES)
find_library(
AUGYANG_LIBRARY
NAMES
srds_augeas.so
PATHS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/local/lib
/sw/lib
${CMAKE_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}/lib

# srds_augeas.so
${CMAKE_INSTALL_PREFIX}/lib/sysrepo/plugins
)

if (AUGYANG_LIBRARY)
set(AUGYANG_FOUND TRUE)
else (AUGYANG_LIBRARY)
set(AUGYANG_FOUND FALSE)
endif (AUGYANG_LIBRARY)

set(AUGYANG_LIBRARIES ${AUGYANG_LIBRARY})

mark_as_advanced(AUGYANG_LIBRARIES)
endif(AUGYANG_LIBRARIES)
24 changes: 24 additions & 0 deletions CMakeModules/FindLIBSYSTEMD.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# - Try to find SYSTEMD
# Once done, this will define
#
# SYSTEMD_FOUND - system has SYSTEMD
# SYSTEMD_INCLUDE_DIRS - the SYSTEMD include directories
# SYSTEMD_LIBRARIES - the SYSTEMD library
find_package(PkgConfig)

pkg_check_modules(SYSTEMD_PKGCONF libsystemd)

find_path(SYSTEMD_INCLUDE_DIRS
NAMES systemd/sd-bus.h
PATHS ${SYSTEMD_PKGCONF_INCLUDE_DIRS}
)

find_library(SYSTEMD_LIBRARIES
NAMES systemd
PATHS ${SYSTEMD_PKGCONF_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Systemd DEFAULT_MSG SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES)

mark_as_advanced(SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES)
File renamed without changes.
47 changes: 47 additions & 0 deletions CMakeModules/FindNL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# modified version of https://github.com/nasa/channel-emulator/blob/master/cmake/Modules/FindLibNL.cmake

find_path(NL_INCLUDE_DIRS netlink/netlink.h
/usr/include
/usr/include/libnl3
/usr/local/include
/usr/local/include/libnl3
${CMAKE_INCLUDE_PATH}
${CMAKE_PREFIX_PATH}/include/libnl3
)

find_library(
NL_LIBRARY
NAMES nl nl-3
PATHS /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 /opt/local/lib /sw/lib ${CMAKE_LIBRARY_PATH} ${CMAKE_INSTALL_PREFIX}/lib
)
find_library(
NL_ROUTE_LIBRARY
NAMES nl-route nl-route-3
PATHS /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 /opt/local/lib /sw/lib ${CMAKE_LIBRARY_PATH} ${CMAKE_INSTALL_PREFIX}/lib
)
find_library(
NL_NETFILTER_LIBRARY
NAMES nl-nf nl-nf-3
PATHS /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 /opt/local/lib /sw/lib ${CMAKE_LIBRARY_PATH} ${CMAKE_INSTALL_PREFIX}/lib
)
find_library(
NL_GENL_LIBRARY
NAMES nl-genl nl-genl-3
PATHS /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 /opt/local/lib /sw/lib ${CMAKE_LIBRARY_PATH} ${CMAKE_INSTALL_PREFIX}/lib
)

if (NL_INCLUDE_DIRS AND NL_LIBRARY)
set(NL_FOUND TRUE)
endif (NL_INCLUDE_DIRS AND NL_LIBRARY)

if (NL_FOUND)
if (NOT NL_FIND_QUIETLY)
set(NL_LIBRARIES ${NL_LIBRARY} ${NL_ROUTE_LIBRARY} ${NL_NETFILTER_LIBRARY} ${NL_GENL_LIBRARY})
message("Found netlink libraries: ${NL_LIBRARIES}")
message("Found netlink includes: ${NL_INCLUDE_DIRS}")
endif (NOT NL_FIND_QUIETLY)
ELSE (NL_FOUND)
if (NL_FIND_REQUIRED)
message(FATAL_ERROR "Could not find netlink library.")
endif (NL_FIND_REQUIRED)
endif (NL_FOUND)
24 changes: 24 additions & 0 deletions CMakeModules/FindPTHREAD.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
if(PTHREAD_LIBRARIES AND PTHREAD_INCLUDE_DIRS)
set(PTHREAD_FOUND TRUE)
else()
find_path(
PTHREAD_INCLUDE_DIR
NAMES pthread.h
PATHS /usr/include /usr/local/include /opt/local/include /sw/include ${CMAKE_INCLUDE_PATH} ${CMAKE_INSTALL_PREFIX}/include
)

find_library(
PTHREAD_LIBRARY
NAMES pthread
PATHS /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 /opt/local/lib /sw/lib ${CMAKE_LIBRARY_PATH} ${CMAKE_INSTALL_PREFIX}/lib
)

if(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
set(PTHREAD_FOUND TRUE)
else(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
set(PTHREAD_FOUND FALSE)
endif(PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)

set(PTHREAD_INCLUDE_DIRS ${PTHREAD_INCLUDE_DIR})
set(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
endif()
Loading

0 comments on commit 08a6c62

Please sign in to comment.