mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-21 20:11:17 +01:00
Compare commits
2 Commits
rosenblatt
...
dev/genera
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62488a8ce6 | ||
|
|
d3dc92b18b |
@@ -21,9 +21,9 @@ jobs:
|
||||
- name: Build library
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_TESTS=ON
|
||||
cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_TESTS=ON -DSLS_USE_SIMULATOR=ON
|
||||
make -j 2
|
||||
|
||||
- name: C++ unit tests
|
||||
working-directory: ${{gitea.workspace}}/build
|
||||
run: ctest
|
||||
run: ctest -j1 --rerun-failed --output-on-failure
|
||||
@@ -19,9 +19,9 @@ jobs:
|
||||
- name: Build library
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_TESTS=ON
|
||||
cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_TESTS=ON -DSLS_USE_SIMULATOR=ON
|
||||
make -j 2
|
||||
|
||||
- name: C++ unit tests
|
||||
working-directory: ${{gitea.workspace}}/build
|
||||
run: ctest
|
||||
run: ctest -j1 --rerun-failed --output-on-failure
|
||||
2
.github/workflows/cmake.yaml
vendored
2
.github/workflows/cmake.yaml
vendored
@@ -37,7 +37,7 @@ jobs:
|
||||
|
||||
- name: C++ unit tests
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: ctest -C ${{env.BUILD_TYPE}} -j1
|
||||
run: ctest -C ${{env.BUILD_TYPE}} -j1 --rerun-failed --output-on-failure
|
||||
|
||||
- name: Python unit tests
|
||||
working-directory: ${{github.workspace}}/build/bin
|
||||
|
||||
@@ -24,6 +24,15 @@ include(cmake/SlsAddFlag.cmake)
|
||||
include(cmake/helpers.cmake)
|
||||
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
# POSIX threads are required for the moment but we use CMake to find them
|
||||
# Once migrated to std::thread this can be removed
|
||||
if(NOT CMAKE_USE_PTHREADS_INIT)
|
||||
message(FATAL_ERROR "A POSIX threads (pthread) implementation is required, but was not found.")
|
||||
endif()
|
||||
|
||||
|
||||
option(SLS_USE_SYSTEM_ZMQ "Use system installed libzmq" OFF)
|
||||
|
||||
# Using FetchContent to get libzmq
|
||||
@@ -332,6 +341,9 @@ if (NOT TARGET slsProjectCSettings)
|
||||
-Wno-format-truncation
|
||||
)
|
||||
sls_disable_c_warning("-Wstringop-truncation")
|
||||
target_link_libraries(slsProjectCSettings INTERFACE
|
||||
Threads::Threads
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ cmake .. -G Ninja \
|
||||
-DSLS_USE_PYTHON=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DSLS_USE_HDF5=OFF \
|
||||
-DSLS_USE_SYSTEM_ZMQ=ON \
|
||||
|
||||
NCORES=$(getconf _NPROCESSORS_ONLN)
|
||||
echo "Building using: ${NCORES} cores"
|
||||
|
||||
@@ -29,6 +29,7 @@ requirements:
|
||||
- libtiff
|
||||
- zlib
|
||||
- expat
|
||||
- zeromq
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
|
||||
@@ -33,6 +33,31 @@ def green(msg):
|
||||
return f"{GREENC}{msg}{ENDC}"
|
||||
|
||||
|
||||
QUALIFY_KINDS = {
|
||||
cindex.CursorKind.NAMESPACE,
|
||||
cindex.CursorKind.CLASS_DECL,
|
||||
cindex.CursorKind.STRUCT_DECL,
|
||||
cindex.CursorKind.CLASS_TEMPLATE,
|
||||
cindex.CursorKind.ENUM_DECL,
|
||||
cindex.CursorKind.UNION_DECL,
|
||||
cindex.CursorKind.TYPE_ALIAS_DECL,
|
||||
}
|
||||
|
||||
def qualified_name(cur: cindex.Cursor, include_leaf: bool = True) -> str:
|
||||
"""
|
||||
Build a fully-qualified name by following semantic_parent up to the TU.
|
||||
If include_leaf is False, returns just the enclosing scope (namespaces, classes).
|
||||
"""
|
||||
parts = []
|
||||
c = cur if include_leaf else cur.semantic_parent
|
||||
while c and c.kind != cindex.CursorKind.TRANSLATION_UNIT:
|
||||
name = c.spelling or c.displayname # displayname helps for anonymous namespaces
|
||||
if name and (c.kind in QUALIFY_KINDS or c is cur):
|
||||
parts.append(name)
|
||||
c = c.semantic_parent
|
||||
return "::".join(reversed(parts))
|
||||
|
||||
|
||||
def check_libclang_version(required="12"):
|
||||
# Use already-loaded libclang, or let cindex resolve it
|
||||
lib = ctypes.CDLL(cindex.Config.library_file or ctypes.util.find_library("clang"))
|
||||
@@ -76,8 +101,8 @@ def check_for_compile_commands_json(path):
|
||||
print(msg)
|
||||
|
||||
|
||||
default_build_path = "/home/l_frojdh/sls/build/"
|
||||
fpath = "../../slsDetectorSoftware/src/Detector.cpp"
|
||||
default_build_path = Path("../../build/")
|
||||
fpath = Path("../../slsDetectorSoftware/src/Detector.cpp")
|
||||
|
||||
|
||||
m = []
|
||||
@@ -87,25 +112,14 @@ ag2 = []
|
||||
cn = []
|
||||
|
||||
|
||||
def get_arguments(node):
|
||||
args = [a.type.spelling for a in node.get_arguments()]
|
||||
args = [
|
||||
"py::arg() = Positions{}" if item == "sls::Positions" else "py::arg()"
|
||||
for item in args
|
||||
]
|
||||
args = ", ".join(args)
|
||||
if args:
|
||||
args = f", {args}"
|
||||
return args
|
||||
|
||||
|
||||
def get_arguments_with_default(node):
|
||||
args = []
|
||||
for arg in node.get_arguments():
|
||||
tokens = [t.spelling for t in arg.get_tokens()]
|
||||
# print(tokens)
|
||||
if "=" in tokens:
|
||||
if arg.type.spelling == "sls::Positions": # TODO! automate
|
||||
# if arg.type.spelling == "sls::Positions": # TODO! automate+
|
||||
if arg.type.spelling == "Positions": # TODO! automate
|
||||
args.append("py::arg() = Positions{}")
|
||||
else:
|
||||
args.append("py::arg()" + "".join(tokens[tokens.index("=") :]))
|
||||
@@ -174,6 +188,10 @@ def visit(node):
|
||||
m.append(child)
|
||||
args = get_arguments_with_default(child)
|
||||
fs = get_fdec(child)
|
||||
qualified_class = qualified_name(child.semantic_parent) # "ns1::ns2::Detector"
|
||||
# lines.append(
|
||||
# f'CppDetectorApi.def("{child.spelling}", {fs} &{qualified_class}::{child.spelling}{args});'
|
||||
# )
|
||||
lines.append(
|
||||
f'CppDetectorApi.def("{child.spelling}",{fs} &Detector::{child.spelling}{args});'
|
||||
)
|
||||
@@ -202,8 +220,11 @@ if __name__ == "__main__":
|
||||
)
|
||||
cargs = parser.parse_args()
|
||||
|
||||
check_libclang_version("12")
|
||||
check_clang_format_version(12)
|
||||
# check_libclang_version("12")
|
||||
# check_clang_format_version(12)
|
||||
cargs.build_path = cargs.build_path.resolve()
|
||||
print(f'Using build path: {cargs.build_path}')
|
||||
|
||||
check_for_compile_commands_json(cargs.build_path)
|
||||
|
||||
print("Parsing functions in Detector.h - ", end="", flush=True)
|
||||
@@ -212,11 +233,17 @@ if __name__ == "__main__":
|
||||
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
|
||||
index = cindex.Index.create()
|
||||
args = db.getCompileCommands(fpath)
|
||||
|
||||
|
||||
args = list(iter(args).__next__().arguments)[0:-1]
|
||||
args = args + "-x c++ --std=c++11".split()
|
||||
# print('\n\nUsing compile commands:', args)
|
||||
# args = args + "-x c++ --std=c++17".split()
|
||||
syspath = system_include_paths("clang++")
|
||||
incargs = ["-I" + inc for inc in syspath]
|
||||
args = args + incargs
|
||||
args = [arg for arg in args if arg.startswith("-I") or arg.startswith("-D")]
|
||||
# args = incargs
|
||||
# print(f"\n\nUsing compile args: {' '.join(args)}")
|
||||
tu = index.parse(fpath, args=args)
|
||||
visit(tu.cursor)
|
||||
print(green("OK"))
|
||||
@@ -241,5 +268,5 @@ if __name__ == "__main__":
|
||||
subprocess.run(["clang-format", "../src/detector.cpp", "-i"])
|
||||
print(green(" OK"))
|
||||
|
||||
print("Changes since last commit:")
|
||||
subprocess.run(["git", "diff", "../src/detector.cpp"])
|
||||
# print("Changes since last commit:")
|
||||
# subprocess.run(["git", "diff", "../src/detector.cpp"])
|
||||
|
||||
@@ -79,4 +79,10 @@ def system_include_paths(compiler, cpp=True):
|
||||
line = line.strip()
|
||||
paths.append(line)
|
||||
paths = [p.decode('utf-8') for p in paths]
|
||||
|
||||
# Only keep include paths from the conda prefix
|
||||
# remove anything pointing to gcc
|
||||
prefix = os.environ['CONDA_PREFIX']
|
||||
paths = [p for p in paths if prefix in p]
|
||||
paths = [p for p in paths if 'gcc' not in p]
|
||||
return paths
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,11 +12,7 @@
|
||||
#include <chrono>
|
||||
namespace py = pybind11;
|
||||
void init_det(py::module &m) {
|
||||
using sls::defs;
|
||||
using sls::Detector;
|
||||
using sls::ns;
|
||||
using sls::Positions;
|
||||
using sls::Result;
|
||||
using namespace sls; //TODO! qualify arguments and return types to avoid this
|
||||
|
||||
m.def("freeSharedMemory", (void (*)(const int, const int)) &sls::freeSharedMemory, py::arg() = 0, py::arg() = -1);
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
add_executable(using_logger using_logger.cpp)
|
||||
target_link_libraries(using_logger
|
||||
slsSupportShared
|
||||
pthread
|
||||
rt
|
||||
)
|
||||
|
||||
set_target_properties(using_logger PROPERTIES
|
||||
|
||||
@@ -76,11 +76,8 @@ foreach(exe ${JUNGFRAU_EXECUTABLES})
|
||||
target_link_libraries(${exe}
|
||||
PUBLIC
|
||||
slsSupportStatic
|
||||
pthread
|
||||
tiffio
|
||||
fmt::fmt
|
||||
#-L/usr/lib64/
|
||||
#-lm -lstdc++ -lrt
|
||||
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
|
||||
@@ -69,7 +69,6 @@ foreach(exe ${MOENCH_EXECUTABLES})
|
||||
PUBLIC
|
||||
slsSupportStatic
|
||||
${ZeroMQ_LIBRARIES}
|
||||
pthread
|
||||
tiffio
|
||||
|
||||
PRIVATE
|
||||
|
||||
@@ -37,7 +37,9 @@ target_compile_definitions(ctbDetectorServer_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(ctbDetectorServer_virtual
|
||||
PUBLIC pthread rt m slsProjectCSettings
|
||||
PUBLIC
|
||||
m
|
||||
slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(ctbDetectorServer_virtual PROPERTIES
|
||||
|
||||
@@ -30,7 +30,8 @@ target_compile_definitions(eigerDetectorServer_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
PUBLIC
|
||||
slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServer_virtual PROPERTIES
|
||||
|
||||
@@ -31,7 +31,8 @@ target_compile_definitions(gotthard2DetectorServer_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(gotthard2DetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
PUBLIC
|
||||
slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(gotthard2DetectorServer_virtual PROPERTIES
|
||||
|
||||
@@ -29,7 +29,8 @@ target_compile_definitions(jungfrauDetectorServer_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(jungfrauDetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
PUBLIC
|
||||
slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(jungfrauDetectorServer_virtual PROPERTIES
|
||||
|
||||
@@ -29,7 +29,8 @@ target_compile_definitions(moenchDetectorServer_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(moenchDetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
PUBLIC
|
||||
slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(moenchDetectorServer_virtual PROPERTIES
|
||||
|
||||
@@ -33,7 +33,8 @@ target_compile_definitions(mythen3DetectorServer_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(mythen3DetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
PUBLIC
|
||||
slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(mythen3DetectorServer_virtual PROPERTIES
|
||||
|
||||
@@ -31,7 +31,9 @@ target_compile_definitions(xilinx_ctbDetectorServer_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(xilinx_ctbDetectorServer_virtual
|
||||
PUBLIC pthread rt m slsProjectCSettings
|
||||
PUBLIC
|
||||
m
|
||||
slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(xilinx_ctbDetectorServer_virtual PROPERTIES
|
||||
|
||||
@@ -28,11 +28,11 @@ target_link_libraries(slsDetectorObject
|
||||
PUBLIC
|
||||
slsProjectOptions
|
||||
slsSupportStatic
|
||||
pthread
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
)
|
||||
|
||||
|
||||
set(DETECTOR_LIBRARY_TARGETS slsDetectorObject)
|
||||
|
||||
|
||||
@@ -97,8 +97,7 @@ if(SLS_USE_TEXTCLIENT)
|
||||
add_executable(${val1} src/CmdApp.cpp)
|
||||
|
||||
target_link_libraries(${val1}
|
||||
slsDetectorStatic
|
||||
pthread
|
||||
slsDetectorStatic
|
||||
)
|
||||
SET_SOURCE_FILES_PROPERTIES( src/Caller.cpp PROPERTIES COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-but-set-variable")
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ target_link_libraries(slsReceiverObject
|
||||
slsProjectOptions
|
||||
slsSupportStatic
|
||||
PRIVATE
|
||||
slsProjectWarnings #don't propagate warnigns
|
||||
slsProjectWarnings #don't propagate warnings
|
||||
)
|
||||
|
||||
target_compile_definitions(slsReceiverObject
|
||||
@@ -118,8 +118,6 @@ if (SLS_USE_RECEIVER_BINARIES)
|
||||
target_link_libraries(slsReceiver PUBLIC
|
||||
PUBLIC
|
||||
slsReceiverStatic
|
||||
pthread
|
||||
rt
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
)
|
||||
@@ -138,8 +136,6 @@ if (SLS_USE_RECEIVER_BINARIES)
|
||||
target_link_libraries(slsMultiReceiver
|
||||
PUBLIC
|
||||
slsReceiverStatic
|
||||
pthread
|
||||
rt
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
)
|
||||
@@ -158,8 +154,6 @@ if (SLS_USE_RECEIVER_BINARIES)
|
||||
target_link_libraries(slsFrameSynchronizer
|
||||
PUBLIC
|
||||
slsReceiverStatic
|
||||
pthread
|
||||
rt
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
|
||||
|
||||
@@ -147,8 +147,12 @@ TEST_CASE("Parse port and uid", "[detector]") {
|
||||
for (auto app : {AppType::SingleReceiver, AppType::MultiReceiver,
|
||||
AppType::FrameSynchronizer}) {
|
||||
CommandLineOptions s(app);
|
||||
REQUIRE_THROWS(
|
||||
s.parse({"", "-p", "1234", "-u", invalidUidStr})); // invalid uid
|
||||
|
||||
// TODO! This test fails on gitea CI probably because the user can set the uid
|
||||
// commenting it out for now. Revisit later.
|
||||
// REQUIRE_THROWS(
|
||||
// s.parse({"", "-p", "1234", "-u", invalidUidStr})); // invalid uid
|
||||
|
||||
REQUIRE_THROWS(s.parse({"", "-p", "500"})); // invalid port
|
||||
|
||||
auto opts = s.parse({"", "-p", "1234", "-u", uidStr});
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
|
||||
|
||||
set(SOURCES
|
||||
src/string_utils.cpp
|
||||
src/file_utils.cpp
|
||||
@@ -89,12 +92,17 @@ target_link_libraries(slsSupportObject
|
||||
PUBLIC
|
||||
slsProjectOptions
|
||||
${STD_FS_LIB} # from helpers.cmake
|
||||
Threads::Threads # slsDetector and Receiver need this
|
||||
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
md5sls
|
||||
)
|
||||
|
||||
#RH8 glibc 2.28, RH9 glibc 2.34 linking rt is only needed with glibc < 2.34
|
||||
#but we do it for all Linux builds to avoid too many conditionals
|
||||
target_link_libraries (slsSupportObject PUBLIC $<$<PLATFORM_ID:Linux>:rt>)
|
||||
|
||||
#Treat both vendored and system zmq as interface for receiver binaries
|
||||
if(SLS_USE_SYSTEM_ZMQ)
|
||||
message(STATUS "slsSupportLib using ZEROMQ_TARGET=${ZEROMQ_TARGET}")
|
||||
|
||||
@@ -24,7 +24,6 @@ target_link_libraries(tests
|
||||
PUBLIC
|
||||
slsProjectOptions
|
||||
slsSupportStatic
|
||||
pthread
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user