From 97d8ff26752d72da5ba4a851d6aded5e80fceb91 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Mon, 1 Jul 2024 15:26:00 +0300 Subject: [PATCH 001/134] [build] Clean up dependencies after codegen removal --- CMakeLists.txt | 3 --- docs/thirdparty.md | 1 - sc-tools/sc-builder/CMakeLists.txt | 1 + 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e9d76828d..4ca0a4f7c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,9 +31,6 @@ code_coverage(SC_COVERAGE "Flag to generate coverage report" OFF "-g -O0 --cover option(SC_CLANG_FORMAT_CODE "Flag to add clangformat and clangformat_check targets" OFF) sanitizer(SC_USE_SANITIZER "Build with specified sanitizer" "none") -set(SC_MEMORY_SRC "${SC_MACHINE_ROOT}/sc-memory") -set(SC_KPM_SRC "${SC_MACHINE_ROOT}/sc-kpm") -set(SC_TOOLS_SRC "${SC_MACHINE_ROOT}/sc-tools") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSC_DEBUG -DSC_PROFILE") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSC_DEBUG -DSC_PROFILE") diff --git a/docs/thirdparty.md b/docs/thirdparty.md index ef1d880c91..b352122f5b 100644 --- a/docs/thirdparty.md +++ b/docs/thirdparty.md @@ -4,5 +4,4 @@ Based on refactored code from: [CPP-Reflection](https://github.com/AustinBrunkho ## Sc-memory * [JSON for Modern C++](https://github.com/nlohmann/json) * [Antlr 4](https://github.com/antlr/antlr4) -* [libclang](https://clang.llvm.org/docs/Tooling.html) * [Websocketcpp](https://docs.websocketpp.org/) diff --git a/sc-tools/sc-builder/CMakeLists.txt b/sc-tools/sc-builder/CMakeLists.txt index 580f9f744c..f9bbebf859 100644 --- a/sc-tools/sc-builder/CMakeLists.txt +++ b/sc-tools/sc-builder/CMakeLists.txt @@ -20,6 +20,7 @@ target_link_libraries(sc-builder-lib LINK_PUBLIC LibXml2::LibXml2 ) target_include_directories(sc-builder-lib + PRIVATE ${GLIB2_INCLUDE_DIRS} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ) From 179572b1906e85b1888db1450d040138d21adcb2 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Sat, 27 Jul 2024 19:29:17 +0300 Subject: [PATCH 002/134] [build] WIP: Conan support --- .gitignore | 1 + CMakeLists.txt | 20 +- cmake/FindGLIB2.cmake | 237 ---------------------- cmake/FindGlib2_module.cmake | 83 -------- cmake/install.cmake | 38 ++++ cmake/sc_machine-config-version.cmake.in | 13 ++ cmake/sc_machine-config.cmake.in | 3 + conanfile.py | 79 ++++++++ sc-kpm/sc-agents-common/CMakeLists.txt | 7 +- sc-kpm/sc-common/CMakeLists.txt | 5 + sc-memory/sc-core/CMakeLists.txt | 7 +- sc-memory/sc-memory/CMakeLists.txt | 3 +- sc-tools/sc-builder/CMakeLists.txt | 7 +- sc-tools/sc-config/CMakeLists.txt | 14 +- sc-tools/sc-machine-runner/CMakeLists.txt | 8 +- sc-tools/sc-server/CMakeLists.txt | 9 +- 16 files changed, 201 insertions(+), 333 deletions(-) delete mode 100644 cmake/FindGLIB2.cmake delete mode 100644 cmake/FindGlib2_module.cmake create mode 100644 cmake/install.cmake create mode 100644 cmake/sc_machine-config-version.cmake.in create mode 100644 cmake/sc_machine-config.cmake.in create mode 100644 conanfile.py diff --git a/.gitignore b/.gitignore index 46c7af3842..c1dc83dffd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ generated cmake-build-debug cmake-build-release cmake-build-debug-coverage +/CMakeUserPresets.json test_defines.hpp *.scdb diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ca0a4f7c6..1b39b0da4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.11) set(CMAKE_CXX_STANDARD 17) -project(sc-machine) +project(sc-machine VERSION "0.9.0") site_name(www.ostis.net) cmake_policy(SET CMP0048 NEW) @@ -94,11 +94,29 @@ endif() include(CTest) +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG) + +include(GNUInstallDirs) + message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") message("Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, path: ${CMAKE_CXX_COMPILER}") +# Set up dynamic linking paths for our own libraries +# For macOS, use @loader_path instead of $ORIGIN +if(APPLE) + set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib") +else() + set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib") +endif() + +# Always use full RPATH +set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + add_subdirectory(${SC_MACHINE_ROOT}/thirdparty) add_subdirectory(${SC_MACHINE_ROOT}/sc-memory) add_subdirectory(${SC_MACHINE_ROOT}/sc-kpm) add_subdirectory(${SC_MACHINE_ROOT}/sc-tools) + +include(${SC_MACHINE_ROOT}/cmake/install.cmake) diff --git a/cmake/FindGLIB2.cmake b/cmake/FindGLIB2.cmake deleted file mode 100644 index f367815330..0000000000 --- a/cmake/FindGLIB2.cmake +++ /dev/null @@ -1,237 +0,0 @@ -# - Try to find GLib2 -# Once done this will define -# -# GLIB2_FOUND - system has GLib2 -# GLIB2_INCLUDE_DIRS - the GLib2 include directory -# GLIB2_LIBRARIES - Link these to use GLib2 -# -# HAVE_GLIB_GREGEX_H glib has gregex.h header and -# supports g_regex_match_simple -# -# Copyright (c) 2006 Andreas Schneider -# Copyright (c) 2006 Philippe Bernery -# Copyright (c) 2007 Daniel Gollub -# Copyright (c) 2007 Alban Browaeys -# Copyright (c) 2008 Michael Bell -# Copyright (c) 2008-2009 Bjoern Ricks -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - - -IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) - # in cache already - SET(GLIB2_FOUND TRUE) - -ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) - - INCLUDE(FindPkgConfig) - - ## Glib - IF ( GLIB2_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "REQUIRED" ) - ELSE ( GLIB2_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "" ) - ENDIF ( GLIB2_FIND_REQUIRED ) - - IF ( GLIB2_MIN_VERSION ) - PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) - ELSE ( GLIB2_MIN_VERSION ) - PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) - ENDIF ( GLIB2_MIN_VERSION ) - IF ( PKG_CONFIG_FOUND ) - IF ( GLIB2_FOUND ) - SET ( GLIB2_CORE_FOUND TRUE ) - ELSE ( GLIB2_FOUND ) - SET ( GLIB2_CORE_FOUND FALSE ) - ENDIF ( GLIB2_FOUND ) - ENDIF ( PKG_CONFIG_FOUND ) - - # Look for glib2 include dir and libraries w/o pkgconfig - IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) - FIND_PATH( - _glibconfig_include_DIR - NAMES - glibconfig.h - PATHS - /opt/gnome/lib64 - /opt/gnome/lib - /opt/lib/ - /opt/local/lib - /sw/lib/ - /usr/lib64 - /usr/lib - /usr/local/include - /usr/local/lib - ${CMAKE_LIBRARY_PATH} - PATH_SUFFIXES - glib-2.0/include - ) - - FIND_PATH( - _glib2_include_DIR - NAMES - glib.h - PATHS - /opt/gnome/include - /opt/local/include - /sw/include - /usr/include - /usr/local/include - PATH_SUFFIXES - glib-2.0 - ) - - #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") - - FIND_LIBRARY( - _glib2_link_DIR - NAMES - glib-2.0 - glib - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/lib - /usr/local/lib - ) - IF ( _glib2_include_DIR AND _glib2_link_DIR ) - SET ( _glib2_FOUND TRUE ) - ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) - - - IF ( _glib2_FOUND ) - SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) - SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) - SET ( GLIB2_CORE_FOUND TRUE ) - ELSE ( _glib2_FOUND ) - SET ( GLIB2_CORE_FOUND FALSE ) - ENDIF ( _glib2_FOUND ) - - # Handle dependencies - # libintl - IF ( NOT LIBINTL_FOUND ) - FIND_PATH(LIBINTL_INCLUDE_DIR - NAMES - libintl.h - PATHS - /opt/gnome/include - /opt/local/include - /sw/include - /usr/include - /usr/local/include - ) - - FIND_LIBRARY(LIBINTL_LIBRARY - NAMES - intl - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/local/lib - /usr/lib - ) - - IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) - SET (LIBINTL_FOUND TRUE) - ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) - ENDIF ( NOT LIBINTL_FOUND ) - - # libiconv - IF ( NOT LIBICONV_FOUND ) - FIND_PATH(LIBICONV_INCLUDE_DIR - NAMES - iconv.h - PATHS - /opt/gnome/include - /opt/local/include - /opt/local/include - /sw/include - /sw/include - /usr/local/include - /usr/include - PATH_SUFFIXES - glib-2.0 - ) - - FIND_LIBRARY(LIBICONV_LIBRARY - NAMES - iconv - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/lib - /usr/local/lib - ) - - IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - SET (LIBICONV_FOUND TRUE) - ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - ENDIF ( NOT LIBICONV_FOUND ) - - IF (LIBINTL_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) - ENDIF (LIBINTL_FOUND) - - IF (LIBICONV_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) - ENDIF (LIBICONV_FOUND) - - ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) - ## - - IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) - SET (GLIB2_FOUND TRUE) - ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) - - IF (GLIB2_FOUND) - IF (NOT GLIB2_FIND_QUIETLY) - MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") - ENDIF (NOT GLIB2_FIND_QUIETLY) - ELSE (GLIB2_FOUND) - IF (GLIB2_FIND_REQUIRED) - MESSAGE (SEND_ERROR "Could not find GLib2") - ENDIF (GLIB2_FIND_REQUIRED) - ENDIF (GLIB2_FOUND) - - # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view - MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) - MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) - MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) - -ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) - -IF ( WIN32 ) - # include libiconv for win32 - IF ( NOT LIBICONV_FOUND ) - FIND_PATH(LIBICONV_INCLUDE_DIR iconv.h PATH_SUFFIXES glib-2.0) - - FIND_LIBRARY(LIBICONV_LIBRARY NAMES iconv) - - IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - SET (LIBICONV_FOUND TRUE) - ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - ENDIF ( NOT LIBICONV_FOUND ) - IF (LIBICONV_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) - ENDIF (LIBICONV_FOUND) -ENDIF ( WIN32 ) - -IF ( GLIB2_FOUND ) - # Check if system has a newer version of glib - # which supports g_regex_match_simple - INCLUDE( CheckIncludeFiles ) - SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) - CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) - CHECK_INCLUDE_FILES ( glib/gchecksum.h HAVE_GLIB_GCHECKSUM_H ) - # Reset CMAKE_REQUIRED_INCLUDES - SET( CMAKE_REQUIRED_INCLUDES "" ) -ENDIF( GLIB2_FOUND ) diff --git a/cmake/FindGlib2_module.cmake b/cmake/FindGlib2_module.cmake deleted file mode 100644 index 806a11634b..0000000000 --- a/cmake/FindGlib2_module.cmake +++ /dev/null @@ -1,83 +0,0 @@ -# - Try to find GLib2Module -# Once done this will define -# -# GLIB2_MODULE_FOUND - system has GLib2 -# GLIB2_MODULE_INCLUDE_DIRS - the GLib2 include directory -# GLIB2_MODULE_LIBRARIES - Link these to use GLib2 -# - -IF (GLIB2_MODULE_LIBRARIES AND GLIB2_MODULE_INCLUDE_DIRS ) - # in cache already - SET(GLIB2_MODULE_FOUND TRUE) - -ELSE (GLIB2_MODULE_LIBRARIES AND GLIB2_MODULE_INCLUDE_DIRS ) - - INCLUDE(FindPkgConfig) - - ## Glib - IF ( GLIB2_MODULE_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "REQUIRED" ) - ELSE ( GLIB2_MODULE_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "" ) - ENDIF ( GLIB2_MODULE_FIND_REQUIRED ) - - # Look for glib2 include dir and libraries w/o pkgconfig - IF ( NOT GLIB2_MODULE_FOUND AND NOT PKG_CONFIG_FOUND ) - FIND_PATH( - _glib2_module_include_DIR - NAMES - gmodule.h - PATHS - /opt/gnome/include - /opt/local/include - /sw/include - /usr/include - /usr/local/include - PATH_SUFFIXES - glib-2.0 - ) - - #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") - - FIND_LIBRARY( - _glib2_module_link_DIR - NAMES - gmodule-2.0 - gmodule - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/lib - /usr/local/lib - ) - IF ( _glib2_module_include_DIR AND _glib2_module_link_DIR ) - SET ( _glib2_module_FOUND TRUE ) - ENDIF ( _glib2_module_include_DIR AND _glib2_module_link_DIR ) - - - IF ( _glib2_module_FOUND ) - SET ( GLIB2_MODULE_INCLUDE_DIRS ${_glib2_module_include_DIR}) - SET ( GLIB2_MODULE_LIBRARIES ${_glib2_module_link_DIR} ) - SET ( GLIB2_MODULE_FOUND TRUE ) - ELSE ( _glib2_module_FOUND ) - SET ( GLIB2_MODULE_FOUND FALSE ) - ENDIF ( _glib2_module_FOUND ) - - ENDIF ( NOT GLIB2_MODULE_FOUND AND NOT PKG_CONFIG_FOUND ) - ## - - IF (GLIB2_MODULE_FOUND) - IF (NOT GLIB2_MODULE_FIND_QUIETLY) - MESSAGE (STATUS "Found GLib2 module: ${GLIB2_MODULE_LIBRARIES} ${GLIB2_MODULE_INCLUDE_DIRS}") - ENDIF (NOT GLIB2_MODULE_FIND_QUIETLY) - ELSE (GLIB2_MODULE_FOUND) - IF (GLIB2_MODEUL_FIND_REQUIRED) - MESSAGE (SEND_ERROR "Could not find GLib2 module") - ENDIF (GLIB2_MODULE_FIND_REQUIRED) - ENDIF (GLIB2_MODULE_FOUND) - - # show the GLIB2_MODULE_INCLUDE_DIRS and GLIB2_MODULE_LIBRARIES variables only in the advanced view - MARK_AS_ADVANCED(GLIB2_MODULE_INCLUDE_DIRS GLIB2_MODULE_LIBRARIES) - -ENDIF (GLIB2_MODULE_LIBRARIES AND GLIB2_MODULE_INCLUDE_DIRS) diff --git a/cmake/install.cmake b/cmake/install.cmake new file mode 100644 index 0000000000..683002d642 --- /dev/null +++ b/cmake/install.cmake @@ -0,0 +1,38 @@ +install(TARGETS + sc-machine sc-builder sc-machine-runner sc-server sc-server-lib + sc-kpm-common + sc-core sc-memory sc-agents-common sc-builder-lib sc-config + EXPORT sc-machineExport + LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +install(EXPORT sc-machineExport + FILE sc_machineTargets.cmake + NAMESPACE sc_machine:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc_machine +) + +include(CMakePackageConfigHelpers) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/sc_machine-config-version.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion +) + +configure_package_config_file( + ${SC_MACHINE_ROOT}/cmake/sc_machine-config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/sc_machine-config.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc_machine +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/sc_machine-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/sc_machine-config-version.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc_machine) + +include(CPack) diff --git a/cmake/sc_machine-config-version.cmake.in b/cmake/sc_machine-config-version.cmake.in new file mode 100644 index 0000000000..61c5fa0850 --- /dev/null +++ b/cmake/sc_machine-config-version.cmake.in @@ -0,0 +1,13 @@ +set(PACKAGE_VERSION "@PROJECT_VERSION@") + +if(PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE TRUE) +else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) +endif() + +if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) +else() + set(PACKAGE_VERSION_EXACT FALSE) +endif() diff --git a/cmake/sc_machine-config.cmake.in b/cmake/sc_machine-config.cmake.in new file mode 100644 index 0000000000..557ea54330 --- /dev/null +++ b/cmake/sc_machine-config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/sc_machineTargets.cmake") diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000000..ab03feb7e3 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,79 @@ +from conan import ConanFile, tools +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +import re + + +def get_version(): + try: + content = tools.load("CMakeLists.txt") + version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1) + return version.strip() + except Exception: + return None + + +class sc_machineRecipe(ConanFile): + name = "sc-machine" + package_type = "library" + version = get_version() + author = "OSTIS AI" + license = "https://github.com/ostis-ai/sc-machine/blob/master/LICENSE" + url = "https://github.com/ostis-ai/sc-machine" + description = "Software implementation of semantic network storage" + exports = ["LICENSE.md"] + settings = "os", "compiler", "build_type", "arch" + requires = () + options = { # remove for a header-only library + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + } + scm = { + "type": "git", + "url": "auto", + "revision": "auto", + "submodule": "recursive" + } + + @property + def _run_tests(self): + return tools.get_env("CONAN_RUN_TESTS", False) + + def build_requirements(self): + self.build_requires("websocketpp/0.8.2") + self.build_requires("nlohmann_json/3.11.3") + self.build_requires("glib/2.78.3") + self.build_requires("antlr4-cppruntime/4.9.3") + + def layout(self): + cmake_layout(self, build_folder="build") + + def test_requirements(self): + if self._run_tests: + self.build_requires("gtest/1.14.0") + + def generate(self): + deps = CMakeDeps(self) + # deps.build_context_activated = ["my_tool"] + deps.generate() + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ['new-project'] + + # uncomment for a header-only library + # def package_id(self): + # self.info.header_only() diff --git a/sc-kpm/sc-agents-common/CMakeLists.txt b/sc-kpm/sc-agents-common/CMakeLists.txt index 18b7b27f08..46485b2fe8 100644 --- a/sc-kpm/sc-agents-common/CMakeLists.txt +++ b/sc-kpm/sc-agents-common/CMakeLists.txt @@ -13,7 +13,12 @@ target_link_libraries(sc-agents-common ) target_include_directories(sc-agents-common PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include + PUBLIC $ + PUBLIC $ +) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-kpm/sc-common/CMakeLists.txt b/sc-kpm/sc-common/CMakeLists.txt index 4beb5fc906..8240156580 100644 --- a/sc-kpm/sc-common/CMakeLists.txt +++ b/sc-kpm/sc-common/CMakeLists.txt @@ -11,6 +11,11 @@ target_include_directories(sc-kpm-common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.h" +) + if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-kpm-common) endif() diff --git a/sc-memory/sc-core/CMakeLists.txt b/sc-memory/sc-core/CMakeLists.txt index acac446e3b..de65daa25c 100644 --- a/sc-memory/sc-core/CMakeLists.txt +++ b/sc-memory/sc-core/CMakeLists.txt @@ -16,7 +16,12 @@ target_link_libraries(sc-core LINK_PRIVATE ${GLIB2_LIBRARIES}) target_include_directories(sc-core PRIVATE ${GLIB2_INCLUDE_DIRS} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include + PUBLIC $ + PUBLIC $ +) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-memory/sc-memory/CMakeLists.txt b/sc-memory/sc-memory/CMakeLists.txt index 054b42fb9b..dd63200c03 100644 --- a/sc-memory/sc-memory/CMakeLists.txt +++ b/sc-memory/sc-memory/CMakeLists.txt @@ -47,7 +47,8 @@ target_include_directories(sc-memory PRIVATE ${GLIB2_INCLUDE_DIRS} PRIVATE ${SC_MACHINE_ANTRL_DIR}/runtime/src PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include + PUBLIC $ + PUBLIC $ ) add_dependencies(sc-memory diff --git a/sc-tools/sc-builder/CMakeLists.txt b/sc-tools/sc-builder/CMakeLists.txt index f9bbebf859..7132058327 100644 --- a/sc-tools/sc-builder/CMakeLists.txt +++ b/sc-tools/sc-builder/CMakeLists.txt @@ -22,7 +22,12 @@ target_link_libraries(sc-builder-lib target_include_directories(sc-builder-lib PRIVATE ${GLIB2_INCLUDE_DIRS} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include + PUBLIC $ + PUBLIC $ +) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) add_executable(sc-builder "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp") diff --git a/sc-tools/sc-config/CMakeLists.txt b/sc-tools/sc-config/CMakeLists.txt index 72180db8c4..778d4eb347 100644 --- a/sc-tools/sc-config/CMakeLists.txt +++ b/sc-tools/sc-config/CMakeLists.txt @@ -1,8 +1,6 @@ file(GLOB SOURCES CONFIGURE_DEPENDS "src/*.cpp" "src/*.c" - "src/*/*.cpp" "src/*/*.c" - "include/sc-config/*.h" "include/sc-config/*.hpp" - "include/sc-config/*/*.h" "include/sc-config/*/*.hpp" "include/sc-config/*/*.tpp" + "include/sc-config/*.h" "include/sc-config/*.hpp" "include/sc-config/*/*.tpp" ) find_package(PkgConfig REQUIRED) @@ -18,8 +16,14 @@ target_link_libraries(sc-config ) target_include_directories(sc-config PRIVATE ${GLIB2_INCLUDE_DIRS} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE $ + PUBLIC $ +) + +# TODO: CMake 3.23+ supports FILE_SET (https://discourse.cmake.org/t/installing-headers-the-modern-way-regurgitated-and-revisited/3238/3) which is a more stable and portable solution. +# For compatibility reasons we're exporting the whole folder, should be replaced in the future (Ubuntu LTS should have cmake 3.23 oob by that time) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-tools/sc-machine-runner/CMakeLists.txt b/sc-tools/sc-machine-runner/CMakeLists.txt index 55bb5f07cc..10805d0ad7 100644 --- a/sc-tools/sc-machine-runner/CMakeLists.txt +++ b/sc-tools/sc-machine-runner/CMakeLists.txt @@ -6,9 +6,15 @@ target_link_libraries(sc-machine-runner LINK_PUBLIC sc-memory LINK_PUBLIC sc-config ) + target_include_directories(sc-machine-runner - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src + PUBLIC $ + PUBLIC $ +) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) add_executable(sc-machine "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp") diff --git a/sc-tools/sc-server/CMakeLists.txt b/sc-tools/sc-server/CMakeLists.txt index 2dd97a3267..f1bd01e5c9 100644 --- a/sc-tools/sc-server/CMakeLists.txt +++ b/sc-tools/sc-server/CMakeLists.txt @@ -19,8 +19,13 @@ target_compile_definitions(sc-server-lib PUBLIC ASIO_STANDALONE ) target_include_directories(sc-server-lib - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src - PRIVATE ${SC_MEMORY_SRC}/sc-core/src + PRIVATE $ + PRIVATE $ + PUBLIC $ +) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) if(${SC_CLANG_FORMAT_CODE}) From 5d69293dcea31e580f692391cbf8205e089be5ac Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Thu, 8 Aug 2024 17:03:33 +0300 Subject: [PATCH 003/134] [build] Use system-wide gtest and benchmark libs --- .gitmodules | 8 -------- CMakeLists.txt | 6 ++++++ scripts/install_deps_macOS.sh | 2 +- scripts/install_deps_ubuntu.sh | 2 ++ thirdparty/CMakeLists.txt | 8 -------- thirdparty/benchmark | 1 - thirdparty/benchmark.cmake | 6 ------ thirdparty/googletest | 1 - thirdparty/gtest.cmake | 12 ------------ 9 files changed, 9 insertions(+), 37 deletions(-) delete mode 160000 thirdparty/benchmark delete mode 100644 thirdparty/benchmark.cmake delete mode 160000 thirdparty/googletest delete mode 100644 thirdparty/gtest.cmake diff --git a/.gitmodules b/.gitmodules index 7e6a6e067a..08d4cdce62 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,11 +1,3 @@ -[submodule "googletest"] - path = thirdparty/googletest - url = https://github.com/google/googletest.git - -[submodule "benchmark"] - path = thirdparty/benchmark - url = https://github.com/google/benchmark.git - [submodule "docs/scn"] path = docs/scn url = https://github.com/ostis-ai/scn-latex-plugin diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b39b0da4d..c03f434b0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,9 +45,15 @@ if(${SC_AUTO_TEST}) endif() if(${SC_BUILD_TESTS}) + include(GoogleTest) + find_package(GTest REQUIRED) include(${CMAKE_MODULE_PATH}/tests.cmake) endif() +if(${SC_BUILD_BENCH}) + find_package(benchmark REQUIRED) +endif() + if(${SC_CLANG_FORMAT_CODE}) include(${CMAKE_MODULE_PATH}/ClangFormat.cmake) endif() diff --git a/scripts/install_deps_macOS.sh b/scripts/install_deps_macOS.sh index f087e6360c..b330ea6af6 100755 --- a/scripts/install_deps_macOS.sh +++ b/scripts/install_deps_macOS.sh @@ -6,6 +6,6 @@ then source "$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)/set_vars.sh" fi -brew install glib antlr antlr4-cpp-runtime temurin pkgconfig cmake ninja ccache asio websocketpp nlohmann-json libxml2 +brew install glib temurin pkgconfig cmake ninja ccache asio websocketpp nlohmann-json libxml2 googletest google-benchmark "${SC_MACHINE_PATH}/scripts/install_deps_python.sh" diff --git a/scripts/install_deps_ubuntu.sh b/scripts/install_deps_ubuntu.sh index d620caec18..050c1d66bf 100755 --- a/scripts/install_deps_ubuntu.sh +++ b/scripts/install_deps_ubuntu.sh @@ -40,6 +40,8 @@ packagelist_dev=( nlohmann-json3-dev libxml2-dev python3-dev + libgtest-dev + libbenchmark-dev ) packages=() diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 198943a317..a7de087eb5 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,10 +1,2 @@ # build antlr4 runtime add_subdirectory(antlr/runtime) - -if(${SC_BUILD_TESTS}) - include(gtest.cmake) -endif() - -if(${SC_BUILD_BENCH}) - include(benchmark.cmake) -endif() diff --git a/thirdparty/benchmark b/thirdparty/benchmark deleted file mode 160000 index e33986a000..0000000000 --- a/thirdparty/benchmark +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e33986a000987387c92ad29590a88fefe12e746b diff --git a/thirdparty/benchmark.cmake b/thirdparty/benchmark.cmake deleted file mode 100644 index 1633e5ba3b..0000000000 --- a/thirdparty/benchmark.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(GOOGLETEST_PATH ${CMAKE_CURRENT_LIST_DIR}/gtest) - -set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable google tests" FORCE) -set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable google tests" FORCE) - -add_subdirectory(benchmark) diff --git a/thirdparty/googletest b/thirdparty/googletest deleted file mode 160000 index c9461a9b55..0000000000 --- a/thirdparty/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c9461a9b55ba954df0489bab6420eb297bed846b diff --git a/thirdparty/gtest.cmake b/thirdparty/gtest.cmake deleted file mode 100644 index c900c7d3f3..0000000000 --- a/thirdparty/gtest.cmake +++ /dev/null @@ -1,12 +0,0 @@ -add_library(gtest STATIC - "googletest/googletest/src/gtest-all.cc" - "googletest/googlemock/src/gmock-all.cc" - "googletest/googletest/src/gtest_main.cc" -) - -target_include_directories(gtest - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googletest - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googletest/include - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googlemock - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googlemock/include -) From cee1b4e26efd9a8740bfb45cd1fdaf941c15646c Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 30 Aug 2024 16:04:49 +0300 Subject: [PATCH 004/134] [build][cmake] fix glib variables --- CMakeLists.txt | 5 +++- cmake/FindGLIB.cmake | 18 +++++++++++++ sc-kpm/sc-common/CMakeLists.txt | 7 +++--- sc-memory/sc-core/CMakeLists.txt | 12 +++------ .../sc-core/tests/src/sc-core/CMakeLists.txt | 25 +++++++++++++++++++ sc-memory/sc-memory/CMakeLists.txt | 14 +++++------ .../sc-memory/tests/sc-memory/CMakeLists.txt | 4 +-- sc-tools/sc-builder/CMakeLists.txt | 2 +- sc-tools/sc-config/CMakeLists.txt | 13 ++++------ sc-tools/sc-server/CMakeLists.txt | 5 ++-- 10 files changed, 73 insertions(+), 32 deletions(-) create mode 100644 cmake/FindGLIB.cmake create mode 100644 sc-memory/sc-core/tests/src/sc-core/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index c03f434b0e..a7eeca127e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,9 +120,12 @@ endif() set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +include(${CMAKE_MODULE_PATH}/FindGLIB.cmake) + +set(SC_CORE_SRC "${SC_MACHINE_ROOT}/sc-memory/sc-core/src") add_subdirectory(${SC_MACHINE_ROOT}/thirdparty) add_subdirectory(${SC_MACHINE_ROOT}/sc-memory) add_subdirectory(${SC_MACHINE_ROOT}/sc-kpm) add_subdirectory(${SC_MACHINE_ROOT}/sc-tools) -include(${SC_MACHINE_ROOT}/cmake/install.cmake) +include(${CMAKE_MODULE_PATH}/install.cmake) diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake new file mode 100644 index 0000000000..e88ffbb3b3 --- /dev/null +++ b/cmake/FindGLIB.cmake @@ -0,0 +1,18 @@ +macro(FindGLIB) + find_package(glib QUIET) + + if (NOT glib_FOUND) + message("Trying to use system-installed glib") + + find_package(PkgConfig REQUIRED) + pkg_search_module(GLIB2 REQUIRED glib-2.0) + pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) + + if (NOT GLIB2_FOUND OR NOT GLIB2_MODULE_FOUND) + error("glib2 not found!") + endif() + + set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS}) + set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS}) + endif() +endmacro(FindGLIB) diff --git a/sc-kpm/sc-common/CMakeLists.txt b/sc-kpm/sc-common/CMakeLists.txt index 8240156580..8704fe5a0f 100644 --- a/sc-kpm/sc-common/CMakeLists.txt +++ b/sc-kpm/sc-common/CMakeLists.txt @@ -8,12 +8,13 @@ add_library(sc-kpm-common SHARED ${SOURCES}) target_link_libraries(sc-kpm-common LINK_PUBLIC sc-core) target_include_directories(sc-kpm-common PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include + PUBLIC $ + PUBLIC $ ) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING PATTERN "*.h" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.h" ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-memory/sc-core/CMakeLists.txt b/sc-memory/sc-core/CMakeLists.txt index de65daa25c..5b33722bc0 100644 --- a/sc-memory/sc-core/CMakeLists.txt +++ b/sc-memory/sc-core/CMakeLists.txt @@ -5,23 +5,19 @@ file(GLOB SOURCES CONFIGURE_DEPENDS "include/sc-core/*.h" ) -find_package(PkgConfig REQUIRED) -pkg_search_module(GLIB2 REQUIRED glib-2.0) -pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) - -set(GLIB2_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS}) +FindGLIB() add_library(sc-core SHARED ${SOURCES}) -target_link_libraries(sc-core LINK_PRIVATE ${GLIB2_LIBRARIES}) +target_link_libraries(sc-core LINK_PRIVATE ${glib_LIBRARIES}) target_include_directories(sc-core - PRIVATE ${GLIB2_INCLUDE_DIRS} + PRIVATE ${glib_INCLUDE_DIRS} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src PUBLIC $ PUBLIC $ ) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-memory/sc-core/tests/src/sc-core/CMakeLists.txt b/sc-memory/sc-core/tests/src/sc-core/CMakeLists.txt new file mode 100644 index 0000000000..cf888d0847 --- /dev/null +++ b/sc-memory/sc-core/tests/src/sc-core/CMakeLists.txt @@ -0,0 +1,25 @@ +make_tests_from_folder(${CMAKE_CURRENT_LIST_DIR}/units/containers + NAME sc-memory-containers-tests + DEPENDS ${glib_LIBRARIES} sc-memory + INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} +) + +if(${SC_CLANG_FORMAT_CODE}) + target_clangformat_setup(sc-memory-containers-tests) +endif() + +make_tests_from_folder(${CMAKE_CURRENT_LIST_DIR}/units/fs-storage + NAME sc-fs-storage-tests + DEPENDS ${glib_LIBRARIES} sc-memory + INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} +) + +if(${SC_CLANG_FORMAT_CODE}) + target_clangformat_setup(sc-fs-storage-tests) +endif() + +configure_file( + "${CMAKE_CURRENT_LIST_DIR}/units/fs-storage/test_defines.hpp.in" + "${CMAKE_CURRENT_LIST_DIR}/units/fs-storage/test_defines.hpp" +) + diff --git a/sc-memory/sc-memory/CMakeLists.txt b/sc-memory/sc-memory/CMakeLists.txt index dd63200c03..53c783d471 100644 --- a/sc-memory/sc-memory/CMakeLists.txt +++ b/sc-memory/sc-memory/CMakeLists.txt @@ -31,26 +31,26 @@ file(GLOB SOURCES CONFIGURE_DEPENDS "include/sc-memory/*/*.tpp" ) -find_package(PkgConfig REQUIRED) -pkg_search_module(GLIB2 REQUIRED glib-2.0) -pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) - -set(GLIB2_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS}) +FindGLIB() add_library(sc-memory SHARED ${SOURCES} ${SOURCES_PARSER}) target_link_libraries(sc-memory - LINK_PRIVATE ${GLIB2_LIBRARIES} + LINK_PRIVATE ${glib_LIBRARIES} LINK_PUBLIC sc-core LINK_PRIVATE antlr4_static ) target_include_directories(sc-memory - PRIVATE ${GLIB2_INCLUDE_DIRS} + PRIVATE ${glib_INCLUDE_DIRS} PRIVATE ${SC_MACHINE_ANTRL_DIR}/runtime/src PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src PUBLIC $ PUBLIC $ ) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + add_dependencies(sc-memory sc-core antlr4_static diff --git a/sc-memory/sc-memory/tests/sc-memory/CMakeLists.txt b/sc-memory/sc-memory/tests/sc-memory/CMakeLists.txt index 73ce352ea7..3fc7d38b40 100644 --- a/sc-memory/sc-memory/tests/sc-memory/CMakeLists.txt +++ b/sc-memory/sc-memory/tests/sc-memory/CMakeLists.txt @@ -1,7 +1,7 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/common NAME sc-memory-common-tests - DEPENDS ${GLIB2_LIBRARIES} sc-memory - INCLUDES ${GLIB2_INCLUDE_DIRS} ${SC_CORE_SRC} + DEPENDS ${glib_LIBRARIES} sc-memory + INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-tools/sc-builder/CMakeLists.txt b/sc-tools/sc-builder/CMakeLists.txt index 7132058327..19ed55ce65 100644 --- a/sc-tools/sc-builder/CMakeLists.txt +++ b/sc-tools/sc-builder/CMakeLists.txt @@ -20,7 +20,7 @@ target_link_libraries(sc-builder-lib LINK_PUBLIC LibXml2::LibXml2 ) target_include_directories(sc-builder-lib - PRIVATE ${GLIB2_INCLUDE_DIRS} + PRIVATE ${glib_INCLUDE_DIRS} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src PUBLIC $ PUBLIC $ diff --git a/sc-tools/sc-config/CMakeLists.txt b/sc-tools/sc-config/CMakeLists.txt index 778d4eb347..41d4aabaf6 100644 --- a/sc-tools/sc-config/CMakeLists.txt +++ b/sc-tools/sc-config/CMakeLists.txt @@ -3,20 +3,17 @@ file(GLOB SOURCES CONFIGURE_DEPENDS "include/sc-config/*.h" "include/sc-config/*.hpp" "include/sc-config/*/*.tpp" ) -find_package(PkgConfig REQUIRED) -pkg_search_module(GLIB2 REQUIRED glib-2.0) -pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) - -set(GLIB2_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS}) +FindGLIB() add_library(sc-config SHARED ${SOURCES}) target_link_libraries(sc-config - LINK_PRIVATE ${GLIB2_LIBRARIES} + LINK_PRIVATE ${glib_LIBRARIES} LINK_PUBLIC sc-memory ) target_include_directories(sc-config - PRIVATE ${GLIB2_INCLUDE_DIRS} - PRIVATE $ + PRIVATE ${glib_INCLUDE_DIRS} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src + PUBLIC $ PUBLIC $ ) diff --git a/sc-tools/sc-server/CMakeLists.txt b/sc-tools/sc-server/CMakeLists.txt index f1bd01e5c9..360b349245 100644 --- a/sc-tools/sc-server/CMakeLists.txt +++ b/sc-tools/sc-server/CMakeLists.txt @@ -19,8 +19,9 @@ target_compile_definitions(sc-server-lib PUBLIC ASIO_STANDALONE ) target_include_directories(sc-server-lib - PRIVATE $ - PRIVATE $ + PRIVATE ${SC_CORE_SRC} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src + PUBLIC $ PUBLIC $ ) From 20f7fb5c6de0a0ae5100f67ccbcbc15e0e020978 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 30 Aug 2024 16:15:23 +0300 Subject: [PATCH 005/134] [docs][build] Rename exported package, update docs --- cmake/install.cmake | 41 +++-- ....in => sc-machine-config-version.cmake.in} | 0 cmake/sc-machine-config.cmake.in | 3 + cmake/sc_machine-config.cmake.in | 3 - docs/build/build_system.md | 148 ++++++++++++++++++ docs/build/linux_build.md | 28 ---- docs/build/osx_build.md | 28 ---- docs/index.md | 7 +- mkdocs.yml | 3 +- 9 files changed, 184 insertions(+), 77 deletions(-) rename cmake/{sc_machine-config-version.cmake.in => sc-machine-config-version.cmake.in} (100%) create mode 100644 cmake/sc-machine-config.cmake.in delete mode 100644 cmake/sc_machine-config.cmake.in create mode 100644 docs/build/build_system.md delete mode 100644 docs/build/linux_build.md delete mode 100644 docs/build/osx_build.md diff --git a/cmake/install.cmake b/cmake/install.cmake index 683002d642..6da8379a27 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -1,38 +1,55 @@ install(TARGETS - sc-machine sc-builder sc-machine-runner sc-server sc-server-lib + sc-machine sc-builder sc-machine-runner sc-server sc-kpm-common sc-core sc-memory sc-agents-common sc-builder-lib sc-config EXPORT sc-machineExport - LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) +# a target set for things we don't want to export to the consumers +install(TARGETS sc-server-lib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(EXPORT sc-machineExport - FILE sc_machineTargets.cmake - NAMESPACE sc_machine:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc_machine + FILE sc-machineTargets.cmake + NAMESPACE sc-machine:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc-machine ) include(CMakePackageConfigHelpers) write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/sc_machine-config-version.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/sc-machine-config-version.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ) configure_package_config_file( - ${SC_MACHINE_ROOT}/cmake/sc_machine-config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/sc_machine-config.cmake" - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc_machine + ${SC_MACHINE_ROOT}/cmake/sc-machine-config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/sc-machine-config.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc-machine ) install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/sc_machine-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/sc_machine-config-version.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc_machine) + "${CMAKE_CURRENT_BINARY_DIR}/sc-machine-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/sc-machine-config-version.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc-machine) + +set(CPACK_PACKAGE_NAME sc-machine) +set(CPACK_PACKAGE_VENDOR "OSTIS AI") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Software implementation of semantic network storage") +set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set(CPACK_VERBATIM_VARIABLES TRUE) +if (WIN32) + set(CPACK_GENERATOR ZIP) +else() + set(CPACK_GENERATOR TGZ) +endif() include(CPack) diff --git a/cmake/sc_machine-config-version.cmake.in b/cmake/sc-machine-config-version.cmake.in similarity index 100% rename from cmake/sc_machine-config-version.cmake.in rename to cmake/sc-machine-config-version.cmake.in diff --git a/cmake/sc-machine-config.cmake.in b/cmake/sc-machine-config.cmake.in new file mode 100644 index 0000000000..a0b9598ca1 --- /dev/null +++ b/cmake/sc-machine-config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/sc-machineTargets.cmake") diff --git a/cmake/sc_machine-config.cmake.in b/cmake/sc_machine-config.cmake.in deleted file mode 100644 index 557ea54330..0000000000 --- a/cmake/sc_machine-config.cmake.in +++ /dev/null @@ -1,3 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/sc_machineTargets.cmake") diff --git a/docs/build/build_system.md b/docs/build/build_system.md new file mode 100644 index 0000000000..efe14454af --- /dev/null +++ b/docs/build/build_system.md @@ -0,0 +1,148 @@ +# Build system + +## Implementation details + +The project uses CMake as the build system generator. CMake allows for cross-platform builds and provides the necessary flexibility for both project development and its use in external projects. + +[Conan](https://conan.io) is integrated as an optional dependency manager via dependency resolver mechanism introduced in CMake 3.24 (see `cmake/conan_provider.cmake`). Conan helps us manage external libraries and allows us to create reproducible developer environment with ease. However, the build system is designed to work without Conan if needed. + +## Compilation steps + +Typical configurations of the project are provided in the `CMakePresets.json` file – this means that if you use a modern IDE, **no additional configuration is needed**. Just pick one of the configurations provided by this file and use controls in your IDE to recompile and run tests (should work with VSCode + CMake Tools extension, JetBrains CLion and probably many others). + +If you wish to use CLI instead, you can list all the available configurations in the `CMakePresets.json` file and pick one of the presets: + +```sh +cmake --list-presets +``` + +For example, this is how to build sc-machine in debug mode using dependencies from Conan: + +```sh +# use pipx to install Conan if not already installed +# Install pipx first using this guide: https://pipx.pypa.io/stable/installation/ +pipx install conan +# Use preset with Conan-provided dependencies and debug build type +cmake --preset debug-conan +# Use debug build preset since we've used a debug configure preset +cmake --build --preset debug +``` + +This is how you would build sc-machine in release mode using system-provided dependencies: +```sh +# release build type with tests (no conan postfix = system-provided deps) +cmake --preset release-with-tests +cmake --build --preset release +``` + +The build artifacts will be located in the `build//bin` folder. + +Default installation folder location (used for package consumption) is `build//install`, installation process can be fired by appending `--target install` to the `cmake --build --preset ` command. + +## Consuming the package + +
+ +find_package() using CPack artifacts on GitHub Actions + +The package artifacts are available [here](https://github.com/ostis-ai/sc-machine/releases). To use these in your CMake project, download and extract the release for your platform to any convenient location. Then make it available to CMake by appending folder path to `CMAKE_PREFIX_PATH`: + +```cmake +# import sc-machine from the Releases archive +# you can override this variable via -D_PATH_SC_MACHINE_PATH or CMakeUserPreset.json / CMakePreset.json files +set(_SC_MACHINE_PATH "/location/to/sc-machine--" CACHE PATH "sc-machine installation path") + +# can be overriden using env variables as well +if(DEFINED ENV{_SC_MACHINE_PATH}) + set(_SC_MACHINE_PATH "$ENV{_SC_MACHINE_PATH}") +endif() + +list(APPEND CMAKE_PREFIX_PATH ${_SC_MACHINE_PATH}) +``` +
+ +
+ +find_package() using Conan + +- You want to use a package version that is not published in a Conan repo: +- + +
+ +After making sc-machine available to find_package() in any of the above ways, use this to import our targets: + +```cmake +find_package(sc-machine REQUIRED) +``` + +After adding this code to your build system, using sc-machine libraries and executables will be available to you. Linking to a library will automatically make headers available to you as well. + +Let's try to use it! + +```cmake +add_executable(wave-find-path main.cpp) +target_link_libraries(wave-find-path sc-machine::sc-memory) +``` + +```cpp +#include "sc-memory/sc_addr.hpp" + +ScAddr graph, rrel_arcs, rrel_nodes; +``` + +If your IDE doesn't integrate well with this solution, try exporting compile commands in CMake: + +```cmake +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +``` + +## Advanced Usage + +### Cross-Compilation + +For cross-compilation, use the appropriate CMake toolchain file. + +### Editing sc-machine while consuming it as a library + +It's almost always problematic to edit a project while also consuming it as a library from another project. Luckily, if you've installed sc-machine in your project using Conan, there is a relatively easy solution to that problem. + +```sh +conan editable add +conan editable list +# sc-machine of the corersponding version should be in the output +# make changes in the project and run a rebuild +cmake --preset debug-conan +# using a debug build since that would allow us to step into the library's code while debugging +cmake --build --preset debug +``` + +The same is true for installations that have used GitHub Releases artifacts. Download the sc-machine repo, configure it, run `cmake --build --preset --target install` and add `sc-machine/build//install` to `CMAKE_PREFIX_PATH` of your project. Re-running `cmake --build --preset --target install` is enough to propagate changes to the consumer. + +Relaunch the compilation steps in your project and you should be good to go! + +You can find more info in [Conan docs](https://docs.conan.io/2/tutorial/developing_packages/editable_packages.html). + +### Falling Back to System Dependencies + +If Conan is not used, the build system will attempt to find system-installed dependencies. Ensure that the necessary development packages are installed on your system. + +Currently, we require the following packages to be available to CMake at build-time: + +- `glib2` +- `websocketpp` + - [`asio`](https://think-async.com/Asio/) as the transitive dependency +- `nlohmann_json` + +You can use convenience scripts provided in our repo (`scripts/install_deps_ubuntu.sh` and `scripts/install_deps_macOS.sh`) to install these dependencies. + +### Testing Conan package definition + +It is possible to write tests for the Conan packaging using [local package development flow](https://docs.conan.io/2/tutorial/developing_packages/local_package_development_flow.html). +## Troubleshooting + +- If you encounter issues with Conan, try clearing the Conan cache: `conan cache clean` +- For CMake configuration issues, check the CMakeCache.txt file in your build directory +- Ensure that your CMake version is compatible with the project requirements + +For further assistance, please consult the project's issue tracker or contact the maintainers. diff --git a/docs/build/linux_build.md b/docs/build/linux_build.md deleted file mode 100644 index 32695b863c..0000000000 --- a/docs/build/linux_build.md +++ /dev/null @@ -1,28 +0,0 @@ -This instruction is intended to be used on Debian-based distros. For other distros, skip [Install dependencies](#install-dependencies) section and make sure you install all the required packages manually. - -## Clone - -```sh -git clone https://github.com/ostis-ai/sc-machine.git --recursive -cd sc-machine -``` - -## Install dependencies - -```sh -./scripts/install_deps_ubuntu.sh --dev -``` - -## Build - -```sh -cmake -B build -DCMAKE_BUILD_TYPE=Release # use Debug for debug build -cmake --build build -j$(nproc) -``` - -Alternatively, you can use a script: -```sh -./scripts/build_sc_machine.sh -r #You can also pass -h to get help menu -``` - -Note: by default the binary outputs are saved in the `bin` folder, it is located at the same level as CMake build tree (the `build` folder). If you've generated the build tree in a location different from the root folder of the project, you may need to change further commands in the tutorial to accommodate for changed `bin` folder location. diff --git a/docs/build/osx_build.md b/docs/build/osx_build.md deleted file mode 100644 index 28cad8f40f..0000000000 --- a/docs/build/osx_build.md +++ /dev/null @@ -1,28 +0,0 @@ -## Clone - -```sh -git clone https://github.com/ostis-ai/sc-machine.git --recursive -cd sc-machine -``` - -## Install dependencies - -Note: you will need [Homebrew](https://docs.brew.sh/Installation) installed and configured on your Mac. - -```sh -./scripts/install_deps_macOS.sh -``` - -## Build - -```sh -cmake -B build -DCMAKE_BUILD_TYPE=Release # use Debug for debug build -cmake --build build -j$(nproc) -``` - -Alternatively, you can use a script: -```sh -./scripts/build_sc_machine.sh -r #You can also pass -h to get help menu -``` - -Note: by default the binary outputs are saved in the `bin` folder, it is located at the same level as CMake build tree (the `build` folder). If you've generated the build tree in a location different from the root folder of the project, you may need to change further commands in the tutorial to accommodate for changed `bin` folder location. diff --git a/docs/index.md b/docs/index.md index 852e99f725..8cf8ce8866 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,9 +1,8 @@ # Documentation -- **Build** - * [Build on Linux](build/linux_build.md) - *installation manual of sc-machine on Linux-based systems* - * [Build on OSX](build/osx_build.md) - *installation manual of sc-machine on OSX-based systems* - * [CMake Flags](build/cmake_flags.md) - *description of CMake flags using to configure sc-machine* +- **Build system** + * [Build system](build/build_system.md) - *how to build the project and use it as a library* + * [CMake Flags](build/cmake_flags.md) - *description of CMake flags used to configure sc-machine* * [Configuration File](build/config.md) - *description of a configuration file of sc-machine* - **API** * C++ API - *documentation of C++ API provided by sc-machine* diff --git a/mkdocs.yml b/mkdocs.yml index 96d4561cf1..e0974512cd 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,8 +10,7 @@ nav: - Home: index.md - Installation with Docker: docker.md - Build: - - Build on Linux: build/linux_build.md - - Build on OSX: build/osx_build.md + - Build system: build/build_system.md - CMake flags: build/cmake_flags.md - Configuration file: build/config.md - API: From 76e9cb2c4c937a937aeaa3760b16db3031dd3cc5 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 30 Aug 2024 16:16:54 +0300 Subject: [PATCH 006/134] [cmake] delete SC_AUTO_TEST flag --- CMakeLists.txt | 16 ++++------------ docs/build/build_system.md | 1 + 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7eeca127e..69170d7fa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.24) set(CMAKE_CXX_STANDARD 17) project(sc-machine VERSION "0.9.0") site_name(www.ostis.net) @@ -20,7 +20,6 @@ file(MAKE_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) message("Binary output dir:" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty") -option(SC_AUTO_TEST "Flag to build for automation testing" OFF) option(SC_BUILD_TESTS "Flag to build unit tests" OFF) option(SC_BUILD_BENCH "Flag to build benchmark" OFF) @@ -40,10 +39,6 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG") option(AUTO_CCACHE "Use ccache to speed up rebuilds" ON) -if(${SC_AUTO_TEST}) - add_definitions(-DSC_BUILD_AUTO_TESTS) -endif() - if(${SC_BUILD_TESTS}) include(GoogleTest) find_package(GTest REQUIRED) @@ -59,21 +54,18 @@ if(${SC_CLANG_FORMAT_CODE}) endif() if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics -std=c++17") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics") if (${SC_USE_SANITIZER} STREQUAL "none" AND NOT ${SC_COVERAGE}) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") endif() - if(${SC_AUTO_TEST}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated-declarations") - endif() elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") if(${SC_USE_SANITIZER} STREQUAL "none" AND NOT ${SC_COVERAGE}) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") ## Optimize endif() set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s") ## Strip binary elseif (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") diff --git a/docs/build/build_system.md b/docs/build/build_system.md index efe14454af..de7b5f511d 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -29,6 +29,7 @@ cmake --build --preset debug ``` This is how you would build sc-machine in release mode using system-provided dependencies: + ```sh # release build type with tests (no conan postfix = system-provided deps) cmake --preset release-with-tests From ce980b45f8d073cd0403f589ef5618be2e1e8b48 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 30 Aug 2024 16:17:06 +0300 Subject: [PATCH 007/134] [build] update default CMake presets --- CMakePresets.json | 86 +++++++++++++++++++++++++++++++++++++++ docs/build/cmake_flags.md | 2 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 CMakePresets.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000000..35e2a3fd50 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,86 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "debug", + "displayName": "Debug config", + "description": "Debug config with tests and benchmarks", + "binaryDir": "${sourceDir}/build/Debug", + "generator": "Ninja", + "installDir": "${sourceDir}/build/Debug/install", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "SC_BUILD_TESTS": true, + "SC_BUILD_BENCH": true + } + }, + { + "name": "debug-conan", + "displayName": "Debug config (Conan)", + "description": "Debug config with tests and benchmarks (Conan dependencies used)", + "inherits": ["debug"], + "cacheVariables": { + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "./cmake/conan_provider.cmake" + } + }, + { + "name": "release", + "displayName": "Release config", + "description": "Release config", + "binaryDir": "${sourceDir}/build/Release", + "generator": "Ninja", + "installDir": "${sourceDir}/build/Release/install", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "release-conan", + "displayName": "Release config (Conan)", + "description": "Release config (Conan dependencies used)", + "inherits": "release", + "cacheVariables": { + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "./cmake/conan_provider.cmake" + } + }, + { + "name": "release-with-tests", + "displayName": "Release config with tests", + "description": "Release config with tests", + "inherits": "release", + "cacheVariables": { + "SC_BUILD_TESTS": true, + "SC_BUILD_BENCH": true + } + }, + { + "name": "release-with-tests-conan", + "displayName": "Release config with tests (Conan)", + "description": "Release config with tests (Conan dependencies used)", + "inherits": "release-with-tests" + } + ], + "buildPresets": [ + { + "name": "debug", + "configurePreset": "debug" + + }, + { + "name": "release", + "configurePreset": "release" + } + ], + "packagePresets": [ + { + "name": "release-conan", + "configurePreset": "release-conan", + "generators": ["TGZ"] + }, + { + "name": "release", + "configurePreset": "release", + "generators": ["TGZ"] + } + ] +} diff --git a/docs/build/cmake_flags.md b/docs/build/cmake_flags.md index 849d6271d7..7552936679 100644 --- a/docs/build/cmake_flags.md +++ b/docs/build/cmake_flags.md @@ -3,7 +3,7 @@ This project uses ccache automatically if it's available in the system. To disab ## Building tests: ```sh -cmake -B build -DSC_BUILD_TESTS=ON -DSC_AUTO_TEST=ON +cmake -B build -DSC_BUILD_TESTS=ON cmake --build build -j$(nproc) ``` From 4886a9af726918b0adf445843cb7403cc592a7f8 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 30 Aug 2024 17:38:49 +0300 Subject: [PATCH 008/134] [build][docs] Add documentation about library consumption --- conanfile.py | 43 ++++++++++++++++----------- docs/build/build_system.md | 59 ++++++++++++++++++++++++++++++++++++-- mkdocs.yml | 1 + 3 files changed, 84 insertions(+), 19 deletions(-) diff --git a/conanfile.py b/conanfile.py index ab03feb7e3..2878625b7b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,5 @@ from conan import ConanFile, tools -from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.cmake import cmake_layout, CMakeDeps, CMakeToolchain, CMake import re @@ -21,21 +21,13 @@ class sc_machineRecipe(ConanFile): url = "https://github.com/ostis-ai/sc-machine" description = "Software implementation of semantic network storage" exports = ["LICENSE.md"] + exports_sources = "*", "!.venv", "!build", "!.cache", "!kb", "!kb.bin", "!.env", "!ConanPresets.json", "!docs" settings = "os", "compiler", "build_type", "arch" requires = () - options = { # remove for a header-only library - "shared": [True, False], - "fPIC": [True, False] - } + options = {"shared": [True], "fPIC": [True, False]} default_options = { - "shared": False, + "shared": True, "fPIC": True, - } - scm = { - "type": "git", - "url": "auto", - "revision": "auto", - "submodule": "recursive" } @property @@ -49,7 +41,12 @@ def build_requirements(self): self.build_requires("antlr4-cppruntime/4.9.3") def layout(self): - cmake_layout(self, build_folder="build") + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() # equivalent to self.run("cmake . ") + cmake.build() def test_requirements(self): if self._run_tests: @@ -62,10 +59,24 @@ def generate(self): tc = CMakeToolchain(self) tc.generate() - def build(self): + def package(self): cmake = CMake(self) - cmake.configure() - cmake.build() + cmake.install() + + def package_id(self): + del self.info.settings.os + del self.info.settings.compiler + del self.info.settings.build_type + + def package_info(self): + # Not settings cpp_info.libs since this is already defined in sc-machine-config.cmake + self.cpp_info.builddirs = ["lib/cmake/sc-machine"] + self.cpp_info.set_property("cmake_find_mode", "none") + + def parse_version(self): + content = tools.files.load(self, self.recipe_folder + "/CMakeLists.txt") + version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1) + return version.strip() def package(self): cmake = CMake(self) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index de7b5f511d..778bba2982 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -42,7 +42,7 @@ Default installation folder location (used for package consumption) is `build/ +
find_package() using CPack artifacts on GitHub Actions @@ -62,12 +62,65 @@ list(APPEND CMAKE_PREFIX_PATH ${_SC_MACHINE_PATH}) ```
-
+
find_package() using Conan +- You want to use a released version of sc-machine + + Simply add sc-machine as a dependency to your project and use Conan to install it for you. + + conanfile.txt: + + ```ini + [requires] + sc-machine/0.10.0 + + [generators] + CMakeDeps + CMakeToolchain + + [layout] + cmake_layout + ``` + + ```sh + conan install . + ``` + - You want to use a package version that is not published in a Conan repo: -- + + Export the version you'd like to use to local conan cache: + ```sh + git clone https://github.com/ostis-ai/sc-machine + git checkout + cmake --preset release-conan + cmake --build --preset release --target install + conan export-pkg . + # you should see the package version and revision exported to local conan cache + ``` + + Then in your project edit conanfile.txt and add the following: + + ```ini + [requires] + # git commit is also the revision + sc-machine/0.10.0#0c1889bc6a34450c7728b4b12af9083910cebb36 + + [generators] + CMakeDeps + CMakeToolchain + + [layout] + cmake_layout + ``` + + Finally, build your project + + ```sh + conan install . + cmake --build --preset conan-release + ```
diff --git a/mkdocs.yml b/mkdocs.yml index e0974512cd..bd5cf8875a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -57,6 +57,7 @@ theme: material markdown_extensions: - admonition - codehilite + - md_in_html - pymdownx.highlight: anchor_linenums: true - pymdownx.inlinehilite From e7ee0794a38bbba5bf11c4ffe56a61c1e82dd221 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 30 Aug 2024 18:15:48 +0300 Subject: [PATCH 009/134] [build] fix export dirs and targets --- CMakeLists.txt | 12 ++++++------ cmake/install.cmake | 7 ++++++- conanfile.py | 5 ----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69170d7fa9..4db9aa24a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,12 @@ project_version(SC_MACHINE "0.9.0-Unlock") set(CMAKE_MODULE_PATH "${SC_MACHINE_ROOT}/cmake") # CMAKE_BINARY_DIR is a path to the top level of the build tree (i.e to the "build" folder). Placing a "bin" folder nearby -if(NOT SC_BIN_PATH) - set(SC_BIN_PATH "${CMAKE_BINARY_DIR}/../bin") -endif() -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_BIN_PATH}) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SC_BIN_PATH}) -set(SC_EXTENSIONS_DIRECTORY "${SC_BIN_PATH}/extensions") +# if(NOT SC_BIN_PATH) +# set(SC_BIN_PATH "${CMAKE_BINARY_DIR}/../bin") +# endif() +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(SC_EXTENSIONS_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/extensions") file(MAKE_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) message("Binary output dir:" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty") diff --git a/cmake/install.cmake b/cmake/install.cmake index 6da8379a27..78dd25f0ee 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -11,7 +11,7 @@ install(TARGETS ) # a target set for things we don't want to export to the consumers -install(TARGETS sc-server-lib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS sc-server-lib EXPORT privateExport LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(EXPORT sc-machineExport FILE sc-machineTargets.cmake @@ -19,6 +19,11 @@ install(EXPORT sc-machineExport DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc-machine ) +install(EXPORT privateExport + FILE privateTargets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc-machine +) + include(CMakePackageConfigHelpers) write_basic_package_version_file( diff --git a/conanfile.py b/conanfile.py index 2878625b7b..4a38065938 100644 --- a/conanfile.py +++ b/conanfile.py @@ -68,11 +68,6 @@ def package_id(self): del self.info.settings.compiler del self.info.settings.build_type - def package_info(self): - # Not settings cpp_info.libs since this is already defined in sc-machine-config.cmake - self.cpp_info.builddirs = ["lib/cmake/sc-machine"] - self.cpp_info.set_property("cmake_find_mode", "none") - def parse_version(self): content = tools.files.load(self, self.recipe_folder + "/CMakeLists.txt") version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1) From 896fbce74e8fb2155c66fde8a7816550c9643180 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 14:57:11 +0300 Subject: [PATCH 010/134] [cmake] Fix paths in tests --- cmake/tests.cmake | 5 ++-- sc-kpm/sc-search/CMakeLists.txt | 1 + sc-kpm/sc-search/tests/CMakeLists.txt | 2 +- sc-kpm/sc-ui/CMakeLists.txt | 1 + sc-kpm/sc-ui/tests/CMakeLists.txt | 2 +- sc-kpm/sc-utils/CMakeLists.txt | 1 + sc-kpm/sc-utils/tests/CMakeLists.txt | 2 +- sc-memory/sc-core/tests/CMakeLists.txt | 18 ++++++------- .../sc-core/tests/src/sc-core/CMakeLists.txt | 25 ------------------- sc-tools/sc-server/CMakeLists.txt | 5 ++-- 10 files changed, 17 insertions(+), 45 deletions(-) delete mode 100644 sc-memory/sc-core/tests/src/sc-core/CMakeLists.txt diff --git a/cmake/tests.cmake b/cmake/tests.cmake index aaf94ac549..bab7913b5c 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -14,9 +14,8 @@ function(make_tests_from_folder folder) "${folder}/*.hpp") add_executable(${target} ${SOURCES}) - target_link_libraries(${target} gtest ${TEST_DEPENDS}) + target_link_libraries(${target} GTest::gtest GTest::gtest_main ${TEST_DEPENDS}) target_include_directories(${target} PRIVATE ${TEST_INCLUDES}) - - add_test(NAME ${target} COMMAND ${target} ${TEST_ARGUMENTS}) + gtest_discover_tests(${target} TEST_LIST ${target_tests}) endfunction() diff --git a/sc-kpm/sc-search/CMakeLists.txt b/sc-kpm/sc-search/CMakeLists.txt index e1294fed9b..372f1ebcab 100644 --- a/sc-kpm/sc-search/CMakeLists.txt +++ b/sc-kpm/sc-search/CMakeLists.txt @@ -12,5 +12,6 @@ if(${SC_CLANG_FORMAT_CODE}) endif() if(${SC_BUILD_TESTS}) + set(SC_KPM_SEARCH_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src") add_subdirectory(tests) endif() diff --git a/sc-kpm/sc-search/tests/CMakeLists.txt b/sc-kpm/sc-search/tests/CMakeLists.txt index b614fbee3d..71836f3b83 100644 --- a/sc-kpm/sc-search/tests/CMakeLists.txt +++ b/sc-kpm/sc-search/tests/CMakeLists.txt @@ -1,7 +1,7 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units NAME sc-kpm-search-utils-tests DEPENDS sc-memory sc-kpm-search - INCLUDES ${SC_KPM_SRC}/sc-search/src + INCLUDES ${SC_KPM_SEARCH_SRC} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-kpm/sc-ui/CMakeLists.txt b/sc-kpm/sc-ui/CMakeLists.txt index a34335a829..cfd555a0c8 100644 --- a/sc-kpm/sc-ui/CMakeLists.txt +++ b/sc-kpm/sc-ui/CMakeLists.txt @@ -18,5 +18,6 @@ if(${SC_CLANG_FORMAT_CODE}) endif() if(${SC_BUILD_TESTS}) + set(SC_KPM_UI_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src") add_subdirectory(tests) endif() diff --git a/sc-kpm/sc-ui/tests/CMakeLists.txt b/sc-kpm/sc-ui/tests/CMakeLists.txt index 6261bda61b..d49194f030 100644 --- a/sc-kpm/sc-ui/tests/CMakeLists.txt +++ b/sc-kpm/sc-ui/tests/CMakeLists.txt @@ -1,7 +1,7 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units NAME sc-kpm-ui-translators-tests DEPENDS sc-memory sc-kpm-ui - INCLUDES ${SC_KPM_SRC}/sc-ui/src + INCLUDES ${SC_KPM_UI_SRC} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-kpm/sc-utils/CMakeLists.txt b/sc-kpm/sc-utils/CMakeLists.txt index 454429bd53..67d93f11d5 100644 --- a/sc-kpm/sc-utils/CMakeLists.txt +++ b/sc-kpm/sc-utils/CMakeLists.txt @@ -11,5 +11,6 @@ if(${SC_CLANG_FORMAT_CODE}) endif() if(${SC_BUILD_TESTS}) + set(SC_KPM_UTILS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src") add_subdirectory(tests) endif() diff --git a/sc-kpm/sc-utils/tests/CMakeLists.txt b/sc-kpm/sc-utils/tests/CMakeLists.txt index 35fc5fb111..fbad3c187e 100644 --- a/sc-kpm/sc-utils/tests/CMakeLists.txt +++ b/sc-kpm/sc-utils/tests/CMakeLists.txt @@ -1,7 +1,7 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units NAME sc-kpm-utils-tests DEPENDS sc-memory sc-kpm-utils - INCLUDES ${SC_KPM_SRC}/sc-utils/src + INCLUDES ${SC_KPM_UTILS_SRC} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-memory/sc-core/tests/CMakeLists.txt b/sc-memory/sc-core/tests/CMakeLists.txt index f5d8aa1970..7428ba6ba8 100644 --- a/sc-memory/sc-core/tests/CMakeLists.txt +++ b/sc-memory/sc-core/tests/CMakeLists.txt @@ -1,13 +1,9 @@ -find_package(PkgConfig REQUIRED) -pkg_search_module(GLIB2 REQUIRED glib-2.0) -pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) - -set(GLIB2_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS}) +FindGLIB() make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/common NAME sc-core-common-tests - DEPENDS ${GLIB2_LIBRARIES} sc-memory - INCLUDES ${GLIB2_INCLUDE_DIRS} ${SC_CORE_SRC} + DEPENDS ${glib_LIBRARIES} sc-memory + INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} ) if(${SC_CLANG_FORMAT_CODE}) @@ -16,8 +12,8 @@ endif() make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/containers NAME sc-core-containers-tests - DEPENDS ${GLIB2_LIBRARIES} sc-memory - INCLUDES ${GLIB2_INCLUDE_DIRS} ${SC_CORE_SRC} + DEPENDS ${glib_LIBRARIES} sc-memory + INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} ) if(${SC_CLANG_FORMAT_CODE}) @@ -26,8 +22,8 @@ endif() make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/fs-storage NAME sc-core-fs-storage-tests - DEPENDS ${GLIB2_LIBRARIES} sc-memory - INCLUDES ${GLIB2_INCLUDE_DIRS} ${SC_CORE_SRC} + DEPENDS ${glib_LIBRARIES} sc-memory + INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-memory/sc-core/tests/src/sc-core/CMakeLists.txt b/sc-memory/sc-core/tests/src/sc-core/CMakeLists.txt deleted file mode 100644 index cf888d0847..0000000000 --- a/sc-memory/sc-core/tests/src/sc-core/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -make_tests_from_folder(${CMAKE_CURRENT_LIST_DIR}/units/containers - NAME sc-memory-containers-tests - DEPENDS ${glib_LIBRARIES} sc-memory - INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} -) - -if(${SC_CLANG_FORMAT_CODE}) - target_clangformat_setup(sc-memory-containers-tests) -endif() - -make_tests_from_folder(${CMAKE_CURRENT_LIST_DIR}/units/fs-storage - NAME sc-fs-storage-tests - DEPENDS ${glib_LIBRARIES} sc-memory - INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} -) - -if(${SC_CLANG_FORMAT_CODE}) - target_clangformat_setup(sc-fs-storage-tests) -endif() - -configure_file( - "${CMAKE_CURRENT_LIST_DIR}/units/fs-storage/test_defines.hpp.in" - "${CMAKE_CURRENT_LIST_DIR}/units/fs-storage/test_defines.hpp" -) - diff --git a/sc-tools/sc-server/CMakeLists.txt b/sc-tools/sc-server/CMakeLists.txt index 360b349245..7128f755c3 100644 --- a/sc-tools/sc-server/CMakeLists.txt +++ b/sc-tools/sc-server/CMakeLists.txt @@ -20,9 +20,8 @@ target_compile_definitions(sc-server-lib ) target_include_directories(sc-server-lib PRIVATE ${SC_CORE_SRC} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - PUBLIC $ - PUBLIC $ + PUBLIC $ + PUBLIC $ ) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ From 63a8e9d32a6f5eb39d5007e8a1e66e3ca6c518d8 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 15:09:48 +0300 Subject: [PATCH 011/134] [cmake] Fix install path for extensions --- CMakeLists.txt | 2 -- cmake/tests.cmake | 17 ++++++++--------- sc-kpm/CMakeLists.txt | 10 ---------- sc-tools/CMakeLists.txt | 11 ----------- 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db9aa24a4..5bae4863ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,6 @@ set(CMAKE_MODULE_PATH "${SC_MACHINE_ROOT}/cmake") # endif() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(SC_EXTENSIONS_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/extensions") -file(MAKE_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) message("Binary output dir:" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty") diff --git a/cmake/tests.cmake b/cmake/tests.cmake index bab7913b5c..a553d08fd9 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -1,21 +1,20 @@ function(make_tests_from_folder folder) - - set (SINGLE_ARGS NAME) - set (MULTI_ARGS DEPENDS INCLUDES ARGUMENTS) + set(SINGLE_ARGS NAME) + set(MULTI_ARGS DEPENDS INCLUDES ARGUMENTS) cmake_parse_arguments(TEST "" "${SINGLE_ARGS}" "${MULTI_ARGS}" ${ARGN}) - set (target "${TEST_NAME}") + set(target "${TEST_NAME}") message(STATUS "Create test ${target}") - file (GLOB_RECURSE SOURCES - "${folder}/*.cpp" - "${folder}/*.hpp") + file(GLOB_RECURSE SOURCES + "${folder}/*.cpp" + "${folder}/*.hpp" + ) add_executable(${target} ${SOURCES}) - target_link_libraries(${target} GTest::gtest GTest::gtest_main ${TEST_DEPENDS}) + target_link_libraries(${target} GTest::gtest_main ${TEST_DEPENDS}) target_include_directories(${target} PRIVATE ${TEST_INCLUDES}) gtest_discover_tests(${target} TEST_LIST ${target_tests}) - endfunction() diff --git a/sc-kpm/CMakeLists.txt b/sc-kpm/CMakeLists.txt index 1e8e08edcc..59f7b9464e 100644 --- a/sc-kpm/CMakeLists.txt +++ b/sc-kpm/CMakeLists.txt @@ -1,21 +1,11 @@ add_subdirectory(sc-common) add_subdirectory(sc-agents-common) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) - -# for multi-config builds (e.g. msvc) -foreach(OUTPUT_CONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${OUTPUT_CONFIG} OUTPUT_CONFIG) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUT_CONFIG} "${SC_EXTENSIONS_DIRECTORY}") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUT_CONFIG} "${SC_EXTENSIONS_DIRECTORY}") -endforeach(OUTPUT_CONFIG) - add_subdirectory(sc-ui) add_subdirectory(sc-search) add_subdirectory(sc-utils) add_custom_target(sc-kpm) - add_dependencies(sc-kpm sc-agents-common sc-kpm-common diff --git a/sc-tools/CMakeLists.txt b/sc-tools/CMakeLists.txt index 2ad7cc1c9f..a6cd7371ad 100644 --- a/sc-tools/CMakeLists.txt +++ b/sc-tools/CMakeLists.txt @@ -4,20 +4,9 @@ set(SC_BUILDER_SRC ${SC_TOOLS_SRC}/sc-builder) add_subdirectory(sc-config) add_subdirectory(sc-builder) add_subdirectory(sc-machine-runner) - -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) - -# for multi-config builds (e.g. msvc) -foreach(OUTPUT_CONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${OUTPUT_CONFIG} OUTPUT_CONFIG) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUT_CONFIG} "${SC_EXTENSIONS_DIRECTORY}") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUT_CONFIG} "${SC_EXTENSIONS_DIRECTORY}") -endforeach(OUTPUT_CONFIG) - add_subdirectory(sc-server) add_custom_target(sc-tools) - add_dependencies(sc-tools sc-config sc-builder From e66968bf77ac3387d4f56ad46037e5828da53016 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 15:25:56 +0300 Subject: [PATCH 012/134] [cmake] Remove duplicating project version --- CMakeLists.txt | 14 ++++++-------- cmake/FindGLIB.cmake | 2 +- macro/macros.cmake | 2 +- ...t_version.cmake => parse_project_version.cmake} | 7 ++++--- 4 files changed, 12 insertions(+), 13 deletions(-) rename macro/{project_version.cmake => parse_project_version.cmake} (82%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bae4863ba..25900bfb3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,17 @@ cmake_minimum_required(VERSION 3.24) set(CMAKE_CXX_STANDARD 17) project(sc-machine VERSION "0.9.0") +message(STATUS "Current Project Version: ${CMAKE_PROJECT_VERSION}") site_name(www.ostis.net) cmake_policy(SET CMP0048 NEW) set(SC_MACHINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) -include(${SC_MACHINE_ROOT}/macro/macros.cmake) -project_version(SC_MACHINE "0.9.0-Unlock") set(CMAKE_MODULE_PATH "${SC_MACHINE_ROOT}/cmake") -# CMAKE_BINARY_DIR is a path to the top level of the build tree (i.e to the "build" folder). Placing a "bin" folder nearby -# if(NOT SC_BIN_PATH) -# set(SC_BIN_PATH "${CMAKE_BINARY_DIR}/../bin") -# endif() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -message("Binary output dir:" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +message(STATUS "Binary output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") +message(STATUS "Libary output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty") option(SC_BUILD_TESTS "Flag to build unit tests" OFF) @@ -24,11 +20,13 @@ option(SC_BUILD_BENCH "Flag to build benchmark" OFF) set(SC_FILE_MEMORY "Dictionary" CACHE STRING "Sc-fs-storage type") option(SC_OPTIMIZE_SEARCHING_INCOMING_CONNECTORS_FROM_STRUCTURES "Flag to optimize searching incoming sc-connctors from sc-structures" ON) +include(${SC_MACHINE_ROOT}/macro/macros.cmake) +parse_project_version() + code_coverage(SC_COVERAGE "Flag to generate coverage report" OFF "-g -O0 --coverage") option(SC_CLANG_FORMAT_CODE "Flag to add clangformat and clangformat_check targets" OFF) sanitizer(SC_USE_SANITIZER "Build with specified sanitizer" "none") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSC_DEBUG -DSC_PROFILE") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSC_DEBUG -DSC_PROFILE") diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake index e88ffbb3b3..91cef40634 100644 --- a/cmake/FindGLIB.cmake +++ b/cmake/FindGLIB.cmake @@ -15,4 +15,4 @@ macro(FindGLIB) set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS}) set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS}) endif() -endmacro(FindGLIB) +endmacro() diff --git a/macro/macros.cmake b/macro/macros.cmake index 3c2c9803d3..3a633b3f39 100644 --- a/macro/macros.cmake +++ b/macro/macros.cmake @@ -1,4 +1,4 @@ -include(${CMAKE_CURRENT_LIST_DIR}/project_version.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/parse_project_version.cmake) include(${CMAKE_CURRENT_LIST_DIR}/code_coverage.cmake) include(${CMAKE_CURRENT_LIST_DIR}/sanitizer.cmake) diff --git a/macro/project_version.cmake b/macro/parse_project_version.cmake similarity index 82% rename from macro/project_version.cmake rename to macro/parse_project_version.cmake index c3257322fe..dfd01a2980 100644 --- a/macro/project_version.cmake +++ b/macro/parse_project_version.cmake @@ -1,6 +1,7 @@ -macro(project_version _PACKAGE _VERSION) - set(${_PACKAGE}_VERSION ${_VERSION}) - add_definitions(-D${_PACKAGE}_VERSION=${_VERSION}) +macro(parse_project_version) + set(_PACKAGE SC_MACHINE) + set(${_PACKAGE}_VERSION ${CMAKE_PROJECT_VERSION}) + add_definitions(-D${_PACKAGE}_VERSION=${CMAKE_PROJECT_VERSION}) string(REGEX MATCHALL "[0-9A-Za-z]+" _VERSION_COMPONENTS "${${_PACKAGE}_VERSION}") list(LENGTH _VERSION_COMPONENTS _LEN) From 77eb7ed28329bec81b39ce2a57984f990dd0d6f6 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 15:30:28 +0300 Subject: [PATCH 013/134] [ci][scripts] Remove duplicating build tests scripts --- .github/workflows/coverage.yml | 4 ++-- .github/workflows/main.yml | 8 ++++---- .github/workflows/sanitizers.yml | 4 ++-- CMakeLists.txt | 5 ++--- sc-tools/sc-server/CMakeLists.txt | 2 ++ scripts/ci/make_tests.sh | 13 ------------- scripts/ci/run_tests.sh | 8 -------- scripts/set_vars.sh | 2 +- 8 files changed, 13 insertions(+), 33 deletions(-) delete mode 100755 scripts/ci/make_tests.sh delete mode 100755 scripts/ci/run_tests.sh diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 095d85aa2a..067a37c027 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -47,7 +47,7 @@ jobs: BUILD_TYPE: ${{ matrix.config.build_type }} COVERAGE: ON SANITIZER_TYPE: none - run: scripts/ci/make_tests.sh + run: scripts/build_sc_machine.sh --cmake-arg "-DSC_COVERAGE=ON" -t - name: Prepare coverage id: prepare_coverage @@ -55,7 +55,7 @@ jobs: - name: Run tests id: run_tests - run: scripts/ci/run_tests.sh + run: scripts/run_tests.sh - name: Export coverage report id: export_coverage diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e3165cfdb2..2b095d8df3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,15 +43,15 @@ jobs: BUILD_TYPE: ${{ matrix.build_type }} COVERAGE: OFF SANITIZER_TYPE: none - run: scripts/ci/make_tests.sh + run: scripts/build_sc_machine.sh -t - name: Run tests id: run_tests - run: scripts/ci/run_tests.sh + run: scripts/run_tests.sh - name: Run sc-machine id: run_sc_machine run: | mkdir kb - bin/sc-builder -i kb -o kb.bin --clear - bin/sc-machine -t -c sc-machine.ini -s kb.bin + build/bin/sc-builder -i kb -o kb.bin --clear + build/bin/sc-machine -t -c sc-machine.ini -s kb.bin diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index bee0554e0b..62f49aa948 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -47,8 +47,8 @@ jobs: BUILD_TYPE: ${{ matrix.config.build_type }} COVERAGE: OFF SANITIZER_TYPE: ${{ matrix.config.sanitizer }} - run: scripts/ci/make_tests.sh + run: scripts/build_sc_machine.sh -t - name: Run tests id: run_tests - run: scripts/ci/run_tests.sh + run: scripts/run_tests.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 25900bfb3b..7df1e69f4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.24) set(CMAKE_CXX_STANDARD 17) -project(sc-machine VERSION "0.9.0") +project(sc-machine VERSION "0.9.0" LANGUAGES C CXX) message(STATUS "Current Project Version: ${CMAKE_PROJECT_VERSION}") site_name(www.ostis.net) cmake_policy(SET CMP0048 NEW) @@ -10,8 +10,8 @@ set(SC_MACHINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_MODULE_PATH "${SC_MACHINE_ROOT}/cmake") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +message(STATUS "Libary output directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") message(STATUS "Binary output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") -message(STATUS "Libary output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty") option(SC_BUILD_TESTS "Flag to build unit tests" OFF) @@ -110,7 +110,6 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) include(${CMAKE_MODULE_PATH}/FindGLIB.cmake) -set(SC_CORE_SRC "${SC_MACHINE_ROOT}/sc-memory/sc-core/src") add_subdirectory(${SC_MACHINE_ROOT}/thirdparty) add_subdirectory(${SC_MACHINE_ROOT}/sc-memory) add_subdirectory(${SC_MACHINE_ROOT}/sc-kpm) diff --git a/sc-tools/sc-server/CMakeLists.txt b/sc-tools/sc-server/CMakeLists.txt index 7128f755c3..c87efc0fab 100644 --- a/sc-tools/sc-server/CMakeLists.txt +++ b/sc-tools/sc-server/CMakeLists.txt @@ -1,3 +1,5 @@ +set(SC_CORE_SRC "${SC_MACHINE_ROOT}/sc-memory/sc-core/src") + file(GLOB SOURCES CONFIGURE_DEPENDS "src/*.cpp" "src/*.hpp" "src/*/*.cpp" "src/*/*.hpp" diff --git a/scripts/ci/make_tests.sh b/scripts/ci/make_tests.sh deleted file mode 100755 index 2ebc0c4fb1..0000000000 --- a/scripts/ci/make_tests.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -eo pipefail - -cmake -B build -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DSC_COVERAGE="${COVERAGE}" -DSC_AUTO_TEST=ON -DSC_BUILD_TESTS=ON -echo ::group::Make -cmake --build build -j"$(nproc)" -echo ::endgroup:: - -pushd build -../bin/sc-builder -i ../sc-tools/sc-builder/tests/repo.path -o ../bin/sc-builder-test-repo --clear -f -../bin/sc-builder -i ../sc-tools/sc-server/tests/kb -o ../bin/sc-server-test-repo --clear -f -popd diff --git a/scripts/ci/run_tests.sh b/scripts/ci/run_tests.sh deleted file mode 100755 index 7bbe96c1bf..0000000000 --- a/scripts/ci/run_tests.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -eo pipefail - -pushd build -ctest -C Debug -V - -popd diff --git a/scripts/set_vars.sh b/scripts/set_vars.sh index ed6d812a41..411054f145 100644 --- a/scripts/set_vars.sh +++ b/scripts/set_vars.sh @@ -8,7 +8,7 @@ export ROOT_CMAKE_PATH="${ROOT_CMAKE_PATH:-${SC_MACHINE_PATH}}" export PROBLEM_SOLVER_PATH="${PROBLEM_SOLVER_PATH:-${SC_MACHINE_PATH}}" # backward compatibility export CXX_SOURCES_PATH="${PROBLEM_SOLVER_PATH:-${SC_MACHINE_PATH}}" export BUILD_PATH="${BUILD_PATH:-${ROOT_CMAKE_PATH}/build}" -export BINARY_PATH="${BINARY_PATH:-${ROOT_CMAKE_PATH}/bin}" +export BINARY_PATH="${BINARY_PATH:-${BUILD_PATH}/bin}" export CONFIG_PATH="${CONFIG_PATH:-${SC_MACHINE_PATH}/sc-machine.ini}" export REPO_PATH="${REPO_PATH:-${SC_MACHINE_PATH}/repo.path}" From d32ab51337e20c35af07823baa12432a4e3be0bf Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 15:56:29 +0300 Subject: [PATCH 014/134] [cmake] Add conand provider --- cmake/conan_provider.cmake | 675 +++++++++++++++++++++++++++++++++++++ 1 file changed, 675 insertions(+) create mode 100644 cmake/conan_provider.cmake diff --git a/cmake/conan_provider.cmake b/cmake/conan_provider.cmake new file mode 100644 index 0000000000..9fea0434be --- /dev/null +++ b/cmake/conan_provider.cmake @@ -0,0 +1,675 @@ +# Taken from https://github.com/conan-io/cmake-conan/blob/8bf396b92f37f8942d0be24453e8aa268d61ecba/conan_provider.cmake +# The MIT License (MIT) +# +# Copyright (c) 2024 JFrog +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set(CONAN_MINIMUM_VERSION 2.0.5) + +# Create a new policy scope and set the minimum required cmake version so the +# features behind a policy setting like if(... IN_LIST ...) behaves as expected +# even if the parent project does not specify a minimum cmake version or a minimum +# version less than this module requires (e.g. 3.0) before the first project() call. +# (see: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.html) +# +# The policy-affecting calls like cmake_policy(SET...) or `cmake_minimum_required` only +# affects the current policy scope, i.e. between the PUSH and POP in this case. +# +# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Policies.html#the-policy-stack +cmake_policy(PUSH) +cmake_minimum_required(VERSION 3.24) + +function(detect_os OS OS_API_LEVEL OS_SDK OS_SUBSYSTEM OS_VERSION) + # it could be cross compilation + message(STATUS "CMake-Conan: cmake_system_name=${CMAKE_SYSTEM_NAME}") + if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(${OS} Macos PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX") + set(${OS} Neutrino PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "CYGWIN") + set(${OS} Windows PARENT_SCOPE) + set(${OS_SUBSYSTEM} cygwin PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME MATCHES "^MSYS") + set(${OS} Windows PARENT_SCOPE) + set(${OS_SUBSYSTEM} msys2 PARENT_SCOPE) + else() + set(${OS} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Android") + if(DEFINED ANDROID_PLATFORM) + string(REGEX MATCH "[0-9]+" _OS_API_LEVEL ${ANDROID_PLATFORM}) + elseif(DEFINED CMAKE_SYSTEM_VERSION) + set(_OS_API_LEVEL ${CMAKE_SYSTEM_VERSION}) + endif() + message(STATUS "CMake-Conan: android api level=${_OS_API_LEVEL}") + set(${OS_API_LEVEL} ${_OS_API_LEVEL} PARENT_SCOPE) + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS") + # CMAKE_OSX_SYSROOT contains the full path to the SDK for MakeFile/Ninja + # generators, but just has the original input string for Xcode. + if(NOT IS_DIRECTORY ${CMAKE_OSX_SYSROOT}) + set(_OS_SDK ${CMAKE_OSX_SYSROOT}) + else() + if(CMAKE_OSX_SYSROOT MATCHES Simulator) + set(apple_platform_suffix simulator) + else() + set(apple_platform_suffix os) + endif() + if(CMAKE_OSX_SYSROOT MATCHES AppleTV) + set(_OS_SDK "appletv${apple_platform_suffix}") + elseif(CMAKE_OSX_SYSROOT MATCHES iPhone) + set(_OS_SDK "iphone${apple_platform_suffix}") + elseif(CMAKE_OSX_SYSROOT MATCHES Watch) + set(_OS_SDK "watch${apple_platform_suffix}") + endif() + endif() + if(DEFINED _OS_SDK) + message(STATUS "CMake-Conan: cmake_osx_sysroot=${CMAKE_OSX_SYSROOT}") + set(${OS_SDK} ${_OS_SDK} PARENT_SCOPE) + endif() + if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET) + message(STATUS "CMake-Conan: cmake_osx_deployment_target=${CMAKE_OSX_DEPLOYMENT_TARGET}") + set(${OS_VERSION} ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + + +function(detect_arch ARCH) + # CMAKE_OSX_ARCHITECTURES can contain multiple architectures, but Conan only supports one. + # Therefore this code only finds one. If the recipes support multiple architectures, the + # build will work. Otherwise, there will be a linker error for the missing architecture(s). + if(DEFINED CMAKE_OSX_ARCHITECTURES) + string(REPLACE " " ";" apple_arch_list "${CMAKE_OSX_ARCHITECTURES}") + list(LENGTH apple_arch_list apple_arch_count) + if(apple_arch_count GREATER 1) + message(WARNING "CMake-Conan: Multiple architectures detected, this will only work if Conan recipe(s) produce fat binaries.") + endif() + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS" AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "") + set(host_arch ${CMAKE_OSX_ARCHITECTURES}) + elseif(MSVC) + set(host_arch ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}) + else() + set(host_arch ${CMAKE_SYSTEM_PROCESSOR}) + endif() + if(host_arch MATCHES "aarch64|arm64|ARM64") + set(_ARCH armv8) + elseif(host_arch MATCHES "armv7|armv7-a|armv7l|ARMV7") + set(_ARCH armv7) + elseif(host_arch MATCHES armv7s) + set(_ARCH armv7s) + elseif(host_arch MATCHES "i686|i386|X86") + set(_ARCH x86) + elseif(host_arch MATCHES "AMD64|amd64|x86_64|x64") + set(_ARCH x86_64) + endif() + message(STATUS "CMake-Conan: cmake_system_processor=${_ARCH}") + set(${ARCH} ${_ARCH} PARENT_SCOPE) +endfunction() + + +function(detect_cxx_standard CXX_STANDARD) + set(${CXX_STANDARD} ${CMAKE_CXX_STANDARD} PARENT_SCOPE) + if(CMAKE_CXX_EXTENSIONS) + set(${CXX_STANDARD} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE) + endif() +endfunction() + + +macro(detect_gnu_libstdcxx) + # _CONAN_IS_GNU_LIBSTDCXX true if GNU libstdc++ + check_cxx_source_compiles(" + #include + #if !defined(__GLIBCXX__) && !defined(__GLIBCPP__) + static_assert(false); + #endif + int main(){}" _CONAN_IS_GNU_LIBSTDCXX) + + # _CONAN_GNU_LIBSTDCXX_IS_CXX11_ABI true if C++11 ABI + check_cxx_source_compiles(" + #include + static_assert(sizeof(std::string) != sizeof(void*), \"using libstdc++\"); + int main () {}" _CONAN_GNU_LIBSTDCXX_IS_CXX11_ABI) + + set(_CONAN_GNU_LIBSTDCXX_SUFFIX "") + if(_CONAN_GNU_LIBSTDCXX_IS_CXX11_ABI) + set(_CONAN_GNU_LIBSTDCXX_SUFFIX "11") + endif() + unset (_CONAN_GNU_LIBSTDCXX_IS_CXX11_ABI) +endmacro() + + +macro(detect_libcxx) + # _CONAN_IS_LIBCXX true if LLVM libc++ + check_cxx_source_compiles(" + #include + #if !defined(_LIBCPP_VERSION) + static_assert(false); + #endif + int main(){}" _CONAN_IS_LIBCXX) +endmacro() + + +function(detect_lib_cxx LIB_CXX) + if(CMAKE_SYSTEM_NAME STREQUAL "Android") + message(STATUS "CMake-Conan: android_stl=${CMAKE_ANDROID_STL_TYPE}") + set(${LIB_CXX} ${CMAKE_ANDROID_STL_TYPE} PARENT_SCOPE) + return() + endif() + + include(CheckCXXSourceCompiles) + + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + detect_gnu_libstdcxx() + set(${LIB_CXX} "libstdc++${_CONAN_GNU_LIBSTDCXX_SUFFIX}" PARENT_SCOPE) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") + set(${LIB_CXX} "libc++" PARENT_SCOPE) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows") + # Check for libc++ + detect_libcxx() + if(_CONAN_IS_LIBCXX) + set(${LIB_CXX} "libc++" PARENT_SCOPE) + return() + endif() + + # Check for libstdc++ + detect_gnu_libstdcxx() + if(_CONAN_IS_GNU_LIBSTDCXX) + set(${LIB_CXX} "libstdc++${_CONAN_GNU_LIBSTDCXX_SUFFIX}" PARENT_SCOPE) + return() + endif() + + # TODO: it would be an error if we reach this point + elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + # Do nothing - compiler.runtime and compiler.runtime_type + # should be handled separately: https://github.com/conan-io/cmake-conan/pull/516 + return() + else() + # TODO: unable to determine, ask user to provide a full profile file instead + endif() +endfunction() + + +function(detect_compiler COMPILER COMPILER_VERSION COMPILER_RUNTIME COMPILER_RUNTIME_TYPE) + if(DEFINED CMAKE_CXX_COMPILER_ID) + set(_COMPILER ${CMAKE_CXX_COMPILER_ID}) + set(_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}) + else() + if(NOT DEFINED CMAKE_C_COMPILER_ID) + message(FATAL_ERROR "C or C++ compiler not defined") + endif() + set(_COMPILER ${CMAKE_C_COMPILER_ID}) + set(_COMPILER_VERSION ${CMAKE_C_COMPILER_VERSION}) + endif() + + message(STATUS "CMake-Conan: CMake compiler=${_COMPILER}") + message(STATUS "CMake-Conan: CMake compiler version=${_COMPILER_VERSION}") + + if(_COMPILER MATCHES MSVC) + set(_COMPILER "msvc") + string(SUBSTRING ${MSVC_VERSION} 0 3 _COMPILER_VERSION) + # Configure compiler.runtime and compiler.runtime_type settings for MSVC + if(CMAKE_MSVC_RUNTIME_LIBRARY) + set(_msvc_runtime_library ${CMAKE_MSVC_RUNTIME_LIBRARY}) + else() + set(_msvc_runtime_library MultiThreaded$<$:Debug>DLL) # default value documented by CMake + endif() + + set(_KNOWN_MSVC_RUNTIME_VALUES "") + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded MultiThreadedDLL) + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreadedDebug MultiThreadedDebugDLL) + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded$<$:Debug> MultiThreaded$<$:Debug>DLL) + + # only accept the 6 possible values, otherwise we don't don't know to map this + if(NOT _msvc_runtime_library IN_LIST _KNOWN_MSVC_RUNTIME_VALUES) + message(FATAL_ERROR "CMake-Conan: unable to map MSVC runtime: ${_msvc_runtime_library} to Conan settings") + endif() + + # Runtime is "dynamic" in all cases if it ends in DLL + if(_msvc_runtime_library MATCHES ".*DLL$") + set(_COMPILER_RUNTIME "dynamic") + else() + set(_COMPILER_RUNTIME "static") + endif() + message(STATUS "CMake-Conan: CMake compiler.runtime=${_COMPILER_RUNTIME}") + + # Only define compiler.runtime_type when explicitly requested + # If a generator expression is used, let Conan handle it conditional on build_type + if(NOT _msvc_runtime_library MATCHES ":Debug>") + if(_msvc_runtime_library MATCHES "Debug") + set(_COMPILER_RUNTIME_TYPE "Debug") + else() + set(_COMPILER_RUNTIME_TYPE "Release") + endif() + message(STATUS "CMake-Conan: CMake compiler.runtime_type=${_COMPILER_RUNTIME_TYPE}") + endif() + + unset(_KNOWN_MSVC_RUNTIME_VALUES) + + elseif(_COMPILER MATCHES AppleClang) + set(_COMPILER "apple-clang") + string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION}) + list(GET VERSION_LIST 0 _COMPILER_VERSION) + elseif(_COMPILER MATCHES Clang) + set(_COMPILER "clang") + string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION}) + list(GET VERSION_LIST 0 _COMPILER_VERSION) + elseif(_COMPILER MATCHES GNU) + set(_COMPILER "gcc") + string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION}) + list(GET VERSION_LIST 0 _COMPILER_VERSION) + endif() + + message(STATUS "CMake-Conan: [settings] compiler=${_COMPILER}") + message(STATUS "CMake-Conan: [settings] compiler.version=${_COMPILER_VERSION}") + if (_COMPILER_RUNTIME) + message(STATUS "CMake-Conan: [settings] compiler.runtime=${_COMPILER_RUNTIME}") + endif() + if (_COMPILER_RUNTIME_TYPE) + message(STATUS "CMake-Conan: [settings] compiler.runtime_type=${_COMPILER_RUNTIME_TYPE}") + endif() + + set(${COMPILER} ${_COMPILER} PARENT_SCOPE) + set(${COMPILER_VERSION} ${_COMPILER_VERSION} PARENT_SCOPE) + set(${COMPILER_RUNTIME} ${_COMPILER_RUNTIME} PARENT_SCOPE) + set(${COMPILER_RUNTIME_TYPE} ${_COMPILER_RUNTIME_TYPE} PARENT_SCOPE) +endfunction() + + +function(detect_build_type BUILD_TYPE) + get_property(_MULTICONFIG_GENERATOR GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(NOT _MULTICONFIG_GENERATOR) + # Only set when we know we are in a single-configuration generator + # Note: we may want to fail early if `CMAKE_BUILD_TYPE` is not defined + set(${BUILD_TYPE} ${CMAKE_BUILD_TYPE} PARENT_SCOPE) + endif() +endfunction() + +macro(set_conan_compiler_if_appleclang lang command output_variable) + if(CMAKE_${lang}_COMPILER_ID STREQUAL "AppleClang") + execute_process(COMMAND xcrun --find ${command} + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE) + cmake_path(GET _xcrun_out PARENT_PATH _xcrun_toolchain_path) + cmake_path(GET CMAKE_${lang}_COMPILER PARENT_PATH _compiler_parent_path) + if ("${_xcrun_toolchain_path}" STREQUAL "${_compiler_parent_path}") + set(${output_variable} "") + endif() + unset(_xcrun_out) + unset(_xcrun_toolchain_path) + unset(_compiler_parent_path) + endif() +endmacro() + + +macro(append_compiler_executables_configuration) + set(_conan_c_compiler "") + set(_conan_cpp_compiler "") + set(_conan_rc_compiler "") + set(_conan_compilers_list "") + if(CMAKE_C_COMPILER) + set(_conan_c_compiler "\"c\":\"${CMAKE_C_COMPILER}\"") + set_conan_compiler_if_appleclang(C cc _conan_c_compiler) + list(APPEND _conan_compilers_list ${_conan_c_compiler}) + else() + message(WARNING "CMake-Conan: The C compiler is not defined. " + "Please define CMAKE_C_COMPILER or enable the C language.") + endif() + if(CMAKE_CXX_COMPILER) + set(_conan_cpp_compiler "\"cpp\":\"${CMAKE_CXX_COMPILER}\"") + set_conan_compiler_if_appleclang(CXX c++ _conan_cpp_compiler) + list(APPEND _conan_compilers_list ${_conan_cpp_compiler}) + else() + message(WARNING "CMake-Conan: The C++ compiler is not defined. " + "Please define CMAKE_CXX_COMPILER or enable the C++ language.") + endif() + if(CMAKE_RC_COMPILER) + set(_conan_rc_compiler "\"rc\":\"${CMAKE_RC_COMPILER}\"") + list(APPEND _conan_compilers_list ${_conan_rc_compiler}) + # Not necessary to warn if RC not defined + endif() + if(NOT "x${_conan_compilers_list}" STREQUAL "x") + string(REPLACE ";" "," _conan_compilers_list "${_conan_compilers_list}") + string(APPEND PROFILE "tools.build:compiler_executables={${_conan_compilers_list}}\n") + endif() + unset(_conan_c_compiler) + unset(_conan_cpp_compiler) + unset(_conan_rc_compiler) + unset(_conan_compilers_list) +endmacro() + + +function(detect_host_profile output_file) + detect_os(MYOS MYOS_API_LEVEL MYOS_SDK MYOS_SUBSYSTEM MYOS_VERSION) + detect_arch(MYARCH) + detect_compiler(MYCOMPILER MYCOMPILER_VERSION MYCOMPILER_RUNTIME MYCOMPILER_RUNTIME_TYPE) + detect_cxx_standard(MYCXX_STANDARD) + detect_lib_cxx(MYLIB_CXX) + detect_build_type(MYBUILD_TYPE) + + set(PROFILE "") + string(APPEND PROFILE "[settings]\n") + if(MYARCH) + string(APPEND PROFILE arch=${MYARCH} "\n") + endif() + if(MYOS) + string(APPEND PROFILE os=${MYOS} "\n") + endif() + if(MYOS_API_LEVEL) + string(APPEND PROFILE os.api_level=${MYOS_API_LEVEL} "\n") + endif() + if(MYOS_VERSION) + string(APPEND PROFILE os.version=${MYOS_VERSION} "\n") + endif() + if(MYOS_SDK) + string(APPEND PROFILE os.sdk=${MYOS_SDK} "\n") + endif() + if(MYOS_SUBSYSTEM) + string(APPEND PROFILE os.subsystem=${MYOS_SUBSYSTEM} "\n") + endif() + if(MYCOMPILER) + string(APPEND PROFILE compiler=${MYCOMPILER} "\n") + endif() + if(MYCOMPILER_VERSION) + string(APPEND PROFILE compiler.version=${MYCOMPILER_VERSION} "\n") + endif() + if(MYCOMPILER_RUNTIME) + string(APPEND PROFILE compiler.runtime=${MYCOMPILER_RUNTIME} "\n") + endif() + if(MYCOMPILER_RUNTIME_TYPE) + string(APPEND PROFILE compiler.runtime_type=${MYCOMPILER_RUNTIME_TYPE} "\n") + endif() + if(MYCXX_STANDARD) + string(APPEND PROFILE compiler.cppstd=${MYCXX_STANDARD} "\n") + endif() + if(MYLIB_CXX) + string(APPEND PROFILE compiler.libcxx=${MYLIB_CXX} "\n") + endif() + if(MYBUILD_TYPE) + string(APPEND PROFILE "build_type=${MYBUILD_TYPE}\n") + endif() + + if(NOT DEFINED output_file) + set(_FN "${CMAKE_BINARY_DIR}/profile") + else() + set(_FN ${output_file}) + endif() + + string(APPEND PROFILE "[conf]\n") + string(APPEND PROFILE "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}\n") + + # propagate compilers via profile + append_compiler_executables_configuration() + + if(MYOS STREQUAL "Android") + string(APPEND PROFILE "tools.android:ndk_path=${CMAKE_ANDROID_NDK}\n") + endif() + + message(STATUS "CMake-Conan: Creating profile ${_FN}") + file(WRITE ${_FN} ${PROFILE}) + message(STATUS "CMake-Conan: Profile: \n${PROFILE}") +endfunction() + + +function(conan_profile_detect_default) + message(STATUS "CMake-Conan: Checking if a default profile exists") + execute_process(COMMAND ${CONAN_COMMAND} profile path default + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + ECHO_OUTPUT_VARIABLE + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + if(NOT ${return_code} EQUAL "0") + message(STATUS "CMake-Conan: The default profile doesn't exist, detecting it.") + execute_process(COMMAND ${CONAN_COMMAND} profile detect + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + ECHO_OUTPUT_VARIABLE + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() +endfunction() + + +function(conan_install) + cmake_parse_arguments(ARGS CONAN_ARGS ${ARGN}) + set(CONAN_OUTPUT_FOLDER ${CMAKE_BINARY_DIR}/conan) + # Invoke "conan install" with the provided arguments + set(CONAN_ARGS ${CONAN_ARGS} -of=${CONAN_OUTPUT_FOLDER}) + message(STATUS "CMake-Conan: conan install ${CMAKE_SOURCE_DIR} ${CONAN_ARGS} ${ARGN}") + + + # In case there was not a valid cmake executable in the PATH, we inject the + # same we used to invoke the provider to the PATH + if(DEFINED PATH_TO_CMAKE_BIN) + set(_OLD_PATH $ENV{PATH}) + set(ENV{PATH} "$ENV{PATH}:${PATH_TO_CMAKE_BIN}") + endif() + + execute_process(COMMAND ${CONAN_COMMAND} install ${CMAKE_SOURCE_DIR} ${CONAN_ARGS} ${ARGN} --format=json + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + if(DEFINED PATH_TO_CMAKE_BIN) + set(ENV{PATH} "${_OLD_PATH}") + endif() + + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan install failed='${return_code}'") + endif() + + # the files are generated in a folder that depends on the layout used, if + # one is specified, but we don't know a priori where this is. + # TODO: this can be made more robust if Conan can provide this in the json output + string(JSON CONAN_GENERATORS_FOLDER GET "${conan_stdout}" graph nodes 0 generators_folder) + cmake_path(CONVERT ${CONAN_GENERATORS_FOLDER} TO_CMAKE_PATH_LIST CONAN_GENERATORS_FOLDER) + # message("conan stdout: ${conan_stdout}") + message(STATUS "CMake-Conan: CONAN_GENERATORS_FOLDER=${CONAN_GENERATORS_FOLDER}") + set_property(GLOBAL PROPERTY CONAN_GENERATORS_FOLDER "${CONAN_GENERATORS_FOLDER}") + # reconfigure on conanfile changes + string(JSON CONANFILE GET "${conan_stdout}" graph nodes 0 label) + message(STATUS "CMake-Conan: CONANFILE=${CMAKE_SOURCE_DIR}/${CONANFILE}") + set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/${CONANFILE}") + # success + set_property(GLOBAL PROPERTY CONAN_INSTALL_SUCCESS TRUE) + +endfunction() + + +function(conan_get_version conan_command conan_current_version) + execute_process( + COMMAND ${conan_command} --version + OUTPUT_VARIABLE conan_output + RESULT_VARIABLE conan_result + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(conan_result) + message(FATAL_ERROR "CMake-Conan: Error when trying to run Conan") + endif() + + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" conan_version ${conan_output}) + set(${conan_current_version} ${conan_version} PARENT_SCOPE) +endfunction() + + +function(conan_version_check) + set(options ) + set(oneValueArgs MINIMUM CURRENT) + set(multiValueArgs ) + cmake_parse_arguments(CONAN_VERSION_CHECK + "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT CONAN_VERSION_CHECK_MINIMUM) + message(FATAL_ERROR "CMake-Conan: Required parameter MINIMUM not set!") + endif() + if(NOT CONAN_VERSION_CHECK_CURRENT) + message(FATAL_ERROR "CMake-Conan: Required parameter CURRENT not set!") + endif() + + if(CONAN_VERSION_CHECK_CURRENT VERSION_LESS CONAN_VERSION_CHECK_MINIMUM) + message(FATAL_ERROR "CMake-Conan: Conan version must be ${CONAN_VERSION_CHECK_MINIMUM} or later") + endif() +endfunction() + + +macro(construct_profile_argument argument_variable profile_list) + set(${argument_variable} "") + if("${profile_list}" STREQUAL "CONAN_HOST_PROFILE") + set(_arg_flag "--profile:host=") + elseif("${profile_list}" STREQUAL "CONAN_BUILD_PROFILE") + set(_arg_flag "--profile:build=") + endif() + + set(_profile_list "${${profile_list}}") + list(TRANSFORM _profile_list REPLACE "auto-cmake" "${CMAKE_BINARY_DIR}/conan_host_profile") + list(TRANSFORM _profile_list PREPEND ${_arg_flag}) + set(${argument_variable} ${_profile_list}) + + unset(_arg_flag) + unset(_profile_list) +endmacro() + + +macro(conan_provide_dependency method package_name) + set_property(GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED TRUE) + get_property(_conan_install_success GLOBAL PROPERTY CONAN_INSTALL_SUCCESS) + if(NOT _conan_install_success) + find_program(CONAN_COMMAND "conan" REQUIRED) + conan_get_version(${CONAN_COMMAND} CONAN_CURRENT_VERSION) + conan_version_check(MINIMUM ${CONAN_MINIMUM_VERSION} CURRENT ${CONAN_CURRENT_VERSION}) + message(STATUS "CMake-Conan: first find_package() found. Installing dependencies with Conan") + if("default" IN_LIST CONAN_HOST_PROFILE OR "default" IN_LIST CONAN_BUILD_PROFILE) + conan_profile_detect_default() + endif() + if("auto-cmake" IN_LIST CONAN_HOST_PROFILE) + detect_host_profile(${CMAKE_BINARY_DIR}/conan_host_profile) + endif() + construct_profile_argument(_host_profile_flags CONAN_HOST_PROFILE) + construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE) + if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py") + file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile) + if(NOT "${outfile}" MATCHES ".*CMakeDeps.*") + message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile") + endif() + set(generator "") + elseif (EXISTS "${CMAKE_SOURCE_DIR}/conanfile.txt") + file(READ "${CMAKE_SOURCE_DIR}/conanfile.txt" outfile) + if(NOT "${outfile}" MATCHES ".*CMakeDeps.*") + message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile. " + "Please define the generator as it will be mandatory in the future") + endif() + set(generator "-g;CMakeDeps") + endif() + get_property(_multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(NOT _multiconfig_generator) + message(STATUS "CMake-Conan: Installing single configuration ${CMAKE_BUILD_TYPE}") + conan_install(${_host_profile_flags} ${_build_profile_flags} ${CONAN_INSTALL_ARGS} ${generator}) + else() + message(STATUS "CMake-Conan: Installing both Debug and Release") + conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Release ${CONAN_INSTALL_ARGS} ${generator}) + conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Debug ${CONAN_INSTALL_ARGS} ${generator}) + endif() + unset(_host_profile_flags) + unset(_build_profile_flags) + unset(_multiconfig_generator) + unset(_conan_install_success) + else() + message(STATUS "CMake-Conan: find_package(${ARGV1}) found, 'conan install' already ran") + unset(_conan_install_success) + endif() + + get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER) + + # Ensure that we consider Conan-provided packages ahead of any other, + # irrespective of other settings that modify the search order or search paths + # This follows the guidelines from the find_package documentation + # (https://cmake.org/cmake/help/latest/command/find_package.html): + # find_package ( PATHS paths... NO_DEFAULT_PATH) + # find_package () + + # Filter out `REQUIRED` from the argument list, as the first call may fail + set(_find_args_${package_name} "${ARGN}") + list(REMOVE_ITEM _find_args_${package_name} "REQUIRED") + if(NOT "MODULE" IN_LIST _find_args_${package_name}) + find_package(${package_name} ${_find_args_${package_name}} BYPASS_PROVIDER PATHS "${_conan_generators_folder}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + unset(_find_args_${package_name}) + endif() + + # Invoke find_package a second time - if the first call succeeded, + # this will simply reuse the result. If not, fall back to CMake default search + # behaviour, also allowing modules to be searched. + if(NOT ${package_name}_FOUND) + list(FIND CMAKE_MODULE_PATH "${_conan_generators_folder}" _index) + if(_index EQUAL -1) + list(PREPEND CMAKE_MODULE_PATH "${_conan_generators_folder}") + endif() + unset(_index) + find_package(${package_name} ${ARGN} BYPASS_PROVIDER) + list(REMOVE_ITEM CMAKE_MODULE_PATH "${_conan_generators_folder}") + endif() +endmacro() + + +cmake_language( + SET_DEPENDENCY_PROVIDER conan_provide_dependency + SUPPORTED_METHODS FIND_PACKAGE +) + + +macro(conan_provide_dependency_check) + set(_CONAN_PROVIDE_DEPENDENCY_INVOKED FALSE) + get_property(_CONAN_PROVIDE_DEPENDENCY_INVOKED GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED) + if(NOT _CONAN_PROVIDE_DEPENDENCY_INVOKED) + message(WARNING "Conan is correctly configured as dependency provider, " + "but Conan has not been invoked. Please add at least one " + "call to `find_package()`.") + if(DEFINED CONAN_COMMAND) + # supress warning in case `CONAN_COMMAND` was specified but unused. + set(_CONAN_COMMAND ${CONAN_COMMAND}) + unset(_CONAN_COMMAND) + endif() + endif() + unset(_CONAN_PROVIDE_DEPENDENCY_INVOKED) +endmacro() + + +# Add a deferred call at the end of processing the top-level directory +# to check if the dependency provider was invoked at all. +cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" CALL conan_provide_dependency_check) + +# Configurable variables for Conan profiles +set(CONAN_HOST_PROFILE "default;auto-cmake" CACHE STRING "Conan host profile") +set(CONAN_BUILD_PROFILE "default" CACHE STRING "Conan build profile") +set(CONAN_INSTALL_ARGS "--build=missing" CACHE STRING "Command line arguments for conan install") + +find_program(_cmake_program NAMES cmake NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) +if(NOT _cmake_program) + get_filename_component(PATH_TO_CMAKE_BIN "${CMAKE_COMMAND}" DIRECTORY) + set(PATH_TO_CMAKE_BIN "${PATH_TO_CMAKE_BIN}" CACHE INTERNAL "Path where the CMake executable is") +endif() + +cmake_policy(POP) From 6f7a16cf9e15a72bf2d14542fc4fb2547477b7e1 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 16:12:02 +0300 Subject: [PATCH 015/134] [ci][docker] Use ubuntu 24.04 --- .github/workflows/coverage.yml | 2 +- .github/workflows/sanitizers.yml | 2 +- .github/workflows/style.yml | 2 +- Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 067a37c027..ba57c158f3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -18,7 +18,7 @@ jobs: config: - { name: "Coverage C++", - os: ubuntu-22.04, + os: ubuntu-24.04, build_type: "Debug", cc: "gcc", cxx: "g++", diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 62f49aa948..3603a5996f 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -18,7 +18,7 @@ jobs: config: - { name: "Sanitizer - address", - os: ubuntu-22.04, + os: ubuntu-24.04, sanitizer: "address", cc: clang, cxx: clang++, diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index c74ea2fd24..01ef879308 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -10,7 +10,7 @@ on: jobs: check_pr_commits: name: Check commit messages - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: GS Commit Message Checker diff --git a/Dockerfile b/Dockerfile index b9767bdafe..35662afa82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal as base +FROM ubuntu:noble as base ENV CCACHE_DIR=/ccache USER root From 5b5ca92d18161d99bfda0d524583102a9ebd9219 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 16:12:48 +0300 Subject: [PATCH 016/134] [build] Fix performance tests build --- sc-memory/sc-memory/tests/performance/CMakeLists.txt | 2 +- sc-tools/sc-server/tests/units/performance/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sc-memory/sc-memory/tests/performance/CMakeLists.txt b/sc-memory/sc-memory/tests/performance/CMakeLists.txt index ed0d30362e..ef1ae729be 100644 --- a/sc-memory/sc-memory/tests/performance/CMakeLists.txt +++ b/sc-memory/sc-memory/tests/performance/CMakeLists.txt @@ -4,5 +4,5 @@ add_executable(sc-memory-performance-tests ${SOURCES}) target_link_libraries(sc-memory-performance-tests LINK_PRIVATE sc-memory - LINK_PRIVATE benchmark + LINK_PRIVATE benchmark::benchmark ) diff --git a/sc-tools/sc-server/tests/units/performance/CMakeLists.txt b/sc-tools/sc-server/tests/units/performance/CMakeLists.txt index 7173510f52..2a2c8ec185 100644 --- a/sc-tools/sc-server/tests/units/performance/CMakeLists.txt +++ b/sc-tools/sc-server/tests/units/performance/CMakeLists.txt @@ -6,7 +6,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS add_executable(sc-server-performance-tests ${SOURCES}) target_link_libraries(sc-server-performance-tests LINK_PRIVATE sc-server-lib - LINK_PRIVATE benchmark + LINK_PRIVATE benchmark::benchmark ) target_include_directories(sc-server-performance-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include From 1befbe84da3f05c78d44f2a0ebd8ca3b3626b786 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 16:14:48 +0300 Subject: [PATCH 017/134] [ci][docs] Allow build scope --- .github/workflows/style.yml | 2 +- CONTRIBUTING.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 01ef879308..24a551b063 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -19,7 +19,7 @@ jobs: uses: GsActions/commit-message-checker@v2 with: # A regex pattern to check if a commit message is valid. - pattern: "((\\[(builder|changelog|ci|thirdparty|config|doc|docs|docker|kpm|test|tests|memory|tools|review|refactor|scripts|server|git|cmake)\\])+(.)+)|(Review fixes)$" + pattern: "((\\[(builder|changelog|ci|thirdparty|config|doc|docs|docker|kpm|test|tests|memory|tools|review|refactor|scripts|server|git|cmake|build)\\])+(.)+)|(Review fixes)$" # Expression flags change how the expression is interpreted. flags: # optional, default is gm # A error message which will be returned in case of an error. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6de2feafad..46575e7b00 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,6 +52,7 @@ Examples: Possible tags: + * `[build]` - changes in build system; * `[memory]` - changes in `sc-memory` module; * `[kpm]` - changes in `sc-kpm` module; * `[tests]` or `[test]` - changes in tests; From 3870c7b365b4a964f13a582b343a828cb557a8f8 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 16:27:23 +0300 Subject: [PATCH 018/134] [scripts][ci] Remove pushd and popd for coverage --- scripts/ci/export_coverage.sh | 4 ---- scripts/ci/prepare_coverage.sh | 4 ---- 2 files changed, 8 deletions(-) diff --git a/scripts/ci/export_coverage.sh b/scripts/ci/export_coverage.sh index 91c796a9d0..dc1b93182b 100755 --- a/scripts/ci/export_coverage.sh +++ b/scripts/ci/export_coverage.sh @@ -2,10 +2,6 @@ set -eo pipefail -pushd build - lcov -c -d . -o coverage.info lcov -a base_coverage.info -a coverage.info -o coverage.info lcov -r coverage.info "/usr/*" -o coverage.info - -popd diff --git a/scripts/ci/prepare_coverage.sh b/scripts/ci/prepare_coverage.sh index 9b028abbeb..cf8e5809f9 100755 --- a/scripts/ci/prepare_coverage.sh +++ b/scripts/ci/prepare_coverage.sh @@ -4,8 +4,4 @@ set -eo pipefail sudo apt-get install lcov -pushd build - lcov -c -i -d . -o base_coverage.info - -popd From fcdb1c46599eb5f7fca7f404ca9fe2f5f99ea588 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 16:30:14 +0300 Subject: [PATCH 019/134] [memory][tests] Include missed algoritm lib --- .../sc-memory/tests/sc-memory/units/common/test_sc_type.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sc-memory/sc-memory/tests/sc-memory/units/common/test_sc_type.cpp b/sc-memory/sc-memory/tests/sc-memory/units/common/test_sc_type.cpp index 08f6c016d4..c0b6134f7a 100644 --- a/sc-memory/sc-memory/tests/sc-memory/units/common/test_sc_type.cpp +++ b/sc-memory/sc-memory/tests/sc-memory/units/common/test_sc_type.cpp @@ -6,6 +6,7 @@ #include +#include #include #include From a034cfa8c74c7cd08fc99bd76eb9784328ff4c72 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 7 Oct 2024 16:43:39 +0300 Subject: [PATCH 020/134] [docker] Fix bin path in docker file --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 35662afa82..d51a1242b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ FROM base AS final COPY --from=builder /sc-machine/requirements.txt /sc-machine/requirements.txt COPY --from=builder /sc-machine/scripts /sc-machine/scripts COPY --from=builder /sc-machine/sc-machine.ini /sc-machine/sc-machine.ini -COPY --from=builder /sc-machine/bin /sc-machine/bin +COPY --from=builder /sc-machine/build/bin /sc-machine/build/bin RUN /sc-machine/scripts/install_deps_python.sh WORKDIR /sc-machine/scripts From c089cdbbab2b7db19eed18a4af6c92cbb5fa036d Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 8 Oct 2024 11:27:54 +0300 Subject: [PATCH 021/134] [cmake] Cache find glib --- cmake/FindGLIB.cmake | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake index 91cef40634..f4a1e581db 100644 --- a/cmake/FindGLIB.cmake +++ b/cmake/FindGLIB.cmake @@ -1,18 +1,27 @@ -macro(FindGLIB) +function(FindGLIB) + if (glib_CACHED) + message(STATUS "GLib found in cache.") + return() + endif() + find_package(glib QUIET) if (NOT glib_FOUND) - message("Trying to use system-installed glib") + message(STATUS "Trying to use system-installed glib") find_package(PkgConfig REQUIRED) pkg_search_module(GLIB2 REQUIRED glib-2.0) pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) if (NOT GLIB2_FOUND OR NOT GLIB2_MODULE_FOUND) - error("glib2 not found!") + message(FATAL_ERROR "glib2 not found!") endif() - set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS}) - set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS}) + set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS} CACHE STRING "Include directories for GLib") + set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS} CACHE STRING "Libraries for GLib") + + set(glib_CACHED TRUE CACHE BOOL "GLib found") + else() + message(STATUS "GLib is already found.") endif() -endmacro() +endfunction() From a37631fd26ed8d7d18526da548a92bd5723b801e Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 8 Oct 2024 11:28:10 +0300 Subject: [PATCH 022/134] [docs] Correct typos in build system --- docs/build/build_system.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index 778bba2982..a9524cdd77 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -53,7 +53,7 @@ The package artifacts are available [here](https://github.com/ostis-ai/sc-machin # you can override this variable via -D_PATH_SC_MACHINE_PATH or CMakeUserPreset.json / CMakePreset.json files set(_SC_MACHINE_PATH "/location/to/sc-machine--" CACHE PATH "sc-machine installation path") -# can be overriden using env variables as well +# can be override using env variables as well if(DEFINED ENV{_SC_MACHINE_PATH}) set(_SC_MACHINE_PATH "$ENV{_SC_MACHINE_PATH}") endif() @@ -140,7 +140,7 @@ target_link_libraries(wave-find-path sc-machine::sc-memory) ``` ```cpp -#include "sc-memory/sc_addr.hpp" +#include ScAddr graph, rrel_arcs, rrel_nodes; ``` @@ -164,7 +164,7 @@ It's almost always problematic to edit a project while also consuming it as a li ```sh conan editable add conan editable list -# sc-machine of the corersponding version should be in the output +# sc-machine of the corresponding version should be in the output # make changes in the project and run a rebuild cmake --preset debug-conan # using a debug build since that would allow us to step into the library's code while debugging @@ -193,6 +193,7 @@ You can use convenience scripts provided in our repo (`scripts/install_deps_ubun ### Testing Conan package definition It is possible to write tests for the Conan packaging using [local package development flow](https://docs.conan.io/2/tutorial/developing_packages/local_package_development_flow.html). + ## Troubleshooting - If you encounter issues with Conan, try clearing the Conan cache: `conan cache clean` From bac1239989cc34a9bbc1b11f11d24bbedb405bd9 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 8 Oct 2024 15:44:29 +0300 Subject: [PATCH 023/134] [cmake][scripts] Create custom target to generate server and builder kb; don't use configure ini --- cmake/FindGLIB.cmake | 4 ++-- sc-memory/sc-core/tests/CMakeLists.txt | 8 +++----- sc-memory/sc-core/tests/test_defines.hpp.in | 3 --- .../test_sc_dictionary_fs_memory_api.cpp | 2 -- .../units/fs-storage/test_sc_fs_memory_api.cpp | 2 -- sc-tools/sc-builder/.gitignore | 2 -- sc-tools/sc-builder/CMakeLists.txt | 8 +++----- sc-tools/sc-builder/src/builder_defines.hpp | 1 + sc-tools/sc-builder/src/builder_defines.hpp.in | 1 - sc-tools/sc-builder/tests/CMakeLists.txt | 13 ++++++++++--- sc-tools/sc-builder/tests/test_defines.hpp.in | 6 ------ .../sc-builder/tests/units/builder_test.hpp | 2 -- .../units/repo_path_collector_test_api.hpp | 2 -- sc-tools/sc-machine-runner/.gitignore | 1 - sc-tools/sc-machine-runner/tests/CMakeLists.txt | 10 +++++----- .../sc-machine-runner/tests/test_defines.hpp.in | 3 --- .../sc-machine-runner/tests/units/test_base.cpp | 2 -- sc-tools/sc-server/.gitignore | 1 - sc-tools/sc-server/tests/CMakeLists.txt | 17 +++++++++-------- .../tests/units/api/sc_server_test.hpp | 2 -- .../units/performance/units/sc_server_test.hpp | 1 - scripts/run_tests.sh | 3 --- 22 files changed, 33 insertions(+), 61 deletions(-) delete mode 100644 sc-memory/sc-core/tests/test_defines.hpp.in delete mode 100644 sc-tools/sc-builder/.gitignore create mode 100644 sc-tools/sc-builder/src/builder_defines.hpp delete mode 100644 sc-tools/sc-builder/src/builder_defines.hpp.in delete mode 100644 sc-tools/sc-builder/tests/test_defines.hpp.in delete mode 100644 sc-tools/sc-machine-runner/.gitignore delete mode 100644 sc-tools/sc-machine-runner/tests/test_defines.hpp.in delete mode 100644 sc-tools/sc-server/.gitignore diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake index f4a1e581db..d3f17df21c 100644 --- a/cmake/FindGLIB.cmake +++ b/cmake/FindGLIB.cmake @@ -1,6 +1,6 @@ function(FindGLIB) if (glib_CACHED) - message(STATUS "GLib found in cache.") + message(STATUS "GLib found in cache") return() endif() @@ -22,6 +22,6 @@ function(FindGLIB) set(glib_CACHED TRUE CACHE BOOL "GLib found") else() - message(STATUS "GLib is already found.") + message(STATUS "GLib is already found") endif() endfunction() diff --git a/sc-memory/sc-core/tests/CMakeLists.txt b/sc-memory/sc-core/tests/CMakeLists.txt index 7428ba6ba8..7d14686b1e 100644 --- a/sc-memory/sc-core/tests/CMakeLists.txt +++ b/sc-memory/sc-core/tests/CMakeLists.txt @@ -25,12 +25,10 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/fs-storage DEPENDS ${glib_LIBRARIES} sc-memory INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} ) +target_compile_definitions(sc-core-fs-storage-tests PRIVATE + SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH="${CMAKE_CURRENT_SOURCE_DIR}/units/fs-storage/deprecated-kb" +) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-core-fs-storage-tests) endif() - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/test_defines.hpp.in" - "${CMAKE_CURRENT_SOURCE_DIR}/units/fs-storage/test_defines.hpp" -) diff --git a/sc-memory/sc-core/tests/test_defines.hpp.in b/sc-memory/sc-core/tests/test_defines.hpp.in deleted file mode 100644 index 74dafa48a2..0000000000 --- a/sc-memory/sc-core/tests/test_defines.hpp.in +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/units/fs-storage/deprecated-kb" diff --git a/sc-memory/sc-core/tests/units/fs-storage/test_sc_dictionary_fs_memory_api.cpp b/sc-memory/sc-core/tests/units/fs-storage/test_sc_dictionary_fs_memory_api.cpp index 4c9671cd04..e0c0ab8e1c 100644 --- a/sc-memory/sc-core/tests/units/fs-storage/test_sc_dictionary_fs_memory_api.cpp +++ b/sc-memory/sc-core/tests/units/fs-storage/test_sc_dictionary_fs_memory_api.cpp @@ -6,8 +6,6 @@ #include -#include "test_defines.hpp" - extern "C" { #include diff --git a/sc-memory/sc-core/tests/units/fs-storage/test_sc_fs_memory_api.cpp b/sc-memory/sc-core/tests/units/fs-storage/test_sc_fs_memory_api.cpp index 964924d0d5..a3ddd07e4d 100644 --- a/sc-memory/sc-core/tests/units/fs-storage/test_sc_fs_memory_api.cpp +++ b/sc-memory/sc-core/tests/units/fs-storage/test_sc_fs_memory_api.cpp @@ -6,8 +6,6 @@ #include -#include "test_defines.hpp" - extern "C" { #include diff --git a/sc-tools/sc-builder/.gitignore b/sc-tools/sc-builder/.gitignore deleted file mode 100644 index 2601b710b4..0000000000 --- a/sc-tools/sc-builder/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -tests/units/test_defines.hpp -src/builder_defines.hpp diff --git a/sc-tools/sc-builder/CMakeLists.txt b/sc-tools/sc-builder/CMakeLists.txt index 19ed55ce65..b606e9fd60 100644 --- a/sc-tools/sc-builder/CMakeLists.txt +++ b/sc-tools/sc-builder/CMakeLists.txt @@ -1,10 +1,5 @@ set(SC_BUILDER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src") -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/src/builder_defines.hpp.in" - "${CMAKE_CURRENT_SOURCE_DIR}/src/builder_defines.hpp" -) - file(GLOB SOURCES CONFIGURE_DEPENDS "src/*.cpp" "src/*.hpp" "include/sc-builder/*.hpp" @@ -25,6 +20,9 @@ target_include_directories(sc-builder-lib PUBLIC $ PUBLIC $ ) +target_compile_definitions(sc-builder-lib PRIVATE + SC_PREPARE_BUILD_SCRIPTS_PATH="${SC_MACHINE_ROOT}/scripts" +) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} diff --git a/sc-tools/sc-builder/src/builder_defines.hpp b/sc-tools/sc-builder/src/builder_defines.hpp new file mode 100644 index 0000000000..6b47d59797 --- /dev/null +++ b/sc-tools/sc-builder/src/builder_defines.hpp @@ -0,0 +1 @@ +#define SC_PREPARE_BUILD_SCRIPTS_PATH "/Users/nikitazotov/Development/apps/ostis/ostis-apps/ostis-example-app/ostis-web-platform/sc-machine/scripts" diff --git a/sc-tools/sc-builder/src/builder_defines.hpp.in b/sc-tools/sc-builder/src/builder_defines.hpp.in deleted file mode 100644 index 0cc0629228..0000000000 --- a/sc-tools/sc-builder/src/builder_defines.hpp.in +++ /dev/null @@ -1 +0,0 @@ -#define SC_PREPARE_BUILD_SCRIPTS_PATH "${SC_MACHINE_ROOT}/scripts" diff --git a/sc-tools/sc-builder/tests/CMakeLists.txt b/sc-tools/sc-builder/tests/CMakeLists.txt index ab91112825..666ff6df50 100644 --- a/sc-tools/sc-builder/tests/CMakeLists.txt +++ b/sc-tools/sc-builder/tests/CMakeLists.txt @@ -1,6 +1,6 @@ -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/test_defines.hpp.in" - "${CMAKE_CURRENT_SOURCE_DIR}/units/test_defines.hpp" +add_custom_target(sc-builder-tests-kb-generator ALL + COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder" -i "${CMAKE_CURRENT_SOURCE_DIR}/kb" -o "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder-test-repo" --clear + DEPENDS sc-builder ) make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units @@ -8,6 +8,13 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units DEPENDS sc-builder-lib INCLUDES ${SC_BUILDER_SRC} ) +add_dependencies(sc-builder-tests sc-builder-tests-kb-generator) +target_compile_definitions(sc-builder-tests PRIVATE + SC_BUILDER_REPO_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder-test-repo" + SC_BUILDER_KB="${CMAKE_CURRENT_SOURCE_DIR}/kb" + SC_BUILDER_INI="${CMAKE_CURRENT_SOURCE_DIR}/sc-builder-test.ini" + SC_BUILDER_TEST_REPOS="${CMAKE_CURRENT_SOURCE_DIR}/repos" +) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-builder-tests) diff --git a/sc-tools/sc-builder/tests/test_defines.hpp.in b/sc-tools/sc-builder/tests/test_defines.hpp.in deleted file mode 100644 index 0d4fc762b0..0000000000 --- a/sc-tools/sc-builder/tests/test_defines.hpp.in +++ /dev/null @@ -1,6 +0,0 @@ -#define SC_BUILDER_KB_BIN "${SC_BIN_PATH}/sc-builder-test-repo" -#define SC_BUILDER_REPO_PATH "${CMAKE_CURRENT_LIST_DIR}/repo.path" -#define SC_BUILDER_KB "${CMAKE_CURRENT_LIST_DIR}/kb" -#define SC_BUILDER_INI "${CMAKE_CURRENT_LIST_DIR}/sc-builder-test.ini" -#define SC_BUILDER_CONFIGS "${CMAKE_CURRENT_LIST_DIR}" -#define SC_BUILDER_TEST_REPOS "${CMAKE_CURRENT_LIST_DIR}/repos" diff --git a/sc-tools/sc-builder/tests/units/builder_test.hpp b/sc-tools/sc-builder/tests/units/builder_test.hpp index 75ce3e5a9a..77a222d799 100644 --- a/sc-tools/sc-builder/tests/units/builder_test.hpp +++ b/sc-tools/sc-builder/tests/units/builder_test.hpp @@ -14,8 +14,6 @@ #include #include -#include "test_defines.hpp" - class ScBuilderTest : public testing::Test { protected: diff --git a/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp b/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp index 43752b3035..13b2657e3c 100644 --- a/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp +++ b/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp @@ -10,8 +10,6 @@ #include "sc_repo_path_collector.hpp" -#include "test_defines.hpp" - #define TEST_REPOS_KB SC_BUILDER_TEST_REPOS "/kb" class ScRepoPathCollectorTestAPI : public testing::Test diff --git a/sc-tools/sc-machine-runner/.gitignore b/sc-tools/sc-machine-runner/.gitignore deleted file mode 100644 index 1a068079d5..0000000000 --- a/sc-tools/sc-machine-runner/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tests/units/test_defines.hpp diff --git a/sc-tools/sc-machine-runner/tests/CMakeLists.txt b/sc-tools/sc-machine-runner/tests/CMakeLists.txt index e7fb17ecbf..191078130a 100644 --- a/sc-tools/sc-machine-runner/tests/CMakeLists.txt +++ b/sc-tools/sc-machine-runner/tests/CMakeLists.txt @@ -1,12 +1,12 @@ -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/test_defines.hpp.in" - "${CMAKE_CURRENT_SOURCE_DIR}/units/test_defines.hpp" -) - make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units NAME sc-machine-tests DEPENDS sc-machine-runner ) +target_compile_definitions(sc-machine-tests PRIVATE + SC_MACHINE_REPO_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-machine-test-repo" + SC_MACHINE_EXTENSIONS="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/kb" + SC_MACHINE_INI="${CMAKE_CURRENT_SOURCE_DIR}/sc-machine-test.ini" +) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-machine-tests) diff --git a/sc-tools/sc-machine-runner/tests/test_defines.hpp.in b/sc-tools/sc-machine-runner/tests/test_defines.hpp.in deleted file mode 100644 index 901cdaf8ee..0000000000 --- a/sc-tools/sc-machine-runner/tests/test_defines.hpp.in +++ /dev/null @@ -1,3 +0,0 @@ -#define SC_MACHINE_REPO_PATH "${SC_BIN_PATH}/sc-machine-test-repo" -#define SC_MACHINE_EXTENSIONS "${SC_BIN_PATH}/extensions" -#define SC_MACHINE_INI "${CMAKE_CURRENT_SOURCE_DIR}/sc-machine-test.ini" diff --git a/sc-tools/sc-machine-runner/tests/units/test_base.cpp b/sc-tools/sc-machine-runner/tests/units/test_base.cpp index 138f90720a..a4ee3c9962 100644 --- a/sc-tools/sc-machine-runner/tests/units/test_base.cpp +++ b/sc-tools/sc-machine-runner/tests/units/test_base.cpp @@ -6,8 +6,6 @@ #include -#include "test_defines.hpp" - #include #include diff --git a/sc-tools/sc-server/.gitignore b/sc-tools/sc-server/.gitignore deleted file mode 100644 index 7da492ad0f..0000000000 --- a/sc-tools/sc-server/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tests/units/api/test_defines.hpp diff --git a/sc-tools/sc-server/tests/CMakeLists.txt b/sc-tools/sc-server/tests/CMakeLists.txt index 01c8b993bc..ac8c340621 100644 --- a/sc-tools/sc-server/tests/CMakeLists.txt +++ b/sc-tools/sc-server/tests/CMakeLists.txt @@ -1,11 +1,6 @@ -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/test_defines.hpp.in" - "${CMAKE_CURRENT_SOURCE_DIR}/units/api/test_defines.hpp" -) - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/test_defines.hpp.in" - "${CMAKE_CURRENT_SOURCE_DIR}/units/performance/units/test_defines.hpp" +add_custom_target(sc-server-tests-kb-generator ALL + COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder" -i "${CMAKE_CURRENT_SOURCE_DIR}/kb" -o "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-server-test-repo" --clear + DEPENDS sc-builder ) make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/api @@ -13,6 +8,12 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/api DEPENDS sc-server-lib INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include" ) +add_dependencies(sc-server-tests sc-server-tests-kb-generator) +target_compile_definitions(sc-server-tests PRIVATE + SC_SERVER_REPO_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-server-test-repo" + SC_SERVER_EXTENSIONS="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/kb" + SC_SERVER_INI="${CMAKE_CURRENT_SOURCE_DIR}/sc-server-test.ini" +) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-server-tests) diff --git a/sc-tools/sc-server/tests/units/api/sc_server_test.hpp b/sc-tools/sc-server/tests/units/api/sc_server_test.hpp index c9b0c16b62..d73ac19603 100644 --- a/sc-tools/sc-server/tests/units/api/sc_server_test.hpp +++ b/sc-tools/sc-server/tests/units/api/sc_server_test.hpp @@ -13,8 +13,6 @@ #include #include -#include "test_defines.hpp" - #include "sc-server-impl/sc_server_impl.hpp" class ScServerTest : public testing::Test diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp b/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp index 60d989c30f..be897b648e 100644 --- a/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp +++ b/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp @@ -13,7 +13,6 @@ extern "C" #include } -#include "test_defines.hpp" #include "sc-client/sc_client.hpp" #include "sc-server-impl/sc_server_impl.hpp" diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 44f0debe97..d4cdceda6c 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -6,7 +6,4 @@ then source "$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)/set_vars.sh" fi -"${BINARY_PATH}/sc-builder" -i "${SC_MACHINE_PATH}/sc-tools/sc-builder/tests/repo.path" -o "${BINARY_PATH}/sc-builder-test-repo" --clear -f -"${BINARY_PATH}/sc-builder" -i "${SC_MACHINE_PATH}/sc-tools/sc-server/tests/kb" -o "${BINARY_PATH}/sc-server-test-repo" --clear -f - cd "${BUILD_PATH}" && ctest -C Debug -V From 08db1f6c23703f0f44e89164ef37d38e37ceafee Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 8 Oct 2024 16:10:42 +0300 Subject: [PATCH 024/134] [docker] Update binary path --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2efa2ba4a6..5c7049cc13 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,7 @@ services: # Use the commented env variable if you need to rebuild KB every startup. - "REBUILD_KB=${REBUILD_KB:-0}" - "KB_PATH=${KB_PATH:-/kb/repo.path}" - - "BINARY_PATH=/sc-machine/bin" + - "BINARY_PATH=/sc-machine/build/bin" - "CONFIG_PATH=/sc-machine/sc-machine.ini" command: - "run" From 9117962755bf333fb4422e2e43f0d86d5cda9fa9 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 8 Oct 2024 16:11:12 +0300 Subject: [PATCH 025/134] [ci] Update native ci; implement conan ci --- .github/workflows/conan.yml | 67 +++++++++++++++++++ .github/workflows/{main.yml => native.yml} | 2 +- .../tests/units/performance/CMakeLists.txt | 6 ++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/conan.yml rename .github/workflows/{main.yml => native.yml} (95%) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml new file mode 100644 index 0000000000..17e81f6273 --- /dev/null +++ b/.github/workflows/conan.yml @@ -0,0 +1,67 @@ +name: Tests + +on: + pull_request: + branches: [main] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + run_tests: + name: Conan build + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + config: + - { cc: "gcc", cxx: "g++" } + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Set up pipx + run: | + python -m pip install --user pipx + python -m pipx ensurepath + + - name: Set up Conan + run: | + pipx install conan + + - name: Install compilers + run: | + sudo apt-get install ninja-build + ./scripts/install_deps_ubuntu.sh --dev + + - name: Restore build caches + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} + + - name: Build sc-machine with tests + id: run_cmake + run: | + cmake --preset=release-with-tests-conan + cmake --build --preset release + + - name: Run sc-machine tests + id: run_tests + run: cd build && ctest -C Debug -V + + - name: Run sc-machine + id: run_sc_machine + run: | + mkdir kb + build/Release/bin/sc-builder -i kb -o kb.bin --clear -f + build/Release/bin/sc-server -t -c sc-machine.ini -r kb.bin + build/Release/bin/sc-machine -t -c sc-machine.ini -r kb.bin diff --git a/.github/workflows/main.yml b/.github/workflows/native.yml similarity index 95% rename from .github/workflows/main.yml rename to .github/workflows/native.yml index 2b095d8df3..a81835d9cf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/native.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-14, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] + os: [macos-14, ubuntu-22.04, ubuntu-24.04] build_type: ["Debug", "Release"] config: - { cc: "gcc", cxx: "g++" } diff --git a/sc-tools/sc-server/tests/units/performance/CMakeLists.txt b/sc-tools/sc-server/tests/units/performance/CMakeLists.txt index 2a2c8ec185..a80bd9b7c4 100644 --- a/sc-tools/sc-server/tests/units/performance/CMakeLists.txt +++ b/sc-tools/sc-server/tests/units/performance/CMakeLists.txt @@ -11,6 +11,12 @@ target_link_libraries(sc-server-performance-tests target_include_directories(sc-server-performance-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include ) +add_dependencies(sc-server-performance-tests sc-server-tests-kb-generator) +target_compile_definitions(sc-server-performance-tests PRIVATE + SC_SERVER_REPO_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-server-test-repo" + SC_SERVER_EXTENSIONS="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/kb" + SC_SERVER_INI="${CMAKE_CURRENT_SOURCE_DIR}/../../sc-server-test.ini" +) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-server-performance-tests) From a825c181bff4780875085f60ee3eb6c2d798266f Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 8 Oct 2024 17:24:21 +0300 Subject: [PATCH 026/134] [docker][scripts] Set extensions path --- Dockerfile | 1 + docker-compose.yml | 1 + scripts/docker_entrypoint.sh | 4 ++-- scripts/set_vars.sh | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d51a1242b2..2c445324b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,7 @@ COPY --from=builder /sc-machine/requirements.txt /sc-machine/requirements.txt COPY --from=builder /sc-machine/scripts /sc-machine/scripts COPY --from=builder /sc-machine/sc-machine.ini /sc-machine/sc-machine.ini COPY --from=builder /sc-machine/build/bin /sc-machine/build/bin +COPY --from=builder /sc-machine/build/lib /sc-machine/build/lib RUN /sc-machine/scripts/install_deps_python.sh WORKDIR /sc-machine/scripts diff --git a/docker-compose.yml b/docker-compose.yml index 5c7049cc13..32605e2997 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,6 +21,7 @@ services: - "REBUILD_KB=${REBUILD_KB:-0}" - "KB_PATH=${KB_PATH:-/kb/repo.path}" - "BINARY_PATH=/sc-machine/build/bin" + - "EXTENSIONS_PATH=/sc-machine/build/lib" - "CONFIG_PATH=/sc-machine/sc-machine.ini" command: - "run" diff --git a/scripts/docker_entrypoint.sh b/scripts/docker_entrypoint.sh index d74bcfa405..3659db2424 100755 --- a/scripts/docker_entrypoint.sh +++ b/scripts/docker_entrypoint.sh @@ -49,7 +49,7 @@ function start_server() { then # you should provide the config file path and host settings yourself in case you want to use custom options! echo "Using default arguments." - "$BINARY_PATH"/sc-server -c "$CONFIG_PATH" -h 0.0.0.0 -e "$BINARY_PATH/extensions" + "$BINARY_PATH"/sc-server -c "$CONFIG_PATH" -h 0.0.0.0 -e "$EXTENSIONS_PATH" else "$BINARY_PATH"/sc-server "$@" fi @@ -67,7 +67,7 @@ function start_machine { then # you should provide the config file path and host settings yourself in case you want to use custom options! echo "Using default arguments." - "$BINARY_PATH"/sc-machine -c "$CONFIG_PATH" -e "$BINARY_PATH/extensions" + "$BINARY_PATH"/sc-machine -c "$CONFIG_PATH" -e "$EXTENSIONS_PATH" else "$BINARY_PATH"/sc-machine "$@" fi diff --git a/scripts/set_vars.sh b/scripts/set_vars.sh index 411054f145..2821f2bff0 100644 --- a/scripts/set_vars.sh +++ b/scripts/set_vars.sh @@ -9,6 +9,7 @@ export PROBLEM_SOLVER_PATH="${PROBLEM_SOLVER_PATH:-${SC_MACHINE_PATH}}" # backwa export CXX_SOURCES_PATH="${PROBLEM_SOLVER_PATH:-${SC_MACHINE_PATH}}" export BUILD_PATH="${BUILD_PATH:-${ROOT_CMAKE_PATH}/build}" export BINARY_PATH="${BINARY_PATH:-${BUILD_PATH}/bin}" +export EXTENSIONS_PATH="${BINARY_PATH:-${BUILD_PATH}/lib}" export CONFIG_PATH="${CONFIG_PATH:-${SC_MACHINE_PATH}/sc-machine.ini}" export REPO_PATH="${REPO_PATH:-${SC_MACHINE_PATH}/repo.path}" From 84d89435a70fa4277bd916837531263312786156 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 11 Oct 2024 19:10:05 +0300 Subject: [PATCH 027/134] [cmake][tools][builder][tests] Fix repo path for generator after rebase --- sc-tools/sc-builder/src/gwf_translator.cpp | 2 -- sc-tools/sc-builder/tests/CMakeLists.txt | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sc-tools/sc-builder/src/gwf_translator.cpp b/sc-tools/sc-builder/src/gwf_translator.cpp index 695cfbc143..f916e13aa2 100644 --- a/sc-tools/sc-builder/src/gwf_translator.cpp +++ b/sc-tools/sc-builder/src/gwf_translator.cpp @@ -10,8 +10,6 @@ #include -#include "builder_defines.hpp" - #include "gwf_parser.hpp" #include "sc_scs_writer.hpp" #include "gwf_translator_constants.hpp" diff --git a/sc-tools/sc-builder/tests/CMakeLists.txt b/sc-tools/sc-builder/tests/CMakeLists.txt index 666ff6df50..891084fcbf 100644 --- a/sc-tools/sc-builder/tests/CMakeLists.txt +++ b/sc-tools/sc-builder/tests/CMakeLists.txt @@ -1,5 +1,5 @@ add_custom_target(sc-builder-tests-kb-generator ALL - COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder" -i "${CMAKE_CURRENT_SOURCE_DIR}/kb" -o "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder-test-repo" --clear + COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder" -i "${CMAKE_CURRENT_SOURCE_DIR}/repo.path" -o "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder-test-repo" --clear DEPENDS sc-builder ) @@ -10,7 +10,8 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units ) add_dependencies(sc-builder-tests sc-builder-tests-kb-generator) target_compile_definitions(sc-builder-tests PRIVATE - SC_BUILDER_REPO_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder-test-repo" + SC_BUILDER_KB_BIN="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder-test-repo" + SC_BUILDER_REPO_PATH="${CMAKE_CURRENT_SOURCE_DIR}/repo.path" SC_BUILDER_KB="${CMAKE_CURRENT_SOURCE_DIR}/kb" SC_BUILDER_INI="${CMAKE_CURRENT_SOURCE_DIR}/sc-builder-test.ini" SC_BUILDER_TEST_REPOS="${CMAKE_CURRENT_SOURCE_DIR}/repos" From 5e2ac89b5115b62d82860913545863737a0db3ec Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Sat, 12 Oct 2024 00:01:32 +0300 Subject: [PATCH 028/134] [cmake][wip] Separate libraries and extensions --- CMakeLists.txt | 13 ++++++++----- cmake/install.cmake | 2 +- sc-kpm/sc-search/CMakeLists.txt | 1 + sc-kpm/sc-ui/CMakeLists.txt | 1 + sc-kpm/sc-utils/CMakeLists.txt | 1 + sc-machine.ini | 2 +- sc-memory/sc-memory/tests/scs/CMakeLists.txt | 4 ++++ sc-tools/sc-server/CMakeLists.txt | 1 + 8 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7df1e69f4f..1587449fd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,20 @@ cmake_minimum_required(VERSION 3.24) set(CMAKE_CXX_STANDARD 17) project(sc-machine VERSION "0.9.0" LANGUAGES C CXX) -message(STATUS "Current Project Version: ${CMAKE_PROJECT_VERSION}") +message(STATUS "Current project version: ${CMAKE_PROJECT_VERSION}") site_name(www.ostis.net) cmake_policy(SET CMP0048 NEW) set(SC_MACHINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_MODULE_PATH "${SC_MACHINE_ROOT}/cmake") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -message(STATUS "Libary output directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(SC_EXTENSIONS_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/extensions) +make_directory(${SC_EXTENSIONS_DIRECTORY}) + message(STATUS "Binary output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") +message(STATUS "Libary output directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty") option(SC_BUILD_TESTS "Flag to build unit tests" OFF) @@ -99,9 +102,9 @@ message("Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, path: # Set up dynamic linking paths for our own libraries # For macOS, use @loader_path instead of $ORIGIN if(APPLE) - set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib") + set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib;@loader_path/../lib/extensions") else() - set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib") + set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib;$ORIGIN/../lib/extensions") endif() # Always use full RPATH diff --git a/cmake/install.cmake b/cmake/install.cmake index 78dd25f0ee..2264c2c534 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -11,7 +11,7 @@ install(TARGETS ) # a target set for things we don't want to export to the consumers -install(TARGETS sc-server-lib EXPORT privateExport LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS sc-kpm-search sc-kpm-utils sc-kpm-ui sc-server-lib EXPORT privateExport LIBRARY DESTINATION lib/extensions) install(EXPORT sc-machineExport FILE sc-machineTargets.cmake diff --git a/sc-kpm/sc-search/CMakeLists.txt b/sc-kpm/sc-search/CMakeLists.txt index 372f1ebcab..1560de1b0a 100644 --- a/sc-kpm/sc-search/CMakeLists.txt +++ b/sc-kpm/sc-search/CMakeLists.txt @@ -6,6 +6,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS add_library(sc-kpm-search SHARED ${SOURCES}) target_link_libraries(sc-kpm-search LINK_PUBLIC sc-kpm-common) target_include_directories(sc-kpm-search PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) +set_target_properties(sc-kpm-search PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-kpm-search) diff --git a/sc-kpm/sc-ui/CMakeLists.txt b/sc-kpm/sc-ui/CMakeLists.txt index cfd555a0c8..7270880586 100644 --- a/sc-kpm/sc-ui/CMakeLists.txt +++ b/sc-kpm/sc-ui/CMakeLists.txt @@ -12,6 +12,7 @@ target_link_libraries(sc-kpm-ui LINK_PUBLIC nlohmann_json::nlohmann_json ) target_include_directories(sc-kpm-ui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) +set_target_properties(sc-kpm-ui PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-kpm-ui) diff --git a/sc-kpm/sc-utils/CMakeLists.txt b/sc-kpm/sc-utils/CMakeLists.txt index 67d93f11d5..451fff0920 100644 --- a/sc-kpm/sc-utils/CMakeLists.txt +++ b/sc-kpm/sc-utils/CMakeLists.txt @@ -5,6 +5,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS add_library(sc-kpm-utils SHARED ${SOURCES}) target_link_libraries(sc-kpm-utils LINK_PUBLIC sc-kpm-common) target_include_directories(sc-kpm-utils PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) +set_target_properties(sc-kpm-utils PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-kpm-utils) diff --git a/sc-machine.ini b/sc-machine.ini index 5c18fdb895..4a1a0c1405 100644 --- a/sc-machine.ini +++ b/sc-machine.ini @@ -10,7 +10,7 @@ dump_memory_statistics = false dump_memory_statistics_period = 1800 storage = ./kb.bin -extensions = ./bin/extensions +extensions = ./build/lib/extensions log_type = Console log_file = ./sc-memory.log diff --git a/sc-memory/sc-memory/tests/scs/CMakeLists.txt b/sc-memory/sc-memory/tests/scs/CMakeLists.txt index 588309ac3f..9615545f6f 100644 --- a/sc-memory/sc-memory/tests/scs/CMakeLists.txt +++ b/sc-memory/sc-memory/tests/scs/CMakeLists.txt @@ -2,3 +2,7 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units NAME scs-tests DEPENDS sc-memory ) + +if(${SC_CLANG_FORMAT_CODE}) + target_clangformat_setup(scs-tests) +endif() diff --git a/sc-tools/sc-server/CMakeLists.txt b/sc-tools/sc-server/CMakeLists.txt index c87efc0fab..7509778e7d 100644 --- a/sc-tools/sc-server/CMakeLists.txt +++ b/sc-tools/sc-server/CMakeLists.txt @@ -25,6 +25,7 @@ target_include_directories(sc-server-lib PUBLIC $ PUBLIC $ ) +set_target_properties(sc-server-lib PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} From 470951dbc231074d433e4869a9486f6519142593 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 15 Oct 2024 03:36:48 +0300 Subject: [PATCH 029/134] [build] Avoid CMake crashes when Conan Toolchain was used and build folder was deleted Renamed CMakeUserPresets.json that is being generated by default to something non-conflicting --- .gitignore | 1 + conanfile.py | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c1dc83dffd..4a9fcd2a76 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ cmake-build-debug cmake-build-release cmake-build-debug-coverage /CMakeUserPresets.json +/ConanPresets.json test_defines.hpp *.scdb diff --git a/conanfile.py b/conanfile.py index 4a38065938..0714d8b7b5 100644 --- a/conanfile.py +++ b/conanfile.py @@ -57,6 +57,7 @@ def generate(self): # deps.build_context_activated = ["my_tool"] deps.generate() tc = CMakeToolchain(self) + tc.user_presets_path = "ConanPresets.json" tc.generate() def package(self): From 2112716974301c03a6785d07eee165cef54e2183 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 15 Oct 2024 03:46:27 +0300 Subject: [PATCH 030/134] [docker] Fixes for the new preset systems and extensions path --- .dockerignore | 2 ++ Dockerfile | 10 +++++----- docker-compose.yml | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index d2129a136d..1294667a08 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,5 @@ README.md codecov.yml .git .venv +**/*.scdb +/CMakeUserPresets.json diff --git a/Dockerfile b/Dockerfile index 2c445324b8..ebd4016f24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,16 +12,16 @@ RUN apt update && apt install -y --no-install-recommends sudo tini && /tmp/sc-ma #build using ccache FROM base as devdeps -RUN /tmp/sc-machine/scripts/install_deps_ubuntu.sh --dev +RUN /tmp/sc-machine/scripts/install_deps_ubuntu.sh --dev && sudo apt install ninja-build FROM devdeps as devcontainer -RUN apt install -y --no-install-recommends git cppcheck valgrind gdb bash-completion ninja-build curl +RUN apt install -y --no-install-recommends git cppcheck valgrind gdb bash-completion curl ENTRYPOINT ["/bin/bash"] FROM devdeps as builder WORKDIR /sc-machine COPY . . -RUN --mount=type=cache,target=/ccache/ ./scripts/build_sc_machine.sh -r +RUN --mount=type=cache,target=/ccache/ cmake --preset release . && cmake --build --preset release #Gathering all artifacts together FROM base AS final @@ -29,8 +29,8 @@ FROM base AS final COPY --from=builder /sc-machine/requirements.txt /sc-machine/requirements.txt COPY --from=builder /sc-machine/scripts /sc-machine/scripts COPY --from=builder /sc-machine/sc-machine.ini /sc-machine/sc-machine.ini -COPY --from=builder /sc-machine/build/bin /sc-machine/build/bin -COPY --from=builder /sc-machine/build/lib /sc-machine/build/lib +COPY --from=builder /sc-machine/build/Release/bin /sc-machine/build/bin +COPY --from=builder /sc-machine/build/Release/lib /sc-machine/build/lib RUN /sc-machine/scripts/install_deps_python.sh WORKDIR /sc-machine/scripts diff --git a/docker-compose.yml b/docker-compose.yml index 32605e2997..64e0d6b9fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: - "REBUILD_KB=${REBUILD_KB:-0}" - "KB_PATH=${KB_PATH:-/kb/repo.path}" - "BINARY_PATH=/sc-machine/build/bin" - - "EXTENSIONS_PATH=/sc-machine/build/lib" + - "EXTENSIONS_PATH=/sc-machine/build/lib/extensions" - "CONFIG_PATH=/sc-machine/sc-machine.ini" command: - "run" From 436b66cd21510df830d8c30f6352c50d8a5ecbd5 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 15 Oct 2024 03:47:23 +0300 Subject: [PATCH 031/134] [build][ci] Get rid of CMake script wrappers --- .github/workflows/conan.yml | 2 +- .github/workflows/coverage.yml | 6 +- .github/workflows/native.yml | 17 +++-- .github/workflows/sanitizers.yml | 4 +- scripts/build-scripts/build_cxx_project.sh | 83 ---------------------- scripts/build_sc_machine.sh | 34 --------- scripts/run_tests.sh | 9 --- 7 files changed, 14 insertions(+), 141 deletions(-) delete mode 100755 scripts/build-scripts/build_cxx_project.sh delete mode 100755 scripts/build_sc_machine.sh delete mode 100755 scripts/run_tests.sh diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 17e81f6273..11ca635e48 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -56,7 +56,7 @@ jobs: - name: Run sc-machine tests id: run_tests - run: cd build && ctest -C Debug -V + run: cd build/Release && ctest -C Debug -V - name: Run sc-machine id: run_sc_machine diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ba57c158f3..d4755cf4df 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -47,7 +47,7 @@ jobs: BUILD_TYPE: ${{ matrix.config.build_type }} COVERAGE: ON SANITIZER_TYPE: none - run: scripts/build_sc_machine.sh --cmake-arg "-DSC_COVERAGE=ON" -t + run: cmake --preset debug -DSC_COVERAGE=ON && cmake --build --preset debug - name: Prepare coverage id: prepare_coverage @@ -55,7 +55,7 @@ jobs: - name: Run tests id: run_tests - run: scripts/run_tests.sh + run: cd build/Debug && ctest -C Debug -V - name: Export coverage report id: export_coverage @@ -65,7 +65,7 @@ jobs: uses: codecov/codecov-action@v4 with: token: ${{secrets.CODECOV_TOKEN}} - directory: ${{github.workspace}}/build + directory: ${{github.workspace}}/build/Debug files: coverage.info flags: unittests fail_ci_if_error: true diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index a81835d9cf..500e9753da 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -16,7 +16,9 @@ jobs: fail-fast: false matrix: os: [macos-14, ubuntu-22.04, ubuntu-24.04] - build_type: ["Debug", "Release"] + build_type: + - { preset: "release", name: "Release" } + - { preset: "debug", name: "Debug" } config: - { cc: "gcc", cxx: "g++" } @@ -33,25 +35,22 @@ jobs: - name: Restore build caches uses: hendrikmuhs/ccache-action@v1.2 with: - key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.config.cxx }}-${{ matrix.build_type }} + key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.config.cxx }}-${{ matrix.build_type.name }} - name: Build id: run_cmake env: CC: ${{ matrix.config.cc }} CXX: ${{ matrix.config.cxx }} - BUILD_TYPE: ${{ matrix.build_type }} - COVERAGE: OFF - SANITIZER_TYPE: none - run: scripts/build_sc_machine.sh -t + run: cmake --preset ${{ matrix.build_type.preset }} && cmake --build --preset ${{ matrix.build_type.preset }} - name: Run tests id: run_tests - run: scripts/run_tests.sh + run: cd build/${{ matrix.build_type.name }} && ctest -C ${{ matrix.build_type.name }} -V - name: Run sc-machine id: run_sc_machine run: | mkdir kb - build/bin/sc-builder -i kb -o kb.bin --clear - build/bin/sc-machine -t -c sc-machine.ini -s kb.bin + build/${{ matrix.build_type.name }}/bin/sc-builder -i kb -o kb.bin --clear + build/${{ matrix.build_type.name }}/bin/sc-machine -c sc-machine.ini -s kb.bin -t diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 3603a5996f..ffdefe5148 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -47,8 +47,8 @@ jobs: BUILD_TYPE: ${{ matrix.config.build_type }} COVERAGE: OFF SANITIZER_TYPE: ${{ matrix.config.sanitizer }} - run: scripts/build_sc_machine.sh -t + run: cmake --preset debug -DSC_USE_SANITIZER=${{ matrix.config.sanitizer }} && cmake --build --preset debug - name: Run tests id: run_tests - run: scripts/run_tests.sh + run: cd build/Debug && ctest -C Debug -V diff --git a/scripts/build-scripts/build_cxx_project.sh b/scripts/build-scripts/build_cxx_project.sh deleted file mode 100755 index 2b36c2d588..0000000000 --- a/scripts/build-scripts/build_cxx_project.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -CURRENT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd) -source "${CURRENT_DIR}/../formats.sh" - -function usage() { - cat </dev/null 2>&1 && pwd) -source "${CURRENT_DIR}/formats.sh" - -if [[ -z "${ROOT_CMAKE_PATH}" || -z "${CXX_SOURCES_PATH}" || -z "${BUILD_PATH}" || -z "${BINARY_PATH}" ]]; -then - source "${CURRENT_DIR}/set_vars.sh" -fi - -ARGS=("$@") -while [ "$1" != "" ]; -do - case $1 in - "-f"|"--force" ) - build_force=1 - ;; - esac - shift 1 -done - -stage "Build sc-machine" - -if (( build_force == 1 )); -then - rm -rf "${BINARY_PATH}" -fi - -BUILD_SCRIPTS="${CURRENT_DIR}/build-scripts" -"${BUILD_SCRIPTS}/build_cxx_project.sh" -p "${ROOT_CMAKE_PATH}" -s "${CXX_SOURCES_PATH}" -b "${BUILD_PATH}" \ - --cmake-arg "-DSC_BIN_PATH=${BINARY_PATH}" "${ARGS[@]}" - -stage "sc-machine is built successfully" diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh deleted file mode 100755 index d4cdceda6c..0000000000 --- a/scripts/run_tests.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -if [[ -z "${BINARY_PATH}" || -z "${BUILD_PATH}" || -z "${SC_MACHINE_PATH}" ]]; -then - source "$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)/set_vars.sh" -fi - -cd "${BUILD_PATH}" && ctest -C Debug -V From c032fc819a8377fbe7039aef76981f066f2bf489 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 15 Oct 2024 14:38:15 +0300 Subject: [PATCH 032/134] [scripts] Add Ninja as a dev requirement on apt distros --- .github/workflows/conan.yml | 4 +--- Dockerfile | 2 +- scripts/install_deps_ubuntu.sh | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 11ca635e48..b788882add 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -39,9 +39,7 @@ jobs: pipx install conan - name: Install compilers - run: | - sudo apt-get install ninja-build - ./scripts/install_deps_ubuntu.sh --dev + run: ./scripts/install_deps_ubuntu.sh --dev - name: Restore build caches uses: hendrikmuhs/ccache-action@v1.2 diff --git a/Dockerfile b/Dockerfile index ebd4016f24..da41959bce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN apt update && apt install -y --no-install-recommends sudo tini && /tmp/sc-ma #build using ccache FROM base as devdeps -RUN /tmp/sc-machine/scripts/install_deps_ubuntu.sh --dev && sudo apt install ninja-build +RUN /tmp/sc-machine/scripts/install_deps_ubuntu.sh --dev FROM devdeps as devcontainer RUN apt install -y --no-install-recommends git cppcheck valgrind gdb bash-completion curl diff --git a/scripts/install_deps_ubuntu.sh b/scripts/install_deps_ubuntu.sh index 050c1d66bf..14fbff399b 100755 --- a/scripts/install_deps_ubuntu.sh +++ b/scripts/install_deps_ubuntu.sh @@ -33,6 +33,7 @@ packagelist_dev=( gcc g++ clang + ninja-build default-jre clang-format libasio-dev From 467a60c771a71034bbae6e57fb5e0bceff9960a3 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 15 Oct 2024 17:00:25 +0300 Subject: [PATCH 033/134] [docker][ci][fix] Improve dependencies caching in CI --- .github/workflows/conan.yml | 28 +++++++++++++++++++++------- .github/workflows/coverage.yml | 8 ++++++++ .github/workflows/docker.yml | 15 ++++++++++----- .github/workflows/native.yml | 8 ++++++++ .github/workflows/sanitizers.yml | 8 ++++++++ Dockerfile | 4 +++- 6 files changed, 58 insertions(+), 13 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index b788882add..0dfb8c35f0 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -24,10 +24,29 @@ jobs: with: submodules: recursive + - name: Restore ccache caches + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} + + - name: Conan cache + uses: actions/cache@v4 + with: + path: ~/.conan/data + key: conan-${{ runner.os }}-${{ hashFiles('**/conanfile.py') }} + + - name: apt cache + uses: actions/cache@v4 + with: + path: | + /var/cache/apt/ + /var/lib/apt/ + key: apt-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/install_deps_ubuntu.sh') }} + - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.12' + python-version: "3.12" - name: Set up pipx run: | @@ -39,12 +58,7 @@ jobs: pipx install conan - name: Install compilers - run: ./scripts/install_deps_ubuntu.sh --dev - - - name: Restore build caches - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ github.job }} + run: sudo apt install build-essential ninja-build - name: Build sc-machine with tests id: run_cmake diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d4755cf4df..7a161b3731 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -30,6 +30,14 @@ jobs: with: submodules: recursive + - name: apt cache + uses: actions/cache@v4 + with: + path: | + /var/cache/apt/ + /var/lib/apt/ + key: apt-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/install_deps_ubuntu.sh') }} + - name: Install dependencies id: install_deps run: scripts/install_deps_ubuntu.sh --dev diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 52f5614b7b..d1d0321aae 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,8 +15,13 @@ jobs: with: submodules: recursive - - name: Run Docker image - run: | - mkdir kb - DOCKER_BUILDKIT=1 docker build . -t ostis/sc-machine:latest - docker compose up -d --wait + - name: Build Docker image + uses: docker/build-push-action@v6 + with: + push: false + tags: ostis/sc-machine:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Run Docker Compose + run: docker-compose up -d --wait diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index 500e9753da..f4cb8d29fd 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -28,6 +28,14 @@ jobs: with: submodules: recursive + - name: apt cache + uses: actions/cache@v4 + with: + path: | + /var/cache/apt/ + /var/lib/apt/ + key: apt-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/install_deps_ubuntu.sh') }} + - name: Install dependencies run: | scripts/install_dependencies.sh --dev diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index ffdefe5148..c7471558b1 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -30,6 +30,14 @@ jobs: with: submodules: recursive + - name: apt cache + uses: actions/cache@v4 + with: + path: | + /var/cache/apt/ + /var/lib/apt/ + key: apt-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/install_deps_ubuntu.sh') }} + - name: Install dependencies id: install_deps run: scripts/install_deps_ubuntu.sh --dev diff --git a/Dockerfile b/Dockerfile index da41959bce..83ac25e9cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,9 @@ RUN apt update && apt install -y --no-install-recommends sudo tini && /tmp/sc-ma #build using ccache FROM base as devdeps -RUN /tmp/sc-machine/scripts/install_deps_ubuntu.sh --dev +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ +--mount=type=cache,target=/var/lib/apt,sharing=locked \ +/tmp/sc-machine/scripts/install_deps_ubuntu.sh --dev FROM devdeps as devcontainer RUN apt install -y --no-install-recommends git cppcheck valgrind gdb bash-completion curl From 31933069364c2f9c8959a4cab18b0509b9972533 Mon Sep 17 00:00:00 2001 From: FallenChromium <43214067+FallenChromium@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:15:46 +0300 Subject: [PATCH 034/134] [build][fix] Fix Conan provider for release-with-tests preset --- CMakePresets.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 35e2a3fd50..10bb51bc1c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -57,7 +57,10 @@ "name": "release-with-tests-conan", "displayName": "Release config with tests (Conan)", "description": "Release config with tests (Conan dependencies used)", - "inherits": "release-with-tests" + "inherits": "release-with-tests", + "cacheVariables": { + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "./cmake/conan_provider.cmake" + } } ], "buildPresets": [ From 5f393e965296b47416c663792e82b6b4bdcd4ec8 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 15 Oct 2024 21:37:04 +0300 Subject: [PATCH 035/134] [ci] Use Buildx in Docker workflow --- .github/workflows/docker.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d1d0321aae..0f1d6f735a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,13 +15,17 @@ jobs: with: submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build Docker image uses: docker/build-push-action@v6 with: push: false + load: true tags: ostis/sc-machine:latest cache-from: type=gha cache-to: type=gha,mode=max - name: Run Docker Compose - run: docker-compose up -d --wait + run: docker compose up -d --wait From 7fa68e4ed5df5c184e30849a43c2ed7cc17c24f9 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 15 Oct 2024 22:03:48 +0300 Subject: [PATCH 036/134] [ci] Use default cache action for ccache --- .github/workflows/coverage.yml | 3 ++- .github/workflows/native.yml | 3 ++- .github/workflows/sanitizers.yml | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7a161b3731..e0e810c258 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -43,8 +43,9 @@ jobs: run: scripts/install_deps_ubuntu.sh --dev - name: Restore build caches - uses: hendrikmuhs/ccache-action@v1.2 + uses: actions/cache@v4 with: + path: ~/.ccache key: ${{ github.job }}-${{ matrix.config.os }}-${{ matrix.config.cxx }}-${{ matrix.config.build_type }} - name: Build diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index f4cb8d29fd..9648271d81 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -41,8 +41,9 @@ jobs: scripts/install_dependencies.sh --dev - name: Restore build caches - uses: hendrikmuhs/ccache-action@v1.2 + uses: actions/cache@v4 with: + path: ~/.ccache key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.config.cxx }}-${{ matrix.build_type.name }} - name: Build diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index c7471558b1..a6a2819f47 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -43,8 +43,9 @@ jobs: run: scripts/install_deps_ubuntu.sh --dev - name: Restore build caches - uses: hendrikmuhs/ccache-action@v1.2 + uses: actions/cache@v4 with: + path: ~/.ccache key: ${{ github.job }}-${{ matrix.config.os}}-${{ matrix.config.cxx }}-${{ matrix.config.build_type }} - name: Build From 2c62b1e7092bb1ef19dc8b1834f1ce87d7778318 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 15 Oct 2024 22:09:39 +0300 Subject: [PATCH 037/134] [build] Conan: add gtest as a build requirement unconditionally --- .github/workflows/conan.yml | 6 +++--- conanfile.py | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 0dfb8c35f0..bb8e091365 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -58,17 +58,17 @@ jobs: pipx install conan - name: Install compilers - run: sudo apt install build-essential ninja-build + run: sudo apt install build-essential ninja-build ccache cmake - name: Build sc-machine with tests id: run_cmake run: | - cmake --preset=release-with-tests-conan + cmake --preset release-with-tests-conan cmake --build --preset release - name: Run sc-machine tests id: run_tests - run: cd build/Release && ctest -C Debug -V + run: cd build/Release && ctest -C Release -V - name: Run sc-machine id: run_sc_machine diff --git a/conanfile.py b/conanfile.py index 0714d8b7b5..ef098fb675 100644 --- a/conanfile.py +++ b/conanfile.py @@ -39,6 +39,7 @@ def build_requirements(self): self.build_requires("nlohmann_json/3.11.3") self.build_requires("glib/2.78.3") self.build_requires("antlr4-cppruntime/4.9.3") + self.test_requires("gtest/1.14.0") def layout(self): cmake_layout(self) @@ -48,10 +49,6 @@ def build(self): cmake.configure() # equivalent to self.run("cmake . ") cmake.build() - def test_requirements(self): - if self._run_tests: - self.build_requires("gtest/1.14.0") - def generate(self): deps = CMakeDeps(self) # deps.build_context_activated = ["my_tool"] From bd26feab78c40c47ae4d35127ca2e4342316855c Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 15 Oct 2024 22:41:57 +0300 Subject: [PATCH 038/134] [build] Conan: Add dependencies for benchmarking and gwf translator --- conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conanfile.py b/conanfile.py index ef098fb675..bb9ffb55e9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -39,7 +39,9 @@ def build_requirements(self): self.build_requires("nlohmann_json/3.11.3") self.build_requires("glib/2.78.3") self.build_requires("antlr4-cppruntime/4.9.3") + self.build_requires("libxml2/2.13.4") self.test_requires("gtest/1.14.0") + self.test_requires("benchmark/1.9.0") def layout(self): cmake_layout(self) From 92706a98d5cf379dc5103af89eda70c484e9eafd Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Sun, 27 Oct 2024 13:56:15 +0300 Subject: [PATCH 039/134] [tests][refactor][fix] Configure tests in pre-execution stage, not during cmake build --- cmake/install.cmake | 2 +- cmake/tests.cmake | 2 +- sc-memory/sc-core/tests/CMakeLists.txt | 3 - .../deprecated-kb/test/segments.scdb | Bin 2359344 -> 0 bytes .../deprecated-kb/test/strings.scdb | Bin 2585 -> 0 bytes .../sc_dictionary_fs_memory_test.hpp | 28 ++++++ .../units/fs-storage/sc_fs_memory_test.hpp | 28 ++++++ .../test_sc_dictionary_fs_memory_api.cpp | 95 +++++++----------- .../fs-storage/test_sc_file_system_api.cpp | 1 + .../fs-storage/test_sc_fs_memory_api.cpp | 56 ++--------- sc-tools/sc-builder/CMakeLists.txt | 3 - sc-tools/sc-builder/src/builder_defines.hpp | 1 - sc-tools/sc-builder/tests/CMakeLists.txt | 13 --- .../{ => configs}/deprecated-input-path.ini | 0 .../{ => configs}/output-path-as-storage.ini | 0 .../{ => configs}/unused-builder-group.ini | 0 .../{ => configs}/used-builder-group.ini | 0 .../{ => configs}/without-builder-group.ini | 0 sc-tools/sc-builder/tests/repo.path | 1 + .../sc-builder/tests/units/builder_test.hpp | 32 +++++- .../units/repo_path_collector_test_api.hpp | 11 +- .../sc-builder/tests/units/test_aliases.cpp | 4 +- sc-tools/sc-builder/tests/units/test_base.cpp | 16 ++- .../sc-builder/tests/units/test_clean.cpp | 2 +- .../sc-builder/tests/units/test_config.cpp | 60 ++++++----- .../sc-builder/tests/units/test_contents.cpp | 16 ++- .../tests/units/test_gwf_translator.cpp | 34 +++---- .../units/test_repo_path_collector_api.cpp | 34 +++---- .../sc-builder/tests/units/test_users.cpp | 7 +- .../tests/units/test_visibility.cpp | 12 ++- sc-tools/sc-config/tests/CMakeLists.txt | 5 - .../deprecated-extensions-path.ini | 0 .../{ => configs}/deprecated-repo-path.ini | 0 .../{ => configs}/empty-multiextensions.ini | 0 .../multiextensions-with-spaces.ini | 0 .../tests/{ => configs}/multiextensions.ini | 0 .../not-normalized-multiextensions.ini | 2 +- .../{ => configs}/removed-save-period.ini | 0 .../{ => configs}/removed-update-period.ini | 0 sc-tools/sc-config/tests/test_defines.hpp.in | 4 - .../sc-config/tests/units/sc_config_test.hpp | 25 +++++ .../sc-config/tests/units/test_config.cpp | 58 +++++------ .../sc-machine-runner/tests/CMakeLists.txt | 5 - .../tests/sc-machine-test.ini | 2 +- .../tests/units/sc_machine_test.hpp | 29 ++++++ .../tests/units/test_base.cpp | 26 ++--- sc-tools/sc-server/tests/CMakeLists.txt | 13 +-- sc-tools/sc-server/tests/test_defines.hpp.in | 3 - .../tests/units/api/sc_server_test.hpp | 33 ++++-- .../sc-server/tests/units/api/test_base.cpp | 8 ++ .../tests/units/api/test_connection.cpp | 4 +- .../tests/units/performance/CMakeLists.txt | 6 -- .../performance/units/sc_server_test.hpp | 4 +- 53 files changed, 385 insertions(+), 303 deletions(-) delete mode 100644 sc-memory/sc-core/tests/units/fs-storage/deprecated-kb/test/segments.scdb delete mode 100644 sc-memory/sc-core/tests/units/fs-storage/deprecated-kb/test/strings.scdb create mode 100644 sc-memory/sc-core/tests/units/fs-storage/sc_dictionary_fs_memory_test.hpp create mode 100644 sc-memory/sc-core/tests/units/fs-storage/sc_fs_memory_test.hpp delete mode 100644 sc-tools/sc-builder/src/builder_defines.hpp rename sc-tools/sc-builder/tests/{ => configs}/deprecated-input-path.ini (100%) rename sc-tools/sc-builder/tests/{ => configs}/output-path-as-storage.ini (100%) rename sc-tools/sc-builder/tests/{ => configs}/unused-builder-group.ini (100%) rename sc-tools/sc-builder/tests/{ => configs}/used-builder-group.ini (100%) rename sc-tools/sc-builder/tests/{ => configs}/without-builder-group.ini (100%) rename sc-tools/sc-config/tests/{ => configs}/deprecated-extensions-path.ini (100%) rename sc-tools/sc-config/tests/{ => configs}/deprecated-repo-path.ini (100%) rename sc-tools/sc-config/tests/{ => configs}/empty-multiextensions.ini (100%) rename sc-tools/sc-config/tests/{ => configs}/multiextensions-with-spaces.ini (100%) rename sc-tools/sc-config/tests/{ => configs}/multiextensions.ini (100%) rename sc-tools/sc-config/tests/{ => configs}/not-normalized-multiextensions.ini (77%) rename sc-tools/sc-config/tests/{ => configs}/removed-save-period.ini (100%) rename sc-tools/sc-config/tests/{ => configs}/removed-update-period.ini (100%) delete mode 100644 sc-tools/sc-config/tests/test_defines.hpp.in create mode 100644 sc-tools/sc-config/tests/units/sc_config_test.hpp create mode 100644 sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp delete mode 100644 sc-tools/sc-server/tests/test_defines.hpp.in diff --git a/cmake/install.cmake b/cmake/install.cmake index 2264c2c534..cb4784672c 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -1,5 +1,5 @@ install(TARGETS - sc-machine sc-builder sc-machine-runner sc-server + sc-machine sc-builder sc-machine-runner sc-kpm-common sc-core sc-memory sc-agents-common sc-builder-lib sc-config EXPORT sc-machineExport diff --git a/cmake/tests.cmake b/cmake/tests.cmake index a553d08fd9..18d38f25db 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -16,5 +16,5 @@ function(make_tests_from_folder folder) add_executable(${target} ${SOURCES}) target_link_libraries(${target} GTest::gtest_main ${TEST_DEPENDS}) target_include_directories(${target} PRIVATE ${TEST_INCLUDES}) - gtest_discover_tests(${target} TEST_LIST ${target_tests}) + gtest_discover_tests(${target} TEST_LIST ${target_tests} WORKING_DIRECTORY ${folder}) endfunction() diff --git a/sc-memory/sc-core/tests/CMakeLists.txt b/sc-memory/sc-core/tests/CMakeLists.txt index 7d14686b1e..6e004a2ce1 100644 --- a/sc-memory/sc-core/tests/CMakeLists.txt +++ b/sc-memory/sc-core/tests/CMakeLists.txt @@ -25,9 +25,6 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/fs-storage DEPENDS ${glib_LIBRARIES} sc-memory INCLUDES ${glib_INCLUDE_DIRS} ${SC_CORE_SRC} ) -target_compile_definitions(sc-core-fs-storage-tests PRIVATE - SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH="${CMAKE_CURRENT_SOURCE_DIR}/units/fs-storage/deprecated-kb" -) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-core-fs-storage-tests) diff --git a/sc-memory/sc-core/tests/units/fs-storage/deprecated-kb/test/segments.scdb b/sc-memory/sc-core/tests/units/fs-storage/deprecated-kb/test/segments.scdb deleted file mode 100644 index 7976aa5262bb72f3426ac9e51bd09e4f4bd18748..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2359344 zcmeI*F>hnrdLCfiYtH4lah!YY#ECCb&4~maxNsLBjVnta0=r0+B3)n&_#bkcQ)s{{ zND(8QI}I2F2z-hdaqURpA4s|sDWtH-F9>2J`9AK&S=`#%9L|u^8EHQo*dj$PuEqU` zdhxBrE$W}0G}}+&;xFF+`LEyp&6|_ufBp5p`K@37`+xh-zx|WZpZ~vqc=d<>oB!~S|MSW3|J5JgU;oK}y8kc#^q>6XzyI~SKmK=r{jdMmfBfIS_?Q3f zSEv8;|Nhy(`h$N_x_p+4x1(RgIE&xgHQ3v4^4<@>xvR|&>o%JfqtVI9=w~M<=W&_a zS#z<+*SG6OO!sK12>}8xUEtgAGkKT0r+wcI zbu1awXXJJQuSMXylTH5oX&lmT#Qu-A4lQpxIr;A6EthdE3zXB3x15~3Th~R8sYgBIF5a?`vLAHK;Xp+{P4{tfASDAfBvZK`F-Zi$w@m~vdwwyO*WmJ z++~voZPxRz2#-zO^M2iCpD*39rtz?gGWT2U(}gw!2)rVJX8q?Tj_7^w8c;hoGJmcj ze>Qc`hrKo4u3IkSu{Ht(2%MbMHJQwy$G2|&jABK4Q}^6H{-8&0tz#`8xz|ku2nnir^4na46t|EUnbr^B=&}f0 zt}~(CX1)IN^OKWJ-ScMe+-UccV`UvQD`U;}?x#G!1pxvtT%cM1Igj7{{&RrZxv^gV ziTv5rJ!gC8#@n^k{HIa-?ERP*&gs8z z@5ems!}kOTydHtNCX;imQS7IkZ0P3CRpih9bwI{-PKFO#S@C5;-LbL`T9wYm^5@G~J&M4K6)5NbL=H6PIzM(Gb>4JX z2DS5N9z$gflxxtrIWMSj@Rh)D1ZuY2^wu|Z-gKKe75n?%w!7rsuJ4?wb9N!QkHCNg zYPRHD>nir^PPVk`mYkzy9d!B2hUsGOJgHf?>WncUa)(NQKoRI>OV&Y`B_A%=+0v~4 zob8=6eYiF2a;;|(V=T9FNL|$D=5_+FRiODyp7WjAQtOt(GN_w%SqIHZ292|@vJoIK zAc2}K{TWp2mYi$dM_#3n!qpxn)RQXoxk^W-t=K-yH5$$T5A$(J>!x;)3{Xk ze9F%K1YV;+&6fTQs=1MKt#`4%|Dqgvy9Uhcu@N9ZVEgl*bFOt2`*kN<+ViIM`9IO- zqO`l%J5OrXtvX})Sr8yFJb`YuWF2%_^5JrwE#>^5y>q5dvDQ)fUi%`(SZ?Kzx~R|1 z?F3${K(qcc|JAPJt98rSK^fG|x~zl7C4&|R^}Xx)yN>{YuT!9A%X#nbf2~_`u5}-I z@us)!uA^+{Pu4&4*fWD{1PBaKpk_R(0u;$Mf?p`|5oQ{XELat$vp%Je5OFnmh;|h zsdKcPYu!g}^rpA%XAZA90RjUSsM(Tpt^D7nr(4+)|K=;U?i?-apxZJ>yWMI(U`U5f zfWT)9bh9Pvpu3VSck65^=l>j>GwreR{r6?;`5stqlP2t%Z+s;{U;qN;|9?fcob?`U zouhp?D1++zU$Ukb+Z_Z3Bv7;ErZ-#a94+Ts?_z)7+jc;74wV3b0|jcfqO`j(Z#wX2;Nb*@D$vcAtb;B~wp^~WrJVmGXNLMBaohx+NT6B&Ige~P z>pcgk&e6_f&=dU}bW31}0ySGQgC5`N94+Ts_fZ?Y>23RX56!LZS}WiGnnz!ozr|R6 zQJ=fUa~}Z$U$;QbmYi#iVn6NVKsz^b{U__7+cHPH?X>SZ;`;uVtm!jyJAokybh9Pv zpu3VSck65^=l|@TGeh!otON*rxj;GpC$gpgZ@}st?Sl;Za%ztxK;VHu&6b=5W?OV&Y` zC0j1n*;3B`IXGw9W99o_(->#-w-}3q``>Yx?jk_oD-BWH&CB5~XVo=Bja{}b7A(L2Jo z-*4{vAcHm(E(s7gSfFOhO>ef;IaCVxz4!SLKwA)Vm!QeSi0t5~c=w?gSL3brv?$+5- z&i^?$XWC=s`(Mi#$KPTc^aJ!@0xwvgoc|Nq^1k;dzWsi4*N1~LsP;4aX49if0tALD zP&47CH(Tl)E$3SAGOK#q?vnhWe5zv8=IR&m`OneM^ry}DtH`9~7xlYqO!pBW@bwDR zY{|LSRqWTD3~0}r*6063n~T!!V((g}-OoHwGJodre>WDTFLlw^`%3Z52pnIaoe7yO zSqEK~Jh)tEOF92%@0{s-md*KxGN#YR?F5DYx~ze01PBaWpqnjO2VItIxm@Q&IsfP2 z%xKp?dH(Y<##xlLpGEX9mxlg&bo|2-DChsg@BV%7f!Dg_?4S(#?&AoP=qKl1nLoL$ z%4PGNuLKATL!f5Md2hDV+{n4sePqR(-nP5cy0uo;JJU@DeNmsg#&aJ50$;a4&6b>N zjbcCTVP|p8}9C#CdhyM6h=V%`e%And$)<8A_1cok9GvTH; z6Y3l-=UVS#f8X17muI{FS%3ad^s`xep8Ty?kN%>5ca7;j0tCKZftoEj*Sd=Rx|0Fj zIa=017p2`rtm9cvYj&AHdS^sy+H`}Lz00Rpc>pqnjO2VIstxLjvTIsa$xoavM4 zjvjSJzD|K={pakrc0Ic~M>{(xBbt8Z(MQg;Yy=1lU7%*md2c4v zc~j1{?xS9L)7y5JXLtQ)9Q|zOUb8RibJuw8BS7Hm7O2^hbFESAr&~F2`b>2|CA?qjW4mo<=$0D++kbh9Pvpu3VSck7%e=l>j>8QuD48huVmzmv#1xis|G zqvIczK(qd{iVV14*E)|KeXUzQ9F#$|)>=eA zZsc6+UF`3B+wMBzZml(sepaQ{n)T-2u0GvIfWXTYsM(Tpt*h9tx3XomzTVA^tb;B} zyNkVZqsh8yv~T)-xoVy{0RqPm=w?gSL6;?4F4x&o&i~mvXZoJkgY};nV;OsnXCpvh zhyu;}&myv=d9Uj+gE~h$J1B!{KUo9W2oM;$K+S~n-b|=-w47_*N4@fU z{^27iv2Y9&9+!y@6OS(4!SM5G21l$UXegITe1$iE7@|l&V_cHQ5^kMd{)PKQFy<1cC`D+&#|AzV;5zt z$=`lOtPX_$fjtD8^`BY%?w|Gk{Q==x8z+0;Gnw%YGDX|iq^?Pq&GW_OS7B|zXM3v_Fetb^`KO>(!+iFTXy z{3~wX)IIO_&XNb~KQYEM9-He;HUb2OC{RBCC+eL3I;NXHqpkKI_RgO=*UK8nMu5Q3 z1!^YT^kzagf36~bHg(T!@8cfYKB#|U4SODs-K;&&qEET>(9HJ)Ub8@5|H--5RqWSW zd9sR3cy#^e@0^@$>Yn?p_PeF(SgUx3Zs$g>KacYK zpVEH!{|?*kt(oi1BWEVEW*f$J0s|GO>p$ncnea&d{4&n}>22Rf*+8qu1PHtifx0G>bFESAr(3zQh`Q)_Tg|$xfouc_3|*jI+vNIB)ImPPFTv z{2PvG^uJkqorNTyGdZJx594Wee1rB+ zQvW>VQRnir^tsGh%b^WJiUDiN00tALG&|Q(*LX@60wC^yK3|_MF^CfWVI@P-~K$YmH(*-O7PQ)J4bJnygz!|Ff+z zj@Q4Q2oQK#0^OP<>!7<*liVFOCmyW-#QR>;=>Nw1UoYz=tzjOBS2v20yPtEo;(vC)ITxaJoe4n^DN%$mrFx`Jv#nj3DotUoNHahejWQ} zoBnij?HHGJtW}ILjXm=xx5d_&%`LtXAn^JHy6Zn#2VIstxIF6lhuyK3G0vonwK(cn zum30K2noD=foA<@_VbgI{r`{GmmYO9*PBPqOk~ZMB6=KwS0qr^f6kvg6WZ%Pqj-;P z9Aln4_wW_Ho*W8+&k?9=GC9{8#eTY#LyK=dr>{@7tyz~fkc|L=p$l}^WU>yrD{C^h zKRKpPyZ*U~F{UxrX6<00n{oM6OfWXTZXx4wGkuxjx&ddH$diDffoWO(ipLpME898+0{jV4I zlk|iMygY&W{#VvOHUb0)JfFaW`X|0-Xu0%! zKMo@i7?ePL|0~y;bMBS-liR9XHsAS5fB=DG3v}QA%6ey3vS*?8IX1Zd2oU%v@OFJ| z`gcFx;0gf(1fEHtu0PM!I?rTo7y<+ufx7;abFFF4y|!{lUF3B_fWXrUbk~2f4w{q< znwXb89lf3j3|^pF{~1Tl%>TjQF#r%C@T>xL{UDjK!5-N0s|5F;e7i*^YahKQ44K8du$ok zr`{XeCUTts0RjXF5FkK+009DDDA4}=`F#I<6??u1w%M#pZzNn2AaGoPdj4U)2WBHc zfWY$!wCkT-e_m{@KQI1%)I)OV`Faf%f`OF8jpwI96aImhZwU}MoAgfWQNRy8g4=ns+^Dj`XiNr1p^fx7-Yl|j3y+)IGKkp=4dPoC>Dj(xI~L-VccM;=&r1PBaXpuPT+ z=O0cZbEakOdF+3}5B?PbfWXrUwDTwHpXKkA4BGl1U{5!`o(T{bu0XT??0*an_Z8sC z3H*2hb^Uo|t>?%4F&LS^AO-6BbFTF)a{jfIL+YYIz9<|tfoBqEum9xwbJjt#l0ggW z&(HL8Fbshq3bgn)Tih5W$eo;fW&Y$g zRSz`~z7intL;~&gpZxs!tan!a_r()=>y`ik0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF k5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U__Vy!FkWLC7}k5Ru7+NGIJ75cDGg@+tb1 z{zm7BvzB6QGr%rkaWtGc=gd&ld^YLqcmD6Us?`2e1f|Q;mCD$+d0}?yJ}>j5r-q{I zcf4%f@tE74+8b;9YrUiFo4ENkFB@a?@pU0g)c)2{mI`ytJL95anUI$Ov zr_mR$oPDYJGCsv3u{rdLs!!r`lu(wsPz!3W;v-~Z@#vTvtIRI!>F`6`Li%rwHycx! z@W2(6KG6ExxQP-AO60(le|3RxUefxD=jLHnS#&IWCR@}V^LK#2f(erNXbYAT3L zB`Z|7$-Sob`~L|B%$B!Q4-#11&adaU3pz-(IAB}o+^T=5dKTmKhb|};CQ$ANiE`-q z4K?!0ue^PRSO~W+sJ%N`rV}W!4d~pSd~iol3)$|0tqDHhfKuR=}$$^l6hixa^Mq&&w zh!r$aGsM&bd$Mn=duOTPr!egH(3)WKfPNhV8>N>?g+KFaebC2I-~+!+tspz<1!25G zxomyabNVwrn*79TSDSzEK_9s{xrxl)=#o;&3EcuprEAWV&MB4T;K-vX_m5pjtq2K6 z7P&nrZ7CUnzoNBFBSer6_J4Iu)C6@wQQ9INiw^k-DAgYJXI?DI~EFKys zXGF3Q5e~SOHWdhwO&?3Gsg_ir zm&>`q*S7Fp?H)=N7CV!F5CoR zNAXnQws}G87tsew8~AjCUR)~lFWXsKcl16!=_XBAzAp5UrAcdHc_enZ-%`O7v80b{ z9LgOp&UcSje4$NC@R#(z&E5@4(It; + +#include + +class ScDictionaryFSMemoryTest : public testing::Test +{ +public: + static inline sc_char SC_DICTIONARY_FS_MEMORY_PATH[10] = "fs-memory"; + static inline sc_char SC_DICTIONARY_FS_MEMORY_STRINGS_PATH[24] = "fs-memory/strings1.scdb"; + +protected: + void SetUp() override + { + } + + void TearDown() override + { + std::filesystem::remove_all(SC_DICTIONARY_FS_MEMORY_PATH); + } +}; diff --git a/sc-memory/sc-core/tests/units/fs-storage/sc_fs_memory_test.hpp b/sc-memory/sc-core/tests/units/fs-storage/sc_fs_memory_test.hpp new file mode 100644 index 0000000000..70b867379c --- /dev/null +++ b/sc-memory/sc-core/tests/units/fs-storage/sc_fs_memory_test.hpp @@ -0,0 +1,28 @@ +/* + * This source file is part of an OSTIS project. For the latest info, see http://ostis.net + * Distributed under the MIT License + * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) + */ + +#pragma once + +#include + +#include + +class ScFSMemoryTest : public testing::Test +{ +public: + static inline sc_char SC_FS_MEMORY_PATH[10] = "fs-memory"; + static inline sc_char SC_FS_MEMORY_SEGMENTS_PATH[24] = "fs-memory/segments.scdb"; + +protected: + void SetUp() override + { + } + + void TearDown() override + { + std::filesystem::remove_all(SC_FS_MEMORY_PATH); + } +}; diff --git a/sc-memory/sc-core/tests/units/fs-storage/test_sc_dictionary_fs_memory_api.cpp b/sc-memory/sc-core/tests/units/fs-storage/test_sc_dictionary_fs_memory_api.cpp index e0c0ab8e1c..4f651d2bbe 100644 --- a/sc-memory/sc-core/tests/units/fs-storage/test_sc_dictionary_fs_memory_api.cpp +++ b/sc-memory/sc-core/tests/units/fs-storage/test_sc_dictionary_fs_memory_api.cpp @@ -4,7 +4,7 @@ * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) */ -#include +#include "sc_dictionary_fs_memory_test.hpp" extern "C" { @@ -43,10 +43,7 @@ extern "C" #define TEXT_EXAMPLE_1 "it is the first string" #define TEXT_EXAMPLE_2 "it is the second string" -#define SC_DICTIONARY_FS_MEMORY_PATH "fs-memory" -#define SC_DICTIONARY_FS_MEMORY_STRINGS_PATH SC_DICTIONARY_FS_MEMORY_PATH "/strings1.scdb" - -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_shutdown) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_shutdown) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -54,7 +51,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_shutdown) EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_shutdown_no_path) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_shutdown_no_path) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, nullptr), SC_FS_MEMORY_WRONG_PATH); @@ -62,7 +59,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_shutdown_no_path) EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_NO); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_shutdown_no_exist_path) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_shutdown_no_exist_path) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, ""), SC_FS_MEMORY_WRONG_PATH); @@ -70,7 +67,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_shutdown_no_exist_pa EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_NO); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_nullptr) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_nullptr) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, ""), SC_FS_MEMORY_WRONG_PATH); @@ -95,7 +92,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_nullptr) EXPECT_EQ(sc_dictionary_fs_memory_unite_strings_by_terms(memory, nullptr, nullptr), SC_FS_MEMORY_NO); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_save_shutdown_load) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_save_shutdown_load) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -113,7 +110,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_save_shutdown_load) EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_rm_shutdown_load) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_rm_shutdown_load) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -132,7 +129,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_rm_shutdown_load) EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_clear_init_shutdown_load) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_clear_init_shutdown_load) { sc_memory_params * params = _sc_dictionary_fs_memory_get_default_params(SC_DICTIONARY_FS_MEMORY_PATH, SC_TRUE); sc_dictionary_fs_memory * memory; @@ -152,29 +149,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_clear_init_shutdown_load) sc_mem_free(params); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_save_shutdown_load_deprecated_dictionary) -{ - EXPECT_TRUE(sc_fs_copy_file( - SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH "/test/strings.scdb", - SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH "/strings.scdb")); - - sc_dictionary_fs_memory * memory; - EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); - EXPECT_EQ(sc_dictionary_fs_memory_save(memory), SC_FS_MEMORY_OK); - EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); - - EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); - EXPECT_EQ(sc_dictionary_fs_memory_load(memory), SC_FS_MEMORY_OK); - EXPECT_EQ(sc_dictionary_fs_memory_save(memory), SC_FS_MEMORY_OK); - EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); - - EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); - EXPECT_EQ(sc_dictionary_fs_memory_load(memory), SC_FS_MEMORY_OK); - EXPECT_EQ(sc_dictionary_fs_memory_save(memory), SC_FS_MEMORY_OK); - EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); -} - -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -202,7 +177,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash) EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_invalid_data) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_invalid_data) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -254,7 +229,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_i EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_reset) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_reset) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -281,7 +256,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_r EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_not_found) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_not_found) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -309,7 +284,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_n EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_no_file) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_no_file) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -345,7 +320,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_n EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_reset_save_load) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_reset_save_load) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -410,7 +385,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_r EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_reset_save_load_empty) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_string_by_link_hash_reset_save_load_empty) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -464,7 +439,7 @@ void _test_push_link_hash(void * data, sc_addr const link_addr) sc_list_push_back((sc_list *)data, (sc_addr_hash_to_sc_pointer)SC_ADDR_LOCAL_TO_INT(link_addr)); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -509,7 +484,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_not_searchable_string) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_not_searchable_string) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -558,7 +533,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_not_se EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string_invalid_data) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string_invalid_data) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -641,7 +616,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string_reset) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string_reset) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -703,7 +678,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string_no_file) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string_no_file) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -747,7 +722,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string_save_load) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string_save_load) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -828,7 +803,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_string EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_substring) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_substring) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -919,7 +894,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_substr EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_substring_when_false_config) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_link_hashes_by_substring_when_false_config) { sc_dictionary_fs_memory * memory; sc_memory_params * params = _sc_dictionary_fs_memory_get_default_params(SC_DICTIONARY_FS_MEMORY_PATH, SC_FALSE); @@ -984,7 +959,7 @@ void _test_push_link_content(void * data, sc_addr const, sc_char const * link_co sc_list_push_back((sc_list *)data, (sc_pointer)copied_string); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_strings_by_substring) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_strings_by_substring) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1050,7 +1025,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_get_strings_by_substring) EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_link_unlink_strings) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_link_unlink_strings) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1105,7 +1080,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_link_unlink_strings) EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_intersect_strings_by_terms) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_intersect_strings_by_terms) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1135,7 +1110,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_intersect_strings_by_term EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_intersect_strings_by_terms_2) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_intersect_strings_by_terms_2) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1163,7 +1138,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_intersect_strings_by_term EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_unite_strings_by_terms) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_unite_strings_by_terms) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1192,7 +1167,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_unite_strings_by_terms) EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_unite_strings_by_term_2) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_unite_strings_by_term_2) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1252,7 +1227,7 @@ void test_sc_dictionary_fs_memory_get_links_intersect_strings_by_terms(sc_dictio sc_list_destroy(found_strings); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_add_save_shutdown_load_intersect) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_add_save_shutdown_load_intersect) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1303,7 +1278,7 @@ void test_sc_dictionary_fs_memory_get_links_unite_strings_by_terms(sc_dictionary sc_list_destroy(found_strings); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_add_save_shutdown_load_unite) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_add_save_shutdown_load_unite) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1337,7 +1312,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_init_add_save_shutdown_lo EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_intersect_link_hashes_by_terms) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_intersect_link_hashes_by_terms) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1367,7 +1342,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_intersect_link_hashes_by_ EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_unite_link_hashes_by_terms) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_unite_link_hashes_by_terms) { sc_dictionary_fs_memory * memory; EXPECT_EQ(sc_dictionary_fs_memory_initialize(&memory, SC_DICTIONARY_FS_MEMORY_PATH), SC_FS_MEMORY_OK); @@ -1398,7 +1373,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_unite_link_hashes_by_term EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_mutiple_link_strings) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_mutiple_link_strings) { sc_memory_params params; params.storage = SC_DICTIONARY_FS_MEMORY_PATH; @@ -1438,7 +1413,7 @@ TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_mutiple_link_strings) EXPECT_EQ(sc_dictionary_fs_memory_shutdown(memory), SC_FS_MEMORY_OK); } -TEST(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_mutiple_link_strings_with_optimized_config) +TEST_F(ScDictionaryFSMemoryTest, sc_dictionary_fs_memory_mutiple_link_strings_with_optimized_config) { sc_memory_params params; params.storage = SC_DICTIONARY_FS_MEMORY_PATH; diff --git a/sc-memory/sc-core/tests/units/fs-storage/test_sc_file_system_api.cpp b/sc-memory/sc-core/tests/units/fs-storage/test_sc_file_system_api.cpp index e25b954e1b..d1de9eba40 100644 --- a/sc-memory/sc-core/tests/units/fs-storage/test_sc_file_system_api.cpp +++ b/sc-memory/sc-core/tests/units/fs-storage/test_sc_file_system_api.cpp @@ -90,6 +90,7 @@ TEST(ScFileSystemTest, sc_file_system_read_binary_file) sc_fs_get_file_content(path, &content, &content_size); EXPECT_TRUE(sc_str_cmp(content, "$\u0010")); sc_mem_free(content); + EXPECT_TRUE(sc_fs_remove_file(path)); } TEST(ScFileSystemTest, sc_file_system_read_invalid_file) diff --git a/sc-memory/sc-core/tests/units/fs-storage/test_sc_fs_memory_api.cpp b/sc-memory/sc-core/tests/units/fs-storage/test_sc_fs_memory_api.cpp index a3ddd07e4d..197d4973e5 100644 --- a/sc-memory/sc-core/tests/units/fs-storage/test_sc_fs_memory_api.cpp +++ b/sc-memory/sc-core/tests/units/fs-storage/test_sc_fs_memory_api.cpp @@ -4,7 +4,7 @@ * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) */ -#include +#include "sc_fs_memory_test.hpp" extern "C" { @@ -17,10 +17,7 @@ extern "C" #include } -#define SC_FS_MEMORY_PATH "fs-memory" -#define SC_FS_MEMORY_SEGMENTS_PATH SC_FS_MEMORY_PATH "/segments.scdb" - -TEST(ScFSMemoryTest, sc_fs_memory_initialize_shutdown) +TEST_F(ScFSMemoryTest, sc_fs_memory_initialize_shutdown) { EXPECT_EQ(sc_fs_memory_initialize(SC_FS_MEMORY_PATH, SC_FALSE), SC_FS_MEMORY_OK); EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); @@ -29,7 +26,7 @@ TEST(ScFSMemoryTest, sc_fs_memory_initialize_shutdown) EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); } -TEST(ScFSMemoryTest, sc_fs_memory_initialize_shutdown_invalid_path) +TEST_F(ScFSMemoryTest, sc_fs_memory_initialize_shutdown_invalid_path) { EXPECT_EQ(sc_fs_memory_initialize("", SC_FALSE), SC_FS_MEMORY_NO); EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_NO); @@ -38,7 +35,7 @@ TEST(ScFSMemoryTest, sc_fs_memory_initialize_shutdown_invalid_path) EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_NO); } -TEST(ScFSMemoryTest, sc_fs_memory_initialize_shutdown_clear) +TEST_F(ScFSMemoryTest, sc_fs_memory_initialize_shutdown_clear) { EXPECT_EQ(sc_fs_memory_initialize(SC_FS_MEMORY_PATH, SC_TRUE), SC_FS_MEMORY_OK); EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); @@ -47,7 +44,7 @@ TEST(ScFSMemoryTest, sc_fs_memory_initialize_shutdown_clear) EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); } -TEST(ScFSMemoryTest, sc_fs_memory_save_load) +TEST_F(ScFSMemoryTest, sc_fs_memory_save_load) { EXPECT_EQ(sc_fs_memory_initialize(SC_FS_MEMORY_PATH, SC_TRUE), SC_FS_MEMORY_OK); @@ -74,38 +71,7 @@ TEST(ScFSMemoryTest, sc_fs_memory_save_load) EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); } -TEST(ScFSMemoryTest, sc_fs_memory_save_load_deprecated_segments) -{ - EXPECT_TRUE(sc_fs_copy_file( - SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH "/test/segments.scdb", - SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH "/segments.scdb")); - EXPECT_TRUE(sc_fs_copy_file( - SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH "/test/strings.scdb", - SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH "/strings.scdb")); - - EXPECT_EQ(sc_fs_memory_initialize(SC_DEPRECATED_DICTIONARY_FS_MEMORY_PATH, SC_FALSE), SC_FS_MEMORY_OK); - - sc_storage * storage = sc_mem_new(sc_storage, 1); - storage->segments = sc_mem_new(sc_segment *, 1); - - EXPECT_EQ(sc_fs_memory_load(storage), SC_FS_MEMORY_OK); - EXPECT_EQ(storage->segments_count, 1u); - - EXPECT_EQ(sc_fs_memory_save(storage), SC_FS_MEMORY_OK); - for (sc_addr_seg i = 0; i < storage->segments_count; ++i) - sc_segment_free(storage->segments[i]); - - EXPECT_EQ(sc_fs_memory_load(storage), SC_FS_MEMORY_OK); - for (sc_addr_seg i = 0; i < storage->segments_count; ++i) - sc_segment_free(storage->segments[i]); - - sc_mem_free(storage->segments); - sc_mem_free(storage); - - EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); -} - -TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_file_read) +TEST_F(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_file_read) { EXPECT_EQ(sc_fs_memory_initialize(SC_FS_MEMORY_PATH, SC_TRUE), SC_FS_MEMORY_OK); @@ -127,7 +93,7 @@ TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_file_read) EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); } -TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segments_num_read) +TEST_F(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segments_num_read) { EXPECT_EQ(sc_fs_memory_initialize(SC_FS_MEMORY_PATH, SC_TRUE), SC_FS_MEMORY_OK); @@ -147,7 +113,7 @@ TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segments_num_read) EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); } -TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segment_read) +TEST_F(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segment_read) { EXPECT_EQ(sc_fs_memory_initialize(SC_FS_MEMORY_PATH, SC_TRUE), SC_FS_MEMORY_OK); @@ -179,7 +145,7 @@ TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segment_read) EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); } -TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_file_write) +TEST_F(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_file_write) { EXPECT_EQ(sc_fs_memory_initialize(SC_FS_MEMORY_PATH, SC_TRUE), SC_FS_MEMORY_OK); EXPECT_TRUE(sc_fs_remove_directory(SC_FS_MEMORY_PATH)); @@ -199,7 +165,7 @@ TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_file_write) EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); } -TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segments_num_write) +TEST_F(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segments_num_write) { EXPECT_EQ(sc_fs_memory_initialize(SC_FS_MEMORY_PATH, SC_TRUE), SC_FS_MEMORY_OK); @@ -218,7 +184,7 @@ TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segments_num_write) EXPECT_EQ(sc_fs_memory_shutdown(), SC_FS_MEMORY_OK); } -TEST(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segment_write) +TEST_F(ScFSMemoryTest, sc_fs_memory_save_load_save_invalid_segment_write) { EXPECT_EQ(sc_fs_memory_initialize(SC_FS_MEMORY_PATH, SC_TRUE), SC_FS_MEMORY_OK); diff --git a/sc-tools/sc-builder/CMakeLists.txt b/sc-tools/sc-builder/CMakeLists.txt index b606e9fd60..6609efb49b 100644 --- a/sc-tools/sc-builder/CMakeLists.txt +++ b/sc-tools/sc-builder/CMakeLists.txt @@ -20,9 +20,6 @@ target_include_directories(sc-builder-lib PUBLIC $ PUBLIC $ ) -target_compile_definitions(sc-builder-lib PRIVATE - SC_PREPARE_BUILD_SCRIPTS_PATH="${SC_MACHINE_ROOT}/scripts" -) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} diff --git a/sc-tools/sc-builder/src/builder_defines.hpp b/sc-tools/sc-builder/src/builder_defines.hpp deleted file mode 100644 index 6b47d59797..0000000000 --- a/sc-tools/sc-builder/src/builder_defines.hpp +++ /dev/null @@ -1 +0,0 @@ -#define SC_PREPARE_BUILD_SCRIPTS_PATH "/Users/nikitazotov/Development/apps/ostis/ostis-apps/ostis-example-app/ostis-web-platform/sc-machine/scripts" diff --git a/sc-tools/sc-builder/tests/CMakeLists.txt b/sc-tools/sc-builder/tests/CMakeLists.txt index 891084fcbf..14636892ec 100644 --- a/sc-tools/sc-builder/tests/CMakeLists.txt +++ b/sc-tools/sc-builder/tests/CMakeLists.txt @@ -1,21 +1,8 @@ -add_custom_target(sc-builder-tests-kb-generator ALL - COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder" -i "${CMAKE_CURRENT_SOURCE_DIR}/repo.path" -o "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder-test-repo" --clear - DEPENDS sc-builder -) - make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units NAME sc-builder-tests DEPENDS sc-builder-lib INCLUDES ${SC_BUILDER_SRC} ) -add_dependencies(sc-builder-tests sc-builder-tests-kb-generator) -target_compile_definitions(sc-builder-tests PRIVATE - SC_BUILDER_KB_BIN="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder-test-repo" - SC_BUILDER_REPO_PATH="${CMAKE_CURRENT_SOURCE_DIR}/repo.path" - SC_BUILDER_KB="${CMAKE_CURRENT_SOURCE_DIR}/kb" - SC_BUILDER_INI="${CMAKE_CURRENT_SOURCE_DIR}/sc-builder-test.ini" - SC_BUILDER_TEST_REPOS="${CMAKE_CURRENT_SOURCE_DIR}/repos" -) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-builder-tests) diff --git a/sc-tools/sc-builder/tests/deprecated-input-path.ini b/sc-tools/sc-builder/tests/configs/deprecated-input-path.ini similarity index 100% rename from sc-tools/sc-builder/tests/deprecated-input-path.ini rename to sc-tools/sc-builder/tests/configs/deprecated-input-path.ini diff --git a/sc-tools/sc-builder/tests/output-path-as-storage.ini b/sc-tools/sc-builder/tests/configs/output-path-as-storage.ini similarity index 100% rename from sc-tools/sc-builder/tests/output-path-as-storage.ini rename to sc-tools/sc-builder/tests/configs/output-path-as-storage.ini diff --git a/sc-tools/sc-builder/tests/unused-builder-group.ini b/sc-tools/sc-builder/tests/configs/unused-builder-group.ini similarity index 100% rename from sc-tools/sc-builder/tests/unused-builder-group.ini rename to sc-tools/sc-builder/tests/configs/unused-builder-group.ini diff --git a/sc-tools/sc-builder/tests/used-builder-group.ini b/sc-tools/sc-builder/tests/configs/used-builder-group.ini similarity index 100% rename from sc-tools/sc-builder/tests/used-builder-group.ini rename to sc-tools/sc-builder/tests/configs/used-builder-group.ini diff --git a/sc-tools/sc-builder/tests/without-builder-group.ini b/sc-tools/sc-builder/tests/configs/without-builder-group.ini similarity index 100% rename from sc-tools/sc-builder/tests/without-builder-group.ini rename to sc-tools/sc-builder/tests/configs/without-builder-group.ini diff --git a/sc-tools/sc-builder/tests/repo.path b/sc-tools/sc-builder/tests/repo.path index 7f1181929c..fe5747f023 100644 --- a/sc-tools/sc-builder/tests/repo.path +++ b/sc-tools/sc-builder/tests/repo.path @@ -1,2 +1,3 @@ kb !kb/tests-gwf-to-scs +!kb/test-gwf diff --git a/sc-tools/sc-builder/tests/units/builder_test.hpp b/sc-tools/sc-builder/tests/units/builder_test.hpp index 77a222d799..26eb17792a 100644 --- a/sc-tools/sc-builder/tests/units/builder_test.hpp +++ b/sc-tools/sc-builder/tests/units/builder_test.hpp @@ -9,14 +9,34 @@ #include #include +#include +#include +#include #include #include -#include + +#include class ScBuilderTest : public testing::Test { +public: + static inline std::string const & SC_BUILDER_INI = "../sc-builder-test.ini"; + static inline std::string const & SC_BUILDER_KB_BIN = "sc-builder-test-bin"; + static inline std::string const & SC_BUILDER_REPO_PATH = "../repo.path"; + static inline std::string const & SC_BUILDER_KB = "../kb"; + static inline std::string const & SC_BUILDER_TEST_REPOS = "../repos"; + static inline std::string const & SC_BUILDER_KB_GWF = SC_BUILDER_KB + "/tests-gwf-to-scs/"; + static inline std::string const & SC_BUILDER_CONFIGS = "../configs"; + protected: + void LoadKB(std::unique_ptr const & m_context, std::unordered_set const & sources) + { + ScsLoader loader; + for (std::string const & source : sources) + loader.loadScsFile(*m_context, ScBuilderTest::SC_BUILDER_KB + "/" + source); + } + virtual void SetUp() { ScBuilderTest::Initialize(); @@ -29,6 +49,8 @@ class ScBuilderTest : public testing::Test m_ctx->Destroy(); ScBuilderTest::Shutdown(); + + std::filesystem::remove_all(SC_BUILDER_KB_BIN); } static void Initialize() @@ -39,8 +61,8 @@ class ScBuilderTest : public testing::Test params.dump_memory = SC_FALSE; params.dump_memory_statistics = SC_FALSE; - params.clear = SC_FALSE; - params.storage = SC_BUILDER_KB_BIN; + params.clear = SC_TRUE; + params.storage = SC_BUILDER_KB_BIN.c_str(); ScMemory::LogMute(); ScMemory::Initialize(params); @@ -55,8 +77,8 @@ class ScBuilderTest : public testing::Test params.dump_memory = SC_FALSE; params.dump_memory_statistics = SC_FALSE; - params.clear = SC_FALSE; - params.storage = SC_BUILDER_KB_BIN; + params.clear = SC_TRUE; + params.storage = SC_BUILDER_KB_BIN.c_str(); params.user_mode = SC_TRUE; diff --git a/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp b/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp index 13b2657e3c..2064a25bce 100644 --- a/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp +++ b/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp @@ -10,10 +10,17 @@ #include "sc_repo_path_collector.hpp" -#define TEST_REPOS_KB SC_BUILDER_TEST_REPOS "/kb" - class ScRepoPathCollectorTestAPI : public testing::Test { +public: + static inline std::string const & SC_BUILDER_TEST_REPOS = "../repos"; + static inline std::string const & SC_BUILDER_TEST_REPOS_KB = SC_BUILDER_TEST_REPOS + "/kb"; + static inline std::string const & SC_BUILDER_TEST_SIMPLE_REPO_PATH = SC_BUILDER_TEST_REPOS + "/simple_repo.path"; + static inline std::string const & SC_BUILDER_TEST_REPEATED_REPOS = SC_BUILDER_TEST_REPOS + "/repeated_repos.path"; + static inline std::string const & SC_BUILDER_TEST_EXCLUDED_REPOS = SC_BUILDER_TEST_REPOS + "/excluded_repos.path"; + static inline std::string const & SC_BUILDER_TEST_NON_TRIM_REPOS = SC_BUILDER_TEST_REPOS + "/non_trim_repos.path"; + static inline std::string const & SC_BUILDER_TEST_INVALID_REPO_PATH = SC_BUILDER_TEST_REPOS + "/invalid_repo_path.path"; + protected: ScRepoPathCollector collector; diff --git a/sc-tools/sc-builder/tests/units/test_aliases.cpp b/sc-tools/sc-builder/tests/units/test_aliases.cpp index caa94e48a2..bba45c2364 100644 --- a/sc-tools/sc-builder/tests/units/test_aliases.cpp +++ b/sc-tools/sc-builder/tests/units/test_aliases.cpp @@ -6,8 +6,10 @@ #include "builder_test.hpp" -TEST_F(ScBuilderTest, aliases) +TEST_F(ScBuilderTest, Aliases) { + LoadKB(m_ctx, {"aliases.scs"}); + std::string const scsTempl = "test_element _-> _[] (* _<- alias_content;; *);;"; ScTemplate templ; diff --git a/sc-tools/sc-builder/tests/units/test_base.cpp b/sc-tools/sc-builder/tests/units/test_base.cpp index 34c413218d..716526ffdc 100644 --- a/sc-tools/sc-builder/tests/units/test_base.cpp +++ b/sc-tools/sc-builder/tests/units/test_base.cpp @@ -8,7 +8,7 @@ TEST_F(ScBuilderTest, Smoke) { - ScMemoryContext ctx; + LoadKB(m_ctx, {"base.scs"}); std::string const scsData = "base" @@ -18,14 +18,16 @@ TEST_F(ScBuilderTest, Smoke) " (* _<- lang_en;; *);;"; ScTemplate templ; - ctx.BuildTemplate(templ, scsData); + m_ctx->BuildTemplate(templ, scsData); ScTemplateSearchResult res; - EXPECT_TRUE(ctx.SearchByTemplate(templ, res)); + EXPECT_TRUE(m_ctx->SearchByTemplate(templ, res)); } TEST_F(ScBuilderTest, TemplateWithVarTriplesBig) { + LoadKB(m_ctx, {"test-templates/template_1.scs"}); + ScAddr checkTemplateStructure = m_ctx->SearchElementBySystemIdentifier("test_template_big"); ScTemplate checkTemplate; @@ -45,6 +47,8 @@ TEST_F(ScBuilderTest, TemplateWithVarTriplesBig) TEST_F(ScBuilderTest, TemplateWithVarTriplesSmall) { + LoadKB(m_ctx, {"test-templates/template_2.scs"}); + ScAddr checkTemplateStructure = m_ctx->SearchElementBySystemIdentifier("test_template_small"); ScTemplate checkTemplate; @@ -56,6 +60,8 @@ TEST_F(ScBuilderTest, TemplateWithVarTriplesSmall) TEST_F(ScBuilderTest, TemplateWithVarTriplesSmall2) { + LoadKB(m_ctx, {"test-templates/template_2.scs"}); + ScAddr const & checkTemplateStructure = m_ctx->SearchElementBySystemIdentifier("test_template_small"); ScTemplateParams params; @@ -75,6 +81,8 @@ TEST_F(ScBuilderTest, TemplateWithVarTriplesSmall2) TEST_F(ScBuilderTest, SearchTemplateWithVarAddrSubstituteInParams) { + LoadKB(m_ctx, {"test-templates/template_2.scs"}); + ScAddr const & checkTemplateStructure = m_ctx->SearchElementBySystemIdentifier("test_template_small"); ScTemplateParams params; @@ -94,6 +102,8 @@ TEST_F(ScBuilderTest, SearchTemplateWithVarAddrSubstituteInParams) TEST_F(ScBuilderTest, TemplateWithVarTriplesSmall3) { + LoadKB(m_ctx, {"test-templates/template_2.scs"}); + ScAddr const & checkTemplateStructure = m_ctx->SearchElementBySystemIdentifier("test_template_small"); ScTemplateParams params; diff --git a/sc-tools/sc-builder/tests/units/test_clean.cpp b/sc-tools/sc-builder/tests/units/test_clean.cpp index 2f916edb6f..9eafb441d4 100644 --- a/sc-tools/sc-builder/tests/units/test_clean.cpp +++ b/sc-tools/sc-builder/tests/units/test_clean.cpp @@ -8,7 +8,7 @@ #include -TEST_F(ScBuilderTest, clean_global_idtfs) +TEST_F(ScBuilderTest, CleanGlobalIdtfs) { ScAddr const nrelSCsIdtf = m_ctx->ResolveElementSystemIdentifier("nrel_scs_global_idtf"); EXPECT_TRUE(nrelSCsIdtf.IsValid()); diff --git a/sc-tools/sc-builder/tests/units/test_config.cpp b/sc-tools/sc-builder/tests/units/test_config.cpp index 53d2c2ab55..117c3195f9 100644 --- a/sc-tools/sc-builder/tests/units/test_config.cpp +++ b/sc-tools/sc-builder/tests/units/test_config.cpp @@ -18,95 +18,109 @@ TEST(ScBuilder, Run) { sc_uint32 const argsNumber = 8; sc_char const * args[argsNumber] = { - "sc-builder", "-c", SC_BUILDER_INI, "-i", SC_BUILDER_REPO_PATH, "-o", SC_BUILDER_KB_BIN, "--clear"}; + "sc-builder", "-c", ScBuilderTest::SC_BUILDER_INI.c_str(), "-i", ScBuilderTest::SC_BUILDER_REPO_PATH.c_str(), "-o", ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_SUCCESS); } TEST(ScBuilder, RunWithOptionsFromBuilderGroup) { + std::string const & configPath = ScBuilderTest::SC_BUILDER_CONFIGS + "/used-builder-group.ini"; + sc_uint32 const argsNumber = 4; - sc_char const * args[argsNumber] = {"sc-builder", "-c", SC_BUILDER_CONFIGS "/used-builder-group.ini", "--clear"}; + sc_char const * args[argsNumber] = {"sc-builder", "-c", configPath.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_SUCCESS); } TEST(ScBuilder, RunWithOptionsFromBuilderGroupAndWithOptionsFromCommandLine) { + std::string const & configPath = ScBuilderTest::SC_BUILDER_CONFIGS + "/unused-builder-group.ini"; + sc_uint32 const argsNumber = 8; sc_char const * args[argsNumber] = { "sc-builder", "-c", - SC_BUILDER_CONFIGS "/unused-builder-group.ini", + configPath.c_str(), "-i", - SC_BUILDER_REPO_PATH, + ScBuilderTest::SC_BUILDER_REPO_PATH.c_str(), "-o", - SC_BUILDER_KB_BIN, + ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_SUCCESS); } TEST(ScBuilder, RunWithoutBuilderGroupAndWithOptionsFromCommandLine) { + std::string const & configPath = ScBuilderTest::SC_BUILDER_CONFIGS + "/without-builder-group.ini"; + sc_uint32 const argsNumber = 8; sc_char const * args[argsNumber] = { "sc-builder", "-c", - SC_BUILDER_CONFIGS "/without-builder-group.ini", + configPath.c_str(), "-i", - SC_BUILDER_REPO_PATH, + ScBuilderTest::SC_BUILDER_REPO_PATH.c_str(), "-o", - SC_BUILDER_KB_BIN, + ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_SUCCESS); } TEST(ScBuilder, RunWithoutBuilderGroupAndWithoutInputOption) { + std::string const & configPath = ScBuilderTest::SC_BUILDER_CONFIGS + "/without-builder-group.ini"; + sc_uint32 const argsNumber = 6; sc_char const * args[argsNumber] = { - "sc-builder", "-c", SC_BUILDER_CONFIGS "/without-builder-group.ini", "-o", SC_BUILDER_KB_BIN, "--clear"}; + "sc-builder", "-c", configPath.c_str(), "-o", ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_FAILURE); } TEST(ScBuilder, RunWithoutBuilderGroupAndWithoutOutputOption) { + std::string const & configPath = ScBuilderTest::SC_BUILDER_CONFIGS + "/without-builder-group.ini"; + sc_uint32 const argsNumber = 6; sc_char const * args[argsNumber] = { - "sc-builder", "-c", SC_BUILDER_CONFIGS "/without-builder-group.ini", "-i", SC_BUILDER_KB, "--clear"}; + "sc-builder", "-c", configPath.c_str(), "-i", ScBuilderTest::SC_BUILDER_KB.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_FAILURE); } TEST(ScBuilder, RunWithDeprecatedInputPathOption) { + std::string const & configPath = ScBuilderTest::SC_BUILDER_CONFIGS + "/deprecated-input-path.ini"; + sc_uint32 const argsNumber = 4; - sc_char const * args[argsNumber] = {"sc-builder", "-c", SC_BUILDER_CONFIGS "/deprecated-input-path.ini", "--clear"}; + sc_char const * args[argsNumber] = {"sc-builder", "-c", configPath.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_SUCCESS); } TEST(ScBuilder, RunWithOutputPathAsMemoryStorage) { + std::string const & configPath = ScBuilderTest::SC_BUILDER_CONFIGS + "/output-path-as-storage.ini"; + sc_uint32 const argsNumber = 4; - sc_char const * args[argsNumber] = {"sc-builder", "-c", SC_BUILDER_CONFIGS "/output-path-as-storage.ini", "--clear"}; + sc_char const * args[argsNumber] = {"sc-builder", "-c", configPath.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_SUCCESS); } TEST(ScBuilder, RunWithoutConfig) { sc_uint32 const argsNumber = 6; - sc_char const * args[argsNumber] = {"sc-builder", "-i", SC_BUILDER_REPO_PATH, "-o", SC_BUILDER_KB_BIN, "--clear"}; + sc_char const * args[argsNumber] = {"sc-builder", "-i", ScBuilderTest::SC_BUILDER_REPO_PATH.c_str(), "-o", ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_SUCCESS); } TEST(ScBuilder, RunWithoutInput) { sc_uint32 const argsNumber = 4; - sc_char const * args[argsNumber] = {"sc-builder", "-o", SC_BUILDER_KB_BIN, "--clear"}; + sc_char const * args[argsNumber] = {"sc-builder", "-o", ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_FAILURE); } TEST(ScBuilder, RunWithoutOutput) { sc_uint32 const argsNumber = 4; - sc_char const * args[argsNumber] = {"sc-builder", "-i", SC_BUILDER_REPO_PATH, "--clear"}; + sc_char const * args[argsNumber] = {"sc-builder", "-i", ScBuilderTest::SC_BUILDER_REPO_PATH.c_str(), "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_FAILURE); } @@ -136,13 +150,13 @@ TEST(ScBuilder, RunStopBuilder) ScOptions options{1, nullptr}; BuilderParams params; - params.m_inputPath = SC_BUILDER_REPO_PATH; - params.m_outputPath = SC_BUILDER_KB_BIN; + params.m_inputPath = ScBuilderTest::SC_BUILDER_REPO_PATH; + params.m_outputPath = ScBuilderTest::SC_BUILDER_KB_BIN; - std::string config = SC_BUILDER_INI; + std::string config = ScBuilderTest::SC_BUILDER_INI; ScParams memoryParams{options, {}}; - memoryParams.Insert({"storage", SC_BUILDER_KB_BIN}); + memoryParams.Insert({"storage", ScBuilderTest::SC_BUILDER_KB_BIN}); ScConfig configFile{config, {"storage"}}; std::string memoryGroupName = "sc-memory"; @@ -194,14 +208,14 @@ TEST(ScBuilder, BuilderConfig) ScOptions options{1, nullptr}; BuilderParams builderParams; - builderParams.m_inputPath = SC_BUILDER_REPO_PATH; - builderParams.m_outputPath = SC_BUILDER_KB_BIN; + builderParams.m_inputPath = ScBuilderTest::SC_BUILDER_REPO_PATH; + builderParams.m_outputPath = ScBuilderTest::SC_BUILDER_KB_BIN; - std::string config = SC_BUILDER_INI; + std::string config = ScBuilderTest::SC_BUILDER_INI; ScConfig configFile{config, {"storage"}}; ScParams memoryParams{options, {}}; - memoryParams.Insert({"storage", SC_BUILDER_KB_BIN}); + memoryParams.Insert({"storage", ScBuilderTest::SC_BUILDER_KB_BIN}); memoryParams.Insert({"clear", {}}); ScMemoryConfig memoryConfig{configFile, memoryParams}; diff --git a/sc-tools/sc-builder/tests/units/test_contents.cpp b/sc-tools/sc-builder/tests/units/test_contents.cpp index ad95c76996..b753ae4505 100644 --- a/sc-tools/sc-builder/tests/units/test_contents.cpp +++ b/sc-tools/sc-builder/tests/units/test_contents.cpp @@ -8,13 +8,15 @@ #include -TEST_F(ScBuilderTest, file_relative) +TEST_F(ScBuilderTest, RelativeFile) { /* "file://file.txt" => nrel_system_identifier: [test_content_file];; */ + LoadKB(m_ctx, {"contents.scs"}); + ScAddr const linkAddr = m_ctx->ResolveElementSystemIdentifier("test_content_file"); EXPECT_TRUE(linkAddr.IsValid()); @@ -23,8 +25,10 @@ TEST_F(ScBuilderTest, file_relative) EXPECT_EQ(content, "file"); } -TEST_F(ScBuilderTest, file_relative_folder) +TEST_F(ScBuilderTest, RelativeFolder) { + LoadKB(m_ctx, {"contents.scs"}); + ScAddr const linkAddr = m_ctx->ResolveElementSystemIdentifier("test_content_file_2"); EXPECT_TRUE(linkAddr.IsValid()); @@ -33,8 +37,10 @@ TEST_F(ScBuilderTest, file_relative_folder) EXPECT_EQ(content, "contents/file"); } -TEST_F(ScBuilderTest, file_relative_folder_scs_level_1) +TEST_F(ScBuilderTest, RelativeFolderSCsLevel1) { + LoadKB(m_ctx, {"contents.scs"}); + ScAddr const linkAddr = m_ctx->ResolveElementSystemIdentifier("test_content_file_3"); EXPECT_TRUE(linkAddr.IsValid()); @@ -55,8 +61,10 @@ void CheckBinaryContent(ScMemoryContext & ctx, std::string const & sysIdtf, Valu EXPECT_EQ(link.Get(), value); } -TEST_F(ScBuilderTest, binary_contents) +TEST_F(ScBuilderTest, BinaryContents) { + LoadKB(m_ctx, {"contents.scs"}); + CheckBinaryContent(*m_ctx, "test_content_string", "string"); CheckBinaryContent(*m_ctx, "test_content_float", 43.567f); CheckBinaryContent(*m_ctx, "test_content_double", 543.345); diff --git a/sc-tools/sc-builder/tests/units/test_gwf_translator.cpp b/sc-tools/sc-builder/tests/units/test_gwf_translator.cpp index faf1dc96f9..aecf6fd937 100644 --- a/sc-tools/sc-builder/tests/units/test_gwf_translator.cpp +++ b/sc-tools/sc-builder/tests/units/test_gwf_translator.cpp @@ -23,8 +23,6 @@ using GWFTranslatorTest = ScBuilderTest; -#define BASE_TEST_PATH SC_BUILDER_KB "/tests-gwf-to-scs/" - std::vector ReadFileToBytes(std::string const & filePath) { std::ifstream file(filePath, std::ios::binary | std::ios::ate); @@ -52,7 +50,7 @@ std::string ReadFileToString(std::string const & filePath) Differences CheckGWFToSCSTranslation(std::string const & fileName) { - std::string const & testGWFFilePath = BASE_TEST_PATH + fileName; + std::string const & testGWFFilePath = ScBuilderTest::SC_BUILDER_KB_GWF + fileName; std::string const & correctSCsFilePath = testGWFFilePath + ".scs"; std::string const & testSCsText = GWFTranslator::TranslateXMLFileContentToSCs(testGWFFilePath); @@ -70,7 +68,7 @@ TEST_F(GWFTranslatorTest, InvalidPath) { GWFTranslator translator(*m_ctx); - std::string const filePath = BASE_TEST_PATH "invalid_path.gwf"; + std::string const filePath = SC_BUILDER_KB_GWF + "/invalid_path.gwf"; EXPECT_THROW(translator.TranslateXMLFileContentToSCs(filePath), utils::ExceptionParseError); } @@ -78,60 +76,60 @@ TEST_F(GWFTranslatorTest, EmptyFile) { GWFTranslator translator(*m_ctx); - std::string const filePath = BASE_TEST_PATH "empty_file.gwf"; + std::string const filePath = SC_BUILDER_KB_GWF + "/empty_file.gwf"; EXPECT_THROW(translator.TranslateXMLFileContentToSCs(filePath), utils::ExceptionParseError); } TEST_F(GWFTranslatorTest, EmptyStatic) { - std::string const & filePath = BASE_TEST_PATH "empty_static.gwf"; + std::string const & filePath = SC_BUILDER_KB_GWF + "/empty_static.gwf"; EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(filePath), utils::ExceptionParseError); } TEST_F(GWFTranslatorTest, NoStatic) { - std::string const & filePath = BASE_TEST_PATH "no_static_sector.gwf"; + std::string const & filePath = SC_BUILDER_KB_GWF + "/no_static_sector.gwf"; EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(filePath), utils::ExceptionParseError); } TEST_F(GWFTranslatorTest, EmptyGWF) { - EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(BASE_TEST_PATH), utils::ExceptionParseError); + EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(SC_BUILDER_KB_GWF), utils::ExceptionParseError); } TEST_F(GWFTranslatorTest, UnknownTag) { - std::string const filePath = BASE_TEST_PATH "unknown_tag.gwf"; + std::string const filePath = SC_BUILDER_KB_GWF + "/unknown_tag.gwf"; EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(filePath), utils::ExceptionParseError); } TEST_F(GWFTranslatorTest, UnknownLinkContent) { - std::string const filePath = BASE_TEST_PATH "unknown_link_content.gwf"; + std::string const filePath = SC_BUILDER_KB_GWF + "/unknown_link_content.gwf"; EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(filePath), utils::ExceptionParseError); } TEST_F(GWFTranslatorTest, ContourWithUnknownParent) { - std::string const filePath = BASE_TEST_PATH "contour_with_unknown_parent.gwf"; + std::string const filePath = SC_BUILDER_KB_GWF + "/contour_with_unknown_parent.gwf"; EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(filePath), utils::ExceptionParseError); } TEST_F(GWFTranslatorTest, NodeWithUnknownId) { - std::string const filePath = BASE_TEST_PATH "node_with_unknown_id.gwf"; + std::string const filePath = SC_BUILDER_KB_GWF + "/node_with_unknown_id.gwf"; EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(filePath), utils::ExceptionParseError); } TEST_F(GWFTranslatorTest, NodeWithUnknownType) { - std::string const filePath = BASE_TEST_PATH "element_with_unknown_type.gwf"; + std::string const filePath = SC_BUILDER_KB_GWF + "/element_with_unknown_type.gwf"; EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(filePath), utils::ExceptionItemNotFound); } TEST_F(GWFTranslatorTest, ConnectorLoopedOnItself) { - std::string const filePath = BASE_TEST_PATH "connector_from_itself_to_itself.gwf"; + std::string const filePath = SC_BUILDER_KB_GWF + "/connector_from_itself_to_itself.gwf"; EXPECT_THROW(GWFTranslator::TranslateXMLFileContentToSCs(filePath), utils::ExceptionInvalidState); } @@ -164,14 +162,14 @@ TEST_F(GWFTranslatorTest, ContentTypes) Differences const & differences = CheckGWFToSCSTranslation("content_types.gwf"); EXPECT_TRUE(differences->empty()) << differencesToString(differences); - EXPECT_TRUE(CompareFiles(BASE_TEST_PATH "ostis.png", BASE_TEST_PATH "ostis_ref.png")); - std::filesystem::remove(BASE_TEST_PATH "ostis.png"); + EXPECT_TRUE(CompareFiles(SC_BUILDER_KB_GWF + "/ostis.png", SC_BUILDER_KB_GWF + "/ostis_ref.png")); + std::filesystem::remove(SC_BUILDER_KB_GWF + "/ostis.png"); } TEST_F(GWFTranslatorTest, SCsTree) { - std::string const & emptyContourGWFFilePath = BASE_TEST_PATH "empty_contour.gwf"; - std::string const & lotOfContoursGWFFilePath = BASE_TEST_PATH "lot_of_contours.gwf"; + std::string const & emptyContourGWFFilePath = SC_BUILDER_KB_GWF + "/empty_contour.gwf"; + std::string const & lotOfContoursGWFFilePath = SC_BUILDER_KB_GWF + "/lot_of_contours.gwf"; std::string const & lotOfContoursSCsFilePath = lotOfContoursGWFFilePath + ".scs"; std::string const & emptyContourSCsText = GWFTranslator::TranslateXMLFileContentToSCs(emptyContourGWFFilePath); diff --git a/sc-tools/sc-builder/tests/units/test_repo_path_collector_api.cpp b/sc-tools/sc-builder/tests/units/test_repo_path_collector_api.cpp index 09dc95d5c9..345a7d58ad 100644 --- a/sc-tools/sc-builder/tests/units/test_repo_path_collector_api.cpp +++ b/sc-tools/sc-builder/tests/units/test_repo_path_collector_api.cpp @@ -8,15 +8,9 @@ #include -#define TEST_SIMPLE_REPO SC_BUILDER_TEST_REPOS "/simple_repo.path" -#define TEST_REPEATED_REPOS SC_BUILDER_TEST_REPOS "/repeated_repos.path" -#define TEST_EXCLUDED_REPOS SC_BUILDER_TEST_REPOS "/excluded_repos.path" -#define TEST_NON_TRIM_REPOS SC_BUILDER_TEST_REPOS "/non_trim_repos.path" -#define TEST_INVALID_REPO_PATH SC_BUILDER_TEST_REPOS "/invalid_repo_path" - TEST_F(ScRepoPathCollectorTestAPI, IsSources) { - std::string const & directory = TEST_REPOS_KB; + std::string const & directory = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_REPOS_KB; EXPECT_TRUE(collector.IsSourceFile(directory + "/child_repos/child_kb/samples/sample1.scs")); EXPECT_TRUE(collector.IsSourceFile(directory + "/child_repos/child_kb/samples/sample2.scs")); @@ -42,13 +36,13 @@ TEST_F(ScRepoPathCollectorTestAPI, IsExcludedPath) TEST_F(ScRepoPathCollectorTestAPI, IsRepoPath) { - EXPECT_TRUE(collector.IsRepoPathFile(TEST_SIMPLE_REPO)); - EXPECT_FALSE(collector.IsRepoPathFile(TEST_INVALID_REPO_PATH)); + EXPECT_TRUE(collector.IsRepoPathFile(ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_SIMPLE_REPO_PATH)); + EXPECT_FALSE(collector.IsRepoPathFile(ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_INVALID_REPO_PATH)); } TEST_F(ScRepoPathCollectorTestAPI, SimpleRepo) { - std::string const & repoPath = TEST_SIMPLE_REPO; + std::string const & repoPath = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_SIMPLE_REPO_PATH; ScRepoPathCollector::Sources excludedSources, checkSources; EXPECT_TRUE(collector.IsRepoPathFile(repoPath)); @@ -58,7 +52,7 @@ TEST_F(ScRepoPathCollectorTestAPI, SimpleRepo) EXPECT_TRUE(excludedSources.empty()); EXPECT_EQ(checkSources.size(), 1u); - std::string const & directory = TEST_REPOS_KB; + std::string const & directory = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_REPOS_KB; EXPECT_EQ(checkSources.count(directory), 1u); ScRepoPathCollector::Sources buildSources; @@ -82,7 +76,7 @@ TEST_F(ScRepoPathCollectorTestAPI, SimpleRepo) TEST_F(ScRepoPathCollectorTestAPI, RepeatedRepos) { - std::string const & repoPath = TEST_REPEATED_REPOS; + std::string const & repoPath = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_REPEATED_REPOS; ScRepoPathCollector::Sources excludedSources, checkSources; EXPECT_TRUE(collector.IsRepoPathFile(repoPath)); @@ -92,7 +86,7 @@ TEST_F(ScRepoPathCollectorTestAPI, RepeatedRepos) EXPECT_TRUE(excludedSources.empty()); EXPECT_EQ(checkSources.size(), 1u); - std::string const & directory = TEST_REPOS_KB; + std::string const & directory = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_REPOS_KB; EXPECT_EQ(checkSources.count(directory), 1u); ScRepoPathCollector::Sources buildSources; @@ -116,7 +110,7 @@ TEST_F(ScRepoPathCollectorTestAPI, RepeatedRepos) TEST_F(ScRepoPathCollectorTestAPI, ExcludedRepos) { - std::string const & repoPath = TEST_EXCLUDED_REPOS; + std::string const & repoPath = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_EXCLUDED_REPOS; ScRepoPathCollector::Sources excludedSources, checkSources; EXPECT_TRUE(collector.IsRepoPathFile(repoPath)); @@ -124,11 +118,11 @@ TEST_F(ScRepoPathCollectorTestAPI, ExcludedRepos) collector.ParseRepoPath(repoPath, excludedSources, checkSources); EXPECT_EQ(excludedSources.size(), 1u); - std::string const & excludedDirectory = TEST_REPOS_KB "/templates"; + std::string const & excludedDirectory = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_REPOS_KB + "/templates"; EXPECT_EQ(excludedSources.count(excludedDirectory), 1u); EXPECT_EQ(checkSources.size(), 1u); - std::string const & directory = TEST_REPOS_KB; + std::string const & directory = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_REPOS_KB; EXPECT_EQ(checkSources.count(directory), 1u); ScRepoPathCollector::Sources buildSources; @@ -149,7 +143,7 @@ TEST_F(ScRepoPathCollectorTestAPI, ExcludedRepos) TEST_F(ScRepoPathCollectorTestAPI, NonTrimRepos) { - std::string const & repoPath = TEST_NON_TRIM_REPOS; + std::string const & repoPath = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_NON_TRIM_REPOS; ScRepoPathCollector::Sources excludedSources, checkSources; EXPECT_TRUE(collector.IsRepoPathFile(repoPath)); @@ -157,11 +151,11 @@ TEST_F(ScRepoPathCollectorTestAPI, NonTrimRepos) collector.ParseRepoPath(repoPath, excludedSources, checkSources); EXPECT_EQ(excludedSources.size(), 1u); - std::string const & excludedDirectory = TEST_REPOS_KB "/templates"; + std::string const & excludedDirectory = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_REPOS_KB + "/templates"; EXPECT_EQ(excludedSources.count(excludedDirectory), 1u); EXPECT_EQ(checkSources.size(), 1u); - std::string const & directory = TEST_REPOS_KB; + std::string const & directory = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_REPOS_KB; EXPECT_EQ(checkSources.count(directory), 1u); ScRepoPathCollector::Sources buildSources; @@ -182,7 +176,7 @@ TEST_F(ScRepoPathCollectorTestAPI, NonTrimRepos) TEST_F(ScRepoPathCollectorTestAPI, InvalidRepoPath) { - std::string const & repoPath = TEST_INVALID_REPO_PATH; + std::string const & repoPath = ScRepoPathCollectorTestAPI::SC_BUILDER_TEST_INVALID_REPO_PATH; ScRepoPathCollector::Sources excludedSources, checkSources; EXPECT_FALSE(collector.IsRepoPathFile(repoPath)); diff --git a/sc-tools/sc-builder/tests/units/test_users.cpp b/sc-tools/sc-builder/tests/units/test_users.cpp index 199f14c57a..23e221c304 100644 --- a/sc-tools/sc-builder/tests/units/test_users.cpp +++ b/sc-tools/sc-builder/tests/units/test_users.cpp @@ -37,6 +37,8 @@ void TestAuthenticationRequestUser( TEST_F(ScBuilderLoadUserPermissionsTest, UserWithGlobalReadPermissionsAndWithLocalWritePermissions) { + LoadKB(m_ctx, {"test-users/test_users.scs"}); + ScAddr const & userAddr = m_ctx->SearchElementBySystemIdentifier("test_user_1"); TestScMemoryContext userContext{userAddr}; @@ -69,6 +71,8 @@ TEST_F(ScBuilderLoadUserPermissionsTest, UserWithGlobalReadPermissionsAndWithLoc TEST_F(ScBuilderLoadUserPermissionsTest, UserWithGlobalReadPermissionsAndWithoutLocalWritePermissions) { + LoadKB(m_ctx, {"test-users/test_users.scs"}); + ScAddr const & userAddr = m_ctx->SearchElementBySystemIdentifier("test_user_2"); TestScMemoryContext userContext{userAddr}; @@ -88,9 +92,6 @@ TEST_F(ScBuilderLoadUserPermissionsTest, UserWithGlobalReadPermissionsAndWithout utils::ExceptionInvalidState); ScAddr const & userStructureAddr = userContext.SearchElementBySystemIdentifier("user_structure"); EXPECT_THROW(userContext.EraseElement(userStructureAddr), utils::ExceptionInvalidState); - EXPECT_THROW( - userContext.GenerateConnector(ScType::ConstTempPosArc, userStructureAddr, classAddr), - utils::ExceptionInvalidState); isAuthenticated = true; }); diff --git a/sc-tools/sc-builder/tests/units/test_visibility.cpp b/sc-tools/sc-builder/tests/units/test_visibility.cpp index 2b005a2794..6e20c5d883 100644 --- a/sc-tools/sc-builder/tests/units/test_visibility.cpp +++ b/sc-tools/sc-builder/tests/units/test_visibility.cpp @@ -34,8 +34,10 @@ std::string GetIdtf(ScMemoryContext & ctx, ScAddr const & addr) } // namespace -TEST_F(ScBuilderTest, visibility_sys_idtf) +TEST_F(ScBuilderTest, SystemIdentifierVisibility) { + LoadKB(m_ctx, {"visibility_first.scs", "visibility_second.scs"}); + ScAddr const visFirst = m_ctx->ResolveElementSystemIdentifier("visibility_first"); EXPECT_TRUE(visFirst.IsValid()); @@ -54,8 +56,10 @@ TEST_F(ScBuilderTest, visibility_sys_idtf) EXPECT_TRUE(m_ctx->SearchByTemplate(templ, result)); } -TEST_F(ScBuilderTest, visibility_global) +TEST_F(ScBuilderTest, GlobalVisibility) { + LoadKB(m_ctx, {"visibility_first.scs", "visibility_second.scs"}); + ScAddr const visFirst = m_ctx->ResolveElementSystemIdentifier("visibility_first_global"); EXPECT_TRUE(visFirst.IsValid()); @@ -77,8 +81,10 @@ TEST_F(ScBuilderTest, visibility_global) EXPECT_EQ(GetIdtf(*m_ctx, element), ".visibility_global"); } -TEST_F(ScBuilderTest, visibility_local) +TEST_F(ScBuilderTest, LocalVisibility) { + LoadKB(m_ctx, {"visibility_first.scs", "visibility_second.scs"}); + ScAddr const visFirst = m_ctx->ResolveElementSystemIdentifier("visibility_first_local"); EXPECT_TRUE(visFirst.IsValid()); diff --git a/sc-tools/sc-config/tests/CMakeLists.txt b/sc-tools/sc-config/tests/CMakeLists.txt index 28173acfd5..98fa0a611c 100644 --- a/sc-tools/sc-config/tests/CMakeLists.txt +++ b/sc-tools/sc-config/tests/CMakeLists.txt @@ -1,8 +1,3 @@ -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/test_defines.hpp.in" - "${CMAKE_CURRENT_SOURCE_DIR}/units/test_defines.hpp" -) - make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units NAME sc-config-tests DEPENDS sc-config diff --git a/sc-tools/sc-config/tests/deprecated-extensions-path.ini b/sc-tools/sc-config/tests/configs/deprecated-extensions-path.ini similarity index 100% rename from sc-tools/sc-config/tests/deprecated-extensions-path.ini rename to sc-tools/sc-config/tests/configs/deprecated-extensions-path.ini diff --git a/sc-tools/sc-config/tests/deprecated-repo-path.ini b/sc-tools/sc-config/tests/configs/deprecated-repo-path.ini similarity index 100% rename from sc-tools/sc-config/tests/deprecated-repo-path.ini rename to sc-tools/sc-config/tests/configs/deprecated-repo-path.ini diff --git a/sc-tools/sc-config/tests/empty-multiextensions.ini b/sc-tools/sc-config/tests/configs/empty-multiextensions.ini similarity index 100% rename from sc-tools/sc-config/tests/empty-multiextensions.ini rename to sc-tools/sc-config/tests/configs/empty-multiextensions.ini diff --git a/sc-tools/sc-config/tests/multiextensions-with-spaces.ini b/sc-tools/sc-config/tests/configs/multiextensions-with-spaces.ini similarity index 100% rename from sc-tools/sc-config/tests/multiextensions-with-spaces.ini rename to sc-tools/sc-config/tests/configs/multiextensions-with-spaces.ini diff --git a/sc-tools/sc-config/tests/multiextensions.ini b/sc-tools/sc-config/tests/configs/multiextensions.ini similarity index 100% rename from sc-tools/sc-config/tests/multiextensions.ini rename to sc-tools/sc-config/tests/configs/multiextensions.ini diff --git a/sc-tools/sc-config/tests/not-normalized-multiextensions.ini b/sc-tools/sc-config/tests/configs/not-normalized-multiextensions.ini similarity index 77% rename from sc-tools/sc-config/tests/not-normalized-multiextensions.ini rename to sc-tools/sc-config/tests/configs/not-normalized-multiextensions.ini index d705694956..b81716301a 100644 --- a/sc-tools/sc-config/tests/not-normalized-multiextensions.ini +++ b/sc-tools/sc-config/tests/configs/not-normalized-multiextensions.ini @@ -11,7 +11,7 @@ log_file = log_level = Debug storage = sc-machine-test-repo -extensions = bin/extensions_1;bin/../bin/extensions_2;../tests/bin/extensions_3;bin/extensions_3 +extensions = bin/extensions_1;bin/../bin/extensions_2;../configs/bin/extensions_3;bin/extensions_3 [sc-server] host = 127.0.0.1 diff --git a/sc-tools/sc-config/tests/removed-save-period.ini b/sc-tools/sc-config/tests/configs/removed-save-period.ini similarity index 100% rename from sc-tools/sc-config/tests/removed-save-period.ini rename to sc-tools/sc-config/tests/configs/removed-save-period.ini diff --git a/sc-tools/sc-config/tests/removed-update-period.ini b/sc-tools/sc-config/tests/configs/removed-update-period.ini similarity index 100% rename from sc-tools/sc-config/tests/removed-update-period.ini rename to sc-tools/sc-config/tests/configs/removed-update-period.ini diff --git a/sc-tools/sc-config/tests/test_defines.hpp.in b/sc-tools/sc-config/tests/test_defines.hpp.in deleted file mode 100644 index ba25ce1e5a..0000000000 --- a/sc-tools/sc-config/tests/test_defines.hpp.in +++ /dev/null @@ -1,4 +0,0 @@ -#define SC_MACHINE_REPO_PATH "${SC_BIN_PATH}/sc-machine-test-repo" -#define SC_MACHINE_EXTENSIONS "${SC_BIN_PATH}/extensions" -#define SC_MACHINE_INI "${CMAKE_CURRENT_SOURCE_DIR}/sc-machine-test.ini" -#define SC_CONFIGS "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/sc-tools/sc-config/tests/units/sc_config_test.hpp b/sc-tools/sc-config/tests/units/sc_config_test.hpp new file mode 100644 index 0000000000..ae13d35309 --- /dev/null +++ b/sc-tools/sc-config/tests/units/sc_config_test.hpp @@ -0,0 +1,25 @@ +/* + * This source file is part of an OSTIS project. For the latest info, see http://ostis.net + * Distributed under the MIT License + * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) + */ + +#pragma once + +#include + +class ScConfigTest : public testing::Test +{ +public: + static inline std::string const & SC_CONFIG_INI = "../sc-machine-test.ini"; + static inline std::string const & SC_CONFIGS = "../configs"; + +protected: + void SetUp() override + { + } + + void TearDown() override + { + } +}; diff --git a/sc-tools/sc-config/tests/units/test_config.cpp b/sc-tools/sc-config/tests/units/test_config.cpp index eff56c538a..257088da4c 100644 --- a/sc-tools/sc-config/tests/units/test_config.cpp +++ b/sc-tools/sc-config/tests/units/test_config.cpp @@ -4,16 +4,14 @@ * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) */ -#include - -#include "test_defines.hpp" +#include "sc_config_test.hpp" #include #include -TEST(ScConfig, ValidConfig) +TEST_F(ScConfigTest, ValidConfig) { - ScConfig config{SC_MACHINE_INI}; + ScConfig config{SC_CONFIG_INI}; ScMemoryConfig memoryConfig{config, {}}; @@ -31,27 +29,27 @@ TEST(ScConfig, ValidConfig) EXPECT_EQ(std::string(params.extensions_directories[0]), "bin/extensions"); } -TEST(ScConfig, RemoveSavePeriod) +TEST_F(ScConfigTest, RemoveSavePeriod) { - ScConfig config{SC_CONFIGS "/removed-save-period.ini"}; + ScConfig config{SC_CONFIGS + "/removed-save-period.ini"}; ScMemoryConfig memoryConfig{config, {}}; EXPECT_THROW(memoryConfig.GetParams(), utils::ExceptionInvalidParams); } -TEST(ScConfig, RemoveUpdatePeriod) +TEST_F(ScConfigTest, RemoveUpdatePeriod) { - ScConfig config{SC_CONFIGS "/removed-update-period.ini"}; + ScConfig config{SC_CONFIGS + "/removed-update-period.ini"}; ScMemoryConfig memoryConfig{config, {}}; EXPECT_THROW(memoryConfig.GetParams(), utils::ExceptionInvalidParams); } -TEST(ScConfig, DeprecatedRepoPath) +TEST_F(ScConfigTest, DeprecatedRepoPath) { - ScConfig config{SC_CONFIGS "/deprecated-repo-path.ini"}; + ScConfig config{SC_CONFIGS + "/deprecated-repo-path.ini"}; ScMemoryConfig memoryConfig{config, {}}; @@ -69,9 +67,9 @@ TEST(ScConfig, DeprecatedRepoPath) EXPECT_EQ(std::string(params.extensions_directories[0]), "bin/extensions"); } -TEST(ScConfig, DeprecatedExtensionsPath) +TEST_F(ScConfigTest, DeprecatedExtensionsPath) { - ScConfig config{SC_CONFIGS "/deprecated-extensions-path.ini"}; + ScConfig config{SC_CONFIGS + "/deprecated-extensions-path.ini"}; ScMemoryConfig memoryConfig{config, {}}; @@ -89,9 +87,9 @@ TEST(ScConfig, DeprecatedExtensionsPath) EXPECT_EQ(std::string(params.extensions_directories[0]), "bin/extensions"); } -TEST(ScConfig, Multiextensions) +TEST_F(ScConfigTest, Multiextensions) { - ScConfig config{SC_CONFIGS "/multiextensions.ini"}; + ScConfig config{SC_CONFIGS + "/multiextensions.ini"}; ScMemoryConfig memoryConfig{config, {}}; @@ -111,9 +109,9 @@ TEST(ScConfig, Multiextensions) EXPECT_EQ(std::string(params.extensions_directories[2]), "bin/extensions_3"); } -TEST(ScConfig, EmptyMultiextensions) +TEST_F(ScConfigTest, EmptyMultiextensions) { - ScConfig config{SC_CONFIGS "/empty-multiextensions.ini"}; + ScConfig config{SC_CONFIGS + "/empty-multiextensions.ini"}; ScMemoryConfig memoryConfig{config, {}}; @@ -131,9 +129,9 @@ TEST(ScConfig, EmptyMultiextensions) EXPECT_EQ(params.extensions_directories, nullptr); } -TEST(ScConfig, MultiextensionsWithSpaces) +TEST_F(ScConfigTest, MultiextensionsWithSpaces) { - ScConfig config{SC_CONFIGS "/multiextensions-with-spaces.ini", {"extensions"}}; + ScConfig config{SC_CONFIGS + "/multiextensions-with-spaces.ini", {"extensions"}}; ScMemoryConfig memoryConfig{config, {}}; @@ -149,17 +147,14 @@ TEST(ScConfig, MultiextensionsWithSpaces) EXPECT_EQ(std::string(params.storage), "sc-machine-test-repo"); EXPECT_EQ(params.extensions_directories_count, 3u); - std::string const & prefix = "../../../../sc-tools/sc-config/tests/"; - // this prefix should be removed after changing current directory for - // gtests that should be done in new build system - EXPECT_EQ(std::string(params.extensions_directories[0]), prefix + "bin/extensions 2"); - EXPECT_EQ(std::string(params.extensions_directories[1]), prefix + "bin/extensions_1"); - EXPECT_EQ(std::string(params.extensions_directories[2]), prefix + "bin/extensions_3"); + EXPECT_EQ(std::string(params.extensions_directories[0]), "../configs/bin/extensions 2"); + EXPECT_EQ(std::string(params.extensions_directories[1]), "../configs/bin/extensions_1"); + EXPECT_EQ(std::string(params.extensions_directories[2]), "../configs/bin/extensions_3"); } -TEST(ScConfig, NotNormalizedMultiextensions) +TEST_F(ScConfigTest, NotNormalizedMultiextensions) { - ScConfig config{SC_CONFIGS "/../tests/not-normalized-multiextensions.ini", {"extensions"}}; + ScConfig config{SC_CONFIGS + "/not-normalized-multiextensions.ini", {"extensions"}}; ScMemoryConfig memoryConfig{config, {}}; @@ -175,10 +170,7 @@ TEST(ScConfig, NotNormalizedMultiextensions) EXPECT_EQ(std::string(params.storage), "sc-machine-test-repo"); EXPECT_EQ(params.extensions_directories_count, 3u); - std::string const & prefix = "../../../../sc-tools/sc-config/tests/"; - // this prefix should be removed after changing current directory for - // gtests that should be done in new build system - EXPECT_EQ(std::string(params.extensions_directories[0]), prefix + "bin/extensions_1"); - EXPECT_EQ(std::string(params.extensions_directories[1]), prefix + "bin/extensions_2"); - EXPECT_EQ(std::string(params.extensions_directories[2]), prefix + "bin/extensions_3"); + EXPECT_EQ(std::string(params.extensions_directories[0]), "../configs/bin/extensions_1"); + EXPECT_EQ(std::string(params.extensions_directories[1]), "../configs/bin/extensions_2"); + EXPECT_EQ(std::string(params.extensions_directories[2]), "../configs/bin/extensions_3"); } diff --git a/sc-tools/sc-machine-runner/tests/CMakeLists.txt b/sc-tools/sc-machine-runner/tests/CMakeLists.txt index 191078130a..d08f7e2c23 100644 --- a/sc-tools/sc-machine-runner/tests/CMakeLists.txt +++ b/sc-tools/sc-machine-runner/tests/CMakeLists.txt @@ -2,11 +2,6 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units NAME sc-machine-tests DEPENDS sc-machine-runner ) -target_compile_definitions(sc-machine-tests PRIVATE - SC_MACHINE_REPO_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-machine-test-repo" - SC_MACHINE_EXTENSIONS="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/kb" - SC_MACHINE_INI="${CMAKE_CURRENT_SOURCE_DIR}/sc-machine-test.ini" -) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-machine-tests) diff --git a/sc-tools/sc-machine-runner/tests/sc-machine-test.ini b/sc-tools/sc-machine-runner/tests/sc-machine-test.ini index 0a95508362..3bbaa92b48 100644 --- a/sc-tools/sc-machine-runner/tests/sc-machine-test.ini +++ b/sc-tools/sc-machine-runner/tests/sc-machine-test.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-server-test-repo +storage = sc-machine-test-repo extensions = extensions [sc-server] diff --git a/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp b/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp new file mode 100644 index 0000000000..7f259224f5 --- /dev/null +++ b/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp @@ -0,0 +1,29 @@ +/* + * This source file is part of an OSTIS project. For the latest info, see http://ostis.net + * Distributed under the MIT License + * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) + */ + +#pragma once + +#include + +#include + +class ScMachineTest : public testing::Test +{ +public: + static inline std::string const & SC_MACHINE_INI = "../sc-machine-test.ini"; + static inline std::string const & SC_MACHINE_KB_BIN = "../sc-machine-test-bin"; + static inline std::string const & SC_MACHINE_EXTENSIONS = "/extensions"; + +protected: + void SetUp() override + { + } + + void TearDown() override + { + std::filesystem::remove_all(SC_MACHINE_KB_BIN); + } +}; diff --git a/sc-tools/sc-machine-runner/tests/units/test_base.cpp b/sc-tools/sc-machine-runner/tests/units/test_base.cpp index a4ee3c9962..e72fbba40d 100644 --- a/sc-tools/sc-machine-runner/tests/units/test_base.cpp +++ b/sc-tools/sc-machine-runner/tests/units/test_base.cpp @@ -4,62 +4,62 @@ * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) */ -#include +#include "sc_machine_test.hpp" #include #include -TEST(ScMachine, Run) +TEST_F(ScMachineTest, Run) { sc_uint32 const argsNumber = 4; - sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI, "-t"}; + sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI.c_str(), "-t"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_SUCCESS); } -TEST(ScMachine, RunWithExtensions) +TEST_F(ScMachineTest, RunWithExtensions) { sc_uint32 const argsNumber = 6; - sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI, "-e", SC_MACHINE_EXTENSIONS, "-t"}; + sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI.c_str(), "-e", SC_MACHINE_EXTENSIONS.c_str(), "-t"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_SUCCESS); } -TEST(ScMachine, RunWithStorage) +TEST_F(ScMachineTest, RunWithStorage) { sc_uint32 const argsNumber = 6; - sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI, "-s", SC_MACHINE_REPO_PATH, "-t"}; + sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI.c_str(), "-s", SC_MACHINE_KB_BIN.c_str(), "-t"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_SUCCESS); } -TEST(ScMachine, RunWithoutStorage) +TEST_F(ScMachineTest, RunWithoutStorage) { sc_uint32 const argsNumber = 4; sc_char const * args[argsNumber] = {"sc-machine", "-c", "", "-t"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_FAILURE); } -TEST(ScMachine, InvalidRun) +TEST_F(ScMachineTest, InvalidRun) { sc_uint32 const argsNumber = 1; sc_char const * args[argsNumber] = {"sc-machine"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_FAILURE); } -TEST(ScMachine, RunWithVerbose) +TEST_F(ScMachineTest, RunWithVerbose) { sc_uint32 const argsNumber = 5; - sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI, "-t", "-v"}; + sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI.c_str(), "-t", "-v"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_SUCCESS); } -TEST(ScMachine, PrintHelp) +TEST_F(ScMachineTest, PrintHelp) { sc_uint32 const argsNumber = 2; sc_char const * args[argsNumber] = {"sc-machine", "--help"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_SUCCESS); } -TEST(ScMachine, PrintVersion) +TEST_F(ScMachineTest, PrintVersion) { sc_uint32 const argsNumber = 2; sc_char const * args[argsNumber] = {"sc-machine", "--version"}; diff --git a/sc-tools/sc-server/tests/CMakeLists.txt b/sc-tools/sc-server/tests/CMakeLists.txt index ac8c340621..91e52907e2 100644 --- a/sc-tools/sc-server/tests/CMakeLists.txt +++ b/sc-tools/sc-server/tests/CMakeLists.txt @@ -1,19 +1,8 @@ -add_custom_target(sc-server-tests-kb-generator ALL - COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-builder" -i "${CMAKE_CURRENT_SOURCE_DIR}/kb" -o "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-server-test-repo" --clear - DEPENDS sc-builder -) - make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/api NAME sc-server-tests - DEPENDS sc-server-lib + DEPENDS sc-server-lib sc-builder-lib INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include" ) -add_dependencies(sc-server-tests sc-server-tests-kb-generator) -target_compile_definitions(sc-server-tests PRIVATE - SC_SERVER_REPO_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-server-test-repo" - SC_SERVER_EXTENSIONS="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/kb" - SC_SERVER_INI="${CMAKE_CURRENT_SOURCE_DIR}/sc-server-test.ini" -) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-server-tests) diff --git a/sc-tools/sc-server/tests/test_defines.hpp.in b/sc-tools/sc-server/tests/test_defines.hpp.in deleted file mode 100644 index 7a2b6608ca..0000000000 --- a/sc-tools/sc-server/tests/test_defines.hpp.in +++ /dev/null @@ -1,3 +0,0 @@ -#define SC_SERVER_REPO_PATH "${SC_BIN_PATH}/sc-server-test-repo" -#define SC_SERVER_EXTENSIONS "${SC_BIN_PATH}/extensions" -#define SC_SERVER_INI "${CMAKE_CURRENT_SOURCE_DIR}/sc-server-test.ini" diff --git a/sc-tools/sc-server/tests/units/api/sc_server_test.hpp b/sc-tools/sc-server/tests/units/api/sc_server_test.hpp index d73ac19603..ed8826a343 100644 --- a/sc-tools/sc-server/tests/units/api/sc_server_test.hpp +++ b/sc-tools/sc-server/tests/units/api/sc_server_test.hpp @@ -9,19 +9,36 @@ #include #include +#include +#include #include #include +#include + #include "sc-server-impl/sc_server_impl.hpp" class ScServerTest : public testing::Test { +public: + static inline std::string const & SC_SERVER_INI = "../../sc-server-test.ini"; + static inline std::string const & SC_SERVER_KB_BIN = "sc-server-test-bin"; + static inline std::string const & SC_SERVER_EXTENSIONS = "/extensions"; + static inline std::string const & SC_SERVER_KB = "../../kb"; + protected: + void LoadKB(std::unique_ptr const & m_context, std::unordered_set const & sources) + { + ScsLoader loader; + for (std::string const & source : sources) + loader.loadScsFile(*m_context, ScServerTest::SC_SERVER_KB + "/" + source); + } + void SetUp() override { - Initialize(SC_TRUE); - m_ctx = std::make_unique(); + ScServerTest::Initialize(SC_TRUE); + m_ctx = std::make_unique(); } void TearDown() override @@ -29,7 +46,9 @@ class ScServerTest : public testing::Test if (m_ctx != nullptr) m_ctx->Destroy(); - Shutdown(); + ScServerTest::Shutdown(); + + std::filesystem::remove_all(SC_SERVER_KB_BIN); } void Initialize(sc_bool parallel_actions) @@ -40,8 +59,8 @@ class ScServerTest : public testing::Test params.dump_memory = SC_FALSE; params.dump_memory_statistics = SC_FALSE; - params.clear = SC_FALSE; - params.storage = SC_SERVER_REPO_PATH; + params.clear = SC_TRUE; + params.storage = SC_SERVER_KB_BIN.c_str(); ScMemory::LogMute(); ScMemory::Initialize(params); @@ -61,7 +80,7 @@ class ScServerTest : public testing::Test } protected: - std::unique_ptr m_ctx; + std::unique_ptr m_ctx; std::unique_ptr m_server; }; @@ -71,6 +90,6 @@ class ScServerTestWithoutParallelMode : public ScServerTest void SetUp() override { Initialize(SC_FALSE); - m_ctx = std::make_unique(); + m_ctx = std::make_unique(); } }; diff --git a/sc-tools/sc-server/tests/units/api/test_base.cpp b/sc-tools/sc-server/tests/units/api/test_base.cpp index 5e128c83a1..65a661ac31 100644 --- a/sc-tools/sc-server/tests/units/api/test_base.cpp +++ b/sc-tools/sc-server/tests/units/api/test_base.cpp @@ -924,6 +924,8 @@ TEST_F(ScServerTest, SearchStringTemplate) TEST_F(ScServerTest, SearchTemplateByIdtf) { + LoadKB(m_ctx, {"templates.scs", "user.scs"}); + ScClient client; EXPECT_TRUE(client.Connect(m_server->GetUri())); client.Run(); @@ -952,6 +954,8 @@ TEST_F(ScServerTest, SearchTemplateByIdtf) TEST_F(ScServerTest, SearchTemplateByAddr) { + LoadKB(m_ctx, {"templates.scs", "user.scs"}); + ScClient client; EXPECT_TRUE(client.Connect(m_server->GetUri())); client.Run(); @@ -1075,6 +1079,8 @@ TEST_F(ScServerTest, GenerateStringTemplate) TEST_F(ScServerTest, GenerateTemplateByIdtf) { + LoadKB(m_ctx, {"templates.scs"}); + ScClient client; EXPECT_TRUE(client.Connect(m_server->GetUri())); client.Run(); @@ -1103,6 +1109,8 @@ TEST_F(ScServerTest, GenerateTemplateByIdtf) TEST_F(ScServerTest, GenerateTemplateByAddr) { + LoadKB(m_ctx, {"templates.scs"}); + ScClient client; EXPECT_TRUE(client.Connect(m_server->GetUri())); client.Run(); diff --git a/sc-tools/sc-server/tests/units/api/test_connection.cpp b/sc-tools/sc-server/tests/units/api/test_connection.cpp index 6de2ecda23..f2f1c5cc94 100644 --- a/sc-tools/sc-server/tests/units/api/test_connection.cpp +++ b/sc-tools/sc-server/tests/units/api/test_connection.cpp @@ -16,7 +16,7 @@ TEST(ScServer, RunStopServer) { ScOptions options{1, nullptr}; - std::string configFile = SC_SERVER_INI; + std::string configFile = ScServerTest::SC_SERVER_INI.c_str(); ScParams serverParams{options, {}}; @@ -26,7 +26,7 @@ TEST(ScServer, RunStopServer) serverParams.Insert({key, serverConfig[key]}); ScParams memoryParams{options, {}}; - memoryParams.Insert({"storage", SC_SERVER_REPO_PATH}); + memoryParams.Insert({"storage", ScServerTest::SC_SERVER_KB_BIN.c_str()}); ScMemoryConfig memoryConfig{config, memoryParams}; diff --git a/sc-tools/sc-server/tests/units/performance/CMakeLists.txt b/sc-tools/sc-server/tests/units/performance/CMakeLists.txt index a80bd9b7c4..2a2c8ec185 100644 --- a/sc-tools/sc-server/tests/units/performance/CMakeLists.txt +++ b/sc-tools/sc-server/tests/units/performance/CMakeLists.txt @@ -11,12 +11,6 @@ target_link_libraries(sc-server-performance-tests target_include_directories(sc-server-performance-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include ) -add_dependencies(sc-server-performance-tests sc-server-tests-kb-generator) -target_compile_definitions(sc-server-performance-tests PRIVATE - SC_SERVER_REPO_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sc-server-test-repo" - SC_SERVER_EXTENSIONS="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/kb" - SC_SERVER_INI="${CMAKE_CURRENT_SOURCE_DIR}/../../sc-server-test.ini" -) if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-server-performance-tests) diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp b/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp index be897b648e..9163ee0ad1 100644 --- a/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp +++ b/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp @@ -20,11 +20,13 @@ extern "C" class TestScServer { public: + static inline std::string const & SC_SERVER_KB_BIN = "sc-server-test-bin"; + void Initialize(size_t objectsNum = 0) { sc_memory_params params; sc_memory_params_clear(¶ms); - params.storage = SC_SERVER_REPO_PATH; + params.storage = SC_SERVER_KB_BIN.c_str(); params.clear = SC_FALSE; From b3b73d20ec610f74ae26dfd71ccf001dfd483c33 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Sun, 27 Oct 2024 14:07:24 +0300 Subject: [PATCH 040/134] [ci][fix] Use correct presets to launch tests --- .github/workflows/native.yml | 6 +++--- CMakePresets.json | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index 9648271d81..2fce5a2c21 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -17,8 +17,8 @@ jobs: matrix: os: [macos-14, ubuntu-22.04, ubuntu-24.04] build_type: - - { preset: "release", name: "Release" } - - { preset: "debug", name: "Debug" } + - { name: "Release", configure_preset: "release-with-tests", build_preset: "release" } + - { name: "Debug", configure_preset: "debug-with-tests", build_preset: "debug" } config: - { cc: "gcc", cxx: "g++" } @@ -51,7 +51,7 @@ jobs: env: CC: ${{ matrix.config.cc }} CXX: ${{ matrix.config.cxx }} - run: cmake --preset ${{ matrix.build_type.preset }} && cmake --build --preset ${{ matrix.build_type.preset }} + run: cmake --preset ${{ matrix.build_type.configure_preset }} && cmake --build --preset ${{ matrix.build_type.build_preset }} - name: Run tests id: run_tests diff --git a/CMakePresets.json b/CMakePresets.json index 10bb51bc1c..2dc8fcee62 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -23,6 +23,16 @@ "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "./cmake/conan_provider.cmake" } }, + { + "name": "debug-with-tests", + "displayName": "Debug config with tests", + "description": "Debug config with tests", + "inherits": "debug", + "cacheVariables": { + "SC_BUILD_TESTS": true, + "SC_BUILD_BENCH": true + } + }, { "name": "release", "displayName": "Release config", From eb1102e6f44d928eb9673fee35c402f0e0a13655 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Sun, 27 Oct 2024 20:03:22 +0300 Subject: [PATCH 041/134] [build][conan][file][fix] Package info --- conanfile.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/conanfile.py b/conanfile.py index bb9ffb55e9..0c019d55c1 100644 --- a/conanfile.py +++ b/conanfile.py @@ -24,7 +24,10 @@ class sc_machineRecipe(ConanFile): exports_sources = "*", "!.venv", "!build", "!.cache", "!kb", "!kb.bin", "!.env", "!ConanPresets.json", "!docs" settings = "os", "compiler", "build_type", "arch" requires = () - options = {"shared": [True], "fPIC": [True, False]} + options = { + "shared": [True], + "fPIC": [True, False], + } default_options = { "shared": True, "fPIC": True, @@ -53,7 +56,6 @@ def build(self): def generate(self): deps = CMakeDeps(self) - # deps.build_context_activated = ["my_tool"] deps.generate() tc = CMakeToolchain(self) tc.user_presets_path = "ConanPresets.json" @@ -69,17 +71,17 @@ def package_id(self): del self.info.settings.build_type def parse_version(self): - content = tools.files.load(self, self.recipe_folder + "/CMakeLists.txt") - version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1) - return version.strip() - - def package(self): - cmake = CMake(self) - cmake.install() - - def package_info(self): - self.cpp_info.libs = ['new-project'] + content = tools.files.load(self, self.recipe_folder + "/CMakeLists.txt") + version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1) + return version.strip() - # uncomment for a header-only library - # def package_id(self): - # self.info.header_only() + def package_info(self): + self.cpp_info.libs = [ + "sc-core", + "sc-memory", + "sc-agents-common", + "sc-builder-lib", + "sc-config" + ] + self.cpp_info.includedirs = ['include'] + self.cpp_info.libdirs = ["lib"] From 79b8bc5dff7b110df561d0227991d32199737ef6 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Sun, 27 Oct 2024 20:04:03 +0300 Subject: [PATCH 042/134] [cmake][refactor] File install.cmake --- cmake/install.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmake/install.cmake b/cmake/install.cmake index cb4784672c..fb502bdf0b 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -11,7 +11,11 @@ install(TARGETS ) # a target set for things we don't want to export to the consumers -install(TARGETS sc-kpm-search sc-kpm-utils sc-kpm-ui sc-server-lib EXPORT privateExport LIBRARY DESTINATION lib/extensions) +install(TARGETS + sc-kpm-search sc-kpm-utils sc-kpm-ui sc-server-lib + EXPORT privateExport + LIBRARY DESTINATION ${SC_EXTENSIONS_DIRECTORY} +) install(EXPORT sc-machineExport FILE sc-machineTargets.cmake @@ -41,7 +45,8 @@ configure_package_config_file( install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sc-machine-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/sc-machine-config-version.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc-machine) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc-machine +) set(CPACK_PACKAGE_NAME sc-machine) set(CPACK_PACKAGE_VENDOR "OSTIS AI") From 7cb138b739b761102f625659b1c333bdcb299dac Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Sun, 27 Oct 2024 20:04:55 +0300 Subject: [PATCH 043/134] [cmake] Make extensions path configurable --- CMakeLists.txt | 21 ++++++++++++++------- sc-kpm/sc-common/CMakeLists.txt | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1587449fd5..6099f892da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,15 +6,22 @@ site_name(www.ostis.net) cmake_policy(SET CMP0048 NEW) set(SC_MACHINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) - set(CMAKE_MODULE_PATH "${SC_MACHINE_ROOT}/cmake") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +message(STATUS "Binary output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(SC_EXTENSIONS_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/extensions) -make_directory(${SC_EXTENSIONS_DIRECTORY}) +message(STATUS "Library output directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") + +if (DEFINED "${SC_EXTENSIONS_DIRECTORY}") + message(STATUS "Provided extensions directory: ${SC_EXTENSIONS_DIRECTORY}") + file(MAKE_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) +else() + set(SC_EXTENSIONS_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/extensions) + make_directory(${SC_EXTENSIONS_DIRECTORY}) + message(STATUS "No extensions directory provided. Defaulting to: ${SC_EXTENSIONS_DIRECTORY}") +endif() -message(STATUS "Binary output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") -message(STATUS "Libary output directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty") option(SC_BUILD_TESTS "Flag to build unit tests" OFF) @@ -102,9 +109,9 @@ message("Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, path: # Set up dynamic linking paths for our own libraries # For macOS, use @loader_path instead of $ORIGIN if(APPLE) - set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib;@loader_path/../lib/extensions") + set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib;${SC_EXTENSIONS_DIRECTORY}") else() - set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib;$ORIGIN/../lib/extensions") + set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib:${SC_EXTENSIONS_DIRECTORY}") endif() # Always use full RPATH diff --git a/sc-kpm/sc-common/CMakeLists.txt b/sc-kpm/sc-common/CMakeLists.txt index 8704fe5a0f..ff9e2fb94e 100644 --- a/sc-kpm/sc-common/CMakeLists.txt +++ b/sc-kpm/sc-common/CMakeLists.txt @@ -12,7 +12,7 @@ target_include_directories(sc-kpm-common PUBLIC $ ) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" ) From 5057ec44cc083dba4346e2d8fe34cd157b4cb7ce Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Sun, 27 Oct 2024 20:06:25 +0300 Subject: [PATCH 044/134] [docs][build][fix] Build instructions; deps info --- docs/build/build_system.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index a9524cdd77..c4125d85e3 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -53,7 +53,7 @@ The package artifacts are available [here](https://github.com/ostis-ai/sc-machin # you can override this variable via -D_PATH_SC_MACHINE_PATH or CMakeUserPreset.json / CMakePreset.json files set(_SC_MACHINE_PATH "/location/to/sc-machine--" CACHE PATH "sc-machine installation path") -# can be override using env variables as well +# can be overriden using env variables as well if(DEFINED ENV{_SC_MACHINE_PATH}) set(_SC_MACHINE_PATH "$ENV{_SC_MACHINE_PATH}") endif() @@ -86,6 +86,8 @@ list(APPEND CMAKE_PREFIX_PATH ${_SC_MACHINE_PATH}) ```sh conan install . + cmake --preset conan-release + cmake --build --preset conan-release ``` - You want to use a package version that is not published in a Conan repo: @@ -119,6 +121,7 @@ list(APPEND CMAKE_PREFIX_PATH ${_SC_MACHINE_PATH}) ```sh conan install . + cmake --preset conan-release cmake --build --preset conan-release ``` @@ -187,6 +190,7 @@ Currently, we require the following packages to be available to CMake at build-t - `websocketpp` - [`asio`](https://think-async.com/Asio/) as the transitive dependency - `nlohmann_json` +- `xml2` You can use convenience scripts provided in our repo (`scripts/install_deps_ubuntu.sh` and `scripts/install_deps_macOS.sh`) to install these dependencies. From d330ae8a4340f4d47373889094119b1e1bc94f06 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 29 Oct 2024 00:38:02 +0300 Subject: [PATCH 045/134] [cmake][conan] Fix install dir usage for consumers --- cmake/install.cmake | 5 +++++ conanfile.py | 15 +++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmake/install.cmake b/cmake/install.cmake index fb502bdf0b..ad7e878adb 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -17,6 +17,11 @@ install(TARGETS LIBRARY DESTINATION ${SC_EXTENSIONS_DIRECTORY} ) +export(EXPORT sc-machineExport + NAMESPACE sc-machine:: # to simulate a different name and see it works + FILE "${CMAKE_CURRENT_BINARY_DIR}/sc-machineTargets.cmake" +) + install(EXPORT sc-machineExport FILE sc-machineTargets.cmake NAMESPACE sc-machine:: diff --git a/conanfile.py b/conanfile.py index 0c019d55c1..a285fc728b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -21,7 +21,7 @@ class sc_machineRecipe(ConanFile): url = "https://github.com/ostis-ai/sc-machine" description = "Software implementation of semantic network storage" exports = ["LICENSE.md"] - exports_sources = "*", "!.venv", "!build", "!.cache", "!kb", "!kb.bin", "!.env", "!ConanPresets.json", "!docs" + exports_sources = "*", "!.venv", "!build", "!.cache", "!kb", "!kb.bin", "!.env", "!ConanPresets.json", "!docs", "!.git" settings = "os", "compiler", "build_type", "arch" requires = () options = { @@ -59,6 +59,7 @@ def generate(self): deps.generate() tc = CMakeToolchain(self) tc.user_presets_path = "ConanPresets.json" + tc.variables["CMAKE_CXX_STANDARD"] = 17 tc.generate() def package(self): @@ -76,12 +77,6 @@ def parse_version(self): return version.strip() def package_info(self): - self.cpp_info.libs = [ - "sc-core", - "sc-memory", - "sc-agents-common", - "sc-builder-lib", - "sc-config" - ] - self.cpp_info.includedirs = ['include'] - self.cpp_info.libdirs = ["lib"] + self.cpp_info.set_property("cmake_find_mode", "none") # Do NOT generate any files + self.cpp_info.builddirs.append("lib/cmake/sc-machine") + self.cpp_info.builddirs.append("build/" + str(self.settings.build_type)) # Provides correct install path for conan editable From 54f8d6719c62cbdf32e6960e7102bf1ef9f4205d Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 29 Oct 2024 00:38:42 +0300 Subject: [PATCH 046/134] [ci][conan] Remove extra preset for debug tests --- .github/workflows/native.yml | 2 +- CMakePresets.json | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index 2fce5a2c21..7061035c6b 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -18,7 +18,7 @@ jobs: os: [macos-14, ubuntu-22.04, ubuntu-24.04] build_type: - { name: "Release", configure_preset: "release-with-tests", build_preset: "release" } - - { name: "Debug", configure_preset: "debug-with-tests", build_preset: "debug" } + - { name: "Debug", configure_preset: "debug", build_preset: "debug" } config: - { cc: "gcc", cxx: "g++" } diff --git a/CMakePresets.json b/CMakePresets.json index 2dc8fcee62..10bb51bc1c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -23,16 +23,6 @@ "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "./cmake/conan_provider.cmake" } }, - { - "name": "debug-with-tests", - "displayName": "Debug config with tests", - "description": "Debug config with tests", - "inherits": "debug", - "cacheVariables": { - "SC_BUILD_TESTS": true, - "SC_BUILD_BENCH": true - } - }, { "name": "release", "displayName": "Release config", From a037ca4b89e97a2de94cbbee6d34ef47ad7e3c30 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 29 Oct 2024 00:58:51 +0300 Subject: [PATCH 047/134] [cmake][tools][kpm] Fix includes --- sc-kpm/sc-common/CMakeLists.txt | 2 +- sc-tools/sc-machine-runner/CMakeLists.txt | 5 ++++- .../include/sc-machine-runner/sc_machine_setup.hpp | 13 +++++++++++++ sc-tools/sc-server/CMakeLists.txt | 4 ---- 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_setup.hpp diff --git a/sc-kpm/sc-common/CMakeLists.txt b/sc-kpm/sc-common/CMakeLists.txt index ff9e2fb94e..dac5617a89 100644 --- a/sc-kpm/sc-common/CMakeLists.txt +++ b/sc-kpm/sc-common/CMakeLists.txt @@ -12,7 +12,7 @@ target_include_directories(sc-kpm-common PUBLIC $ ) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" ) diff --git a/sc-tools/sc-machine-runner/CMakeLists.txt b/sc-tools/sc-machine-runner/CMakeLists.txt index 10805d0ad7..56b8f28430 100644 --- a/sc-tools/sc-machine-runner/CMakeLists.txt +++ b/sc-tools/sc-machine-runner/CMakeLists.txt @@ -1,4 +1,7 @@ -file(GLOB SOURCES CONFIGURE_DEPENDS "src/*.cpp" "src/*.hpp") +file(GLOB SOURCES CONFIGURE_DEPENDS + "src/*.cpp" + "include/sc-machine-runner/*.hpp" +) list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp") add_library(sc-machine-runner SHARED ${SOURCES}) diff --git a/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_setup.hpp b/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_setup.hpp new file mode 100644 index 0000000000..e7071c2b9a --- /dev/null +++ b/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_setup.hpp @@ -0,0 +1,13 @@ +/* + * This source file is part of an OSTIS project. For the latest info, see http://ostis.net + * Distributed under the MIT License + * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) + */ + +#pragma once + +#include + +void PrintStartMessage(); + +sc_int BuildAndRunMachine(sc_int argc, sc_char * argv[]); diff --git a/sc-tools/sc-server/CMakeLists.txt b/sc-tools/sc-server/CMakeLists.txt index 7509778e7d..24c8b15cc1 100644 --- a/sc-tools/sc-server/CMakeLists.txt +++ b/sc-tools/sc-server/CMakeLists.txt @@ -27,10 +27,6 @@ target_include_directories(sc-server-lib ) set_target_properties(sc-server-lib PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) - if(${SC_CLANG_FORMAT_CODE}) target_clangformat_setup(sc-server-lib) endif() From 4b4e9700b29e170a274db2ffdead791942aafdf3 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 29 Oct 2024 01:17:54 +0300 Subject: [PATCH 048/134] [cmake] Fix rpath for ubuntu --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6099f892da..774bc7e47d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,9 +109,9 @@ message("Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, path: # Set up dynamic linking paths for our own libraries # For macOS, use @loader_path instead of $ORIGIN if(APPLE) - set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib;${SC_EXTENSIONS_DIRECTORY}") + set(CMAKE_INSTALL_RPATH "@loader_path/../lib;${SC_EXTENSIONS_DIRECTORY}") else() - set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib:${SC_EXTENSIONS_DIRECTORY}") + set(CMAKE_INSTALL_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY};${SC_EXTENSIONS_DIRECTORY}") endif() # Always use full RPATH From 3f4ee65081aec9bf24479a3a6e3bbfd025fe1610 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 29 Oct 2024 01:57:05 +0300 Subject: [PATCH 049/134] [memory][tests] Check ScLock is locked before lock --- .../sc-memory/tests/sc-memory/units/agents/test_sc_agent.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sc-memory/sc-memory/tests/sc-memory/units/agents/test_sc_agent.hpp b/sc-memory/sc-memory/tests/sc-memory/units/agents/test_sc_agent.hpp index eecb3f6729..4e5db8dd30 100644 --- a/sc-memory/sc-memory/tests/sc-memory/units/agents/test_sc_agent.hpp +++ b/sc-memory/sc-memory/tests/sc-memory/units/agents/test_sc_agent.hpp @@ -39,7 +39,8 @@ class TestWaiter void Reset() { - m_lock.Lock(); + if (!m_lock.IsLocked()) + m_lock.Lock(); } private: From 1717fe207b1639e3a952eb9303cdfea602b0903d Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 29 Oct 2024 02:13:45 +0300 Subject: [PATCH 050/134] [ci] Provide sc-machine extensions via arguments --- .github/workflows/conan.yml | 4 ++-- .github/workflows/native.yml | 3 ++- sc-machine.ini | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index bb8e091365..e36063f77c 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -75,5 +75,5 @@ jobs: run: | mkdir kb build/Release/bin/sc-builder -i kb -o kb.bin --clear -f - build/Release/bin/sc-server -t -c sc-machine.ini -r kb.bin - build/Release/bin/sc-machine -t -c sc-machine.ini -r kb.bin + build/Release/bin/sc-server -c sc-machine.ini -e build/Release/lib/extensions -r kb.bin -t + build/Release/bin/sc-machine -c sc-machine.ini -e -e build/Release/lib/extensions -r kb.bin -t diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index 7061035c6b..d8adcd540f 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -62,4 +62,5 @@ jobs: run: | mkdir kb build/${{ matrix.build_type.name }}/bin/sc-builder -i kb -o kb.bin --clear - build/${{ matrix.build_type.name }}/bin/sc-machine -c sc-machine.ini -s kb.bin -t + build/${{ matrix.build_type.name }}/bin/sc-machine -c sc-machine.ini -e build/${{ matrix.build_type.name }}/lib/extensions -s kb.bin -t + diff --git a/sc-machine.ini b/sc-machine.ini index 4a1a0c1405..9efd56a9ee 100644 --- a/sc-machine.ini +++ b/sc-machine.ini @@ -10,7 +10,6 @@ dump_memory_statistics = false dump_memory_statistics_period = 1800 storage = ./kb.bin -extensions = ./build/lib/extensions log_type = Console log_file = ./sc-memory.log From df593b77d0c418e45a0a88d5d818189553dda36c Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 29 Oct 2024 02:14:05 +0300 Subject: [PATCH 051/134] [scripts] Remove build-depended scripts --- scripts/build_kb.sh | 9 --------- scripts/run_sc_machine.sh | 10 ---------- 2 files changed, 19 deletions(-) delete mode 100755 scripts/build_kb.sh delete mode 100755 scripts/run_sc_machine.sh diff --git a/scripts/build_kb.sh b/scripts/build_kb.sh deleted file mode 100755 index 0672a88971..0000000000 --- a/scripts/build_kb.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -if [ -z "${BINARY_PATH}" ]; -then - source "$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)/set_vars.sh" -fi - -"${BINARY_PATH}/sc-builder" --clear -c "${CONFIG_PATH}" "$@" diff --git a/scripts/run_sc_machine.sh b/scripts/run_sc_machine.sh deleted file mode 100755 index ad1e5df286..0000000000 --- a/scripts/run_sc_machine.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -CURRENT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd) -if [ -z "${BINARY_PATH}" ]; -then - source "${CURRENT_DIR}/set_vars.sh" -fi - -"${BINARY_PATH}/sc-machine" -c "${CONFIG_PATH}" "$@" From 8181cc71e2d379915eebcf43d83fd7d222af5b45 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 29 Oct 2024 02:40:42 +0300 Subject: [PATCH 052/134] [scripts] Remove unused script vars --- scripts/install_deps_macOS.sh | 7 ++----- scripts/install_deps_python.sh | 5 +---- scripts/install_deps_ubuntu.sh | 9 +++------ scripts/set_vars.sh | 15 --------------- 4 files changed, 6 insertions(+), 30 deletions(-) delete mode 100644 scripts/set_vars.sh diff --git a/scripts/install_deps_macOS.sh b/scripts/install_deps_macOS.sh index b330ea6af6..12878dc336 100755 --- a/scripts/install_deps_macOS.sh +++ b/scripts/install_deps_macOS.sh @@ -1,11 +1,8 @@ #!/usr/bin/env bash set -eo pipefail -if [ -z "${SC_MACHINE_PATH}" ]; -then - source "$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)/set_vars.sh" -fi +SCRIPTS_PATH="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)" brew install glib temurin pkgconfig cmake ninja ccache asio websocketpp nlohmann-json libxml2 googletest google-benchmark -"${SC_MACHINE_PATH}/scripts/install_deps_python.sh" +"${SCRIPTS_PATH}/install_deps_python.sh" diff --git a/scripts/install_deps_python.sh b/scripts/install_deps_python.sh index 5c1eee316b..ba90512209 100755 --- a/scripts/install_deps_python.sh +++ b/scripts/install_deps_python.sh @@ -1,10 +1,7 @@ #!/usr/bin/env bash set -eo pipefail -if [ -z "${SC_MACHINE_PATH}" ]; -then - source "$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)/set_vars.sh" -fi +SC_MACHINE_PATH="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd)" python3 -m venv "${SC_MACHINE_PATH}/.venv" source "${SC_MACHINE_PATH}/.venv/bin/activate" diff --git a/scripts/install_deps_ubuntu.sh b/scripts/install_deps_ubuntu.sh index 14fbff399b..34ff95148a 100755 --- a/scripts/install_deps_ubuntu.sh +++ b/scripts/install_deps_ubuntu.sh @@ -1,10 +1,7 @@ #!/usr/bin/env bash set -eo pipefail -if [[ -z "${SC_MACHINE_PATH}" || -z "${BINARY_PATH}" || -z "${BUILD_PATH}" ]]; -then - source "$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)/set_vars.sh" -fi +SCRIPTS_PATH="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)" function usage() { cat </dev/null 2>&1 && cd .. && pwd) - -export SC_MACHINE_PATH="${SC_MACHINE_PATH:-${ROOT_PATH}}" - -export ROOT_CMAKE_PATH="${ROOT_CMAKE_PATH:-${SC_MACHINE_PATH}}" -export PROBLEM_SOLVER_PATH="${PROBLEM_SOLVER_PATH:-${SC_MACHINE_PATH}}" # backward compatibility -export CXX_SOURCES_PATH="${PROBLEM_SOLVER_PATH:-${SC_MACHINE_PATH}}" -export BUILD_PATH="${BUILD_PATH:-${ROOT_CMAKE_PATH}/build}" -export BINARY_PATH="${BINARY_PATH:-${BUILD_PATH}/bin}" -export EXTENSIONS_PATH="${BINARY_PATH:-${BUILD_PATH}/lib}" - -export CONFIG_PATH="${CONFIG_PATH:-${SC_MACHINE_PATH}/sc-machine.ini}" -export REPO_PATH="${REPO_PATH:-${SC_MACHINE_PATH}/repo.path}" From ddbff774264f8f0c82ec1a42d5f6060baf05fca6 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 29 Oct 2024 02:41:03 +0300 Subject: [PATCH 053/134] [docker] Fix binary and library paths --- Dockerfile | 5 ++--- docker-compose.yml | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 83ac25e9cc..55fdfd6273 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ USER root #install runtime dependencies COPY scripts /tmp/sc-machine/scripts -COPY scripts/set_vars.sh /tmp/sc-machine/scripts/set_vars.sh COPY requirements.txt /tmp/sc-machine/requirements.txt # tini is an init system to forward interrupt signals properly RUN apt update && apt install -y --no-install-recommends sudo tini && /tmp/sc-machine/scripts/install_deps_ubuntu.sh @@ -31,8 +30,8 @@ FROM base AS final COPY --from=builder /sc-machine/requirements.txt /sc-machine/requirements.txt COPY --from=builder /sc-machine/scripts /sc-machine/scripts COPY --from=builder /sc-machine/sc-machine.ini /sc-machine/sc-machine.ini -COPY --from=builder /sc-machine/build/Release/bin /sc-machine/build/bin -COPY --from=builder /sc-machine/build/Release/lib /sc-machine/build/lib +COPY --from=builder /sc-machine/build/Release/bin /sc-machine/build/Release/bin +COPY --from=builder /sc-machine/build/Release/lib /sc-machine/build/Release/lib RUN /sc-machine/scripts/install_deps_python.sh WORKDIR /sc-machine/scripts diff --git a/docker-compose.yml b/docker-compose.yml index 64e0d6b9fd..168af0805d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,8 +20,8 @@ services: # Use the commented env variable if you need to rebuild KB every startup. - "REBUILD_KB=${REBUILD_KB:-0}" - "KB_PATH=${KB_PATH:-/kb/repo.path}" - - "BINARY_PATH=/sc-machine/build/bin" - - "EXTENSIONS_PATH=/sc-machine/build/lib/extensions" + - "BINARY_PATH=/sc-machine/build/Release/bin" + - "EXTENSIONS_PATH=/sc-machine/build/Release/lib/extensions" - "CONFIG_PATH=/sc-machine/sc-machine.ini" command: - "run" From 34d92c24f9fb234a2689226633d290c2d60275db Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 1 Nov 2024 02:13:15 +0300 Subject: [PATCH 054/134] [ci] Implement archive release --- .github/workflows/archive_release.yml | 79 +++++++++++++++++++ .../{release.yml => docker_release.yml} | 2 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/archive_release.yml rename .github/workflows/{release.yml => docker_release.yml} (97%) diff --git a/.github/workflows/archive_release.yml b/.github/workflows/archive_release.yml new file mode 100644 index 0000000000..0e8bbbd710 --- /dev/null +++ b/.github/workflows/archive_release.yml @@ -0,0 +1,79 @@ +name: Release archive + +on: + push: + tags: + - '*.*.*' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + config: + - { cc: "gcc", cxx: "g++" } + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Restore ccache caches + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} + + - name: Conan cache + uses: actions/cache@v4 + with: + path: ~/.conan/data + key: conan-${{ runner.os }}-${{ hashFiles('**/conanfile.py') }} + + - name: apt cache + uses: actions/cache@v4 + with: + path: | + /var/cache/apt/ + /var/lib/apt/ + key: apt-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/install_deps_ubuntu.sh') }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Set up pipx + run: | + python -m pip install --user pipx + python -m pipx ensurepath + + - name: Set up Conan + run: | + pipx install conan + + - name: Install compilers + run: sudo apt install build-essential ninja-build ccache cmake + + - name: Build sc-machine + id: run_cmake + run: | + cmake --preset release-conan + cmake --build --preset release + + - name: Create archive + run: | + tar -czf sc-machine_${{ github.event.ref }}.tar.gz build/Release/bin build/Release/lib + + - name: Upload Release Asset + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.event.ref }} + files: ${{ github.workspace }}/sc-machine_${{ github.event.ref }}.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/docker_release.yml similarity index 97% rename from .github/workflows/release.yml rename to .github/workflows/docker_release.yml index b7a15af37b..e7dd618ab8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/docker_release.yml @@ -1,4 +1,4 @@ -name: Release +name: Release Docker container on: push: From 3ed9d422b10260ac16bd840c136bbe2acd2b9dfd Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 1 Nov 2024 11:51:27 +0300 Subject: [PATCH 055/134] [tests] Try to fix coverage --- sc-tools/sc-builder/tests/units/test_aliases.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sc-tools/sc-builder/tests/units/test_aliases.cpp b/sc-tools/sc-builder/tests/units/test_aliases.cpp index bba45c2364..45b2039b9d 100644 --- a/sc-tools/sc-builder/tests/units/test_aliases.cpp +++ b/sc-tools/sc-builder/tests/units/test_aliases.cpp @@ -19,3 +19,4 @@ TEST_F(ScBuilderTest, Aliases) EXPECT_TRUE(m_ctx->SearchByTemplate(templ, result)); EXPECT_EQ(result.Size(), 1u); } + From 4ab4e94beb667df739bc09b061951c379ab35fb6 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 1 Nov 2024 17:48:28 +0300 Subject: [PATCH 056/134] [scripts][fix] stop using env_vars in healthcheck.sh --- scripts/healthcheck.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/healthcheck.sh b/scripts/healthcheck.sh index acdd260327..df0d148617 100755 --- a/scripts/healthcheck.sh +++ b/scripts/healthcheck.sh @@ -1,12 +1,6 @@ #!/usr/bin/env bash set -eo pipefail -CURRENT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd) -source "${CURRENT_DIR}/formats.sh" - -if [ -z "${SC_MACHINE_PATH}" ]; -then - source "${CURRENT_DIR}/set_vars.sh" -fi +SC_MACHINE_PATH=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd) source "${SC_MACHINE_PATH}/.venv/bin/activate" && python3 "${SC_MACHINE_PATH}/scripts/healthcheck.py" From bc66bfb2c18b8e9f0c31d776e96505d5837c15a2 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 1 Nov 2024 21:22:26 +0300 Subject: [PATCH 057/134] [ci] Use workflow_call in release to check tests beforehand --- .github/workflows/archive_release.yml | 79 ---------- .../{coverage.yml => check_coverage.yml} | 0 .../{docker.yml => check_dockerfile.yml} | 1 + .../{sanitizers.yml => check_sanitizers.yml} | 2 +- .../workflows/{style.yml => check_style.yml} | 0 .github/workflows/docker_release.yml | 57 -------- .../{docs.yml => docs_build_tex.yml} | 0 .github/workflows/release.yml | 138 ++++++++++++++++++ .../workflows/{conan.yml => test_conan.yml} | 3 +- .../workflows/{native.yml => test_native.yml} | 4 +- 10 files changed, 144 insertions(+), 140 deletions(-) delete mode 100644 .github/workflows/archive_release.yml rename .github/workflows/{coverage.yml => check_coverage.yml} (100%) rename .github/workflows/{docker.yml => check_dockerfile.yml} (97%) rename .github/workflows/{sanitizers.yml => check_sanitizers.yml} (93%) rename .github/workflows/{style.yml => check_style.yml} (100%) delete mode 100644 .github/workflows/docker_release.yml rename .github/workflows/{docs.yml => docs_build_tex.yml} (100%) create mode 100644 .github/workflows/release.yml rename .github/workflows/{conan.yml => test_conan.yml} (98%) rename .github/workflows/{native.yml => test_native.yml} (94%) diff --git a/.github/workflows/archive_release.yml b/.github/workflows/archive_release.yml deleted file mode 100644 index 0e8bbbd710..0000000000 --- a/.github/workflows/archive_release.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: Release archive - -on: - push: - tags: - - '*.*.*' - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-24.04 - - strategy: - fail-fast: false - matrix: - config: - - { cc: "gcc", cxx: "g++" } - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Restore ccache caches - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ github.job }} - - - name: Conan cache - uses: actions/cache@v4 - with: - path: ~/.conan/data - key: conan-${{ runner.os }}-${{ hashFiles('**/conanfile.py') }} - - - name: apt cache - uses: actions/cache@v4 - with: - path: | - /var/cache/apt/ - /var/lib/apt/ - key: apt-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/install_deps_ubuntu.sh') }} - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.12" - - - name: Set up pipx - run: | - python -m pip install --user pipx - python -m pipx ensurepath - - - name: Set up Conan - run: | - pipx install conan - - - name: Install compilers - run: sudo apt install build-essential ninja-build ccache cmake - - - name: Build sc-machine - id: run_cmake - run: | - cmake --preset release-conan - cmake --build --preset release - - - name: Create archive - run: | - tar -czf sc-machine_${{ github.event.ref }}.tar.gz build/Release/bin build/Release/lib - - - name: Upload Release Asset - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ github.event.ref }} - files: ${{ github.workspace }}/sc-machine_${{ github.event.ref }}.tar.gz - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/coverage.yml b/.github/workflows/check_coverage.yml similarity index 100% rename from .github/workflows/coverage.yml rename to .github/workflows/check_coverage.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/check_dockerfile.yml similarity index 97% rename from .github/workflows/docker.yml rename to .github/workflows/check_dockerfile.yml index 0f1d6f735a..ca3fb29d21 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/check_dockerfile.yml @@ -3,6 +3,7 @@ name: Docker on: pull_request: branches: [main] + workflow_call: jobs: build: diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/check_sanitizers.yml similarity index 93% rename from .github/workflows/sanitizers.yml rename to .github/workflows/check_sanitizers.yml index a6a2819f47..e53b182a5e 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/check_sanitizers.yml @@ -36,7 +36,7 @@ jobs: path: | /var/cache/apt/ /var/lib/apt/ - key: apt-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/install_deps_ubuntu.sh') }} + key: apt-${{ runner.os }}-dev-${{ hashFiles('**/install_deps_ubuntu.sh') }} - name: Install dependencies id: install_deps diff --git a/.github/workflows/style.yml b/.github/workflows/check_style.yml similarity index 100% rename from .github/workflows/style.yml rename to .github/workflows/check_style.yml diff --git a/.github/workflows/docker_release.yml b/.github/workflows/docker_release.yml deleted file mode 100644 index e7dd618ab8..0000000000 --- a/.github/workflows/docker_release.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Release Docker container - -on: - push: - tags: - - "*.*.*" - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Read changelog - id: changelog_reader - uses: mindsers/changelog-reader-action@v2 - with: - version: ${{ github.ref_name }} - path: docs/changelog.md - - - name: Release - uses: softprops/action-gh-release@v1 - with: - body: ${{ steps.changelog_reader.outputs.changes }} - name: 'v${{ github.ref_name }}' - - docker: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v3 - with: - push: true - tags: ostis/sc-machine:latest,ostis/sc-machine:${{ github.ref_name }} - platforms: linux/amd64,linux/arm64 - cache-from: type=registry,ref=ostis/sc-machine:buildcache - cache-to: type=registry,ref=ostis/sc-machine:buildcache,mode=max diff --git a/.github/workflows/docs.yml b/.github/workflows/docs_build_tex.yml similarity index 100% rename from .github/workflows/docs.yml rename to .github/workflows/docs_build_tex.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..7bcd5810d9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,138 @@ +name: Release Docker container + +on: + push: + tags: + - "*.*.*" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + tests-conan: + uses: ./.github/workflows/test_conan.yml + check-dockerfile: + uses: ./.github/workflows/check_dockerfile.yml + build-conan: + needs: tests-conan + strategy: + fail-fast: true + matrix: + config: + - { os: ubuntu-22.04, cc: "gcc", cxx: "g++" } + - { os: macos-13, cc: "clang", cxx: "clang++" } + + runs-on: ${{ matrix.config.os }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Restore ccache caches + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} + + - name: Conan cache + uses: actions/cache@v4 + with: + path: ~/.conan/data + key: conan-${{ runner.os }}-${{ hashFiles('**/conanfile.py') }} + + - name: apt cache + uses: actions/cache@v4 + if: runner.os == 'Linux' + with: + path: | + /var/cache/apt/ + /var/lib/apt/ + key: apt-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/install_deps_ubuntu.sh') }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Set up pipx + run: | + python -m pip install --user pipx + python -m pipx ensurepath + + - name: Set up Conan + run: | + pipx install conan + + - name: Install compilers (Ubuntu) + if: runner.os == 'Linux' + run: sudo apt install build-essential ninja-build ccache cmake + + - name: Install compilers (macOS) + if: runner.os == 'macOS' + run: brew install cmake ninja ccache + + - name: Build sc-machine + id: run_cmake + run: | + cmake --preset release-conan + cmake --build --preset release + + - name: Create archive + run: | + cd ./build/Release + cpack -G TGZ + + - name: Upload archive + uses: actions/upload-artifact@v4 + with: + name: sc-machine-${{ matrix.config.os }}-${{ github.ref_name }} + path: ./build/Release/sc-machine-*.tar.gz + + changelog: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Read changelog + id: changelog_reader + uses: mindsers/changelog-reader-action@v2 + with: + version: ${{ github.ref_name }} + path: docs/changelog.md + + - name: Release + uses: softprops/action-gh-release@v1 + with: + body: ${{ steps.changelog_reader.outputs.changes }} + name: 'v${{ github.ref_name }}' + + docker: + needs: check-dockerfile + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v3 + with: + push: true + tags: ostis/sc-machine:latest,ostis/sc-machine:${{ github.ref_name }} + platforms: linux/amd64,linux/arm64 + cache-from: type=registry,ref=ostis/sc-machine:buildcache + cache-to: type=registry,ref=ostis/sc-machine:buildcache,mode=max diff --git a/.github/workflows/conan.yml b/.github/workflows/test_conan.yml similarity index 98% rename from .github/workflows/conan.yml rename to .github/workflows/test_conan.yml index e36063f77c..bee81b4749 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/test_conan.yml @@ -1,8 +1,9 @@ -name: Tests +name: Tests (Conan) on: pull_request: branches: [main] + workflow_call: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.github/workflows/native.yml b/.github/workflows/test_native.yml similarity index 94% rename from .github/workflows/native.yml rename to .github/workflows/test_native.yml index d8adcd540f..5709a3281d 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/test_native.yml @@ -1,4 +1,4 @@ -name: Tests +name: Tests (native) on: pull_request: @@ -34,7 +34,7 @@ jobs: path: | /var/cache/apt/ /var/lib/apt/ - key: apt-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/install_deps_ubuntu.sh') }} + key: apt-${{ runner.os }}-dev-${{ hashFiles('**/install_deps_ubuntu.sh') }} - name: Install dependencies run: | From 9c1375fbe4ec3b800e6fcb37fc9679fc6be5ea63 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 1 Nov 2024 21:22:47 +0300 Subject: [PATCH 058/134] [build] use asio in Conan's websocketpp --- conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index a285fc728b..15b1d4eb3b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -38,10 +38,11 @@ def _run_tests(self): return tools.get_env("CONAN_RUN_TESTS", False) def build_requirements(self): - self.build_requires("websocketpp/0.8.2") + self.build_requires("websocketpp/0.8.2", options={"asio": "standalone"}) self.build_requires("nlohmann_json/3.11.3") self.build_requires("glib/2.78.3") - self.build_requires("antlr4-cppruntime/4.9.3") + # TODO: use this instead of thirdparty/antlr4 + # self.build_requires("antlr4-cppruntime/4.9.3") self.build_requires("libxml2/2.13.4") self.test_requires("gtest/1.14.0") self.test_requires("benchmark/1.9.0") @@ -59,7 +60,6 @@ def generate(self): deps.generate() tc = CMakeToolchain(self) tc.user_presets_path = "ConanPresets.json" - tc.variables["CMAKE_CXX_STANDARD"] = 17 tc.generate() def package(self): From 569d6e73d3fbb2aebbdb8e243d66234606b2b333 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 1 Nov 2024 21:28:30 +0300 Subject: [PATCH 059/134] [cmake][fix] An attempt to return at macro-based FindGLIB --- cmake/FindGLIB.cmake | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake index d3f17df21c..16b2db216c 100644 --- a/cmake/FindGLIB.cmake +++ b/cmake/FindGLIB.cmake @@ -1,27 +1,28 @@ -function(FindGLIB) +macro(FindGLIB) if (glib_CACHED) message(STATUS "GLib found in cache") - return() - endif() + else() - find_package(glib QUIET) + find_package(glib QUIET) - if (NOT glib_FOUND) - message(STATUS "Trying to use system-installed glib") + if (NOT glib_FOUND) + message(STATUS "Trying to use system-installed glib") - find_package(PkgConfig REQUIRED) - pkg_search_module(GLIB2 REQUIRED glib-2.0) - pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) + find_package(PkgConfig REQUIRED) + pkg_search_module(GLIB2 REQUIRED glib-2.0) + pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) - if (NOT GLIB2_FOUND OR NOT GLIB2_MODULE_FOUND) - message(FATAL_ERROR "glib2 not found!") + if (NOT GLIB2_FOUND OR NOT GLIB2_MODULE_FOUND) + message(FATAL_ERROR "glib2 not found!") + endif() + + set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS} CACHE STRING "Include directories for GLib") + set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS} CACHE STRING "Libraries for GLib") + + set(glib_CACHED TRUE CACHE BOOL "GLib found") + else() + message(STATUS "GLib is already found") endif() - set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS} CACHE STRING "Include directories for GLib") - set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS} CACHE STRING "Libraries for GLib") - - set(glib_CACHED TRUE CACHE BOOL "GLib found") - else() - message(STATUS "GLib is already found") endif() -endfunction() +endmacro() From 77507604e18e30aad3b9c141e2daa9c5237998c8 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Sat, 2 Nov 2024 00:58:13 +0300 Subject: [PATCH 060/134] [build][fix] Use appropriate requirement types in Conan package definition --- cmake/FindGLIB.cmake | 16 +++++----------- conanfile.py | 17 +++++++++++------ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake index 16b2db216c..61b35c922a 100644 --- a/cmake/FindGLIB.cmake +++ b/cmake/FindGLIB.cmake @@ -1,28 +1,22 @@ macro(FindGLIB) if (glib_CACHED) - message(STATUS "GLib found in cache") - else() - - find_package(glib QUIET) + endif() - if (NOT glib_FOUND) - message(STATUS "Trying to use system-installed glib") + find_package(glib QUIET) - find_package(PkgConfig REQUIRED) + if (NOT glib_FOUND) + include(FindPkgConfig) + find_package(PkgConfig REQUIRED) pkg_search_module(GLIB2 REQUIRED glib-2.0) pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) if (NOT GLIB2_FOUND OR NOT GLIB2_MODULE_FOUND) message(FATAL_ERROR "glib2 not found!") endif() - set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS} CACHE STRING "Include directories for GLib") set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS} CACHE STRING "Libraries for GLib") set(glib_CACHED TRUE CACHE BOOL "GLib found") else() - message(STATUS "GLib is already found") - endif() - endif() endmacro() diff --git a/conanfile.py b/conanfile.py index 15b1d4eb3b..41b3a745c3 100644 --- a/conanfile.py +++ b/conanfile.py @@ -36,14 +36,19 @@ class sc_machineRecipe(ConanFile): @property def _run_tests(self): return tools.get_env("CONAN_RUN_TESTS", False) + + def requirements(self): + self.requires("websocketpp/0.8.2", options={"asio": "standalone"}) + self.requires("nlohmann_json/3.11.3") + self.requires("libxml2/2.13.4") + if self.settings.os == "Linux": + self.requires("glib/2.72.4") + elif self.settings.os == "Macos": + self.requires("glib/2.76.3") + # TODO: use this instead of thirdparty/antlr4 + # self.requires("antlr4-cppruntime/4.9.3") def build_requirements(self): - self.build_requires("websocketpp/0.8.2", options={"asio": "standalone"}) - self.build_requires("nlohmann_json/3.11.3") - self.build_requires("glib/2.78.3") - # TODO: use this instead of thirdparty/antlr4 - # self.build_requires("antlr4-cppruntime/4.9.3") - self.build_requires("libxml2/2.13.4") self.test_requires("gtest/1.14.0") self.test_requires("benchmark/1.9.0") From e2e156048c4617c32f3da12e136daaa93778d45e Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 5 Nov 2024 00:40:47 +0300 Subject: [PATCH 061/134] [build][fix] Bump Conan's glib recipe version to handle Python 3.12 system-wide setuptools issue --- conanfile.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/conanfile.py b/conanfile.py index 41b3a745c3..a7650c8b44 100644 --- a/conanfile.py +++ b/conanfile.py @@ -41,10 +41,7 @@ def requirements(self): self.requires("websocketpp/0.8.2", options={"asio": "standalone"}) self.requires("nlohmann_json/3.11.3") self.requires("libxml2/2.13.4") - if self.settings.os == "Linux": - self.requires("glib/2.72.4") - elif self.settings.os == "Macos": - self.requires("glib/2.76.3") + self.requires("glib/2.76.3") # TODO: use this instead of thirdparty/antlr4 # self.requires("antlr4-cppruntime/4.9.3") From a75b60d65923e40296982500dcabc01c3fe68206 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 5 Nov 2024 14:09:09 +0300 Subject: [PATCH 062/134] [ci] Update ci conan --- .github/workflows/test_conan.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_conan.yml b/.github/workflows/test_conan.yml index bee81b4749..916a3bb091 100644 --- a/.github/workflows/test_conan.yml +++ b/.github/workflows/test_conan.yml @@ -75,6 +75,5 @@ jobs: id: run_sc_machine run: | mkdir kb - build/Release/bin/sc-builder -i kb -o kb.bin --clear -f - build/Release/bin/sc-server -c sc-machine.ini -e build/Release/lib/extensions -r kb.bin -t - build/Release/bin/sc-machine -c sc-machine.ini -e -e build/Release/lib/extensions -r kb.bin -t + build/Release/bin/sc-builder -i kb -o kb.bin --clear + build/Release/bin/sc-machine -c sc-machine.ini -e build/Release/lib/extensions -s kb.bin -t From e49063dd5521a22799034546be20de39e8c54bcd Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 5 Nov 2024 14:20:42 +0300 Subject: [PATCH 063/134] [docs][agents][guide] Update test cmake --- .../api/cpp/guides/simple_guide_for_implementing_agent.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md b/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md index 5d1a46c3df..a11e0a7103 100644 --- a/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md +++ b/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md @@ -418,7 +418,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS ) add_library(set-agents SHARED ${SOURCES}) -target_link_libraries(set-agents LINK_PUBLIC sc-memory) +target_link_libraries(set-agents LINK_PUBLIC sc-machine::sc-memory) target_include_directories(set-agents PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +file(GLOB TEST_SOURCES CONFIGURE_DEPENDS @@ -432,7 +432,10 @@ target_include_directories(set-agents PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} +) -+add_test(NAME set-agents-tests COMMAND set-agents-tests) ++gtest_discover_tests(set-agents-tests ++ TEST_LIST ${TEST_SOURCES} ++ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests ++) ``` **test_sc_agent_calculate_set_power.cpp** From cad5a7698c16e9a7dd028f23dfcdea3a5df1e90b Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 5 Nov 2024 14:23:53 +0300 Subject: [PATCH 064/134] [docker][refactor] Replace as with AS --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 55fdfd6273..8717a59082 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:noble as base +FROM ubuntu:noble AS base ENV CCACHE_DIR=/ccache USER root @@ -10,16 +10,16 @@ COPY requirements.txt /tmp/sc-machine/requirements.txt RUN apt update && apt install -y --no-install-recommends sudo tini && /tmp/sc-machine/scripts/install_deps_ubuntu.sh #build using ccache -FROM base as devdeps +FROM base AS devdeps RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ /tmp/sc-machine/scripts/install_deps_ubuntu.sh --dev -FROM devdeps as devcontainer +FROM devdeps AS devcontainer RUN apt install -y --no-install-recommends git cppcheck valgrind gdb bash-completion curl ENTRYPOINT ["/bin/bash"] -FROM devdeps as builder +FROM devdeps AS builder WORKDIR /sc-machine COPY . . RUN --mount=type=cache,target=/ccache/ cmake --preset release . && cmake --build --preset release From 0dd66d9b21ddfd34f9059b8fcc93a614ba5e7415 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 5 Nov 2024 14:29:24 +0300 Subject: [PATCH 065/134] [tools][machine-runner] Remove machine setup --- .../include/sc-machine-runner/sc_machine_setup.hpp | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_setup.hpp diff --git a/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_setup.hpp b/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_setup.hpp deleted file mode 100644 index e7071c2b9a..0000000000 --- a/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_setup.hpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * This source file is part of an OSTIS project. For the latest info, see http://ostis.net - * Distributed under the MIT License - * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) - */ - -#pragma once - -#include - -void PrintStartMessage(); - -sc_int BuildAndRunMachine(sc_int argc, sc_char * argv[]); From 4afcfcac482935d442dfdf74af95d7e696f85f36 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 5 Nov 2024 14:31:22 +0300 Subject: [PATCH 066/134] [tools][refactor] Rename test-repo to test-kb-bin --- .../tests/configs/output-path-as-storage.ini | 2 +- sc-tools/sc-builder/tests/units/builder_test.hpp | 2 +- .../tests/configs/deprecated-extensions-path.ini | 2 +- .../tests/configs/deprecated-repo-path.ini | 2 +- .../tests/configs/empty-multiextensions.ini | 2 +- .../tests/configs/multiextensions-with-spaces.ini | 2 +- .../sc-config/tests/configs/multiextensions.ini | 2 +- .../configs/not-normalized-multiextensions.ini | 2 +- .../tests/configs/removed-save-period.ini | 2 +- .../tests/configs/removed-update-period.ini | 2 +- sc-tools/sc-config/tests/sc-machine-test.ini | 2 +- sc-tools/sc-config/tests/units/test_config.cpp | 14 +++++++------- .../sc-machine-runner/sc_machine_runner.hpp | 5 +++-- .../sc-machine-runner/tests/sc-machine-test.ini | 2 +- .../tests/units/sc_machine_test.hpp | 2 +- sc-tools/sc-server/tests/sc-server-test.ini | 2 +- .../sc-server/tests/units/api/sc_server_test.hpp | 2 +- .../units/performance/units/sc_server_test.hpp | 2 +- 18 files changed, 26 insertions(+), 25 deletions(-) diff --git a/sc-tools/sc-builder/tests/configs/output-path-as-storage.ini b/sc-tools/sc-builder/tests/configs/output-path-as-storage.ini index 4357b1e596..4bd05e007c 100644 --- a/sc-tools/sc-builder/tests/configs/output-path-as-storage.ini +++ b/sc-tools/sc-builder/tests/configs/output-path-as-storage.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin [sc-server] host = 127.0.0.1 diff --git a/sc-tools/sc-builder/tests/units/builder_test.hpp b/sc-tools/sc-builder/tests/units/builder_test.hpp index 26eb17792a..d2e15b82c4 100644 --- a/sc-tools/sc-builder/tests/units/builder_test.hpp +++ b/sc-tools/sc-builder/tests/units/builder_test.hpp @@ -22,7 +22,7 @@ class ScBuilderTest : public testing::Test { public: static inline std::string const & SC_BUILDER_INI = "../sc-builder-test.ini"; - static inline std::string const & SC_BUILDER_KB_BIN = "sc-builder-test-bin"; + static inline std::string const & SC_BUILDER_KB_BIN = "sc-builder-test-kb-bin"; static inline std::string const & SC_BUILDER_REPO_PATH = "../repo.path"; static inline std::string const & SC_BUILDER_KB = "../kb"; static inline std::string const & SC_BUILDER_TEST_REPOS = "../repos"; diff --git a/sc-tools/sc-config/tests/configs/deprecated-extensions-path.ini b/sc-tools/sc-config/tests/configs/deprecated-extensions-path.ini index ab7ccc0204..868cdb96c6 100644 --- a/sc-tools/sc-config/tests/configs/deprecated-extensions-path.ini +++ b/sc-tools/sc-config/tests/configs/deprecated-extensions-path.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin extensions_path = bin/extensions [sc-server] diff --git a/sc-tools/sc-config/tests/configs/deprecated-repo-path.ini b/sc-tools/sc-config/tests/configs/deprecated-repo-path.ini index 2dc4648ac4..7909961670 100644 --- a/sc-tools/sc-config/tests/configs/deprecated-repo-path.ini +++ b/sc-tools/sc-config/tests/configs/deprecated-repo-path.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -repo_path = sc-machine-test-repo +repo_path = sc-machine-test-kb-bin extensions = bin/extensions [sc-server] diff --git a/sc-tools/sc-config/tests/configs/empty-multiextensions.ini b/sc-tools/sc-config/tests/configs/empty-multiextensions.ini index df7c895afd..58429d4324 100644 --- a/sc-tools/sc-config/tests/configs/empty-multiextensions.ini +++ b/sc-tools/sc-config/tests/configs/empty-multiextensions.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin extensions = "" [sc-server] diff --git a/sc-tools/sc-config/tests/configs/multiextensions-with-spaces.ini b/sc-tools/sc-config/tests/configs/multiextensions-with-spaces.ini index 186eab1ab5..dd574ee0a3 100644 --- a/sc-tools/sc-config/tests/configs/multiextensions-with-spaces.ini +++ b/sc-tools/sc-config/tests/configs/multiextensions-with-spaces.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin extensions = bin/extensions_1 ; bin/extensions 2 ; bin/extensions_3 [sc-server] diff --git a/sc-tools/sc-config/tests/configs/multiextensions.ini b/sc-tools/sc-config/tests/configs/multiextensions.ini index b31ac6ee26..f794a30759 100644 --- a/sc-tools/sc-config/tests/configs/multiextensions.ini +++ b/sc-tools/sc-config/tests/configs/multiextensions.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin extensions = bin/extensions_1;bin/extensions_2;bin/extensions_3 [sc-server] diff --git a/sc-tools/sc-config/tests/configs/not-normalized-multiextensions.ini b/sc-tools/sc-config/tests/configs/not-normalized-multiextensions.ini index b81716301a..cf7dd5deec 100644 --- a/sc-tools/sc-config/tests/configs/not-normalized-multiextensions.ini +++ b/sc-tools/sc-config/tests/configs/not-normalized-multiextensions.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin extensions = bin/extensions_1;bin/../bin/extensions_2;../configs/bin/extensions_3;bin/extensions_3 [sc-server] diff --git a/sc-tools/sc-config/tests/configs/removed-save-period.ini b/sc-tools/sc-config/tests/configs/removed-save-period.ini index bac9b038c7..d5ea38da99 100644 --- a/sc-tools/sc-config/tests/configs/removed-save-period.ini +++ b/sc-tools/sc-config/tests/configs/removed-save-period.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin [sc-server] host = 127.0.0.1 diff --git a/sc-tools/sc-config/tests/configs/removed-update-period.ini b/sc-tools/sc-config/tests/configs/removed-update-period.ini index 2c2010cc71..505a488ad2 100644 --- a/sc-tools/sc-config/tests/configs/removed-update-period.ini +++ b/sc-tools/sc-config/tests/configs/removed-update-period.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin [sc-server] host = 127.0.0.1 diff --git a/sc-tools/sc-config/tests/sc-machine-test.ini b/sc-tools/sc-config/tests/sc-machine-test.ini index 26f4a84a14..49eea3d0c0 100644 --- a/sc-tools/sc-config/tests/sc-machine-test.ini +++ b/sc-tools/sc-config/tests/sc-machine-test.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin extensions = bin/extensions [sc-server] diff --git a/sc-tools/sc-config/tests/units/test_config.cpp b/sc-tools/sc-config/tests/units/test_config.cpp index 257088da4c..8ef0d815be 100644 --- a/sc-tools/sc-config/tests/units/test_config.cpp +++ b/sc-tools/sc-config/tests/units/test_config.cpp @@ -24,7 +24,7 @@ TEST_F(ScConfigTest, ValidConfig) EXPECT_EQ(std::string(params.log_type), "Console"); EXPECT_EQ(std::string(params.log_file), ""); EXPECT_EQ(std::string(params.log_level), "Debug"); - EXPECT_EQ(std::string(params.storage), "sc-machine-test-repo"); + EXPECT_EQ(std::string(params.storage), "sc-machine-test-kb-bin"); EXPECT_EQ(params.extensions_directories_count, 1u); EXPECT_EQ(std::string(params.extensions_directories[0]), "bin/extensions"); } @@ -62,7 +62,7 @@ TEST_F(ScConfigTest, DeprecatedRepoPath) EXPECT_EQ(std::string(params.log_type), "Console"); EXPECT_EQ(std::string(params.log_file), ""); EXPECT_EQ(std::string(params.log_level), "Debug"); - EXPECT_EQ(std::string(params.storage), "sc-machine-test-repo"); + EXPECT_EQ(std::string(params.storage), "sc-machine-test-kb-bin"); EXPECT_EQ(params.extensions_directories_count, 1u); EXPECT_EQ(std::string(params.extensions_directories[0]), "bin/extensions"); } @@ -82,7 +82,7 @@ TEST_F(ScConfigTest, DeprecatedExtensionsPath) EXPECT_EQ(std::string(params.log_type), "Console"); EXPECT_EQ(std::string(params.log_file), ""); EXPECT_EQ(std::string(params.log_level), "Debug"); - EXPECT_EQ(std::string(params.storage), "sc-machine-test-repo"); + EXPECT_EQ(std::string(params.storage), "sc-machine-test-kb-bin"); EXPECT_EQ(params.extensions_directories_count, 1u); EXPECT_EQ(std::string(params.extensions_directories[0]), "bin/extensions"); } @@ -102,7 +102,7 @@ TEST_F(ScConfigTest, Multiextensions) EXPECT_EQ(std::string(params.log_type), "Console"); EXPECT_EQ(std::string(params.log_file), ""); EXPECT_EQ(std::string(params.log_level), "Debug"); - EXPECT_EQ(std::string(params.storage), "sc-machine-test-repo"); + EXPECT_EQ(std::string(params.storage), "sc-machine-test-kb-bin"); EXPECT_EQ(params.extensions_directories_count, 3u); EXPECT_EQ(std::string(params.extensions_directories[0]), "bin/extensions_1"); EXPECT_EQ(std::string(params.extensions_directories[1]), "bin/extensions_2"); @@ -124,7 +124,7 @@ TEST_F(ScConfigTest, EmptyMultiextensions) EXPECT_EQ(std::string(params.log_type), "Console"); EXPECT_EQ(std::string(params.log_file), ""); EXPECT_EQ(std::string(params.log_level), "Debug"); - EXPECT_EQ(std::string(params.storage), "sc-machine-test-repo"); + EXPECT_EQ(std::string(params.storage), "sc-machine-test-kb-bin"); EXPECT_EQ(params.extensions_directories_count, 0u); EXPECT_EQ(params.extensions_directories, nullptr); } @@ -144,7 +144,7 @@ TEST_F(ScConfigTest, MultiextensionsWithSpaces) EXPECT_EQ(std::string(params.log_type), "Console"); EXPECT_EQ(std::string(params.log_file), ""); EXPECT_EQ(std::string(params.log_level), "Debug"); - EXPECT_EQ(std::string(params.storage), "sc-machine-test-repo"); + EXPECT_EQ(std::string(params.storage), "sc-machine-test-kb-bin"); EXPECT_EQ(params.extensions_directories_count, 3u); EXPECT_EQ(std::string(params.extensions_directories[0]), "../configs/bin/extensions 2"); @@ -167,7 +167,7 @@ TEST_F(ScConfigTest, NotNormalizedMultiextensions) EXPECT_EQ(std::string(params.log_type), "Console"); EXPECT_EQ(std::string(params.log_file), ""); EXPECT_EQ(std::string(params.log_level), "Debug"); - EXPECT_EQ(std::string(params.storage), "sc-machine-test-repo"); + EXPECT_EQ(std::string(params.storage), "sc-machine-test-kb-bin"); EXPECT_EQ(params.extensions_directories_count, 3u); EXPECT_EQ(std::string(params.extensions_directories[0]), "../configs/bin/extensions_1"); diff --git a/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_runner.hpp b/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_runner.hpp index 475f4054fb..c9f7fb79f7 100644 --- a/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_runner.hpp +++ b/sc-tools/sc-machine-runner/include/sc-machine-runner/sc_machine_runner.hpp @@ -18,7 +18,7 @@ * @param argc A number of command-line arguments. * @param argv An array of command-line argument strings. * - * @return Returns EXIT_SUCCESS (0) if the operation completes successfully, + * @return Returns EXIT_SUCCESS (0) if the operation completes successfully, * or EXIT_FAILURE (1) if there is an error in processing the command-line options * or during initialization. * @@ -34,7 +34,8 @@ * * Error Handling: * - If required options are missing, appropriate error messages are printed to standard output. - * - The function will return EXIT_FAILURE if any critical errors occur during initialization or if required options are not provided. + * - The function will return EXIT_FAILURE if any critical errors occur during initialization or if required options are + * not provided. * - Exceptions thrown by utility functions are caught, logged, and result in an EXIT_FAILURE return value. */ sc_int RunMachine(sc_int argc, sc_char * argv[]); diff --git a/sc-tools/sc-machine-runner/tests/sc-machine-test.ini b/sc-tools/sc-machine-runner/tests/sc-machine-test.ini index 3bbaa92b48..1e3868d72a 100644 --- a/sc-tools/sc-machine-runner/tests/sc-machine-test.ini +++ b/sc-tools/sc-machine-runner/tests/sc-machine-test.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-machine-test-repo +storage = sc-machine-test-kb-bin extensions = extensions [sc-server] diff --git a/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp b/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp index 7f259224f5..8ab048c960 100644 --- a/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp +++ b/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp @@ -14,7 +14,7 @@ class ScMachineTest : public testing::Test { public: static inline std::string const & SC_MACHINE_INI = "../sc-machine-test.ini"; - static inline std::string const & SC_MACHINE_KB_BIN = "../sc-machine-test-bin"; + static inline std::string const & SC_MACHINE_KB_BIN = "../sc-machine-test-kb-bin"; static inline std::string const & SC_MACHINE_EXTENSIONS = "/extensions"; protected: diff --git a/sc-tools/sc-server/tests/sc-server-test.ini b/sc-tools/sc-server/tests/sc-server-test.ini index 0d8e907d05..62b4234912 100644 --- a/sc-tools/sc-server/tests/sc-server-test.ini +++ b/sc-tools/sc-server/tests/sc-server-test.ini @@ -10,7 +10,7 @@ log_type = Console log_file = log_level = Debug -storage = sc-server-test-repo +storage = sc-server-test-kb-bin [sc-server] host = 127.0.0.1 diff --git a/sc-tools/sc-server/tests/units/api/sc_server_test.hpp b/sc-tools/sc-server/tests/units/api/sc_server_test.hpp index ed8826a343..93ac3f02d7 100644 --- a/sc-tools/sc-server/tests/units/api/sc_server_test.hpp +++ b/sc-tools/sc-server/tests/units/api/sc_server_test.hpp @@ -23,7 +23,7 @@ class ScServerTest : public testing::Test { public: static inline std::string const & SC_SERVER_INI = "../../sc-server-test.ini"; - static inline std::string const & SC_SERVER_KB_BIN = "sc-server-test-bin"; + static inline std::string const & SC_SERVER_KB_BIN = "sc-server-test-kb-bin"; static inline std::string const & SC_SERVER_EXTENSIONS = "/extensions"; static inline std::string const & SC_SERVER_KB = "../../kb"; diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp b/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp index 9163ee0ad1..3c56a6f89d 100644 --- a/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp +++ b/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp @@ -20,7 +20,7 @@ extern "C" class TestScServer { public: - static inline std::string const & SC_SERVER_KB_BIN = "sc-server-test-bin"; + static inline std::string const & SC_SERVER_KB_BIN = "sc-server-test-kb-bin"; void Initialize(size_t objectsNum = 0) { From 3f38c242b3f8f2b35a7fbaf52459cda24a498874 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 5 Nov 2024 14:36:37 +0300 Subject: [PATCH 067/134] [docs] Update readme --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9632a730bd..b8a7449690 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,8 @@ Semantic network storage is a core of any ostis-system, so you can use a referen - Docker: We provide a Docker image for this project. Head to [Installing with Docker](https://ostis-ai.github.io/sc-machine/docker) to learn more. It's the recommended way to deploy the sc-machine. - Native: - If you do not have the option to deploy the system using Docker, please refer to the docs for your OS: - [Build on Linux](https://ostis-ai.github.io/sc-machine/build/linux_build/) or [Build on macOS](https://ostis-ai.github.io/sc-machine/build/osx_build/) respectively. + If you do not have the option to deploy the system using Docker, please refer to the docs: + [Build system](https://ostis-ai.github.io/sc-machine/build/build_system/) Note: currently, the sc-machine isn't _natively_ supported on Windows. @@ -94,13 +94,12 @@ Semantic network storage is a core of any ostis-system, so you can use a referen ```sh # build kb - ./bin/sc-builder --clear -c ./sc-machine.ini -i -o + ./build//bin/sc-builder -c ./sc-machine.ini -i -o --clear # launch sc-machine - ./bin/sc-machine -c ./sc-machine.ini + ./build//bin/sc-machine -c ./sc-machine.ini ``` Most of these commands have a help page bundled inside, so if you have any questions or want to customize the command behavior, use `--help` flag to learn more about them. -You can also use `./scripts/build_kb.sh` and `./scripts/run_sc_machine.sh` to do it. Note that for projects other than sc-machine you might need to copy `scripts/set_vars.sh` to your project, change the variables accordingly and call it before using the scripts provided by sc-machine. ## Config From 79479b38b57ce12eb2e67a9e5da9b670b53a38d2 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 5 Nov 2024 14:39:49 +0300 Subject: [PATCH 068/134] [refactor] Format code --- .../fs-storage/sc_dictionary_fs_memory_test.hpp | 4 +--- .../units/fs-storage/sc_fs_memory_test.hpp | 4 +--- .../units/repo_path_collector_test_api.hpp | 3 ++- .../sc-builder/tests/units/test_aliases.cpp | 3 +-- sc-tools/sc-builder/tests/units/test_config.cpp | 17 +++++++++++++++-- .../sc-config/tests/units/sc_config_test.hpp | 8 ++------ .../tests/units/sc_machine_test.hpp | 4 +--- .../sc-machine-runner/tests/units/test_base.cpp | 6 ++++-- 8 files changed, 27 insertions(+), 22 deletions(-) diff --git a/sc-memory/sc-core/tests/units/fs-storage/sc_dictionary_fs_memory_test.hpp b/sc-memory/sc-core/tests/units/fs-storage/sc_dictionary_fs_memory_test.hpp index 149a6c75cc..d8cbbf8051 100644 --- a/sc-memory/sc-core/tests/units/fs-storage/sc_dictionary_fs_memory_test.hpp +++ b/sc-memory/sc-core/tests/units/fs-storage/sc_dictionary_fs_memory_test.hpp @@ -17,9 +17,7 @@ class ScDictionaryFSMemoryTest : public testing::Test static inline sc_char SC_DICTIONARY_FS_MEMORY_STRINGS_PATH[24] = "fs-memory/strings1.scdb"; protected: - void SetUp() override - { - } + void SetUp() override {} void TearDown() override { diff --git a/sc-memory/sc-core/tests/units/fs-storage/sc_fs_memory_test.hpp b/sc-memory/sc-core/tests/units/fs-storage/sc_fs_memory_test.hpp index 70b867379c..e1e5aa726a 100644 --- a/sc-memory/sc-core/tests/units/fs-storage/sc_fs_memory_test.hpp +++ b/sc-memory/sc-core/tests/units/fs-storage/sc_fs_memory_test.hpp @@ -17,9 +17,7 @@ class ScFSMemoryTest : public testing::Test static inline sc_char SC_FS_MEMORY_SEGMENTS_PATH[24] = "fs-memory/segments.scdb"; protected: - void SetUp() override - { - } + void SetUp() override {} void TearDown() override { diff --git a/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp b/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp index 2064a25bce..5b3550566a 100644 --- a/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp +++ b/sc-tools/sc-builder/tests/units/repo_path_collector_test_api.hpp @@ -19,7 +19,8 @@ class ScRepoPathCollectorTestAPI : public testing::Test static inline std::string const & SC_BUILDER_TEST_REPEATED_REPOS = SC_BUILDER_TEST_REPOS + "/repeated_repos.path"; static inline std::string const & SC_BUILDER_TEST_EXCLUDED_REPOS = SC_BUILDER_TEST_REPOS + "/excluded_repos.path"; static inline std::string const & SC_BUILDER_TEST_NON_TRIM_REPOS = SC_BUILDER_TEST_REPOS + "/non_trim_repos.path"; - static inline std::string const & SC_BUILDER_TEST_INVALID_REPO_PATH = SC_BUILDER_TEST_REPOS + "/invalid_repo_path.path"; + static inline std::string const & SC_BUILDER_TEST_INVALID_REPO_PATH = + SC_BUILDER_TEST_REPOS + "/invalid_repo_path.path"; protected: ScRepoPathCollector collector; diff --git a/sc-tools/sc-builder/tests/units/test_aliases.cpp b/sc-tools/sc-builder/tests/units/test_aliases.cpp index 45b2039b9d..9d700d7ca1 100644 --- a/sc-tools/sc-builder/tests/units/test_aliases.cpp +++ b/sc-tools/sc-builder/tests/units/test_aliases.cpp @@ -9,7 +9,7 @@ TEST_F(ScBuilderTest, Aliases) { LoadKB(m_ctx, {"aliases.scs"}); - + std::string const scsTempl = "test_element _-> _[] (* _<- alias_content;; *);;"; ScTemplate templ; @@ -19,4 +19,3 @@ TEST_F(ScBuilderTest, Aliases) EXPECT_TRUE(m_ctx->SearchByTemplate(templ, result)); EXPECT_EQ(result.Size(), 1u); } - diff --git a/sc-tools/sc-builder/tests/units/test_config.cpp b/sc-tools/sc-builder/tests/units/test_config.cpp index 117c3195f9..c175c3308f 100644 --- a/sc-tools/sc-builder/tests/units/test_config.cpp +++ b/sc-tools/sc-builder/tests/units/test_config.cpp @@ -18,7 +18,14 @@ TEST(ScBuilder, Run) { sc_uint32 const argsNumber = 8; sc_char const * args[argsNumber] = { - "sc-builder", "-c", ScBuilderTest::SC_BUILDER_INI.c_str(), "-i", ScBuilderTest::SC_BUILDER_REPO_PATH.c_str(), "-o", ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), "--clear"}; + "sc-builder", + "-c", + ScBuilderTest::SC_BUILDER_INI.c_str(), + "-i", + ScBuilderTest::SC_BUILDER_REPO_PATH.c_str(), + "-o", + ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), + "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_SUCCESS); } @@ -106,7 +113,13 @@ TEST(ScBuilder, RunWithOutputPathAsMemoryStorage) TEST(ScBuilder, RunWithoutConfig) { sc_uint32 const argsNumber = 6; - sc_char const * args[argsNumber] = {"sc-builder", "-i", ScBuilderTest::SC_BUILDER_REPO_PATH.c_str(), "-o", ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), "--clear"}; + sc_char const * args[argsNumber] = { + "sc-builder", + "-i", + ScBuilderTest::SC_BUILDER_REPO_PATH.c_str(), + "-o", + ScBuilderTest::SC_BUILDER_KB_BIN.c_str(), + "--clear"}; EXPECT_EQ(RunBuilder(argsNumber, (sc_char **)args), EXIT_SUCCESS); } diff --git a/sc-tools/sc-config/tests/units/sc_config_test.hpp b/sc-tools/sc-config/tests/units/sc_config_test.hpp index ae13d35309..9305d67277 100644 --- a/sc-tools/sc-config/tests/units/sc_config_test.hpp +++ b/sc-tools/sc-config/tests/units/sc_config_test.hpp @@ -15,11 +15,7 @@ class ScConfigTest : public testing::Test static inline std::string const & SC_CONFIGS = "../configs"; protected: - void SetUp() override - { - } + void SetUp() override {} - void TearDown() override - { - } + void TearDown() override {} }; diff --git a/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp b/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp index 8ab048c960..519e68c558 100644 --- a/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp +++ b/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp @@ -18,9 +18,7 @@ class ScMachineTest : public testing::Test static inline std::string const & SC_MACHINE_EXTENSIONS = "/extensions"; protected: - void SetUp() override - { - } + void SetUp() override {} void TearDown() override { diff --git a/sc-tools/sc-machine-runner/tests/units/test_base.cpp b/sc-tools/sc-machine-runner/tests/units/test_base.cpp index e72fbba40d..ed01f4fa0a 100644 --- a/sc-tools/sc-machine-runner/tests/units/test_base.cpp +++ b/sc-tools/sc-machine-runner/tests/units/test_base.cpp @@ -20,14 +20,16 @@ TEST_F(ScMachineTest, Run) TEST_F(ScMachineTest, RunWithExtensions) { sc_uint32 const argsNumber = 6; - sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI.c_str(), "-e", SC_MACHINE_EXTENSIONS.c_str(), "-t"}; + sc_char const * args[argsNumber] = { + "sc-machine", "-c", SC_MACHINE_INI.c_str(), "-e", SC_MACHINE_EXTENSIONS.c_str(), "-t"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_SUCCESS); } TEST_F(ScMachineTest, RunWithStorage) { sc_uint32 const argsNumber = 6; - sc_char const * args[argsNumber] = {"sc-machine", "-c", SC_MACHINE_INI.c_str(), "-s", SC_MACHINE_KB_BIN.c_str(), "-t"}; + sc_char const * args[argsNumber] = { + "sc-machine", "-c", SC_MACHINE_INI.c_str(), "-s", SC_MACHINE_KB_BIN.c_str(), "-t"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_SUCCESS); } From bc6d49b14168ae927e29c3fe3499b099a6c74854 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 5 Nov 2024 17:01:32 +0300 Subject: [PATCH 069/134] [ci] Try to fix mismatched endline by newer codecov version --- .github/workflows/check_coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_coverage.yml b/.github/workflows/check_coverage.yml index e0e810c258..63e9bfd4c0 100644 --- a/.github/workflows/check_coverage.yml +++ b/.github/workflows/check_coverage.yml @@ -71,7 +71,7 @@ jobs: run: scripts/ci/export_coverage.sh - name: Upload coverage report to CodeCov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v4.6.0 with: token: ${{secrets.CODECOV_TOKEN}} directory: ${{github.workspace}}/build/Debug From 2f5bf7c58a3bff5533e5b23d72fb6da153b61035 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 5 Nov 2024 17:08:40 +0300 Subject: [PATCH 070/134] [ci] Revert to ubuntu-22.04 for coverage --- .github/workflows/check_coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_coverage.yml b/.github/workflows/check_coverage.yml index 63e9bfd4c0..90ae6b252d 100644 --- a/.github/workflows/check_coverage.yml +++ b/.github/workflows/check_coverage.yml @@ -18,7 +18,7 @@ jobs: config: - { name: "Coverage C++", - os: ubuntu-24.04, + os: ubuntu-22.04, build_type: "Debug", cc: "gcc", cxx: "g++", From 3c19e51f2d9e876319141756be8008ea662ecc07 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Tue, 5 Nov 2024 19:36:12 +0300 Subject: [PATCH 071/134] [build] fix absolute rpaths --- CMakeLists.txt | 6 +++--- sc-kpm/sc-common/CMakeLists.txt | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 774bc7e47d..b6de222192 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,13 +109,13 @@ message("Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, path: # Set up dynamic linking paths for our own libraries # For macOS, use @loader_path instead of $ORIGIN if(APPLE) - set(CMAKE_INSTALL_RPATH "@loader_path/../lib;${SC_EXTENSIONS_DIRECTORY}") + set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib;") else() - set(CMAKE_INSTALL_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY};${SC_EXTENSIONS_DIRECTORY}") + set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib;") endif() # Always use full RPATH -set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) include(${CMAKE_MODULE_PATH}/FindGLIB.cmake) diff --git a/sc-kpm/sc-common/CMakeLists.txt b/sc-kpm/sc-common/CMakeLists.txt index dac5617a89..e63181084d 100644 --- a/sc-kpm/sc-common/CMakeLists.txt +++ b/sc-kpm/sc-common/CMakeLists.txt @@ -6,6 +6,9 @@ file(GLOB SOURCES CONFIGURE_DEPENDS add_library(sc-kpm-common SHARED ${SOURCES}) target_link_libraries(sc-kpm-common LINK_PUBLIC sc-core) + +set_target_properties(sc-kpm-common PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) + target_include_directories(sc-kpm-common PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src PUBLIC $ From 3b8b9ff674da0b5bb0cdb1e1c98cf88170189034 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 6 Nov 2024 13:31:50 +0300 Subject: [PATCH 072/134] [ci] Don't build bench tests for coverage --- .github/workflows/check_coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_coverage.yml b/.github/workflows/check_coverage.yml index 90ae6b252d..bc6a77f968 100644 --- a/.github/workflows/check_coverage.yml +++ b/.github/workflows/check_coverage.yml @@ -56,7 +56,7 @@ jobs: BUILD_TYPE: ${{ matrix.config.build_type }} COVERAGE: ON SANITIZER_TYPE: none - run: cmake --preset debug -DSC_COVERAGE=ON && cmake --build --preset debug + run: cmake --preset debug -DSC_COVERAGE=ON -DSC_BUILD_BENCH=OFF && cmake --build --preset debug - name: Prepare coverage id: prepare_coverage From 9c77e51606590d9d4303536e7d6276bc7405ff1e Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Thu, 7 Nov 2024 15:09:04 +0300 Subject: [PATCH 073/134] [tools][server][tests] Test run/stop sc-server module --- .../sc-server/tests/units/api/test_connection.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sc-tools/sc-server/tests/units/api/test_connection.cpp b/sc-tools/sc-server/tests/units/api/test_connection.cpp index f2f1c5cc94..3d18151359 100644 --- a/sc-tools/sc-server/tests/units/api/test_connection.cpp +++ b/sc-tools/sc-server/tests/units/api/test_connection.cpp @@ -12,6 +12,10 @@ #include "sc-client/sc_client.hpp" +#include "sc_server_module.hpp" + +using ScServerModuleTest = ScMemoryTest; + TEST(ScServer, RunStopServer) { ScOptions options{1, nullptr}; @@ -42,6 +46,15 @@ TEST(ScServer, RunStopServer) ScMemory::Shutdown(); } +TEST_F(ScServerModuleTest, RunStopServerModule) +{ + ScMemory::ms_configPath = ScServerTest::SC_SERVER_INI; + + ScServerModule serverModule; + serverModule.Initialize(m_ctx.get()); + serverModule.Shutdown(m_ctx.get()); +} + TEST_F(ScServerTest, Connect) { ScClient client; From 34cb32a46e2708a73587945c98c9d698cfdd3cc0 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Thu, 7 Nov 2024 15:09:32 +0300 Subject: [PATCH 074/134] [cmake][refactor] Fix indentions --- cmake/FindGLIB.cmake | 19 +++++++++---------- sc-kpm/sc-agents-common/CMakeLists.txt | 2 +- sc-kpm/sc-common/CMakeLists.txt | 1 - 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake index 61b35c922a..b86bc6ee7c 100644 --- a/cmake/FindGLIB.cmake +++ b/cmake/FindGLIB.cmake @@ -7,16 +7,15 @@ macro(FindGLIB) if (NOT glib_FOUND) include(FindPkgConfig) find_package(PkgConfig REQUIRED) - pkg_search_module(GLIB2 REQUIRED glib-2.0) - pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) + pkg_search_module(GLIB2 REQUIRED glib-2.0) + pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) - if (NOT GLIB2_FOUND OR NOT GLIB2_MODULE_FOUND) - message(FATAL_ERROR "glib2 not found!") - endif() - set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS} CACHE STRING "Include directories for GLib") - set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS} CACHE STRING "Libraries for GLib") - - set(glib_CACHED TRUE CACHE BOOL "GLib found") - else() + if (NOT GLIB2_FOUND OR NOT GLIB2_MODULE_FOUND) + message(FATAL_ERROR "glib2 not found!") + endif() + set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS} CACHE STRING "Include directories for GLib") + set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS} CACHE STRING "Libraries for GLib") + + set(glib_CACHED TRUE CACHE BOOL "GLib found") endif() endmacro() diff --git a/sc-kpm/sc-agents-common/CMakeLists.txt b/sc-kpm/sc-agents-common/CMakeLists.txt index 46485b2fe8..01c20a2ade 100644 --- a/sc-kpm/sc-agents-common/CMakeLists.txt +++ b/sc-kpm/sc-agents-common/CMakeLists.txt @@ -18,7 +18,7 @@ target_include_directories(sc-agents-common ) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) if(${SC_CLANG_FORMAT_CODE}) diff --git a/sc-kpm/sc-common/CMakeLists.txt b/sc-kpm/sc-common/CMakeLists.txt index e63181084d..c9f0796298 100644 --- a/sc-kpm/sc-common/CMakeLists.txt +++ b/sc-kpm/sc-common/CMakeLists.txt @@ -6,7 +6,6 @@ file(GLOB SOURCES CONFIGURE_DEPENDS add_library(sc-kpm-common SHARED ${SOURCES}) target_link_libraries(sc-kpm-common LINK_PUBLIC sc-core) - set_target_properties(sc-kpm-common PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) target_include_directories(sc-kpm-common From 1c335789f3711ee80669268175513552522b1526 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Thu, 7 Nov 2024 16:46:47 +0300 Subject: [PATCH 075/134] [cmake][kpm][fix] Loading sc-common extension --- cmake/install.cmake | 5 ++--- sc-kpm/sc-common/src/sc_common.c | 19 +++++++++++++++++++ sc-kpm/sc-common/src/sc_common.h | 13 +++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 sc-kpm/sc-common/src/sc_common.c create mode 100644 sc-kpm/sc-common/src/sc_common.h diff --git a/cmake/install.cmake b/cmake/install.cmake index ad7e878adb..23262f1938 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -1,6 +1,5 @@ install(TARGETS sc-machine sc-builder sc-machine-runner - sc-kpm-common sc-core sc-memory sc-agents-common sc-builder-lib sc-config EXPORT sc-machineExport LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -12,9 +11,9 @@ install(TARGETS # a target set for things we don't want to export to the consumers install(TARGETS - sc-kpm-search sc-kpm-utils sc-kpm-ui sc-server-lib + sc-kpm-common sc-kpm-search sc-kpm-utils sc-kpm-ui sc-server-lib EXPORT privateExport - LIBRARY DESTINATION ${SC_EXTENSIONS_DIRECTORY} + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/extensions" ) export(EXPORT sc-machineExport diff --git a/sc-kpm/sc-common/src/sc_common.c b/sc-kpm/sc-common/src/sc_common.c new file mode 100644 index 0000000000..58a5267768 --- /dev/null +++ b/sc-kpm/sc-common/src/sc_common.c @@ -0,0 +1,19 @@ +/* + * This source file is part of an OSTIS project. For the latest info, see http://ostis.net + * Distributed under the MIT License + * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) + */ + +#include "sc_common.h" + +// --------------------- Module ------------------------ + +sc_result sc_module_initialize() +{ + return SC_RESULT_OK; +} + +sc_result sc_module_shutdown() +{ + return SC_RESULT_OK; +} diff --git a/sc-kpm/sc-common/src/sc_common.h b/sc-kpm/sc-common/src/sc_common.h new file mode 100644 index 0000000000..d464575f8f --- /dev/null +++ b/sc-kpm/sc-common/src/sc_common.h @@ -0,0 +1,13 @@ +/* + * This source file is part of an OSTIS project. For the latest info, see http://ostis.net + * Distributed under the MIT License + * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) + */ + +#pragma once + +#include + +sc_result sc_module_initialize(); + +sc_result sc_module_shutdown(); From 0affbc4e5779c00fc008c3b85b2207256473c3ed Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Thu, 7 Nov 2024 16:48:27 +0300 Subject: [PATCH 076/134] [tests] Add default config for launching tests in vscode --- .vscode/launch.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..e385edeff8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(ctest) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${command:cmake.launchTargetPath}", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [ + { + // add the directory where our target was built to the PATHs + // it gets resolved by CMake Tools: + "name": "PATH", + "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" + }, + ], + "externalConsole": false, + "internalConsoleOptions": "openOnSessionStart", + "MIMode": "lldb" + }, + ] +} \ No newline at end of file From a972a1182825420d7f3219301746283ca3b327da Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Thu, 7 Nov 2024 16:59:26 +0300 Subject: [PATCH 077/134] [docs] Add info about good vscode extension for tests --- docs/build/build_system.md | 2 ++ .../cpp/guides/simple_guide_for_implementing_agent.md | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index c4125d85e3..919beba2fe 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -154,6 +154,8 @@ If your IDE doesn't integrate well with this solution, try exporting compile com set(CMAKE_EXPORT_COMPILE_COMMANDS ON) ``` +By default, the sc-machine repository contains configuration for launching tests in vscode. If you're developing on vscode, you can use this configuration and extension [C++ TestMate](https://marketplace.visualstudio.com/items?itemName=matepek.vscode-catch2-test-adapter) for debugging code. + ## Advanced Usage ### Cross-Compilation diff --git a/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md b/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md index a11e0a7103..236915874c 100644 --- a/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md +++ b/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md @@ -82,6 +82,11 @@ file(GLOB SOURCES CONFIGURE_DEPENDS add_library(set-agents SHARED ${SOURCES}) target_link_libraries(set-agents LINK_PUBLIC sc-memory) target_include_directories(set-agents PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +# Set output path for your extension `set-agents.so`. +# Make sure that variable `SC_EXTENSIONS_DIRECTORY` has value. +set_target_properties(set-agents + PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY} +) ``` --- @@ -420,6 +425,9 @@ file(GLOB SOURCES CONFIGURE_DEPENDS add_library(set-agents SHARED ${SOURCES}) target_link_libraries(set-agents LINK_PUBLIC sc-machine::sc-memory) target_include_directories(set-agents PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +set_target_properties(set-agents + PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY} +) +file(GLOB TEST_SOURCES CONFIGURE_DEPENDS + "tests/*.cpp" @@ -516,6 +524,8 @@ TEST_F(AgentTest, AgentCalculateSetPowerFinishedSuccessfully) `ScMemoryTest` class includes `m_ctx` that is object of `ScAgentContext` class. You can use it to work with sc-memory. See [**C++ Core API**](../core/api.md) and [**C++ Agent context API**](../extended/agents/agents.md) to learn more about available methods for working with sc-memory. +By default, the sc-machine repository contains configuration for launching tests in vscode. If you're developing on vscode, you can use this configuration and extension [C++ TestMate](https://marketplace.visualstudio.com/items?itemName=matepek.vscode-catch2-test-adapter) for debugging code. + --- ## **Frequently Asked Questions** From b154dd3da6efdab9f0655d3293fe84a3b0afd8e4 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Thu, 7 Nov 2024 16:59:37 +0300 Subject: [PATCH 078/134] [docs] Apply changes --- docs/changelog.md | 59 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 61f8f9acf6..3c6bf71866 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -10,10 +10,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking changes - Python dependencies are set up locally in `.venv` environment. Therefore, you should make the following changes: - - fix `docker-compose.yml` file to run `healthcheck.py` for sc-server in `.venv` or use `scripts/healthcheck.sh` -encapsulated this logic; + - fix `docker-compose.yml` file to run `healthcheck.py` for sc-server in `.venv` or use `scripts/healthcheck.sh` encapsulated this logic; - and use `.venv` to launch your python scripts if they use sc-machine python dependencies. -- `sc-server` binary and `run_sc_server.sh` script were removed. Use `sc-machine` binary instead. +- Build system of the sc-machine was upgraded: + - The way to manage build dependencies was changed to [Conan](https://conan.io). You can install sc-machine and its dependencies with Conan. You don't have to worry about installing sc-machine dependencies on your OS anymore. See how to do it -- [Build System](build/build_system.md). + - CMake presets should be used to build the sc-machine. They are located in `CMakePresets.json`. + - Location of the sc-machine build was changed. The following new locations are: + - build tree -- `build/`, + - binaries -- `build//bin`, + - libraries -- `build//lib`, + - extensions -- `build//lib/extensions`. + - Now using sc-machine as a library is much more optimized: adding it to the CMake tree is no longer necessary. You can install sc-machine packages and import sc-machine targets into your cmake using `find_package(sc-machine REQUIRED)`. But if you include sc-machine into CMake tree of your project, remember that the minimum version of cmake for the machine is 3.24. + - Now each release sc-machine binaries are compiled for supported OS and formed as an archives on Github. Minimum required version of macOS is macos-13, of ubuntu is ubuntu-22.04. The sc-machine doesn't support ubuntu-20.04 anymore. You can use them to work with sc-memory or you can use `RunMachine` method from `sc-machine-runner.so` to create your own entry point to initialize sc-memory instead of using compiled `sc-machine` binary. + - Script for the project build (`build_sc_machine.sh`), scripts for running binaries (`run_sc_server.sh`, `build_kb.sh`) were removed from the sc-machine repository scripts. You should use sc-machine binaries directly. + - Now sc-server is not entry point of the sc-machine, it is an extension (`sc-server-lib.so`), that is loaded dynamically when the machine is started. So, `sc-server` binary was removed, `sc-machine` binary was added instead. +- Config was changed: + - `repo_path` option in `[sc-memory]` group was deprecated, `storage` option was added instead; + - `extensions_path` option in `[sc-memory]` group was deprecated, `extensions` option was added instead; + - `[sc-builder]` group was removed. +- Sources of the sc-machine were separated into public and private ones. Public sources of targets are located in `include` directory, private ones - in `src` directory, tests for code - in `tests` directory. Private sources can't be included into project's code directly. Besides that there are changes of location of some API classes of the sc-machine: + - Now `ScTest` class is part of `sc-memory` target. Use `#include ` to include it into code. + - To include `ScsLoader` class into code, use `#include `. +- Configuration of sc-machine tests was changed: + - Now paths to test sources of the knowledge base, test configs, etc. are configured at the pre-run stage, not at the stage of compiling tests. + - Working directory for tests was changed to a directory where tests are located. To run the tests, please use `ctest` rather than the test binaries themselves. + - Scripts for running tests (`run_tests.sh`) was removed. Go to `build/` and use `ctest` instead. - All questions was renamed to actions. - ScAddrHashFunc with template argument was removed. Use non-template ScAddrHashFunc without arguments. It is more safe in use. - Constructors for ScMemoryContext with string and int parameters were removed. Use the one without parameters instead. @@ -22,9 +43,9 @@ encapsulated this logic; - Questions were renamed to actions, answers were renamed to results. - `m_memoryCtx` in ScAgent renamed to `m_context`. - Now we don't use code generation as metaprogramming. The API for agents has been completely redesigned. See the documentation section on how to implement an agent with the new API. We have - - completely moved from code generation to template programming; - - improved the API and aligned with our description of how it should be; - - simplified the API. Now it will be much easier to create agents, go right now and see how to work with the new API -- [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md). + - completely moved from code generation to template programming; + - improved the API and aligned with our description of how it should be; + - simplified the API. Now it will be much easier to create agents, go right now and see how to work with the new API -- [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md). - All `ScMemoryContext` methods were redesigned to a common style. All methods with not correct names were deprecated, and new ones were added. See the table below to see which methods have been replaced. | Deprecated method | Substitution method | @@ -138,15 +159,16 @@ encapsulated this logic; | sc_node_norole_relation | sc_node_non_role_relation | - Type `ScType::NodeAbstract` and sc.s-keynode `sc_node_abstract` were removed. -- Sources of the sc-machine were separated into public and private ones. Public sources of targets are located in `include` directory, private ones - in `src` directory, tests for code - in `tests` directory. Private sources can't be included into project's code directly. Besides that there are changes of location of some API classes of the sc-machine: - - Now `ScTest` class is part of `sc-memory` target. Use `#include ` to include it into code. - - To include `ScsLoader` class into code, use `#include `. See documentation, to learn more about using new API. ### Added - Allow multiple extension directories for sc-memory +- CD for publishing sc-machine binaries as archive on Github +- CI for checking sc-machine tests build with Conan dependencies +- Install target to prepare consuming sc-machine targets +- Conan support for managing sc-machine dependencies - Handling required options for sc-machine and sc-builder - Display versions for sc-machine and sc-builder - Doc strings for sc-config classes @@ -195,9 +217,7 @@ See documentation, to learn more about using new API. - Create guest users during creating sc-memory context - Get user address for sc-server session and sc-memory context - Docker entrypoint run to launch binary `sc-machine` in docker -- Script `run_sc_machine.sh` to launch binary `sc-machine` - Binary `sc-machine` instead of binary `sc-server` that loads extension sc-server -- Generalized build_cxx_project.sh - Collect user permissions during sc-memory initialize - Throw exceptions in get values methods of iterators if sc-element is not accessed - Callback to get and collect sc-links by its contents from fs-memory @@ -213,6 +233,10 @@ See documentation, to learn more about using new API. ### Changed +- Now working directory for tests is a directory where tests are located +- Install `gtest` and `benchmark` via Conan or OS package managers instead of using them as submodules +- Location of the sc-machine build tree, binaries, libraries and extensions +- Up minimum required cmake version to 3.24.0 - Help messages for sc-machine and sc-builder - Clarify sc-machine and sc-builder options - Specify dependencies near targets, not in overall file @@ -232,9 +256,6 @@ See documentation, to learn more about using new API. - Don't check extensions when loading dynamic modules (`g_open_module` does it automatically) - Use venv for python dependencies in scripts and docker - Don't emit events after kb build -- Build codegen target first -- Up minimum required cmake version to 3.11.0 -- Configure SC_BIN_PATH from scripts - Allows assigns sc-link to its system identifier ### Fixed @@ -270,9 +291,12 @@ See documentation, to learn more about using new API. ### Removed -- Config option `update_period` in `[sc-memory]` -- Config option `save_period` in `[sc-memory]` -- `sc-server` binary, `run_sc_server.sh` script and docker entrypoint command `serve` +- Support for ubuntu-20.04 +- Config group `[sc-builder]` +- Config options `update_period` and `save_period` in `[sc-memory]` deprecated in 0.9.0 +- Config option `sync_actions` in `[sc-server]` deprecated in 0.9.0 +- Scripts: `build_sc_machine.sh`, `build_kb.sh`, `run_sc_server.sh`, `set_vars.sh` and `run_tests.sh` +- `sc-server` binary and docker entrypoint command `serve` - gwf2scs-translator in python - Designations of fuzzy sc.s-arcs: ```-/>```, ``````, ```_```, ``````, ```_ Date: Fri, 8 Nov 2024 00:51:38 +0300 Subject: [PATCH 079/134] [build][conan][fix] libxml2 is build requirement --- conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index a7650c8b44..27d8fe05c8 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,7 +15,7 @@ def get_version(): class sc_machineRecipe(ConanFile): name = "sc-machine" package_type = "library" - version = get_version() + version = "0.10.0" author = "OSTIS AI" license = "https://github.com/ostis-ai/sc-machine/blob/master/LICENSE" url = "https://github.com/ostis-ai/sc-machine" @@ -40,12 +40,12 @@ def _run_tests(self): def requirements(self): self.requires("websocketpp/0.8.2", options={"asio": "standalone"}) self.requires("nlohmann_json/3.11.3") - self.requires("libxml2/2.13.4") self.requires("glib/2.76.3") # TODO: use this instead of thirdparty/antlr4 # self.requires("antlr4-cppruntime/4.9.3") def build_requirements(self): + self.build_requires("libxml2/2.13.4") self.test_requires("gtest/1.14.0") self.test_requires("benchmark/1.9.0") From d0df09c84bdcfaa906b3e9aeeaa7d00d21c44673 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 8 Nov 2024 19:40:17 +0300 Subject: [PATCH 080/134] [ci] Use macos-14 in release CD and macos15 in test native CI --- .github/workflows/release.yml | 4 ++-- .github/workflows/test_native.yml | 2 +- docs/changelog.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bcd5810d9..bd91e34021 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release Docker container +name: Release on: push: @@ -20,7 +20,7 @@ jobs: matrix: config: - { os: ubuntu-22.04, cc: "gcc", cxx: "g++" } - - { os: macos-13, cc: "clang", cxx: "clang++" } + - { os: macos-14, cc: "clang", cxx: "clang++" } runs-on: ${{ matrix.config.os }} diff --git a/.github/workflows/test_native.yml b/.github/workflows/test_native.yml index 5709a3281d..e3036f89c1 100644 --- a/.github/workflows/test_native.yml +++ b/.github/workflows/test_native.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-14, ubuntu-22.04, ubuntu-24.04] + os: [macos-15, ubuntu-22.04, ubuntu-24.04] build_type: - { name: "Release", configure_preset: "release-with-tests", build_preset: "release" } - { name: "Debug", configure_preset: "debug", build_preset: "debug" } diff --git a/docs/changelog.md b/docs/changelog.md index 3c6bf71866..0eeff11d32 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -21,7 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - libraries -- `build//lib`, - extensions -- `build//lib/extensions`. - Now using sc-machine as a library is much more optimized: adding it to the CMake tree is no longer necessary. You can install sc-machine packages and import sc-machine targets into your cmake using `find_package(sc-machine REQUIRED)`. But if you include sc-machine into CMake tree of your project, remember that the minimum version of cmake for the machine is 3.24. - - Now each release sc-machine binaries are compiled for supported OS and formed as an archives on Github. Minimum required version of macOS is macos-13, of ubuntu is ubuntu-22.04. The sc-machine doesn't support ubuntu-20.04 anymore. You can use them to work with sc-memory or you can use `RunMachine` method from `sc-machine-runner.so` to create your own entry point to initialize sc-memory instead of using compiled `sc-machine` binary. + - Now each release sc-machine binaries are compiled for supported OS and formed as an archives on Github. Minimum required version of macOS is macOS-14 (arm), of ubuntu is ubuntu-22.04. The sc-machine doesn't support ubuntu-20.04 anymore. You can use them to work with sc-memory or you can use `RunMachine` method from `sc-machine-runner.so` to create your own entry point to initialize sc-memory instead of using compiled `sc-machine` binary. - Script for the project build (`build_sc_machine.sh`), scripts for running binaries (`run_sc_server.sh`, `build_kb.sh`) were removed from the sc-machine repository scripts. You should use sc-machine binaries directly. - Now sc-server is not entry point of the sc-machine, it is an extension (`sc-server-lib.so`), that is loaded dynamically when the machine is started. So, `sc-server` binary was removed, `sc-machine` binary was added instead. - Config was changed: From fb0b231fc8284a3b8ea98c13bfbc29e6f0fb17f6 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 13 Nov 2024 16:47:38 +0300 Subject: [PATCH 081/134] [review] vscode tests config --- .vscode/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e385edeff8..2f3749ac72 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -25,4 +25,4 @@ "MIMode": "lldb" }, ] -} \ No newline at end of file +} From 049544fe7ccb43c229eb64203d31108b209a832d Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 13 Nov 2024 16:48:18 +0300 Subject: [PATCH 082/134] [docker][docs] Update information about entrypoints for docker --- docs/dev/devcontainer.md | 5 +++-- docs/docker.md | 4 ++-- scripts/docker_entrypoint.sh | 18 ------------------ 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/docs/dev/devcontainer.md b/docs/dev/devcontainer.md index cd9907c5b1..a35e8f5b8c 100644 --- a/docs/dev/devcontainer.md +++ b/docs/dev/devcontainer.md @@ -1,5 +1,6 @@ ## Docker development container -We recognize that recreating development environment for this project may be complicated, especially on unsupported platforms. To ease things for our developers and contributors, we created a stable, reproducible environment dubbed "Dev container". It can be used in any IDE or in a standalone manner, but is fully integrated with Visual Studio Code. +We recognize that recreating development environment for this project may be complicated, especially on unsupported platforms. To ease things for our developers and contributors, we created a stable, reproducible environment dubbed "Dev container". It can be used in any IDE or in a standalone manner, but is fully integrated with Visual Studio Code. + ## Usage ### VSCode If you use VSCode as your code editor of choice, things are simple: install Docker, install `Remote - Containers` extension for VSCode, and reload the window. You should see a prompt to reopen the project in container (if it didn't appear, you can fire up `Reopen in Container` action in Command Palette). First load/build may take a while, so don't rush to cancel the process. After the window is reopened, you can open terminals, edit code and recompile the project as usual. @@ -18,4 +19,4 @@ docker build . -t ostis/sc-machine-builder --target=devcontainer 2. Run the container mounting your workspace folder to `/sc-machine` inside the container. Optionally you can create a volume for `ccache` to preserve build cache across restarts: ``` docker run --rm -i -t -v sc-machine_ccache:/ccache -v < path to the project folder>:/sc-machine ostis/sc-machine-builder -``` \ No newline at end of file +``` diff --git a/docs/docker.md b/docs/docker.md index 943b47253f..5007783249 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -17,7 +17,7 @@ Note: By default we expect you to place a [repo.path](sc-tools/kb_repo_file.md) +KB_PATH="/kb" ``` -If you want to auto-rebuild the knowledge base on sc-server restart, you can also configure this behavior in the `.env` file: +If you want to auto-rebuild the knowledge base on sc-machine restart, you can also configure this behavior in the `.env` file: ```diff +REBUILD_KB=1 @@ -25,7 +25,7 @@ If you want to auto-rebuild the knowledge base on sc-server restart, you can als ## docker_entrypoint.sh -Our Docker entrypoint script has two commands: `build` and `serve`. The former is used to build or update knowledge base, and the latter is used to launch `sc-server`. You can use it in your own projects that use sc-server as the entrypoint. Don't forget to configure custom binary and knowledge base paths. Consult with the `docker-entrypoint.sh --help` for the full list of available flags. +Our Docker entrypoint script has two commands: `build` and `run`. The former is used to build or update knowledge base, and the latter is used to launch `sc-machine`. You can use it in your own projects that use sc-machine as the entrypoint. Don't forget to configure custom binary and knowledge base paths. Consult with the `docker-entrypoint.sh --help` for the full list of available flags. ## Rebuild image diff --git a/scripts/docker_entrypoint.sh b/scripts/docker_entrypoint.sh index 3659db2424..5d58958a36 100755 --- a/scripts/docker_entrypoint.sh +++ b/scripts/docker_entrypoint.sh @@ -37,24 +37,6 @@ function rebuild_kb() { fi } -function start_server() { - if [ -n "$REBUILD_KB" ] && [ "$REBUILD_KB" -eq 1 ]; - then - # this expands to $KB_PATH if it's non-null and expands to "/kb" otherwise. - rebuild_kb "${KB_PATH:-"/kb"}" - fi - - # if arguments were provided, use them instead of the default ones. - if [ $# -eq 0 ]; - then - # you should provide the config file path and host settings yourself in case you want to use custom options! - echo "Using default arguments." - "$BINARY_PATH"/sc-server -c "$CONFIG_PATH" -h 0.0.0.0 -e "$EXTENSIONS_PATH" - else - "$BINARY_PATH"/sc-server "$@" - fi -} - function start_machine { if [ -n "$REBUILD_KB" ] && [ "$REBUILD_KB" -eq 1 ]; then From 333ea0a7eb2a6375c5869ec84b01f021a2d67d7e Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 13 Nov 2024 16:49:25 +0300 Subject: [PATCH 083/134] [cmake][conan] Fix parsing version --- CMakeLists.txt | 4 ++-- conanfile.py | 4 ++-- sc-tools/CMakeLists.txt | 3 --- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6de222192..590557fe39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.24) set(CMAKE_CXX_STANDARD 17) -project(sc-machine VERSION "0.9.0" LANGUAGES C CXX) +project(sc-machine VERSION 0.9.0 LANGUAGES C CXX) message(STATUS "Current project version: ${CMAKE_PROJECT_VERSION}") site_name(www.ostis.net) cmake_policy(SET CMP0048 NEW) @@ -18,7 +18,7 @@ if (DEFINED "${SC_EXTENSIONS_DIRECTORY}") file(MAKE_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) else() set(SC_EXTENSIONS_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/extensions) - make_directory(${SC_EXTENSIONS_DIRECTORY}) + file(MAKE_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) message(STATUS "No extensions directory provided. Defaulting to: ${SC_EXTENSIONS_DIRECTORY}") endif() diff --git a/conanfile.py b/conanfile.py index 27d8fe05c8..804100b09d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,7 +15,7 @@ def get_version(): class sc_machineRecipe(ConanFile): name = "sc-machine" package_type = "library" - version = "0.10.0" + version = get_version() author = "OSTIS AI" license = "https://github.com/ostis-ai/sc-machine/blob/master/LICENSE" url = "https://github.com/ostis-ai/sc-machine" @@ -41,7 +41,7 @@ def requirements(self): self.requires("websocketpp/0.8.2", options={"asio": "standalone"}) self.requires("nlohmann_json/3.11.3") self.requires("glib/2.76.3") - # TODO: use this instead of thirdparty/antlr4 + # TODO(FallenChromium): use this instead of thirdparty/antlr4 # self.requires("antlr4-cppruntime/4.9.3") def build_requirements(self): diff --git a/sc-tools/CMakeLists.txt b/sc-tools/CMakeLists.txt index a6cd7371ad..1e00be10a5 100644 --- a/sc-tools/CMakeLists.txt +++ b/sc-tools/CMakeLists.txt @@ -1,6 +1,3 @@ -set(SC_CONFIG_SRC ${SC_TOOLS_SRC}/sc-config) -set(SC_BUILDER_SRC ${SC_TOOLS_SRC}/sc-builder) - add_subdirectory(sc-config) add_subdirectory(sc-builder) add_subdirectory(sc-machine-runner) From 70c624da237de8703b90798979e078365dfd9395 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 13 Nov 2024 16:50:32 +0300 Subject: [PATCH 084/134] [docs] Clarify cmake problems for ubuntu-22.04; clarify target install --- docs/build/build_system.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index 919beba2fe..87857434a2 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -16,6 +16,9 @@ If you wish to use CLI instead, you can list all the available configurations in cmake --list-presets ``` +!!! warning + By default, the standard repositories for Ubuntu 22.04 provide CMake version 3.22, which does not support certain features required for working with CMakePresets.json. To avoid issues during the build process, you need to manually install CMake version 3.24 or higher. + For example, this is how to build sc-machine in debug mode using dependencies from Conan: ```sh @@ -176,7 +179,7 @@ cmake --preset debug-conan cmake --build --preset debug ``` -The same is true for installations that have used GitHub Releases artifacts. Download the sc-machine repo, configure it, run `cmake --build --preset --target install` and add `sc-machine/build//install` to `CMAKE_PREFIX_PATH` of your project. Re-running `cmake --build --preset --target install` is enough to propagate changes to the consumer. +The same is true for installations that have used GitHub Releases artifacts. Download the sc-machine repo, configure it, run `cmake --build --preset --target install`. It will copy the built artifacts from their build location to the designated install location. After that, add `sc-machine/build//install` to `CMAKE_PREFIX_PATH` of your project. Re-running `cmake --build --preset --target install` is enough to propagate changes to the consumer. By these steps, you can seamlessly integrate sc-machine into your project, ensuring that you have access to all necessary components without unnecessary rebuilds. Relaunch the compilation steps in your project and you should be good to go! @@ -188,6 +191,7 @@ If Conan is not used, the build system will attempt to find system-installed dep Currently, we require the following packages to be available to CMake at build-time: +- `java` - `glib2` - `websocketpp` - [`asio`](https://think-async.com/Asio/) as the transitive dependency @@ -206,4 +210,4 @@ It is possible to write tests for the Conan packaging using [local package devel - For CMake configuration issues, check the CMakeCache.txt file in your build directory - Ensure that your CMake version is compatible with the project requirements -For further assistance, please consult the project's issue tracker or contact the maintainers. +For further assistance, please consult the [project's issue tracker](https://github.com/ostis-ai/sc-machine/issues) or contact the maintainers. From 095a8399ff11c6d11e25bebba76542c66d320291 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 13 Nov 2024 17:28:53 +0300 Subject: [PATCH 085/134] [kpm][common] Leave TODO about transitive dependencies for agent tests --- sc-kpm/sc-common/src/sc_common.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sc-kpm/sc-common/src/sc_common.c b/sc-kpm/sc-common/src/sc_common.c index 58a5267768..197fca8472 100644 --- a/sc-kpm/sc-common/src/sc_common.c +++ b/sc-kpm/sc-common/src/sc_common.c @@ -10,6 +10,13 @@ sc_result sc_module_initialize() { + // TODO(NikitaZotov): All test targets for agents in the machine directly depend on the targets of the modules where + // these agents are implemented. That is, they are not loaded as extensions. This is because it is more convenient to + // test agents in tests: when loading an extension, the whole module with all agents is loaded, and when linking it, + // only the ones to be tested are loaded. In sc-kpm, all targets for tests depend on extensions with tests, and these + // extensions depend on sc-kpm-common, which has been made as an extension. If it's not made as an extension, the + // tests don't link completely on ubuntu. We'll have to think about how to make it so that we don't have to make such + // dependencies in the future. Perhaps we should think about how to load not all agents from modules for tests. return SC_RESULT_OK; } From 6c066537820b945d11a42757255ec37ebec965aa Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 13 Nov 2024 17:33:06 +0300 Subject: [PATCH 086/134] [docs][refactor] Fix indentions in changelog --- docs/changelog.md | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 0eeff11d32..49b8008e28 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -10,31 +10,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking changes - Python dependencies are set up locally in `.venv` environment. Therefore, you should make the following changes: - - fix `docker-compose.yml` file to run `healthcheck.py` for sc-server in `.venv` or use `scripts/healthcheck.sh` encapsulated this logic; - - and use `.venv` to launch your python scripts if they use sc-machine python dependencies. + - fix `docker-compose.yml` file to run `healthcheck.py` for sc-server in `.venv` or use `scripts/healthcheck.sh` encapsulated this logic; + - and use `.venv` to launch your python scripts if they use sc-machine python dependencies. - Build system of the sc-machine was upgraded: - - The way to manage build dependencies was changed to [Conan](https://conan.io). You can install sc-machine and its dependencies with Conan. You don't have to worry about installing sc-machine dependencies on your OS anymore. See how to do it -- [Build System](build/build_system.md). - - CMake presets should be used to build the sc-machine. They are located in `CMakePresets.json`. - - Location of the sc-machine build was changed. The following new locations are: - - build tree -- `build/`, - - binaries -- `build//bin`, - - libraries -- `build//lib`, - - extensions -- `build//lib/extensions`. - - Now using sc-machine as a library is much more optimized: adding it to the CMake tree is no longer necessary. You can install sc-machine packages and import sc-machine targets into your cmake using `find_package(sc-machine REQUIRED)`. But if you include sc-machine into CMake tree of your project, remember that the minimum version of cmake for the machine is 3.24. - - Now each release sc-machine binaries are compiled for supported OS and formed as an archives on Github. Minimum required version of macOS is macOS-14 (arm), of ubuntu is ubuntu-22.04. The sc-machine doesn't support ubuntu-20.04 anymore. You can use them to work with sc-memory or you can use `RunMachine` method from `sc-machine-runner.so` to create your own entry point to initialize sc-memory instead of using compiled `sc-machine` binary. - - Script for the project build (`build_sc_machine.sh`), scripts for running binaries (`run_sc_server.sh`, `build_kb.sh`) were removed from the sc-machine repository scripts. You should use sc-machine binaries directly. - - Now sc-server is not entry point of the sc-machine, it is an extension (`sc-server-lib.so`), that is loaded dynamically when the machine is started. So, `sc-server` binary was removed, `sc-machine` binary was added instead. + - The way to manage build dependencies was changed to [Conan](https://conan.io). You can install sc-machine and its dependencies with Conan. You don't have to worry about installing sc-machine dependencies on your OS anymore. See how to do it -- [Build System](build/build_system.md). + - CMake presets should be used to build the sc-machine. They are located in `CMakePresets.json`. + - Location of the sc-machine build was changed. The following new locations are: + - build tree -- `build/`, + - binaries -- `build//bin`, + - libraries -- `build//lib`, + - extensions -- `build//lib/extensions`. + - Now using sc-machine as a library is much more optimized: adding it to the CMake tree is no longer necessary. You can install sc-machine packages and import sc-machine targets into your cmake using `find_package(sc-machine REQUIRED)`. But if you include sc-machine into CMake tree of your project, remember that the minimum version of cmake for the machine is 3.24. + - Now each release sc-machine binaries are compiled for supported OS and formed as an archives on Github. Minimum required version of macOS is macOS-14 (arm), of ubuntu is ubuntu-22.04. The sc-machine doesn't support ubuntu-20.04 anymore. You can use them to work with sc-memory or you can use `RunMachine` method from `sc-machine-runner.so` to create your own entry point to initialize sc-memory instead of using compiled `sc-machine` binary. + - Script for the project build (`build_sc_machine.sh`), scripts for running binaries (`run_sc_server.sh`, `build_kb.sh`) were removed from the sc-machine repository scripts. You should use sc-machine binaries directly. + - Now sc-server is not entry point of the sc-machine, it is an extension (`sc-server-lib.so`), that is loaded dynamically when the machine is started. So, `sc-server` binary was removed, `sc-machine` binary was added instead. - Config was changed: - - `repo_path` option in `[sc-memory]` group was deprecated, `storage` option was added instead; - - `extensions_path` option in `[sc-memory]` group was deprecated, `extensions` option was added instead; - - `[sc-builder]` group was removed. + - `repo_path` option in `[sc-memory]` group was deprecated, `storage` option was added instead; + - `extensions_path` option in `[sc-memory]` group was deprecated, `extensions` option was added instead; + - `[sc-builder]` group was removed. - Sources of the sc-machine were separated into public and private ones. Public sources of targets are located in `include` directory, private ones - in `src` directory, tests for code - in `tests` directory. Private sources can't be included into project's code directly. Besides that there are changes of location of some API classes of the sc-machine: - - Now `ScTest` class is part of `sc-memory` target. Use `#include ` to include it into code. - - To include `ScsLoader` class into code, use `#include `. + - Now `ScTest` class is part of `sc-memory` target. Use `#include ` to include it into code. + - To include `ScsLoader` class into code, use `#include `. - Configuration of sc-machine tests was changed: - - Now paths to test sources of the knowledge base, test configs, etc. are configured at the pre-run stage, not at the stage of compiling tests. - - Working directory for tests was changed to a directory where tests are located. To run the tests, please use `ctest` rather than the test binaries themselves. - - Scripts for running tests (`run_tests.sh`) was removed. Go to `build/` and use `ctest` instead. + - Now paths to test sources of the knowledge base, test configs, etc. are configured at the pre-run stage, not at the stage of compiling tests. + - Working directory for tests was changed to a directory where tests are located. To run the tests, please use `ctest` rather than the test binaries themselves. + - Scripts for running tests (`run_tests.sh`) was removed. Go to `build/` and use `ctest` instead. - All questions was renamed to actions. - ScAddrHashFunc with template argument was removed. Use non-template ScAddrHashFunc without arguments. It is more safe in use. - Constructors for ScMemoryContext with string and int parameters were removed. Use the one without parameters instead. @@ -43,9 +43,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Questions were renamed to actions, answers were renamed to results. - `m_memoryCtx` in ScAgent renamed to `m_context`. - Now we don't use code generation as metaprogramming. The API for agents has been completely redesigned. See the documentation section on how to implement an agent with the new API. We have - - completely moved from code generation to template programming; - - improved the API and aligned with our description of how it should be; - - simplified the API. Now it will be much easier to create agents, go right now and see how to work with the new API -- [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md). + - completely moved from code generation to template programming; + - improved the API and aligned with our description of how it should be; + - simplified the API. Now it will be much easier to create agents, go right now and see how to work with the new API -- [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md). - All `ScMemoryContext` methods were redesigned to a common style. All methods with not correct names were deprecated, and new ones were added. See the table below to see which methods have been replaced. | Deprecated method | Substitution method | From 3ebb6476bc052fc0bc68723b087b962d03a551c4 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 13 Nov 2024 17:44:46 +0300 Subject: [PATCH 087/134] [docs] Eliminate `now` in changelog --- docs/changelog.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 49b8008e28..9f2598e680 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -20,19 +20,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - binaries -- `build//bin`, - libraries -- `build//lib`, - extensions -- `build//lib/extensions`. - - Now using sc-machine as a library is much more optimized: adding it to the CMake tree is no longer necessary. You can install sc-machine packages and import sc-machine targets into your cmake using `find_package(sc-machine REQUIRED)`. But if you include sc-machine into CMake tree of your project, remember that the minimum version of cmake for the machine is 3.24. - - Now each release sc-machine binaries are compiled for supported OS and formed as an archives on Github. Minimum required version of macOS is macOS-14 (arm), of ubuntu is ubuntu-22.04. The sc-machine doesn't support ubuntu-20.04 anymore. You can use them to work with sc-memory or you can use `RunMachine` method from `sc-machine-runner.so` to create your own entry point to initialize sc-memory instead of using compiled `sc-machine` binary. + - Using sc-machine as a library is much more optimized: adding it to the CMake tree is no longer necessary. You can install sc-machine packages and import sc-machine targets into your cmake using `find_package(sc-machine REQUIRED)`. But if you include sc-machine into CMake tree of your project, remember that the minimum version of cmake for the machine is 3.24. + - Each release sc-machine binaries are being compiled for supported OS and formed as an archives on Github. Minimum required version of macOS is macOS-14 (arm), of ubuntu is ubuntu-22.04. The sc-machine doesn't support ubuntu-20.04 anymore. You can use them to work with sc-memory or you can use `RunMachine` method from `sc-machine-runner.so` to create your own entry point to initialize sc-memory instead of using compiled `sc-machine` binary. - Script for the project build (`build_sc_machine.sh`), scripts for running binaries (`run_sc_server.sh`, `build_kb.sh`) were removed from the sc-machine repository scripts. You should use sc-machine binaries directly. - - Now sc-server is not entry point of the sc-machine, it is an extension (`sc-server-lib.so`), that is loaded dynamically when the machine is started. So, `sc-server` binary was removed, `sc-machine` binary was added instead. + - sc-server is no longer entry point of the sc-machine, it is an extension (`sc-server-lib.so`), that is loaded dynamically when the machine is started. So, `sc-server` binary was removed, `sc-machine` binary was added instead. - Config was changed: - `repo_path` option in `[sc-memory]` group was deprecated, `storage` option was added instead; - `extensions_path` option in `[sc-memory]` group was deprecated, `extensions` option was added instead; - `[sc-builder]` group was removed. - Sources of the sc-machine were separated into public and private ones. Public sources of targets are located in `include` directory, private ones - in `src` directory, tests for code - in `tests` directory. Private sources can't be included into project's code directly. Besides that there are changes of location of some API classes of the sc-machine: - - Now `ScTest` class is part of `sc-memory` target. Use `#include ` to include it into code. + - `ScTest` class was made a part of `sc-memory` target. Use `#include ` to include it into code. - To include `ScsLoader` class into code, use `#include `. - Configuration of sc-machine tests was changed: - - Now paths to test sources of the knowledge base, test configs, etc. are configured at the pre-run stage, not at the stage of compiling tests. + - Paths to test sources of the knowledge base, test configs, etc. are being configured at the pre-run stage, not at the stage of compiling tests. - Working directory for tests was changed to a directory where tests are located. To run the tests, please use `ctest` rather than the test binaries themselves. - Scripts for running tests (`run_tests.sh`) was removed. Go to `build/` and use `ctest` instead. - All questions was renamed to actions. @@ -42,7 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Deprecated sc-utils in 0.9.0 were removed from sc-kpm. - Questions were renamed to actions, answers were renamed to results. - `m_memoryCtx` in ScAgent renamed to `m_context`. -- Now we don't use code generation as metaprogramming. The API for agents has been completely redesigned. See the documentation section on how to implement an agent with the new API. We have +- Сode generation is no longer used as metaprogramming. The API for agents has been completely redesigned. See the documentation section on how to implement an agent with the new API. We have - completely moved from code generation to template programming; - improved the API and aligned with our description of how it should be; - simplified the API. Now it will be much easier to create agents, go right now and see how to work with the new API -- [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md). @@ -141,7 +141,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | ```_<~``` | ```<~_``` | | ```_<|~``` | ```<|~_``` | -- Now it is not possible to specify constancy for fuzzy arcs, because it may lead to misunderstanding of the non-factor denoted by this sc-arc. So, designations ```-/>```, ``````, ```_```, ``````, ```_```, ``````, ``````, ``````, ```_```, ``````, ```_```, ``````, ``` Date: Wed, 13 Nov 2024 17:53:14 +0300 Subject: [PATCH 088/134] [tools][config] Leave TODO author --- sc-tools/sc-config/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc-tools/sc-config/CMakeLists.txt b/sc-tools/sc-config/CMakeLists.txt index 41d4aabaf6..f69521a4af 100644 --- a/sc-tools/sc-config/CMakeLists.txt +++ b/sc-tools/sc-config/CMakeLists.txt @@ -17,7 +17,7 @@ target_include_directories(sc-config PUBLIC $ ) -# TODO: CMake 3.23+ supports FILE_SET (https://discourse.cmake.org/t/installing-headers-the-modern-way-regurgitated-and-revisited/3238/3) which is a more stable and portable solution. +# TODO(FallenChromium): CMake 3.23+ supports FILE_SET (https://discourse.cmake.org/t/installing-headers-the-modern-way-regurgitated-and-revisited/3238/3) which is a more stable and portable solution. # For compatibility reasons we're exporting the whole folder, should be replaced in the future (Ubuntu LTS should have cmake 3.23 oob by that time) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} From b4e7c0c632f32e511f358e042fb65d0ed738280e Mon Sep 17 00:00:00 2001 From: Nikita Zotov Date: Fri, 15 Nov 2024 15:35:33 +0300 Subject: [PATCH 089/134] [docs] Update CMake requirements and configuration instructions Co-authored-by: FallenChromium <43214067+FallenChromium@users.noreply.github.com> --- docs/build/build_system.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index 87857434a2..0b854408f0 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -8,6 +8,9 @@ The project uses CMake as the build system generator. CMake allows for cross-pla ## Compilation steps +!!! warning + Our build system settings require using CMake 3.24 or newer. Make sure your version is compatible by running `cmake --version` and use the [CMake installation guide](https://cliutils.gitlab.io/modern-cmake/chapters/intro/installing.html) to upgrade to latest version if yours is older than 3.24. The universal method is to use `pipx install cmake` (don't forget to run `pipx ensurepath` and relaunching your shell after installation), but you may choose reconfiguring your OS's package manager instead. + Typical configurations of the project are provided in the `CMakePresets.json` file – this means that if you use a modern IDE, **no additional configuration is needed**. Just pick one of the configurations provided by this file and use controls in your IDE to recompile and run tests (should work with VSCode + CMake Tools extension, JetBrains CLion and probably many others). If you wish to use CLI instead, you can list all the available configurations in the `CMakePresets.json` file and pick one of the presets: @@ -16,9 +19,6 @@ If you wish to use CLI instead, you can list all the available configurations in cmake --list-presets ``` -!!! warning - By default, the standard repositories for Ubuntu 22.04 provide CMake version 3.22, which does not support certain features required for working with CMakePresets.json. To avoid issues during the build process, you need to manually install CMake version 3.24 or higher. - For example, this is how to build sc-machine in debug mode using dependencies from Conan: ```sh From 2de7ba1bce4bb55ed0f3367e68a1a20676ad08d8 Mon Sep 17 00:00:00 2001 From: Nikita Zotov Date: Fri, 15 Nov 2024 15:36:25 +0300 Subject: [PATCH 090/134] [docs] Improve description of install target Co-authored-by: FallenChromium <43214067+FallenChromium@users.noreply.github.com> --- docs/build/build_system.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index 0b854408f0..479abb2219 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -41,7 +41,7 @@ cmake --build --preset release The build artifacts will be located in the `build//bin` folder. -Default installation folder location (used for package consumption) is `build//install`, installation process can be fired by appending `--target install` to the `cmake --build --preset ` command. +We also define `INSTALL` instructions in our CMake. This routine can be launched by appending `--target install` to the `cmake --build --preset ` folder. The result of this command will reside in `build//install` (our default install folder). Install folder is basically a pack of portable executable files and shared libraries required to get sc-machine up and running, this command is intended to create clutter-free archives/folders with our code which you can then use in your own projects. ## Consuming the package From 4ab1c9382e1734f6f01b74d6ec76cd4bcfedf2e7 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 15 Nov 2024 16:15:45 +0300 Subject: [PATCH 091/134] [docs] Describe cmake presets --- docs/build/build_system.md | 58 ++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index 479abb2219..342e713618 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -19,11 +19,49 @@ If you wish to use CLI instead, you can list all the available configurations in cmake --list-presets ``` +### Configure Presets + +These presets define how the project is configured before building. + +| **Name** | **Description** | **Purpose** | +|------------------------------|------------------------------------------------------------------|-----------------------------------------------------------------| +| `debug` | Debug config with tests and benchmarks | Use for debugging and testing during development. | +| `debug-conan` | Debug config with tests and benchmarks (Conan dependencies used) | Use if you are utilizing Conan for dependency management. | +| `release` | Release config | Use for production-ready builds. | +| `release-conan` | Release config (Conan dependencies used) | Use if you are utilizing Conan for dependency management. | +| `release-with-tests` | Release config with tests | Use for production builds that require testing. | +| `release-with-tests-conan` | Release config with tests (Conan dependencies used) | Use if you want to run tests in a production build using Conan. | + +### Build Presets + +These presets are linked to the configure presets and define how the build process is executed. + +| **Name** | **Configure Preset** | +|------------|-----------------------| +| `debug` | debug | +| `release` | release | + +### Package Presets + +These presets are used for packaging the built project. + +| **Name** | **Configure Preset** | +|------------------|------------------------| +| `release-conan` | release-conan | +| `release` | release | + +### Recommendations + +- For development and debugging, use the **Debug config** (`debug`) preset. This configuration includes options for testing and benchmarking, making it ideal for development environments where you need to troubleshoot and test your code. +- For production builds, choose the **Release config** (`release`) preset to create optimized builds without debugging information. This is suitable for deploying applications. +- If your project relies on Conan, select either the **Debug config (Conan)** (`debug-conan`) or the **Release config (Conan)** (`release-conan`) presets, depending on whether you are debugging or preparing a release. +- Choose the **Release config with tests** (`release-with-tests`) or its Conan variant (`release-with-tests-conan`) if you want to ensure that your production build has been tested thoroughly before deployment. + For example, this is how to build sc-machine in debug mode using dependencies from Conan: ```sh -# use pipx to install Conan if not already installed -# Install pipx first using this guide: https://pipx.pypa.io/stable/installation/ +# Use pipx to install Conan if not already installed +# Install pipx first using guide: https://pipx.pypa.io/stable/installation/ pipx install conan # Use preset with Conan-provided dependencies and debug build type cmake --preset debug-conan @@ -52,11 +90,14 @@ We also define `INSTALL` instructions in our CMake. This routine can be launched The package artifacts are available [here](https://github.com/ostis-ai/sc-machine/releases). To use these in your CMake project, download and extract the release for your platform to any convenient location. Then make it available to CMake by appending folder path to `CMAKE_PREFIX_PATH`: ```cmake -# import sc-machine from the Releases archive -# you can override this variable via -D_PATH_SC_MACHINE_PATH or CMakeUserPreset.json / CMakePreset.json files -set(_SC_MACHINE_PATH "/location/to/sc-machine--" CACHE PATH "sc-machine installation path") - -# can be overriden using env variables as well +# Import sc-machine from the Releases archive. +# You can override this variable via -D_PATH_SC_MACHINE_PATH +# or CMakeUserPreset.json / CMakePreset.json files. +set(_SC_MACHINE_PATH "/location/to/sc-machine--" + CACHE PATH "sc-machine installation path" +) + +# It can be overriden using env variables as well. if(DEFINED ENV{_SC_MACHINE_PATH}) set(_SC_MACHINE_PATH "$ENV{_SC_MACHINE_PATH}") endif() @@ -175,7 +216,8 @@ conan editable list # sc-machine of the corresponding version should be in the output # make changes in the project and run a rebuild cmake --preset debug-conan -# using a debug build since that would allow us to step into the library's code while debugging +# using a debug build since that would allow us to step +# into the library's code while debugging cmake --build --preset debug ``` From b0217f171c379054052a1ddc5fdec912ee6f8f0a Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 15 Nov 2024 16:23:43 +0300 Subject: [PATCH 092/134] [docs][review] Improve mentions about build system --- docs/build/build_system.md | 2 +- scripts/docker_entrypoint.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index 342e713618..ff4ee4aba6 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -229,7 +229,7 @@ You can find more info in [Conan docs](https://docs.conan.io/2/tutorial/developi ### Falling Back to System Dependencies -If Conan is not used, the build system will attempt to find system-installed dependencies. Ensure that the necessary development packages are installed on your system. +If Conan is not used, the CMake will attempt to find system-installed dependencies. Ensure that the necessary development packages are installed on your system. Currently, we require the following packages to be available to CMake at build-time: diff --git a/scripts/docker_entrypoint.sh b/scripts/docker_entrypoint.sh index 5d58958a36..daac79e20a 100755 --- a/scripts/docker_entrypoint.sh +++ b/scripts/docker_entrypoint.sh @@ -18,6 +18,7 @@ function usage() { Setting REBUILD_KB environment variable inside the container will trigger a KB rebuild. Setting custom starting point for sc-builder can be done using KB_PATH environment variable, "/kb" is used as a default KB_PATH. CONFIG_PATH and BINARY_PATH environment variables can provide the respective settings if the use of flags is undesirable. + EXTENSIONS_PATH can be set to specify the path for extensions used by sc-machine. USAGE exit 1 From 3a00c6ac755ff5fbbae8dba18470b9fca78b1e8a Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 18 Nov 2024 12:17:16 +0300 Subject: [PATCH 093/134] [cmake][tools][builder] Make link with libxml2 private --- sc-tools/sc-builder/CMakeLists.txt | 2 +- sc-tools/sc-builder/tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sc-tools/sc-builder/CMakeLists.txt b/sc-tools/sc-builder/CMakeLists.txt index 6609efb49b..10af55cad9 100644 --- a/sc-tools/sc-builder/CMakeLists.txt +++ b/sc-tools/sc-builder/CMakeLists.txt @@ -12,7 +12,7 @@ add_library(sc-builder-lib SHARED ${SOURCES}) target_link_libraries(sc-builder-lib LINK_PUBLIC sc-memory LINK_PUBLIC sc-config - LINK_PUBLIC LibXml2::LibXml2 + LINK_PRIVATE LibXml2::LibXml2 ) target_include_directories(sc-builder-lib PRIVATE ${glib_INCLUDE_DIRS} diff --git a/sc-tools/sc-builder/tests/CMakeLists.txt b/sc-tools/sc-builder/tests/CMakeLists.txt index 14636892ec..eff9949ea2 100644 --- a/sc-tools/sc-builder/tests/CMakeLists.txt +++ b/sc-tools/sc-builder/tests/CMakeLists.txt @@ -1,6 +1,6 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units NAME sc-builder-tests - DEPENDS sc-builder-lib + DEPENDS sc-builder-lib LibXml2::LibXml2 INCLUDES ${SC_BUILDER_SRC} ) From 4631700a6d3a8366934c629082f253d906afbaa9 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 18 Nov 2024 12:19:33 +0300 Subject: [PATCH 094/134] [cmake][refactor] Rename FindGLIB to find_glib --- CMakeLists.txt | 2 +- cmake/{FindGLIB.cmake => find_glib.cmake} | 2 +- sc-memory/sc-core/CMakeLists.txt | 2 +- sc-memory/sc-core/tests/CMakeLists.txt | 2 +- sc-memory/sc-memory/CMakeLists.txt | 2 +- sc-tools/sc-config/CMakeLists.txt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename cmake/{FindGLIB.cmake => find_glib.cmake} (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 590557fe39..02b62c9fe2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,7 +118,7 @@ endif() set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -include(${CMAKE_MODULE_PATH}/FindGLIB.cmake) +include(${CMAKE_MODULE_PATH}/find_glib.cmake) add_subdirectory(${SC_MACHINE_ROOT}/thirdparty) add_subdirectory(${SC_MACHINE_ROOT}/sc-memory) diff --git a/cmake/FindGLIB.cmake b/cmake/find_glib.cmake similarity index 97% rename from cmake/FindGLIB.cmake rename to cmake/find_glib.cmake index b86bc6ee7c..24a2c15a6f 100644 --- a/cmake/FindGLIB.cmake +++ b/cmake/find_glib.cmake @@ -1,4 +1,4 @@ -macro(FindGLIB) +macro(find_glib) if (glib_CACHED) endif() diff --git a/sc-memory/sc-core/CMakeLists.txt b/sc-memory/sc-core/CMakeLists.txt index 5b33722bc0..7109b99534 100644 --- a/sc-memory/sc-core/CMakeLists.txt +++ b/sc-memory/sc-core/CMakeLists.txt @@ -5,7 +5,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS "include/sc-core/*.h" ) -FindGLIB() +find_glib() add_library(sc-core SHARED ${SOURCES}) target_link_libraries(sc-core LINK_PRIVATE ${glib_LIBRARIES}) diff --git a/sc-memory/sc-core/tests/CMakeLists.txt b/sc-memory/sc-core/tests/CMakeLists.txt index 6e004a2ce1..103c64e897 100644 --- a/sc-memory/sc-core/tests/CMakeLists.txt +++ b/sc-memory/sc-core/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -FindGLIB() +find_glib() make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units/common NAME sc-core-common-tests diff --git a/sc-memory/sc-memory/CMakeLists.txt b/sc-memory/sc-memory/CMakeLists.txt index 53c783d471..79e33a1216 100644 --- a/sc-memory/sc-memory/CMakeLists.txt +++ b/sc-memory/sc-memory/CMakeLists.txt @@ -31,7 +31,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS "include/sc-memory/*/*.tpp" ) -FindGLIB() +find_glib() add_library(sc-memory SHARED ${SOURCES} ${SOURCES_PARSER}) target_link_libraries(sc-memory diff --git a/sc-tools/sc-config/CMakeLists.txt b/sc-tools/sc-config/CMakeLists.txt index f69521a4af..282124a249 100644 --- a/sc-tools/sc-config/CMakeLists.txt +++ b/sc-tools/sc-config/CMakeLists.txt @@ -3,7 +3,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS "include/sc-config/*.h" "include/sc-config/*.hpp" "include/sc-config/*/*.tpp" ) -FindGLIB() +find_glib() add_library(sc-config SHARED ${SOURCES}) target_link_libraries(sc-config From 2c79676d987d672e0d21fb56ebbe8f1997829384 Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 22 Nov 2024 23:43:41 +0300 Subject: [PATCH 095/134] Review fixes --- .github/workflows/test_conan.yml | 7 ++----- docs/build/build_system.md | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_conan.yml b/.github/workflows/test_conan.yml index 916a3bb091..3a6950352d 100644 --- a/.github/workflows/test_conan.yml +++ b/.github/workflows/test_conan.yml @@ -20,10 +20,6 @@ jobs: - { cc: "gcc", cxx: "g++" } steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - name: Restore ccache caches uses: hendrikmuhs/ccache-action@v1.2 @@ -56,10 +52,11 @@ jobs: - name: Set up Conan run: | + pipx install cmake pipx install conan - name: Install compilers - run: sudo apt install build-essential ninja-build ccache cmake + run: sudo apt install build-essential ninja-build ccache - name: Build sc-machine with tests id: run_cmake diff --git a/docs/build/build_system.md b/docs/build/build_system.md index ff4ee4aba6..dc68fb7d89 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -34,12 +34,12 @@ These presets define how the project is configured before building. ### Build Presets -These presets are linked to the configure presets and define how the build process is executed. +These presets are linked to the configure presets and are used by CMake to determine the build folder (`build/Debug` or `build/Release` by default). | **Name** | **Configure Preset** | |------------|-----------------------| -| `debug` | debug | -| `release` | release | +| `debug` | debug, debug-conan | +| `release` | release, release-conan, release-with-tests, release-with-tests-conan | ### Package Presets From 449146e0e0e9face132c0541aa7e796ce83254de Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Sun, 24 Nov 2024 00:28:33 +0300 Subject: [PATCH 096/134] Review fixes --- cmake/find_glib.cmake | 33 ++++++++++++++++++--------------- cmake/tests.cmake | 2 +- docs/changelog.md | 12 ++++++------ 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/cmake/find_glib.cmake b/cmake/find_glib.cmake index 24a2c15a6f..5e25f251e7 100644 --- a/cmake/find_glib.cmake +++ b/cmake/find_glib.cmake @@ -1,21 +1,24 @@ macro(find_glib) - if (glib_CACHED) - endif() - - find_package(glib QUIET) + if(NOT glib_CACHED) + find_package(glib QUIET) - if (NOT glib_FOUND) - include(FindPkgConfig) - find_package(PkgConfig REQUIRED) - pkg_search_module(GLIB2 REQUIRED glib-2.0) - pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) + if(NOT glib_FOUND) + include(FindPkgConfig) + find_package(PkgConfig REQUIRED) + pkg_search_module(GLIB2 REQUIRED glib-2.0) + pkg_search_module(GLIB2_MODULE REQUIRED gmodule-2.0) - if (NOT GLIB2_FOUND OR NOT GLIB2_MODULE_FOUND) - message(FATAL_ERROR "glib2 not found!") + if(NOT GLIB2_FOUND OR NOT GLIB2_MODULE_FOUND) + message(FATAL_ERROR "glib2 not found!") + endif() + set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS} + CACHE STRING "Include directories for GLib" + ) + set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS} + CACHE STRING "Libraries for GLib" + ) + + set(glib_CACHED TRUE CACHE BOOL "GLib found") endif() - set(glib_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${GLIB2_MODULE_INCLUDE_DIRS} CACHE STRING "Include directories for GLib") - set(glib_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS} CACHE STRING "Libraries for GLib") - - set(glib_CACHED TRUE CACHE BOOL "GLib found") endif() endmacro() diff --git a/cmake/tests.cmake b/cmake/tests.cmake index 18d38f25db..15cb2e8d4c 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -16,5 +16,5 @@ function(make_tests_from_folder folder) add_executable(${target} ${SOURCES}) target_link_libraries(${target} GTest::gtest_main ${TEST_DEPENDS}) target_include_directories(${target} PRIVATE ${TEST_INCLUDES}) - gtest_discover_tests(${target} TEST_LIST ${target_tests} WORKING_DIRECTORY ${folder}) + gtest_discover_tests(${target} WORKING_DIRECTORY ${folder}) endfunction() diff --git a/docs/changelog.md b/docs/changelog.md index 9f2598e680..1bd6a04748 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking changes - Python dependencies are set up locally in `.venv` environment. Therefore, you should make the following changes: - - fix `docker-compose.yml` file to run `healthcheck.py` for sc-server in `.venv` or use `scripts/healthcheck.sh` encapsulated this logic; + - fix `docker-compose.yml` file to run `healthcheck.py` for sc-server in `.venv` or use `scripts/healthcheck.sh` that encapsulates this logic; - and use `.venv` to launch your python scripts if they use sc-machine python dependencies. - Build system of the sc-machine was upgraded: - The way to manage build dependencies was changed to [Conan](https://conan.io). You can install sc-machine and its dependencies with Conan. You don't have to worry about installing sc-machine dependencies on your OS anymore. See how to do it -- [Build System](build/build_system.md). @@ -20,8 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - binaries -- `build//bin`, - libraries -- `build//lib`, - extensions -- `build//lib/extensions`. - - Using sc-machine as a library is much more optimized: adding it to the CMake tree is no longer necessary. You can install sc-machine packages and import sc-machine targets into your cmake using `find_package(sc-machine REQUIRED)`. But if you include sc-machine into CMake tree of your project, remember that the minimum version of cmake for the machine is 3.24. - - Each release sc-machine binaries are being compiled for supported OS and formed as an archives on Github. Minimum required version of macOS is macOS-14 (arm), of ubuntu is ubuntu-22.04. The sc-machine doesn't support ubuntu-20.04 anymore. You can use them to work with sc-memory or you can use `RunMachine` method from `sc-machine-runner.so` to create your own entry point to initialize sc-memory instead of using compiled `sc-machine` binary. + - Using sc-machine as a library is much more optimized: adding it to the CMake tree is no longer necessary. You can install sc-machine packages and import sc-machine targets into your cmake using `find_package(sc-machine REQUIRED)`. See how to do it -- [Build System](build/build_system.md) + - Each release sc-machine binaries are being compiled for supported OS and formed as an archives on Github. Minimum required version of macOS is macOS-14 (arm), of ubuntu is ubuntu-22.04. The sc-machine doesn't support ubuntu-20.04 anymore. You can use sc-machine binaries to work with sc-memory or you can use `RunMachine` method from `sc-machine-runner.so` to create your own entry point to initialize sc-memory instead of using compiled `sc-machine` binary. - Script for the project build (`build_sc_machine.sh`), scripts for running binaries (`run_sc_server.sh`, `build_kb.sh`) were removed from the sc-machine repository scripts. You should use sc-machine binaries directly. - sc-server is no longer entry point of the sc-machine, it is an extension (`sc-server-lib.so`), that is loaded dynamically when the machine is started. So, `sc-server` binary was removed, `sc-machine` binary was added instead. - Config was changed: @@ -233,10 +233,10 @@ See documentation, to learn more about using new API. ### Changed -- Working directory for tests was changed to a directory where tests are located -- Install `gtest` and `benchmark` via Conan or OS package managers instead of using them as submodules +- Working directory for each test has been changed to the test's source dir +- `gtest` and `benchmark` are installed via Conan or OS package managers instead of using them as git submodules - Location of the sc-machine build tree, binaries, libraries and extensions -- Up minimum required cmake version to 3.24.0 +- Bumped minimum required cmake version to 3.24.0 - Help messages for sc-machine and sc-builder - Clarify sc-machine and sc-builder options - Specify dependencies near targets, not in overall file From cb70fecac28aa1dade8f59b30f7448109690fb55 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Sun, 24 Nov 2024 00:29:52 +0300 Subject: [PATCH 097/134] [tests][vscode] Add settings for TestMate --- .vscode/launch.json | 28 ----- .vscode/settings.json | 109 ++++++++++++++++++ CMakePresets.json | 13 ++- .../tests/performance/CMakeLists.txt | 4 +- .../tests/units/performance/CMakeLists.txt | 8 +- 5 files changed, 124 insertions(+), 38 deletions(-) delete mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 2f3749ac72..0000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "(ctest) Launch", - "type": "cppdbg", - "request": "launch", - "program": "${command:cmake.launchTargetPath}", - "args": [], - "stopAtEntry": false, - "cwd": "${fileDirname}", - "environment": [ - { - // add the directory where our target was built to the PATHs - // it gets resolved by CMake Tools: - "name": "PATH", - "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" - }, - ], - "externalConsole": false, - "internalConsoleOptions": "openOnSessionStart", - "MIMode": "lldb" - }, - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..ae72cc156d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,109 @@ +{ + "cmake.ctest.testExplorerIntegrationEnabled": false, + // Debug configuration for TestMate + "testMate.cpp.debug.configTemplate": { + "type": "cppvsdbg", + "linux": { + "type": "cppdbg", + "MIMode": "gdb" + }, + "darwin": { + "type": "cppdbg", + "MIMode": "lldb" + }, + "program": "${exec}", + "args": "${argsArray}", + "cwd": "${cwd}", + "env": "${envObj}", + "environment": "${envObjArray}", + "sourceFileMap": "${sourceFileMapObj}", + "testMate.cpp.debug.setEnv": { + "GTEST_CATCH_EXCEPTIONS": "0", + } + }, + // Test executables configuration for TestMate + "testMate.cpp.test.advancedExecutables": [ + // Unittests configuration + { + "pattern": "build/**/bin/{sc-core,sc-memory,scs,sc-kpm}*-tests", + "gtest": { + "testGrouping": { + "groupByLabel": { + "label": "unittests", + "groupByExecutable": { + "description": "${relDirpath}/" + } + } + } + }, + }, + { + "pattern": "build/**/bin/sc-builder-tests", + "cwd": "${workspaceFolder}/sc-tools/sc-builder/tests/units", + "gtest": { + "testGrouping": { + "groupByLabel": { + "label": "unittests", + "groupByExecutable": { + "description": "${relDirpath}/" + } + } + } + }, + }, + { + "pattern": "build/**/bin/sc-config-tests", + "cwd": "${workspaceFolder}/sc-tools/sc-config/tests/units", + "gtest": { + "testGrouping": { + "groupByLabel": { + "label": "unittests", + "groupByExecutable": { + "description": "${relDirpath}/" + } + } + } + }, + }, + { + "pattern": "build/**/bin/sc-machine-tests", + "cwd": "${workspaceFolder}/sc-tools/sc-machine-runner/tests/units", + "gtest": { + "testGrouping": { + "groupByLabel": { + "label": "unittests", + "groupByExecutable": { + "description": "${relDirpath}/" + } + } + } + }, + }, + { + "pattern": "build/**/bin/sc-server-tests", + "cwd": "${workspaceFolder}/sc-tools/sc-server/tests/units/api", + "gtest": { + "testGrouping": { + "groupByLabel": { + "label": "unittests", + "groupByExecutable": { + "description": "${relDirpath}/" + } + } + } + }, + }, + // Benchmarks configuration + { + "pattern": "build/**/bin/sc-{memory,server}-benchmarks", + "testGrouping": { + "groupByLabel": { + "label": "benchmarks", + "groupByExecutable": { + "description": "${relDirpath}/" + } + } + } + }, + ] +} diff --git a/CMakePresets.json b/CMakePresets.json index 10bb51bc1c..59d6b1f52d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -18,7 +18,9 @@ "name": "debug-conan", "displayName": "Debug config (Conan)", "description": "Debug config with tests and benchmarks (Conan dependencies used)", - "inherits": ["debug"], + "inherits": [ + "debug" + ], "cacheVariables": { "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "./cmake/conan_provider.cmake" } @@ -67,7 +69,6 @@ { "name": "debug", "configurePreset": "debug" - }, { "name": "release", @@ -78,12 +79,16 @@ { "name": "release-conan", "configurePreset": "release-conan", - "generators": ["TGZ"] + "generators": [ + "TGZ" + ] }, { "name": "release", "configurePreset": "release", - "generators": ["TGZ"] + "generators": [ + "TGZ" + ] } ] } diff --git a/sc-memory/sc-memory/tests/performance/CMakeLists.txt b/sc-memory/sc-memory/tests/performance/CMakeLists.txt index ef1ae729be..b1bc327ae3 100644 --- a/sc-memory/sc-memory/tests/performance/CMakeLists.txt +++ b/sc-memory/sc-memory/tests/performance/CMakeLists.txt @@ -1,8 +1,8 @@ file(GLOB SOURCES CONFIGURE_DEPENDS "*.cpp" "*.hpp") -add_executable(sc-memory-performance-tests ${SOURCES}) +add_executable(sc-memory-benchmarks ${SOURCES}) -target_link_libraries(sc-memory-performance-tests +target_link_libraries(sc-memory-benchmarks LINK_PRIVATE sc-memory LINK_PRIVATE benchmark::benchmark ) diff --git a/sc-tools/sc-server/tests/units/performance/CMakeLists.txt b/sc-tools/sc-server/tests/units/performance/CMakeLists.txt index 2a2c8ec185..6b03dc43d7 100644 --- a/sc-tools/sc-server/tests/units/performance/CMakeLists.txt +++ b/sc-tools/sc-server/tests/units/performance/CMakeLists.txt @@ -3,15 +3,15 @@ file(GLOB SOURCES CONFIGURE_DEPENDS "*/*.cpp" "*/*.hpp" ) -add_executable(sc-server-performance-tests ${SOURCES}) -target_link_libraries(sc-server-performance-tests +add_executable(sc-server-benchmarks ${SOURCES}) +target_link_libraries(sc-server-benchmarks LINK_PRIVATE sc-server-lib LINK_PRIVATE benchmark::benchmark ) -target_include_directories(sc-server-performance-tests +target_include_directories(sc-server-benchmarks PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include ) if(${SC_CLANG_FORMAT_CODE}) - target_clangformat_setup(sc-server-performance-tests) + target_clangformat_setup(sc-server-benchmarks) endif() From 4feda73efedfb572fd9312d94bbcb9b936236b15 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 25 Nov 2024 02:51:19 +0300 Subject: [PATCH 098/134] [docs] Add notes for extensions directory --- .../cpp/guides/simple_guide_for_implementing_agent.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md b/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md index 236915874c..990313fe9e 100644 --- a/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md +++ b/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md @@ -89,6 +89,15 @@ set_target_properties(set-agents ) ``` +!!! note + `LIBRARY_OUTPUT_DIRECTORY` property should be set only for libraries that represent modules with agents. + +!!! note + You can set `CMAKE_OUTPUT_LIBRARY_DIRECTORY` instead of setting `LIBRARY_OUTPUT_DIRECTORY` property for each extension. + +!!! note + `SC_EXTENSIONS_DIRECTORY` variable should have path to the directory with extensions for the sc-machine. After building module with agent this directory path should be specified via `--extensions` when starting the sc-machine to load implemented module with agent. + --- ### **4. Define a class in C++ for this agent and specifies class of actions that this agent performs and its program.** From 32c74caf76208f816a8425bfca5960e1da641b11 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 25 Nov 2024 18:53:23 +0300 Subject: [PATCH 099/134] [memory][tools][tests] Rename performance directories to benchmark --- sc-memory/sc-memory/tests/CMakeLists.txt | 2 +- .../sc-memory/tests/{performance => benchmark}/CMakeLists.txt | 0 sc-memory/sc-memory/tests/{performance => benchmark}/main.cpp | 0 .../units/memory_erase_diff_elements.hpp | 0 .../{performance => benchmark}/units/memory_erase_elements.hpp | 0 .../units/memory_erase_set_elements.hpp | 0 .../units/memory_generate_connector.hpp | 0 .../{performance => benchmark}/units/memory_generate_link.hpp | 0 .../{performance => benchmark}/units/memory_generate_node.hpp | 0 .../{performance => benchmark}/units/memory_iterator_search.hpp | 0 .../units/memory_search_link_by_content.hpp | 0 .../tests/{performance => benchmark}/units/memory_test.hpp | 0 .../{performance => benchmark}/units/sc_code_base_vs_extend.hpp | 0 .../units/template_search_complex.hpp | 0 .../{performance => benchmark}/units/template_search_smoke.hpp | 0 .../tests/{performance => benchmark}/units/template_test.hpp | 0 sc-tools/sc-server/tests/CMakeLists.txt | 2 +- .../tests/units/{performance => benchmark}/CMakeLists.txt | 0 .../sc-server/tests/units/{performance => benchmark}/main.cpp | 0 .../{performance => benchmark}/units/sc_server_complex.hpp | 0 .../units/sc_server_erase_elements.hpp | 0 .../units/sc_server_generate_connector.hpp | 0 .../units/sc_server_generate_link.hpp | 0 .../units/sc_server_generate_node.hpp | 0 .../units/sc_server_search_template.hpp | 0 .../units/{performance => benchmark}/units/sc_server_test.hpp | 0 26 files changed, 2 insertions(+), 2 deletions(-) rename sc-memory/sc-memory/tests/{performance => benchmark}/CMakeLists.txt (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/main.cpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/memory_erase_diff_elements.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/memory_erase_elements.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/memory_erase_set_elements.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/memory_generate_connector.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/memory_generate_link.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/memory_generate_node.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/memory_iterator_search.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/memory_search_link_by_content.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/memory_test.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/sc_code_base_vs_extend.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/template_search_complex.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/template_search_smoke.hpp (100%) rename sc-memory/sc-memory/tests/{performance => benchmark}/units/template_test.hpp (100%) rename sc-tools/sc-server/tests/units/{performance => benchmark}/CMakeLists.txt (100%) rename sc-tools/sc-server/tests/units/{performance => benchmark}/main.cpp (100%) rename sc-tools/sc-server/tests/units/{performance => benchmark}/units/sc_server_complex.hpp (100%) rename sc-tools/sc-server/tests/units/{performance => benchmark}/units/sc_server_erase_elements.hpp (100%) rename sc-tools/sc-server/tests/units/{performance => benchmark}/units/sc_server_generate_connector.hpp (100%) rename sc-tools/sc-server/tests/units/{performance => benchmark}/units/sc_server_generate_link.hpp (100%) rename sc-tools/sc-server/tests/units/{performance => benchmark}/units/sc_server_generate_node.hpp (100%) rename sc-tools/sc-server/tests/units/{performance => benchmark}/units/sc_server_search_template.hpp (100%) rename sc-tools/sc-server/tests/units/{performance => benchmark}/units/sc_server_test.hpp (100%) diff --git a/sc-memory/sc-memory/tests/CMakeLists.txt b/sc-memory/sc-memory/tests/CMakeLists.txt index 033c0c22cb..5b4c81132b 100644 --- a/sc-memory/sc-memory/tests/CMakeLists.txt +++ b/sc-memory/sc-memory/tests/CMakeLists.txt @@ -1,5 +1,5 @@ if(${SC_BUILD_BENCH}) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/performance) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/benchmark) endif() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/sc-memory) diff --git a/sc-memory/sc-memory/tests/performance/CMakeLists.txt b/sc-memory/sc-memory/tests/benchmark/CMakeLists.txt similarity index 100% rename from sc-memory/sc-memory/tests/performance/CMakeLists.txt rename to sc-memory/sc-memory/tests/benchmark/CMakeLists.txt diff --git a/sc-memory/sc-memory/tests/performance/main.cpp b/sc-memory/sc-memory/tests/benchmark/main.cpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/main.cpp rename to sc-memory/sc-memory/tests/benchmark/main.cpp diff --git a/sc-memory/sc-memory/tests/performance/units/memory_erase_diff_elements.hpp b/sc-memory/sc-memory/tests/benchmark/units/memory_erase_diff_elements.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/memory_erase_diff_elements.hpp rename to sc-memory/sc-memory/tests/benchmark/units/memory_erase_diff_elements.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/memory_erase_elements.hpp b/sc-memory/sc-memory/tests/benchmark/units/memory_erase_elements.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/memory_erase_elements.hpp rename to sc-memory/sc-memory/tests/benchmark/units/memory_erase_elements.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/memory_erase_set_elements.hpp b/sc-memory/sc-memory/tests/benchmark/units/memory_erase_set_elements.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/memory_erase_set_elements.hpp rename to sc-memory/sc-memory/tests/benchmark/units/memory_erase_set_elements.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/memory_generate_connector.hpp b/sc-memory/sc-memory/tests/benchmark/units/memory_generate_connector.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/memory_generate_connector.hpp rename to sc-memory/sc-memory/tests/benchmark/units/memory_generate_connector.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/memory_generate_link.hpp b/sc-memory/sc-memory/tests/benchmark/units/memory_generate_link.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/memory_generate_link.hpp rename to sc-memory/sc-memory/tests/benchmark/units/memory_generate_link.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/memory_generate_node.hpp b/sc-memory/sc-memory/tests/benchmark/units/memory_generate_node.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/memory_generate_node.hpp rename to sc-memory/sc-memory/tests/benchmark/units/memory_generate_node.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/memory_iterator_search.hpp b/sc-memory/sc-memory/tests/benchmark/units/memory_iterator_search.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/memory_iterator_search.hpp rename to sc-memory/sc-memory/tests/benchmark/units/memory_iterator_search.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/memory_search_link_by_content.hpp b/sc-memory/sc-memory/tests/benchmark/units/memory_search_link_by_content.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/memory_search_link_by_content.hpp rename to sc-memory/sc-memory/tests/benchmark/units/memory_search_link_by_content.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/memory_test.hpp b/sc-memory/sc-memory/tests/benchmark/units/memory_test.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/memory_test.hpp rename to sc-memory/sc-memory/tests/benchmark/units/memory_test.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/sc_code_base_vs_extend.hpp b/sc-memory/sc-memory/tests/benchmark/units/sc_code_base_vs_extend.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/sc_code_base_vs_extend.hpp rename to sc-memory/sc-memory/tests/benchmark/units/sc_code_base_vs_extend.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/template_search_complex.hpp b/sc-memory/sc-memory/tests/benchmark/units/template_search_complex.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/template_search_complex.hpp rename to sc-memory/sc-memory/tests/benchmark/units/template_search_complex.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/template_search_smoke.hpp b/sc-memory/sc-memory/tests/benchmark/units/template_search_smoke.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/template_search_smoke.hpp rename to sc-memory/sc-memory/tests/benchmark/units/template_search_smoke.hpp diff --git a/sc-memory/sc-memory/tests/performance/units/template_test.hpp b/sc-memory/sc-memory/tests/benchmark/units/template_test.hpp similarity index 100% rename from sc-memory/sc-memory/tests/performance/units/template_test.hpp rename to sc-memory/sc-memory/tests/benchmark/units/template_test.hpp diff --git a/sc-tools/sc-server/tests/CMakeLists.txt b/sc-tools/sc-server/tests/CMakeLists.txt index 91e52907e2..537cba56c1 100644 --- a/sc-tools/sc-server/tests/CMakeLists.txt +++ b/sc-tools/sc-server/tests/CMakeLists.txt @@ -9,5 +9,5 @@ if(${SC_CLANG_FORMAT_CODE}) endif() if(${SC_BUILD_BENCH}) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/units/performance) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/units/benchmark) endif() diff --git a/sc-tools/sc-server/tests/units/performance/CMakeLists.txt b/sc-tools/sc-server/tests/units/benchmark/CMakeLists.txt similarity index 100% rename from sc-tools/sc-server/tests/units/performance/CMakeLists.txt rename to sc-tools/sc-server/tests/units/benchmark/CMakeLists.txt diff --git a/sc-tools/sc-server/tests/units/performance/main.cpp b/sc-tools/sc-server/tests/units/benchmark/main.cpp similarity index 100% rename from sc-tools/sc-server/tests/units/performance/main.cpp rename to sc-tools/sc-server/tests/units/benchmark/main.cpp diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_complex.hpp b/sc-tools/sc-server/tests/units/benchmark/units/sc_server_complex.hpp similarity index 100% rename from sc-tools/sc-server/tests/units/performance/units/sc_server_complex.hpp rename to sc-tools/sc-server/tests/units/benchmark/units/sc_server_complex.hpp diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_erase_elements.hpp b/sc-tools/sc-server/tests/units/benchmark/units/sc_server_erase_elements.hpp similarity index 100% rename from sc-tools/sc-server/tests/units/performance/units/sc_server_erase_elements.hpp rename to sc-tools/sc-server/tests/units/benchmark/units/sc_server_erase_elements.hpp diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_generate_connector.hpp b/sc-tools/sc-server/tests/units/benchmark/units/sc_server_generate_connector.hpp similarity index 100% rename from sc-tools/sc-server/tests/units/performance/units/sc_server_generate_connector.hpp rename to sc-tools/sc-server/tests/units/benchmark/units/sc_server_generate_connector.hpp diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_generate_link.hpp b/sc-tools/sc-server/tests/units/benchmark/units/sc_server_generate_link.hpp similarity index 100% rename from sc-tools/sc-server/tests/units/performance/units/sc_server_generate_link.hpp rename to sc-tools/sc-server/tests/units/benchmark/units/sc_server_generate_link.hpp diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_generate_node.hpp b/sc-tools/sc-server/tests/units/benchmark/units/sc_server_generate_node.hpp similarity index 100% rename from sc-tools/sc-server/tests/units/performance/units/sc_server_generate_node.hpp rename to sc-tools/sc-server/tests/units/benchmark/units/sc_server_generate_node.hpp diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_search_template.hpp b/sc-tools/sc-server/tests/units/benchmark/units/sc_server_search_template.hpp similarity index 100% rename from sc-tools/sc-server/tests/units/performance/units/sc_server_search_template.hpp rename to sc-tools/sc-server/tests/units/benchmark/units/sc_server_search_template.hpp diff --git a/sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp b/sc-tools/sc-server/tests/units/benchmark/units/sc_server_test.hpp similarity index 100% rename from sc-tools/sc-server/tests/units/performance/units/sc_server_test.hpp rename to sc-tools/sc-server/tests/units/benchmark/units/sc_server_test.hpp From 1b05595c8d1e1f9b5fab198a758d11397faa556c Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 25 Nov 2024 18:56:18 +0300 Subject: [PATCH 100/134] [docs][tools] Update paths to binaries --- docs/sc-tools/sc_builder.md | 10 +++++----- docs/sc-tools/sc_machine.md | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/sc-tools/sc_builder.md b/docs/sc-tools/sc_builder.md index 91b958474c..94ae059df0 100644 --- a/docs/sc-tools/sc_builder.md +++ b/docs/sc-tools/sc_builder.md @@ -1,10 +1,10 @@ # sc-builder -Sc-builder tool allows to translate knowledge base sources into binaries. You can find it in a `bin` directory. +Sc-builder tool allows to translate knowledge base sources into binaries. You can find it in a `/build//bin` directory. ```sh Usage: - ./bin/sc-builder [options] + ./build//bin/sc-builder [options] Required options: --input|-i |.path Specify the path to a directory containing knowledge base sources (.scs, .gwf) or a .path file. @@ -15,11 +15,11 @@ Required options: This path can also be provided via the `output` option in the [sc-builder] group of the configuration file provided via --config|-c. If both options are provided, the value from --output|-o takes precedence. --config|-c .ini Specify the path to a configuration file that can set input and output paths. - Use the `input` option in the [sc-builder] group for the input path, and the `output` option for the output path for ./bin/sc-builder. + Use the `input` option in the [sc-builder] group for the input path, and the `output` option for the output path for ./build//bin/sc-builder. Additional Options: --clear Run sc-builder in a mode that overwrites existing knowledge base binaries. - --version Display the version of ./bin/sc-builder. + --version Display the version of ./build//bin/sc-builder. --help Display this help message. ``` @@ -27,5 +27,5 @@ Example of usage: ```sh cd sc-machine -./bin/sc-builder -i ./kb -o ./kb.bin --clear -c ./sc-machine.ini +./build//bin/sc-builder -i ./kb -o ./kb.bin --clear -c ./sc-machine.ini ``` diff --git a/docs/sc-tools/sc_machine.md b/docs/sc-tools/sc_machine.md index 6ccd00100e..abb10d6224 100644 --- a/docs/sc-tools/sc_machine.md +++ b/docs/sc-tools/sc_machine.md @@ -4,18 +4,18 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -Sc-machine is a sc-memory with opportunity to add modules consistent with the general sc-machine interface. All such modules are named extensions, must be shared libraries (with file extension `.so` or `.dylib`) and stored in common directory (by default it is `./bin/extensions`). By default, sc-machine contains sc-server that allows to communicate with sc-memory through network. You can find `sc-machine` in a `bin` directory. +Sc-machine is a sc-memory with opportunity to add modules consistent with the general sc-machine interface. All such modules are named extensions, must be shared libraries (with file extension `.so` or `.dylib`) and stored in common directory (by default it is `./build//lib/extensions`). By default, sc-machine contains sc-server that allows to communicate with sc-memory through network. You can find `sc-machine` in a `/build//bin` directory. ```sh Usage: - ./bin/sc-machine [options] + ./build//bin/sc-machine [options] Required options: --storage|-s Provide a path to directory with knowledge base binaries. Knowledge base binaries should be generated by sc-builder binary. This path can also be provided via the `storage` option in the [sc-memory] group of the configuration file specified with --config|-c. If both options are provided, the value from --storage|-s takes precedence. --config|-c .ini Provide a path to configuration file. If `storage` option is not provided as argument, then this file should contain `storage` option in `[sc-memory]` group. - Configuration file can be used to set additional (optional) options for ./bin/sc-machine. + Configuration file can be used to set additional (optional) options for ./build//bin/sc-machine. Options: --extensions|-e Provide a path to directories containing extensions. Extensions should represent compiled dynamic libraries of agent sc-modules. @@ -24,7 +24,7 @@ Options: --clear Run sc-memory in the mode when it overwrites existing knowledge base binaries. --verbose|-v Shutdown sc-memory without dumping its state into knowledge base binaries. --test|-t Test sc-memory state. If this flag is specified, sc-memory will be initialized and shutdown immediately. - --version Display version of ./bin/sc-machine. + --version Display version of ./build//bin/sc-machine. --help Display this help message. ``` @@ -32,5 +32,5 @@ Example of usage: ```sh cd sc-machine -./bin/sc-machine -c ./sc-machine.ini +./build//bin/sc-machine -c ./sc-machine.ini ``` From da673dbfe14680d266478e3cbe77746beb42f87e Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 25 Nov 2024 18:58:15 +0300 Subject: [PATCH 101/134] [docs][review] Use sc-machine::sc-memory instead of sc-memory --- docs/build/build_system.md | 2 +- .../api/cpp/guides/simple_guide_for_implementing_agent.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index dc68fb7d89..157121efa0 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -93,7 +93,7 @@ The package artifacts are available [here](https://github.com/ostis-ai/sc-machin # Import sc-machine from the Releases archive. # You can override this variable via -D_PATH_SC_MACHINE_PATH # or CMakeUserPreset.json / CMakePreset.json files. -set(_SC_MACHINE_PATH "/location/to/sc-machine--" +set(_SC_MACHINE_PATH "/path/to/sc-machine--" CACHE PATH "sc-machine installation path" ) diff --git a/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md b/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md index 990313fe9e..d4a9b7bac3 100644 --- a/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md +++ b/docs/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md @@ -80,7 +80,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS # Generate and link your library with using libraries. add_library(set-agents SHARED ${SOURCES}) -target_link_libraries(set-agents LINK_PUBLIC sc-memory) +target_link_libraries(set-agents LINK_PUBLIC sc-machine::sc-memory) target_include_directories(set-agents PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) # Set output path for your extension `set-agents.so`. # Make sure that variable `SC_EXTENSIONS_DIRECTORY` has value. From 74b336d50f81ded37e65a3d83f6a90bbe333f0bc Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 2 Dec 2024 15:57:12 +0300 Subject: [PATCH 102/134] [docs][build][refactor] Header namings --- docs/build/build_system.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index 157121efa0..071ab669a2 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -19,7 +19,7 @@ If you wish to use CLI instead, you can list all the available configurations in cmake --list-presets ``` -### Configure Presets +### Configure presets These presets define how the project is configured before building. @@ -32,16 +32,18 @@ These presets define how the project is configured before building. | `release-with-tests` | Release config with tests | Use for production builds that require testing. | | `release-with-tests-conan` | Release config with tests (Conan dependencies used) | Use if you want to run tests in a production build using Conan. | -### Build Presets +### Build presets These presets are linked to the configure presets and are used by CMake to determine the build folder (`build/Debug` or `build/Release` by default). -| **Name** | **Configure Preset** | -|------------|-----------------------| -| `debug` | debug, debug-conan | -| `release` | release, release-conan, release-with-tests, release-with-tests-conan | +| **Name** | **Configure Preset** | +|------------|----------------------------------------------------------------------| +| `debug` | debug, debug-conan | +| `release` | release, release-conan, release-with-tests, release-with-tests-conan | -### Package Presets +The build artifacts will be located in the `build//bin` folder. + +### Package presets These presets are used for packaging the built project. @@ -57,6 +59,8 @@ These presets are used for packaging the built project. - If your project relies on Conan, select either the **Debug config (Conan)** (`debug-conan`) or the **Release config (Conan)** (`release-conan`) presets, depending on whether you are debugging or preparing a release. - Choose the **Release config with tests** (`release-with-tests`) or its Conan variant (`release-with-tests-conan`) if you want to ensure that your production build has been tested thoroughly before deployment. +### Example usage + For example, this is how to build sc-machine in debug mode using dependencies from Conan: ```sh @@ -77,8 +81,6 @@ cmake --preset release-with-tests cmake --build --preset release ``` -The build artifacts will be located in the `build//bin` folder. - We also define `INSTALL` instructions in our CMake. This routine can be launched by appending `--target install` to the `cmake --build --preset ` folder. The result of this command will reside in `build//install` (our default install folder). Install folder is basically a pack of portable executable files and shared libraries required to get sc-machine up and running, this command is intended to create clutter-free archives/folders with our code which you can then use in your own projects. ## Consuming the package From e9510064afe9e2a57a7c378f87f8e06da5dcf916 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 01:14:01 +0300 Subject: [PATCH 103/134] [docs][conan] Update sc-machine recipe description --- conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index 804100b09d..1898efe0e3 100644 --- a/conanfile.py +++ b/conanfile.py @@ -17,9 +17,9 @@ class sc_machineRecipe(ConanFile): package_type = "library" version = get_version() author = "OSTIS AI" - license = "https://github.com/ostis-ai/sc-machine/blob/master/LICENSE" + license = "https://github.com/ostis-ai/sc-machine/blob/master/COPYING.MIT" url = "https://github.com/ostis-ai/sc-machine" - description = "Software implementation of semantic network storage" + description = "Software implementation of semantic memory and its APIs" exports = ["LICENSE.md"] exports_sources = "*", "!.venv", "!build", "!.cache", "!kb", "!kb.bin", "!.env", "!ConanPresets.json", "!docs", "!.git" settings = "os", "compiler", "build_type", "arch" From da735505837ec645a8ff89431c3e647eac5821a5 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 01:19:26 +0300 Subject: [PATCH 104/134] [docs] Abstract example conanfile.txt --- docs/build/build_system.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/build/build_system.md b/docs/build/build_system.md index 071ab669a2..bc17b478f8 100644 --- a/docs/build/build_system.md +++ b/docs/build/build_system.md @@ -67,6 +67,9 @@ For example, this is how to build sc-machine in debug mode using dependencies fr # Use pipx to install Conan if not already installed # Install pipx first using guide: https://pipx.pypa.io/stable/installation/ pipx install conan +``` + +```sh # Use preset with Conan-provided dependencies and debug build type cmake --preset debug-conan # Use debug build preset since we've used a debug configure preset @@ -81,7 +84,7 @@ cmake --preset release-with-tests cmake --build --preset release ``` -We also define `INSTALL` instructions in our CMake. This routine can be launched by appending `--target install` to the `cmake --build --preset ` folder. The result of this command will reside in `build//install` (our default install folder). Install folder is basically a pack of portable executable files and shared libraries required to get sc-machine up and running, this command is intended to create clutter-free archives/folders with our code which you can then use in your own projects. +We also define `INSTALL` instructions in our CMake. This routine can be launched by appending `--target install` to the `cmake --build --preset ` command. The result of this command will reside in `build//install` (our default install folder). Install folder is basically a pack of portable executable files and shared libraries required to get sc-machine up and running, this command is intended to create clutter-free archives/folders with our code which you can then use in your own projects. ## Consuming the package @@ -153,7 +156,7 @@ list(APPEND CMAKE_PREFIX_PATH ${_SC_MACHINE_PATH}) ```ini [requires] # git commit is also the revision - sc-machine/0.10.0#0c1889bc6a34450c7728b4b12af9083910cebb36 + sc-machine/# [generators] CMakeDeps From 94acb12724381c7a5e5251f55ca4a01e4ff9b6c4 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 11:49:58 +0300 Subject: [PATCH 105/134] [ci] Add checkout in test_conan --- .github/workflows/test_conan.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test_conan.yml b/.github/workflows/test_conan.yml index 3a6950352d..e25bae4d32 100644 --- a/.github/workflows/test_conan.yml +++ b/.github/workflows/test_conan.yml @@ -20,6 +20,8 @@ jobs: - { cc: "gcc", cxx: "g++" } steps: + - name: Checkout + uses: actions/checkout@v4 - name: Restore ccache caches uses: hendrikmuhs/ccache-action@v1.2 From e4d0244d96fe115d05f081179af15be2454d6814 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 12:54:19 +0300 Subject: [PATCH 106/134] [cmake] Fix typos --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02b62c9fe2..cc087e6aa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ message(STATUS "Binary output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) message(STATUS "Library output directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") -if (DEFINED "${SC_EXTENSIONS_DIRECTORY}") +if(DEFINED "${SC_EXTENSIONS_DIRECTORY}") message(STATUS "Provided extensions directory: ${SC_EXTENSIONS_DIRECTORY}") file(MAKE_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) else() @@ -27,8 +27,8 @@ set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty") option(SC_BUILD_TESTS "Flag to build unit tests" OFF) option(SC_BUILD_BENCH "Flag to build benchmark" OFF) -set(SC_FILE_MEMORY "Dictionary" CACHE STRING "Sc-fs-storage type") -option(SC_OPTIMIZE_SEARCHING_INCOMING_CONNECTORS_FROM_STRUCTURES "Flag to optimize searching incoming sc-connctors from sc-structures" ON) +set(SC_FILE_MEMORY "Dictionary" CACHE STRING "sc-fs-storage type") +option(SC_OPTIMIZE_SEARCHING_INCOMING_CONNECTORS_FROM_STRUCTURES "Flag to optimize searching incoming sc-connectors from sc-structures" ON) include(${SC_MACHINE_ROOT}/macro/macros.cmake) parse_project_version() From 82a7f070f3df76f854cb345d3b8a2374ac45f39f Mon Sep 17 00:00:00 2001 From: FallenChromium Date: Fri, 22 Nov 2024 23:51:17 +0300 Subject: [PATCH 107/134] [docs] Add Quick Start page --- README.md | 105 ++++++++++++++------------------------------ docs/index.md | 2 + docs/quick_start.md | 70 +++++++++++++++++++++++++++++ mkdocs.yml | 3 +- 4 files changed, 106 insertions(+), 74 deletions(-) create mode 100644 docs/quick_start.md diff --git a/README.md b/README.md index b8a7449690..c18aaefbc3 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,23 @@ [![CI](https://github.com/ostis-ai/sc-machine/actions/workflows/main.yml/badge.svg)](https://github.com/ostis-ai/sc-machine/actions/workflows/main.yml) [![codecov](https://codecov.io/gh/ostis-ai/sc-machine/branch/main/graph/badge.svg?token=WU8O9Z1DNL)](https://codecov.io/gh/ostis-ai/sc-machine) [![license](https://img.shields.io/badge/License-MIT-yellow.svg)](COPYING.MIT) -[![docker](https://img.shields.io/docker/v/ostis/sc-machine?arch=amd64&label=Docker&logo=Docker&sort=date)](https://hub.docker.com/r/ostis/sc-machine) +[![docker](https://img.shields.io/docker/v/ostis/sc-machine?arch=amd64&label=Docker&logo=Docker&sort=semver)](https://hub.docker.com/r/ostis/sc-machine) -Short version: **sc-machine** is a software package of Semantic network storage that emulates semantic computer behaviour. It uses agent-based approach to process knowledge graphs. +[![Quick Start](https://img.shields.io/badge/-Quick%20Start-black?style=for-the-badge&logo=rocket)](https://ostis-ai.github.io/sc-machine/quick_start) +[![Docs](https://img.shields.io/badge/Docs-gray?style=for-the-badge&logo=read-the-docs)](https://ostis-ai.github.io/sc-machine) +[![Community](https://img.shields.io/badge/-Community-teal?style=for-the-badge&logo=matrix)](https://app.element.io/index.html#/room/#ostis_tech_support:matrix.org) -Semantic network storage stores and processes knowledge graphs represented in the SC-code (language of the universal knowledge representation). Theoretical basis of sc-machine is provided by the [**OSTIS Technology**](https://github.com/ostis-ai). +Short version: **sc-machine** is a software package that emulates **semantic computer behavior** by storing and processing knowledge in a semantic network. It uses **agent-based approach** to process knowledge graphs. + +or, if you'll look at it from an angle of databases... + +sc-machine is a **platform-independent graph database management system** that can store / retrieve knowledge graphs and run tasks (agents) on them. + + +sc-machine stores and processes knowledge graphs represented in the SC-code (language of the universal knowledge representation). Theoretical basis of sc-machine is provided by the [**OSTIS Technology**](https://github.com/ostis-ai). + +Both declarative (data, data structures, documentation, tasks specification, etc.) and procedural +(programs, modules, systems, communication between systems) knowledge is represented using that same language. Semantic network storage allows integrating problem solutions from different subject domains **by using the same**: @@ -15,7 +27,12 @@ Semantic network storage allows integrating problem solutions from different sub - **programming and data representation language** - **software stack**. -This project contains: +## Getting started + +To get started, check out our [quick start guide](https://ostis-ai.github.io/sc-machine/quick_start). + + +## This project contains: - `sc-memory` - semantic storage to store graph constructions; - `sc-event-manager` - event-based processing (async program workflow handling); @@ -24,19 +41,18 @@ This project contains: - `sc-server` - a Websocket server that provides a network API to communicate with storage using JSON; - `sc-builder` loads information from SCs files into the storage (SCs-code is one of the external representation languages of the SC-code). -
- More info - -Sc-machine is a **platform-independent graph database management system** that can store / retrieve knowledge graphs and run tasks (agents) on them. - -Both declarative (data, data structures, documentation, tasks specification, etc.) and procedural -(programs, modules, systems, communication between systems) knowledge is represented using the same language: the SC-code. - -
- ## Documentation - A brief user manual and developer docs are hosted on our [GitHub Pages](https://ostis-ai.github.io/sc-machine). + -
+ Build documentation locally + + ```sh + pip3 install mkdocs mkdocs-material + mkdocs serve + # and open http://127.0.0.1:8000/ in your browser + ``` +
- Full documentation, including: - core concepts @@ -44,66 +60,9 @@ Both declarative (data, data structures, documentation, tasks specification, etc - system design - software interfaces - is redistributed in a form of the [SCn-TeX document](https://github.com/ostis-ai/ostis-web-platform/blob/develop/docs/main.pdf). - - or **alternatively** you can build sc-machine documentation only. To do that refer to the [scn-latex-plugin](https://github.com/ostis-ai/scn-latex-plugin) documentation. - -
- Build documentation locally - -```sh -# make sure you're using python12 -pip3 install mkdocs mkdocs-material -mkdocs serve -# and open http://127.0.0.1:8000/ in your browser -``` -
- -## Quick start - -Semantic network storage is a core of any ostis-system, so you can use a reference system named [OSTIS Platform](https://github.com/ostis-ai/ostis-web-platform) to get it up and running quickly. - -## Installation - -- Docker: - We provide a Docker image for this project. Head to [Installing with Docker](https://ostis-ai.github.io/sc-machine/docker) to learn more. It's the recommended way to deploy the sc-machine. -- Native: - If you do not have the option to deploy the system using Docker, please refer to the docs: - [Build system](https://ostis-ai.github.io/sc-machine/build/build_system/) - - Note: currently, the sc-machine isn't _natively_ supported on Windows. - -## Usage - -- Docker - - ```sh - # create empty KB sources folder - mkdir kb && cat "." > kb/repo.path - # note: at this stage you can move your KB sources to the ./kb folder - - # build kb - docker compose run --rm machine build - # run sc-machine - docker compose up - ``` - -- Native - - Note: Currently, only Linux (Ubuntu-20.04, Ubuntu-22.04, Ubuntu-24.04) and macOS are supported by this installation method. If you're going to use it, it might take a while to download dependencies and compile the components. Use it only if you know what you're doing! - - ```sh - # build kb - ./build//bin/sc-builder -c ./sc-machine.ini -i -o --clear - # launch sc-machine - ./build//bin/sc-machine -c ./sc-machine.ini - ``` - -Most of these commands have a help page bundled inside, so if you have any questions or want to customize the command behavior, use `--help` flag to learn more about them. - -## Config + is redistributed in a form of the SCn-TeX document [compiled in PDF format](https://github.com/ostis-ai/ostis-web-platform/blob/develop/docs/main.pdf). -This repository provides a default configuration for the sc-machine. To customize the _sc-machine_ to suit your needs you can [create your own config file](https://ostis-ai.github.io/sc-machine/build/config). + **Alternatively** you can build sc-machine documentation yourself. To do that refer to the [scn-latex-plugin](https://github.com/ostis-ai/scn-latex-plugin) documentation. ## Feedback diff --git a/docs/index.md b/docs/index.md index 8cf8ce8866..f5657c3deb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,7 @@ # Documentation +- [Quick start](quick_start.md) +- [Docker](docker.md) - **Build system** * [Build system](build/build_system.md) - *how to build the project and use it as a library* * [CMake Flags](build/cmake_flags.md) - *description of CMake flags used to configure sc-machine* diff --git a/docs/quick_start.md b/docs/quick_start.md new file mode 100644 index 0000000000..4c5caa8662 --- /dev/null +++ b/docs/quick_start.md @@ -0,0 +1,70 @@ + +# Quick start + +## Use sc-machine as a C++ library in your project + +### GitHub Releases +You can download pre-built artifacts from [GitHub Releases](https://github.com/ostis-ai/sc-machine/releases). Extract it to any location, then make it available to CMake by appending folder path to `CMAKE_PREFIX_PATH`: + +```cmake +set(FABULOUS_PROJECT_SC_MACHINE_PATH "/some/path/to/sc-machine-" +CACHE PATH "sc-machine installation path" +) + +list(APPEND CMAKE_PREFIX_PATH ${FABULOUS_PROJECT_SC_MACHINE_PATH}) +``` + +### Conan + +You can use Conan to install sc-machine, here's what you'll need to add to `conanfile.txt`: +```ini +[requires] +sc-machine/ +``` + +You will be able to use `find_package(sc-machine REQUIRED)` to import sc-machine targets into your CMake project after you'll execute `conan install .`. + +Find more info on installation methods on the [build system page](https://ostis-ai.github.io/sc-machine/build/build_system/) (including some more advanced snippets for CMake). + +Start building! Refer to our [C++ guide](https://ostis-ai.github.io/sc-machine/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent/) on how to quickly develop an sc-machine agent in C++ from scratch. + +## Install sc-machine as a service + +It's possible to use sc-machine through a WebSocket API. Docs for our WebSocket API clients in [Python](https://github.com/ostis-ai/py-sc-client) and [TypeScript](https://github.com/ostis-ai/ts-sc-client) are available in the respective repositories. You might want to check [sc-web](https://github.com/ostis-ai/sc-web) for a more user-friendly interface as well. + +### Docker + +We provide a Docker image for this project. Here's a quick snippet on how to launch it. + +```sh +# clone the repo +git clone https://github.com/ostis-ai/sc-machine +cd sc-machine +# create empty knowledge base sources folder +mkdir kb && cat "." > kb/repo.path +# note: at this stage you can move your KB sources to the ./kb folder + +# build knowledge base +docker compose run --rm machine build +# run sc-machine +docker compose up +``` + +Head to [Installing with Docker](https://ostis-ai.github.io/sc-machine/docker) to learn more. Using Docker is the recommended way to deploy sc-machine in production. + +### Native + +Note: currently, running sc-machine natively on Windows isn't supported. + +Download the [sc-machine release](https://github.com/ostis-ai/sc-machine/releases) for your platform and run it on your system: + +```sh +cd sc-machine-- +./bin/sc-machine -r ../kb.bin # kb.bin will become your KB persistence folder +``` + +In case you want to make changes to the project sources, please refer to the [build system docs](https://ostis-ai.github.io/sc-machine/build/build_system/). + +## Config + +This repository provides a default configuration for the sc-machine. To customize the _sc-machine_ to suit your needs you can [create your own config file](https://ostis-ai.github.io/sc-machine/build/config). diff --git a/mkdocs.yml b/mkdocs.yml index bd5cf8875a..db5793bb3a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,7 +8,8 @@ extra_javascript: nav: - Home: index.md - - Installation with Docker: docker.md + - Quick Start: quick_start.md + - Docker: docker.md - Build: - Build system: build/build_system.md - CMake flags: build/cmake_flags.md From 32a4b13607e50d1ef4eddebc77dc4d5817437b5f Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 01:32:58 +0300 Subject: [PATCH 108/134] [docs] Mention python version for mkdocs --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c18aaefbc3..3fe9dcaa06 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ To get started, check out our [quick start guide](https://ostis-ai.github.io/sc- Build documentation locally ```sh + # make sure you're using python 3.12 pip3 install mkdocs mkdocs-material mkdocs serve # and open http://127.0.0.1:8000/ in your browser From 6ec7b1eb77fab75f26031832ea667bb1bc06d088 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 01:37:30 +0300 Subject: [PATCH 109/134] [docs][quick-start] Make conan section the first --- docs/quick_start.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/quick_start.md b/docs/quick_start.md index 4c5caa8662..f60b833e26 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -1,8 +1,17 @@ - # Quick start ## Use sc-machine as a C++ library in your project +### Conan + +You can use Conan to install sc-machine, here's what you'll need to add to `conanfile.txt`: +```ini +[requires] +sc-machine/ +``` + +You will be able to use `find_package(sc-machine REQUIRED)` to import sc-machine targets into your CMake project after you'll execute `conan install .`. + ### GitHub Releases You can download pre-built artifacts from [GitHub Releases](https://github.com/ostis-ai/sc-machine/releases). Extract it to any location, then make it available to CMake by appending folder path to `CMAKE_PREFIX_PATH`: @@ -14,19 +23,9 @@ CACHE PATH "sc-machine installation path" list(APPEND CMAKE_PREFIX_PATH ${FABULOUS_PROJECT_SC_MACHINE_PATH}) ``` -### Conan - -You can use Conan to install sc-machine, here's what you'll need to add to `conanfile.txt`: -```ini -[requires] -sc-machine/ -``` - -You will be able to use `find_package(sc-machine REQUIRED)` to import sc-machine targets into your CMake project after you'll execute `conan install .`. - Find more info on installation methods on the [build system page](https://ostis-ai.github.io/sc-machine/build/build_system/) (including some more advanced snippets for CMake). -Start building! Refer to our [C++ guide](https://ostis-ai.github.io/sc-machine/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent/) on how to quickly develop an sc-machine agent in C++ from scratch. +Start building! Refer to our [C++ Guide](https://ostis-ai.github.io/sc-machine/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent/) on how to quickly develop an sc-machine agent in C++ from scratch. ## Install sc-machine as a service From 7943cedb84982fb754625a8f58b6affce788a509 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 01:53:55 +0300 Subject: [PATCH 110/134] [docs] Simplify and clarify commands --- README.md | 9 +++------ docs/quick_start.md | 33 ++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3fe9dcaa06..9507a89406 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,11 @@ Short version: **sc-machine** is a software package that emulates **semantic computer behavior** by storing and processing knowledge in a semantic network. It uses **agent-based approach** to process knowledge graphs. -or, if you'll look at it from an angle of databases... - -sc-machine is a **platform-independent graph database management system** that can store / retrieve knowledge graphs and run tasks (agents) on them. - +From the perspective of graph databases, sc-machine is a **graph database management system** designed to store / retrieve knowledge graphs and run tasks (agents) on them. sc-machine stores and processes knowledge graphs represented in the SC-code (language of the universal knowledge representation). Theoretical basis of sc-machine is provided by the [**OSTIS Technology**](https://github.com/ostis-ai). -Both declarative (data, data structures, documentation, tasks specification, etc.) and procedural -(programs, modules, systems, communication between systems) knowledge is represented using that same language. +Both declarative (data, data structures, documentation, problems specification, etc.) and procedural (agents, programs, modules, systems, communication between systems) knowledge is represented using that same language. Semantic network storage allows integrating problem solutions from different subject domains **by using the same**: @@ -60,6 +56,7 @@ To get started, check out our [quick start guide](https://ostis-ai.github.io/sc- - rationale behind the sc-machine - system design - software interfaces + - more rigorous theoretical calculations is redistributed in a form of the SCn-TeX document [compiled in PDF format](https://github.com/ostis-ai/ostis-web-platform/blob/develop/docs/main.pdf). diff --git a/docs/quick_start.md b/docs/quick_start.md index f60b833e26..bfb6f0b10f 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -4,20 +4,33 @@ ### Conan -You can use Conan to install sc-machine, here's what you'll need to add to `conanfile.txt`: +You can use Conan to install sc-machine. To do this you need to create `conanfile.txt` in the root of the project and add to it: + ```ini [requires] sc-machine/ ``` -You will be able to use `find_package(sc-machine REQUIRED)` to import sc-machine targets into your CMake project after you'll execute `conan install .`. +Then run the following command in the project root: + +```sh +conan install . +``` + +Import sc-machine targets into your CMake project by using: + +```cmake +find_package(sc-machine REQUIRED) +``` + +Start building! Refer to our [C++ Guide](https://ostis-ai.github.io/sc-machine/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent/) on how to quickly develop an sc-machine agent in C++ from scratch. ### GitHub Releases You can download pre-built artifacts from [GitHub Releases](https://github.com/ostis-ai/sc-machine/releases). Extract it to any location, then make it available to CMake by appending folder path to `CMAKE_PREFIX_PATH`: ```cmake -set(FABULOUS_PROJECT_SC_MACHINE_PATH "/some/path/to/sc-machine-" -CACHE PATH "sc-machine installation path" +set(FABULOUS_PROJECT_SC_MACHINE_PATH "/path/to/extracted/sc-machine" + CACHE PATH "sc-machine installation path" ) list(APPEND CMAKE_PREFIX_PATH ${FABULOUS_PROJECT_SC_MACHINE_PATH}) @@ -25,8 +38,6 @@ list(APPEND CMAKE_PREFIX_PATH ${FABULOUS_PROJECT_SC_MACHINE_PATH}) Find more info on installation methods on the [build system page](https://ostis-ai.github.io/sc-machine/build/build_system/) (including some more advanced snippets for CMake). -Start building! Refer to our [C++ Guide](https://ostis-ai.github.io/sc-machine/sc-memory/api/cpp/guides/simple_guide_for_implementing_agent/) on how to quickly develop an sc-machine agent in C++ from scratch. - ## Install sc-machine as a service It's possible to use sc-machine through a WebSocket API. Docs for our WebSocket API clients in [Python](https://github.com/ostis-ai/py-sc-client) and [TypeScript](https://github.com/ostis-ai/ts-sc-client) are available in the respective repositories. You might want to check [sc-web](https://github.com/ostis-ai/sc-web) for a more user-friendly interface as well. @@ -58,8 +69,16 @@ Note: currently, running sc-machine natively on Windows isn't supported. Download the [sc-machine release](https://github.com/ostis-ai/sc-machine/releases) for your platform and run it on your system: ```sh +# create empty knowledge base sources folder +mkdir kb && cat "." > kb/repo.path +# note: at this stage you can move your KB sources to the ./kb folder + cd sc-machine-- -./bin/sc-machine -r ../kb.bin # kb.bin will become your KB persistence folder +# build knowledge base +./bin/sc-builder -i kb/repo.path -o ../kb.bin --clear +# run sc-machine +./bin/sc-machine -e lib/extensions -s ../kb.bin +# kb.bin will become your KB persistence folder ``` In case you want to make changes to the project sources, please refer to the [build system docs](https://ostis-ai.github.io/sc-machine/build/build_system/). From f9a58caff2bcd63605323cb725cfffc05d2f4a9b Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 14:15:45 +0300 Subject: [PATCH 111/134] [docs] Apply changes --- docs/changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 1bd6a04748..568629d23f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -42,7 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Deprecated sc-utils in 0.9.0 were removed from sc-kpm. - Questions were renamed to actions, answers were renamed to results. - `m_memoryCtx` in ScAgent renamed to `m_context`. -- Сode generation is no longer used as metaprogramming. The API for agents has been completely redesigned. See the documentation section on how to implement an agent with the new API. We have +- Сode generation is no longer used as metaprogramming. The API for agents has been completely redesigned. See the documentation section on how to implement an agent with the new API -- [C++ Agent Guide](sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md.md). We have - completely moved from code generation to template programming; - improved the API and aligned with our description of how it should be; - simplified the API. Now it will be much easier to create agents, go right now and see how to work with the new API -- [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md). @@ -164,6 +164,7 @@ See documentation, to learn more about using new API. ### Added +- Quick start section in docs - Allow multiple extension directories for sc-memory - CD for publishing sc-machine binaries as archive on Github - CI for checking sc-machine tests build with Conan dependencies From 4704452d324d10530bb4d52f02a77341b75db93e Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 14:21:08 +0300 Subject: [PATCH 112/134] [tools][machine-runner] Allow launch sc-machine without config --- sc-tools/sc-machine-runner/src/sc_machine_runner.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sc-tools/sc-machine-runner/src/sc_machine_runner.cpp b/sc-tools/sc-machine-runner/src/sc_machine_runner.cpp index f64a6f3737..5a0a5b4c17 100644 --- a/sc-tools/sc-machine-runner/src/sc_machine_runner.cpp +++ b/sc-tools/sc-machine-runner/src/sc_machine_runner.cpp @@ -74,13 +74,6 @@ try std::string configPath; if (options.Has({"config", "c"})) configPath = options[{"config", "c"}].second; - else - { - std::cout << "Error: Configuration file is required, but it is missing. Use --config|-c to specify the path to the " - "configuration file.\n"; - std::cout << "For more information, run with --help.\n"; - return EXIT_FAILURE; - } sc_bool saveOnShutdown = !options.Has({"verbose", "v"}); From 5e23a5300971a206fe9bca8f4818fd4b48832b6b Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 14:48:22 +0300 Subject: [PATCH 113/134] [tools][machine-runner][tests] Configure extensions path --- .../sc-machine-runner/tests/units/sc_machine_test.hpp | 2 +- sc-tools/sc-machine-runner/tests/units/test_base.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp b/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp index 519e68c558..32d80d8d03 100644 --- a/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp +++ b/sc-tools/sc-machine-runner/tests/units/sc_machine_test.hpp @@ -15,7 +15,7 @@ class ScMachineTest : public testing::Test public: static inline std::string const & SC_MACHINE_INI = "../sc-machine-test.ini"; static inline std::string const & SC_MACHINE_KB_BIN = "../sc-machine-test-kb-bin"; - static inline std::string const & SC_MACHINE_EXTENSIONS = "/extensions"; + static inline std::string SC_MACHINE_EXTENSIONS; protected: void SetUp() override {} diff --git a/sc-tools/sc-machine-runner/tests/units/test_base.cpp b/sc-tools/sc-machine-runner/tests/units/test_base.cpp index ed01f4fa0a..cb8289021a 100644 --- a/sc-tools/sc-machine-runner/tests/units/test_base.cpp +++ b/sc-tools/sc-machine-runner/tests/units/test_base.cpp @@ -67,3 +67,14 @@ TEST_F(ScMachineTest, PrintVersion) sc_char const * args[argsNumber] = {"sc-machine", "--version"}; EXPECT_EQ(RunMachine(argsNumber, (sc_char **)args), EXIT_SUCCESS); } + +sc_int main(sc_int argc, sc_char ** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + + std::filesystem::path binaryPath = argv[0]; + std::filesystem::path binaryDirectory = binaryPath.parent_path().parent_path(); + ScMachineTest::SC_MACHINE_EXTENSIONS = binaryDirectory / "lib/extensions"; + + return RUN_ALL_TESTS(); +} From d74aeaba7e27a611cd6c89dba7db480a995758f0 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 16:43:13 +0300 Subject: [PATCH 114/134] [docs] Update cmake flags --- docs/build/cmake_flags.md | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/docs/build/cmake_flags.md b/docs/build/cmake_flags.md index 7552936679..e1c011ac4a 100644 --- a/docs/build/cmake_flags.md +++ b/docs/build/cmake_flags.md @@ -1,29 +1,35 @@ -## Build cache: -This project uses ccache automatically if it's available in the system. To disable this, use flag `-DAUTO_CCACHE=OFF` +## Build cache + +This project uses ccache automatically if it's available in the system. To disable this, use flag `-DAUTO_CCACHE=OFF`. + +## Building tests -## Building tests: ```sh -cmake -B build -DSC_BUILD_TESTS=ON -cmake --build build -j$(nproc) +cmake --preset -DSC_BUILD_TESTS=ON +cmake --build --preset ``` Additionally you can use `-DSC_BUILD_BENCH=ON` flag to build performance tests - ## Building with sanitizers + Use `cmake` with `-DSC_USE_SANITIZER=memory` or `-DSC_USE_SANITIZER=address` option to run build with memory or address sanitizer. + **Note: sanitizers are only supported by `clang` compiler** -### Example: + +### Example + ```sh -cmake -B build -DSC_USE_SANITIZER=memory -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -cmake --build build +cmake --preset -DSC_USE_SANITIZER=memory -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang +cmake --build --preset ``` -## Code formatting with CLangFormat: + +## Code formatting with CLangFormat To check code with CLangFormat run: ```sh -cmake -B build -DSC_CLANG_FORMAT_CODE=ON -cmake --build build --target clangformat_check +cmake --preset release-with-tests -DSC_CLANG_FORMAT_CODE=ON +cmake --build --preset release --target clangformat_check ``` or @@ -33,8 +39,8 @@ or To format code with CLangFormat run: ```sh -cmake -B build -DSC_CLANG_FORMAT_CODE=ON -cmake --build build --target clangformat +cmake --preset release-with-tests -DSC_CLANG_FORMAT_CODE=ON +cmake --build --preset release --target clangformat ``` or From ae07edfce6c9c402263de256218eb55eecf1315b Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 16:43:30 +0300 Subject: [PATCH 115/134] [scripts] Update clang-format scripts --- scripts/clang/check_formatting.sh | 4 ++-- scripts/clang/format_code.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/clang/check_formatting.sh b/scripts/clang/check_formatting.sh index c7a870f0ba..6960f9e769 100755 --- a/scripts/clang/check_formatting.sh +++ b/scripts/clang/check_formatting.sh @@ -2,5 +2,5 @@ set -eo pipefail -cmake -B build -DSC_CLANG_FORMAT_CODE=ON -cmake --build build --target clangformat_check +cmake --preset release-with-tests -DSC_CLANG_FORMAT_CODE=ON +cmake --build --preset release --target clangformat_check diff --git a/scripts/clang/format_code.sh b/scripts/clang/format_code.sh index cdb05b3281..1e9aa9e201 100755 --- a/scripts/clang/format_code.sh +++ b/scripts/clang/format_code.sh @@ -2,5 +2,5 @@ set -eo pipefail -cmake -B build -DSC_CLANG_FORMAT_CODE=ON -cmake --build build --target clangformat +cmake --preset release-with-tests -DSC_CLANG_FORMAT_CODE=ON +cmake --build --preset release --target clangformat From 579d5b49da3fdb48380f14d17ca05783854976aa Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 16:44:38 +0300 Subject: [PATCH 116/134] [docs] Devide docs into user guides and developer guides; make pretty intros --- docs/changelog.md | 2 +- docs/index.md | 67 +++++++++++-------- .../api/cpp/extended/agents/actions.md | 2 +- .../api/cpp/extended/agents/agent_context.md | 2 +- .../api/cpp/extended/agents/agents.md | 2 +- .../extended/agents/event_subscriptions.md | 2 +- .../api/cpp/extended/agents/events.md | 2 +- .../api/cpp/extended/agents/keynodes.md | 2 +- .../api/cpp/extended/agents/modules.md | 2 +- .../api/cpp/extended/agents/waiters.md | 2 +- docs/thirdparty.md | 7 -- mkdocs.yml | 26 +++---- 12 files changed, 61 insertions(+), 57 deletions(-) delete mode 100644 docs/thirdparty.md diff --git a/docs/changelog.md b/docs/changelog.md index 568629d23f..2f5eeb2567 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -42,7 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Deprecated sc-utils in 0.9.0 were removed from sc-kpm. - Questions were renamed to actions, answers were renamed to results. - `m_memoryCtx` in ScAgent renamed to `m_context`. -- Сode generation is no longer used as metaprogramming. The API for agents has been completely redesigned. See the documentation section on how to implement an agent with the new API -- [C++ Agent Guide](sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md.md). We have +- Сode generation is no longer used as metaprogramming. The API for agents has been completely redesigned. See the documentation section on how to implement an agent with the new API -- [C++ Agent Guide](sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md). We have - completely moved from code generation to template programming; - improved the API and aligned with our description of how it should be; - simplified the API. Now it will be much easier to create agents, go right now and see how to work with the new API -- [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md). diff --git a/docs/index.md b/docs/index.md index f5657c3deb..b46507ef0c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,43 +1,54 @@ # Documentation -- [Quick start](quick_start.md) -- [Docker](docker.md) -- **Build system** - * [Build system](build/build_system.md) - *how to build the project and use it as a library* - * [CMake Flags](build/cmake_flags.md) - *description of CMake flags used to configure sc-machine* - * [Configuration File](build/config.md) - *description of a configuration file of sc-machine* -- **API** - * C++ API - *documentation of C++ API provided by sc-machine* +Welcome to the sc-machine documentation! This comprehensive guide is designed to help you navigate the features, functionalities, and applications of sc-machine, a C++ software package that emulates semantic computer behavior through the storage and processing of knowledge in a semantic network. + +## What is sc-machine? + +At its core, sc-machine operates as a **graph database management system**, enabling users to efficiently store, retrieve, and manipulate *knowledge graphs* in common shared memory known as *sc-memory*. By leveraging an agent-based approach, it processes these graphs to facilitate complex tasks and workflows. The underlying technology is grounded in **OSTIS Technology**, which allows for the representation of both declarative and procedural knowledge using a unified language known as *SC-code*. + +Table of contents: + +- [Quick start](quick_start.md) - *get up and running with sc-machine quickly* +- [Docker](docker.md) - *get up and running with sc-machine in docker* +- **User guides** - *detailed instructions on implementing agents* + * C++ Guides - *guidelines for implementing agents on C++* + * [C++ Simple guide for implementing agent](sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md) + * [Migrate to new agent API](sc-tools/migrate_to_new_agent_api.md) - *description of script that can be used to migrate to new C++ Agents API* +- **API** - *comprehensive documentation for C++, Python, and TypeScript APIs* + * C++ API - *detailed guides on using the core and extended APIs for interacting with sc-memory* * [C++ Core API](sc-memory/api/cpp/core/api.md) - *documentation of C++ core API for creating, retrieving and erasing sc-elements in sc-memory* - * C++ Extended API: - *documentation of C++ extended API for manipulating with system identifiers of sc-elements and sc-templates* + * C++ Extended API - *documentation of C++ extended API for manipulating with system identifiers of sc-elements and sc-templates* * [C++ System identifier API](sc-memory/api/cpp/extended/helper_api.md) - *documentation of C++ extended API for manipulating with system identifiers of sc-elements* * [C++ ScTemplate API](sc-memory/api/cpp/extended/template_api.md) - *documentation of C++ extended API for creating and retrieving graphs (it is very useful when you want to work big sc-constructions)* - * C++ Agents API: - *documentation of C++ Agents API for creating agents* - * [C++ Events API](sc-memory/api/cpp/extended/agents/events.md) - * [C++ Event subscriptions API](sc-memory/api/cpp/extended/agents/event_subscriptions.md) - * [C++ Waiters API](sc-memory/api/cpp/extended/agents/waiters.md) - * [C++ Keynodes API](sc-memory/api/cpp/extended/agents/keynodes.md) - * [C++ Actions API](sc-memory/api/cpp/extended/agents/actions.md) - * [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md) - * [C++ Agent context API](sc-memory/api/cpp/extended/agents/agent_context.md) - * [C++ Modules API](sc-memory/api/cpp/extended/agents/modules.md) - * C++ Guides: - * [C++ Simple guide for implementing agent](sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md) - * Python API - *documentation of Python API provided by py-sc-client* + * C++ Agents API - *documentation of C++ Agents API for creating agents* + * [C++ Events API](sc-memory/api/cpp/extended/agents/events.md) - *enables developers to create and manage events within the sc-machine, allowing agents to respond dynamically to various triggers* + * [C++ Event subscriptions API](sc-memory/api/cpp/extended/agents/event_subscriptions.md) - *details how agents can subscribe to specific events, manage their subscriptions, and receive notifications when those events occur* + * [C++ Waiters API](sc-memory/api/cpp/extended/agents/waiters.md) - *allows developers to implement wait conditions that pause agent execution until specified conditions are met or events are triggered* + * [C++ Keynodes API](sc-memory/api/cpp/extended/agents/keynodes.md) - *provides functionality for creating, retrieving, and manipulating keynodes, which represent significant concepts within the knowledge graph* + * [C++ Actions API](sc-memory/api/cpp/extended/agents/actions.md) - *outlines how to define and execute actions that agents can perform, detailing their parameters and expected outcomes* + * [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md) - *focuses on agent creation and management* + * [C++ Agent context API](sc-memory/api/cpp/extended/agents/agent_context.md) - *explains how to manage the context in which agents operate, encapsulating their state and environment during execution* + * [C++ Modules API](sc-memory/api/cpp/extended/agents/modules.md) - *describes how to create and manage modular components that extend the functionality of agents* + * Python API - *information on using the Python client for interacting with sc-memory* * [Python Core API](https://github.com/ostis-ai/py-sc-client) - *documentation of Python core API for creating, retrieving and erasing sc-elements and sc-events in sc-memory* * [Python Extended API](https://github.com/ostis-ai/py-sc-kpm) - *documentation of Python extended API for manipulating with large graphs* * TypeScript API - *documentation of TypeScript API provided by ts-sc-client* * [TypeScript Core API](https://github.com/ostis-ai/ts-sc-client) - *documentation of TypeScript core API for creating, retrieving and erasing sc-elements and sc-events in sc-memory* - * [Sc-element types](scs/sc_element_types.md) - *detailed description of supported element types* + * [sc-element types](scs/sc_element_types.md) - *detailed description of supported element types* * [SCs-code](scs/scs.md) - *documentation on SCs Language with examples* -- **Utils** - * [Agents](sc-kpm/kpm.md) - *detailed description of common agents* -- **Tools** +- **Tools** - *information on various tools that enhance your experience with sc-machine* * [Knowledge Base builder](sc-tools/sc_builder.md) - *description of options of sc-builder for knowledge base sources* * [Knowledge Base repo file](sc-tools/kb_repo_file.md) - *description of configuration of knowledge base sources* - * [Sc-machine Runner](sc-tools/sc_machine.md) - *description of options of sc-machine runner* - * [Migrate to new agent API](sc-tools/migrate_to_new_agent_api.md) - *description of script that can be used to migrate to new C++ Agents API* -- **Development** + * [sc-machine Runner](sc-tools/sc_machine.md) - *description of options of sc-machine runner* +- **Developer instructions** - *guidelines for building the project, configuring settings* + * [Build system](build/build_system.md) - *how to build the project and use it as a library* + * [CMake Flags](build/cmake_flags.md) - *description of CMake flags used to configure sc-machine* + * [Configuration File](build/config.md) - *description of a configuration file of sc-machine* + * Architecture + * [Core agents](sc-kpm/kpm.md) - *detailed description of core agents* +- **Development** - *guidelines for contributing to development* * [Contributing Guide](https://github.com/ostis-ai/sc-machine/blob/main/CONTRIBUTING.md) - *guide for those who wants to make contribution into sc-machine* * [Codestyle Guide](dev/codestyle.md) - *guide for those who wants to write code for sc-machine* * [Dev Container](dev/devcontainer.md) - *guide for those who wants to develop sc-machine via docker* +- [License](license.md) +- [Changelog](changelog.md) diff --git a/docs/sc-memory/api/cpp/extended/agents/actions.md b/docs/sc-memory/api/cpp/extended/agents/actions.md index 3369af43f7..0183922211 100644 --- a/docs/sc-memory/api/cpp/extended/agents/actions.md +++ b/docs/sc-memory/api/cpp/extended/agents/actions.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -This API provides functionality to handle sc-actions. +The **C++ Actions API** is dedicated to defining and executing actions that agents can perform within the sc-machine environment. This section provides guidelines on how to implement various actions, including their parameters and expected outcomes. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/sc-memory/api/cpp/extended/agents/agent_context.md b/docs/sc-memory/api/cpp/extended/agents/agent_context.md index b0b3f4a4b9..ed2d5fbc47 100644 --- a/docs/sc-memory/api/cpp/extended/agents/agent_context.md +++ b/docs/sc-memory/api/cpp/extended/agents/agent_context.md @@ -4,7 +4,7 @@ This documentation is correct for only versions of sc-machine that >= 0.10.0. --- -This API provides additional sc-memory methods that simplify working with it and provide additional methods to work with sc-events and agents. +The **C++ Agent context API** provides tools for managing the context in which agents operate. This API provides additional sc-memory methods that simplify working with it and provide additional methods to work with sc-events and agents. This documentation explains how to set up and utilize agent contexts, which encapsulate the state and environment of an agent during its execution. ## **ScAgentContext** diff --git a/docs/sc-memory/api/cpp/extended/agents/agents.md b/docs/sc-memory/api/cpp/extended/agents/agents.md index 9acd984edd..2cda1e9096 100644 --- a/docs/sc-memory/api/cpp/extended/agents/agents.md +++ b/docs/sc-memory/api/cpp/extended/agents/agents.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -This API provides functionality to implement agents on C++. +This section contains detailed documentation on the core functionalities of the **C++ Agents API**, which encompasses all aspects of agent creation and management. It covers how to instantiate agents, define their behaviors, and integrate them into larger systems. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/sc-memory/api/cpp/extended/agents/event_subscriptions.md b/docs/sc-memory/api/cpp/extended/agents/event_subscriptions.md index af362a2d01..f65a9b04e6 100644 --- a/docs/sc-memory/api/cpp/extended/agents/event_subscriptions.md +++ b/docs/sc-memory/api/cpp/extended/agents/event_subscriptions.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -This API provides functionality to subscribe to sc-events on C++. +The **C++ Event Subscriptions API** focuses on managing subscriptions to various events within the system. This documentation explains how agents can subscribe to specific events, manage their subscriptions, and receive notifications when these events occur. It is essential for building systems that require real-time updates and interactions based on event occurrences. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/sc-memory/api/cpp/extended/agents/events.md b/docs/sc-memory/api/cpp/extended/agents/events.md index 6caa44fefc..54b2d75212 100644 --- a/docs/sc-memory/api/cpp/extended/agents/events.md +++ b/docs/sc-memory/api/cpp/extended/agents/events.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -This API describes how to work with sc-events. +The **C++ Events API** is designed to handle event-driven programming within the sc-machine. This section details how to create, manage, and respond to events triggered by agents. It includes mechanisms for defining custom events, subscribing to them, and executing event handlers, allowing developers to implement responsive and interactive applications. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/sc-memory/api/cpp/extended/agents/keynodes.md b/docs/sc-memory/api/cpp/extended/agents/keynodes.md index 4669c431e7..22362110db 100644 --- a/docs/sc-memory/api/cpp/extended/agents/keynodes.md +++ b/docs/sc-memory/api/cpp/extended/agents/keynodes.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -This API provides functionality to define keynodes on C++. +The **C++ Keynodes API** allows developers to work with key nodes in the knowledge graph that represent significant concepts or entities. This documentation describes how to create, retrieve, and manipulate keynodes within the sc-machine, enabling efficient management of critical data points in semantic networks. A keynode is a key sc-element used by some program (agent) during its operation. Typically, keynodes can be classes and relations, which are sc-elements that program (agent) uses to find constructions in sc-memory or generate new ones. However, keynodes can be any sc-elements (incl. connectors between sc-elements). diff --git a/docs/sc-memory/api/cpp/extended/agents/modules.md b/docs/sc-memory/api/cpp/extended/agents/modules.md index 59fc28ffcb..bdb1cc74a5 100644 --- a/docs/sc-memory/api/cpp/extended/agents/modules.md +++ b/docs/sc-memory/api/cpp/extended/agents/modules.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -This API provides functionality to implement modules for subscribe/unsubscribe agents to/from sc-events on C++. +The **C++ Modules API** outlines how to create and manage modules that extend the functionality of agents within sc-machine. This section describes how to develop modular components that can be reused across different agents, promoting code efficiency and organization. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/sc-memory/api/cpp/extended/agents/waiters.md b/docs/sc-memory/api/cpp/extended/agents/waiters.md index 6cf758a4ce..0f8e62b18c 100644 --- a/docs/sc-memory/api/cpp/extended/agents/waiters.md +++ b/docs/sc-memory/api/cpp/extended/agents/waiters.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -This API provides functionality to implement waiters on C++. +The **C++ Waiters API** provides functionality for implementing wait conditions within agent workflows. This section covers how to create waiters that pause agent execution until specified conditions are met or events are triggered. It is particularly useful for synchronizing actions across multiple agents or ensuring that certain prerequisites are fulfilled before proceeding with tasks. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/thirdparty.md b/docs/thirdparty.md deleted file mode 100644 index b352122f5b..0000000000 --- a/docs/thirdparty.md +++ /dev/null @@ -1,7 +0,0 @@ -## Code generator -Based on refactored code from: [CPP-Reflection](https://github.com/AustinBrunkhorst/CPP-Reflection) - -## Sc-memory -* [JSON for Modern C++](https://github.com/nlohmann/json) -* [Antlr 4](https://github.com/antlr/antlr4) -* [Websocketcpp](https://docs.websocketpp.org/) diff --git a/mkdocs.yml b/mkdocs.yml index db5793bb3a..0e16e80942 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,12 +8,12 @@ extra_javascript: nav: - Home: index.md - - Quick Start: quick_start.md + - Quick start: quick_start.md - Docker: docker.md - - Build: - - Build system: build/build_system.md - - CMake flags: build/cmake_flags.md - - Configuration file: build/config.md + - User guides: + - C++ Guides: + - C++ Simple guide for implementing agent: sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md + - Migrate to new agent API: sc-tools/migrate_to_new_agent_api.md - API: - C++ API: - C++ Core API: sc-memory/api/cpp/core/api.md @@ -29,29 +29,29 @@ nav: - C++ Actions API: sc-memory/api/cpp/extended/agents/actions.md - C++ Agent context API: sc-memory/api/cpp/extended/agents/agent_context.md - C++ Modules API: sc-memory/api/cpp/extended/agents/modules.md - - C++ Guides: - - C++ Simple guide for implementing agent: sc-memory/api/cpp/guides/simple_guide_for_implementing_agent.md - Python API: - Python Core API: https://github.com/ostis-ai/py-sc-client - Python Extended API: https://github.com/ostis-ai/py-sc-kpm - TypeScript API: - TypeScript Core API: https://github.com/ostis-ai/ts-sc-client - - Sc-element types: scs/sc_element_types.md + - sc-element types: scs/sc_element_types.md - SCs-code: scs/scs.md - - Utils: - - Agents: sc-kpm/kpm.md - Tools: - Knowledge Base Builder: sc-tools/sc_builder.md - Knowledge Base repo file: sc-tools/kb_repo_file.md - - Sc-machine Runner: sc-tools/sc_machine.md - - Migrate to new agent api: sc-tools/migrate_to_new_agent_api.md + - sc-machine Runner: sc-tools/sc_machine.md + - Developer guides: + - Build system: build/build_system.md + - CMake flags: build/cmake_flags.md + - Configuration file: build/config.md + - Architecture: + - Core agents: sc-kpm/kpm.md - Development: - Contributing Guide: https://github.com/ostis-ai/sc-machine/blob/main/CONTRIBUTING.md - Codestyle Guide: dev/codestyle.md - Dev Container: dev/devcontainer.md - License: license.md - Changelog: changelog.md - - Thirdparty: thirdparty.md theme: material From da323e31b6fec4989802f0ba37f126553b19afd7 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 3 Dec 2024 17:30:50 +0300 Subject: [PATCH 117/134] [docs] Quick start for developers --- docs/build/cmake_flags.md | 2 +- docs/build/quick_start.md | 223 ++++++++++++++++++++++++++++++++++++++ docs/index.md | 1 + mkdocs.yml | 1 + 4 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 docs/build/quick_start.md diff --git a/docs/build/cmake_flags.md b/docs/build/cmake_flags.md index e1c011ac4a..c6e9305b84 100644 --- a/docs/build/cmake_flags.md +++ b/docs/build/cmake_flags.md @@ -11,7 +11,7 @@ cmake --build --preset Additionally you can use `-DSC_BUILD_BENCH=ON` flag to build performance tests -## Building with sanitizers +## Building sc-machine with sanitizers Use `cmake` with `-DSC_USE_SANITIZER=memory` or `-DSC_USE_SANITIZER=address` option to run build with memory or address sanitizer. diff --git a/docs/build/quick_start.md b/docs/build/quick_start.md new file mode 100644 index 0000000000..195d62203c --- /dev/null +++ b/docs/build/quick_start.md @@ -0,0 +1,223 @@ +# Quick start + +This guide provides short information for developers to start to work with sc-machine quickly. You can always learn more about the sc-machine's [build system](build_system.md). + +## Check CMake + +Ensure you are using **CMake version 3.24** or newer. Verify your version with: + +```sh +cmake --version +``` + +To upgrade CMake, follow the installation guide appropriate for your OS or use: + +```sh +# Use pipx to install cmake if not already installed +# Install pipx first using guide: https://pipx.pypa.io/stable/installation/ +pipx install cmake +``` + +## Start develop sc-machine with Conan + +### Install Conan + +Install Conan, to build sc-machine dependencies with Conan-provided dependencies: + +```sh +# Use pipx to install conan if not already installed +pipx install conan +``` + +### Use sc-machine in Debug + +#### Build sc-machine in Debug + +To build sc-machine in debug mode using Conan-provided dependencies, run: + +```sh +# debug build type +cmake --preset debug-conan +cmake --build --preset debug +``` + +Note: By default, configure preset `debug` enables building sc-machine tests. + +#### Run sc-machine tests in Debug + +After that, you can go to `build/Debug` and run tests via `ctest`: + +```sh +cd build/Debug +ctest -V Debug +``` + +#### Run sc-machine in Debug + +```sh +# create empty knowledge base sources folder +mkdir kb +# note: at this stage you can move your KB sources to the ./kb folder + +# build knowledge base +./build/Debug/bin/sc-builder -i kb -o kb.bin --clear +# run sc-machine +./build/Debug/bin/sc-machine -e build/Debug/lib/extensions -s kb.bin +``` + +### Use sc-machine in Release + +#### Build sc-machine in Release + +To build sc-machine in release mode using Conan-provided dependencies, run: + +```sh +# release build type without tests +cmake --preset release-conan +cmake --build --preset release +``` + +To build sc-machine with tests in release mode using Conan-provided dependencies, run: + +```sh +# release build type with tests +cmake --preset release-with-tests-conan +cmake --build --preset release +``` + +#### Run sc-machine tests in Release + +After that, you can run tests: + +```sh +cd build/Release +ctest -V Release +``` + +#### Run sc-machine in Release + +```sh +# create empty knowledge base sources folder +mkdir kb +# note: at this stage you can move your KB sources to the ./kb folder + +# build knowledge base +./build/Release/bin/sc-builder -i kb -o kb.bin --clear +# run sc-machine +./build/Release/bin/sc-machine -e build/Release/lib/extensions -s kb.bin +``` + +You can also check code formatting, build sc-machine with sanitizers and other. To learn more, go to the [CMake flags](cmake_flags.md) page. + +## Start develop sc-machine with system-provided dependencies + +### Install sc-machine dependencies + +Note: sc-machine build system supports installation of dependencies for Ubuntu and macOS only. + +#### Install sc-machine dependencies for Ubuntu + +```sh +cd scripts +./install_deps_ubuntu.sh +``` + +#### Install sc-machine dependencies for macOS + +```sh +cd scripts +./install_deps_macOS.sh +``` + +#### Install sc-machine dependencies for other OS + +Currently, we require the following packages to be available to CMake at build-time: + +- `java` +- `glib2` +- `websocketpp` + - [`asio`](https://think-async.com/Asio/) as the transitive dependency +- `nlohmann_json` +- `xml2` + +You can try install these dependencies on your OS. + +### Use sc-machine in Debug + +#### Build sc-machine in Debug + +To build sc-machine in debug mode using system-provided dependencies, run: + +```sh +# debug build type +cmake --preset debug +cmake --build --preset debug +``` + +Note: By default, configure preset `debug` enables building sc-machine tests. + +#### Run sc-machine tests in Debug + +After that, you can go to `build/Debug` and run tests via `ctest`: + +```sh +cd build/Debug +ctest -V Debug +``` + +#### Run sc-machine in Debug + +```sh +# create empty knowledge base sources folder +mkdir kb +# note: at this stage you can move your KB sources to the ./kb folder + +# build knowledge base +./build/Debug/bin/sc-builder -i kb -o kb.bin --clear +# run sc-machine +./build/Debug/bin/sc-machine -e build/Debug/lib/extensions -s kb.bin +``` + +### Use sc-machine in Release + +#### Build sc-machine in Release + +To build sc-machine in release mode using system-provided dependencies, run: + +```sh +# release build type without tests +cmake --preset release +cmake --build --preset release +``` + +To build sc-machine with tests in release mode using system-provided dependencies, run: + +```sh +# release build type with tests +cmake --preset release-with-tests +cmake --build --preset release +``` + +#### Run sc-machine tests in Release + +After that, you can run tests: + +```sh +cd build/Release +ctest -V Release +``` + +#### Run sc-machine in Release + +```sh +# create empty knowledge base sources folder +mkdir kb +# note: at this stage you can move your KB sources to the ./kb folder + +# build knowledge base +./build/Release/bin/sc-builder -i kb -o kb.bin --clear +# run sc-machine +./build/Release/bin/sc-machine -e build/Release/lib/extensions -s kb.bin +``` + +You can also check code formatting, build sc-machine with sanitizers and other. To learn more, go to the [CMake flags](cmake_flags.md) page. diff --git a/docs/index.md b/docs/index.md index b46507ef0c..3f4d9c1320 100644 --- a/docs/index.md +++ b/docs/index.md @@ -41,6 +41,7 @@ Table of contents: * [Knowledge Base repo file](sc-tools/kb_repo_file.md) - *description of configuration of knowledge base sources* * [sc-machine Runner](sc-tools/sc_machine.md) - *description of options of sc-machine runner* - **Developer instructions** - *guidelines for building the project, configuring settings* + * [Quick start](build/quick_start.md) - *get up and start developing sc-machine quickly* * [Build system](build/build_system.md) - *how to build the project and use it as a library* * [CMake Flags](build/cmake_flags.md) - *description of CMake flags used to configure sc-machine* * [Configuration File](build/config.md) - *description of a configuration file of sc-machine* diff --git a/mkdocs.yml b/mkdocs.yml index 0e16e80942..e09e5bdda7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -41,6 +41,7 @@ nav: - Knowledge Base repo file: sc-tools/kb_repo_file.md - sc-machine Runner: sc-tools/sc_machine.md - Developer guides: + - Quick start: build/quick_start.md - Build system: build/build_system.md - CMake flags: build/cmake_flags.md - Configuration file: build/config.md From cf7cb287aec08fb73a16fa087701e6d11abb4231 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 4 Dec 2024 12:11:45 +0300 Subject: [PATCH 118/134] [docs][refactor] Rename developer instructions to build instructions --- docs/index.md | 2 +- mkdocs.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 3f4d9c1320..b93c284612 100644 --- a/docs/index.md +++ b/docs/index.md @@ -40,7 +40,7 @@ Table of contents: * [Knowledge Base builder](sc-tools/sc_builder.md) - *description of options of sc-builder for knowledge base sources* * [Knowledge Base repo file](sc-tools/kb_repo_file.md) - *description of configuration of knowledge base sources* * [sc-machine Runner](sc-tools/sc_machine.md) - *description of options of sc-machine runner* -- **Developer instructions** - *guidelines for building the project, configuring settings* +- **Build instructions** - *guidelines for building the project, configuring settings* * [Quick start](build/quick_start.md) - *get up and start developing sc-machine quickly* * [Build system](build/build_system.md) - *how to build the project and use it as a library* * [CMake Flags](build/cmake_flags.md) - *description of CMake flags used to configure sc-machine* diff --git a/mkdocs.yml b/mkdocs.yml index e09e5bdda7..0e1b7dde09 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -40,7 +40,7 @@ nav: - Knowledge Base Builder: sc-tools/sc_builder.md - Knowledge Base repo file: sc-tools/kb_repo_file.md - sc-machine Runner: sc-tools/sc_machine.md - - Developer guides: + - Build instructions: - Quick start: build/quick_start.md - Build system: build/build_system.md - CMake flags: build/cmake_flags.md From a279a6b3b9bbd17db621ce96222b91270ec6df39 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 4 Dec 2024 12:13:30 +0300 Subject: [PATCH 119/134] [docs] Make architecture section separated --- docs/index.md | 4 ++-- mkdocs.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/index.md b/docs/index.md index b93c284612..ff7b187c92 100644 --- a/docs/index.md +++ b/docs/index.md @@ -45,8 +45,8 @@ Table of contents: * [Build system](build/build_system.md) - *how to build the project and use it as a library* * [CMake Flags](build/cmake_flags.md) - *description of CMake flags used to configure sc-machine* * [Configuration File](build/config.md) - *description of a configuration file of sc-machine* - * Architecture - * [Core agents](sc-kpm/kpm.md) - *detailed description of core agents* +- **Architecture** - *description of project components* + * [Core agents](sc-kpm/kpm.md) - *detailed description of core agents* - **Development** - *guidelines for contributing to development* * [Contributing Guide](https://github.com/ostis-ai/sc-machine/blob/main/CONTRIBUTING.md) - *guide for those who wants to make contribution into sc-machine* * [Codestyle Guide](dev/codestyle.md) - *guide for those who wants to write code for sc-machine* diff --git a/mkdocs.yml b/mkdocs.yml index 0e1b7dde09..571f9cb7e0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -45,8 +45,8 @@ nav: - Build system: build/build_system.md - CMake flags: build/cmake_flags.md - Configuration file: build/config.md - - Architecture: - - Core agents: sc-kpm/kpm.md + - Architecture: + - Core agents: sc-kpm/kpm.md - Development: - Contributing Guide: https://github.com/ostis-ai/sc-machine/blob/main/CONTRIBUTING.md - Codestyle Guide: dev/codestyle.md From cca0ca673a2c8a62b85f58c955413b3b5c77f1e6 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 4 Dec 2024 12:27:39 +0300 Subject: [PATCH 120/134] [docs] Remove license md --- docs/index.md | 6 +++--- docs/license.md | 21 --------------------- mkdocs.yml | 2 +- 3 files changed, 4 insertions(+), 25 deletions(-) delete mode 100644 docs/license.md diff --git a/docs/index.md b/docs/index.md index ff7b187c92..8142eb4a10 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,10 +1,10 @@ # Documentation -Welcome to the sc-machine documentation! This comprehensive guide is designed to help you navigate the features, functionalities, and applications of sc-machine, a C++ software package that emulates semantic computer behavior through the storage and processing of knowledge in a semantic network. +Welcome to the [sc-machine](https://github.com/ostis-ai/sc-machine) documentation! This comprehensive guide is designed to help you navigate the features, functionalities, and applications of sc-machine, a C++ software package that emulates semantic computer behavior through the storage and processing of knowledge in a semantic network. ## What is sc-machine? -At its core, sc-machine operates as a **graph database management system**, enabling users to efficiently store, retrieve, and manipulate *knowledge graphs* in common shared memory known as *sc-memory*. By leveraging an agent-based approach, it processes these graphs to facilitate complex tasks and workflows. The underlying technology is grounded in **OSTIS Technology**, which allows for the representation of both declarative and procedural knowledge using a unified language known as *SC-code*. +At its core, sc-machine operates as a **graph database management system**, enabling users to efficiently store, retrieve, and manipulate *knowledge graphs* in common shared memory known as *sc-memory*. By leveraging an agent-based approach, it processes these graphs to facilitate complex tasks and workflows. The underlying technology is grounded in the [**OSTIS Technology**](https://github.com/ostis-ai), which allows for the representation of both declarative and procedural knowledge using a unified language known as *SC-code (Semantic Computer code)*. Table of contents: @@ -51,5 +51,5 @@ Table of contents: * [Contributing Guide](https://github.com/ostis-ai/sc-machine/blob/main/CONTRIBUTING.md) - *guide for those who wants to make contribution into sc-machine* * [Codestyle Guide](dev/codestyle.md) - *guide for those who wants to write code for sc-machine* * [Dev Container](dev/devcontainer.md) - *guide for those who wants to develop sc-machine via docker* -- [License](license.md) +- [License](https://github.com/ostis-ai/sc-machine/blob/main/COPYING.MIT) - [Changelog](changelog.md) diff --git a/docs/license.md b/docs/license.md deleted file mode 100644 index 27a4e64cec..0000000000 --- a/docs/license.md +++ /dev/null @@ -1,21 +0,0 @@ -Unless otherwise indicated, Source Code is licensed under MIT license. - -Copyright (c) 2010-2024 OSTIS - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/mkdocs.yml b/mkdocs.yml index 571f9cb7e0..a35d7fe55d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -51,7 +51,7 @@ nav: - Contributing Guide: https://github.com/ostis-ai/sc-machine/blob/main/CONTRIBUTING.md - Codestyle Guide: dev/codestyle.md - Dev Container: dev/devcontainer.md - - License: license.md + - License: https://github.com/ostis-ai/sc-machine/blob/main/COPYING.MIT - Changelog: changelog.md theme: material From e2ab11fb15a62672bfc152c01563677b77789e6e Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 4 Dec 2024 14:30:49 +0300 Subject: [PATCH 121/134] [docs] Update launching ctest --- docs/build/quick_start.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/build/quick_start.md b/docs/build/quick_start.md index 195d62203c..d46281c924 100644 --- a/docs/build/quick_start.md +++ b/docs/build/quick_start.md @@ -49,7 +49,7 @@ After that, you can go to `build/Debug` and run tests via `ctest`: ```sh cd build/Debug -ctest -V Debug +ctest -C Debug -V ``` #### Run sc-machine in Debug @@ -91,7 +91,7 @@ After that, you can run tests: ```sh cd build/Release -ctest -V Release +ctest -C Release -V ``` #### Run sc-machine in Release @@ -162,7 +162,7 @@ After that, you can go to `build/Debug` and run tests via `ctest`: ```sh cd build/Debug -ctest -V Debug +ctest -C Debug -V ``` #### Run sc-machine in Debug @@ -204,7 +204,7 @@ After that, you can run tests: ```sh cd build/Release -ctest -V Release +ctest -C Release -V ``` #### Run sc-machine in Release From fce3c74149f699f46291da41bd1819caa8290d3a Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 6 Dec 2024 00:26:07 +0300 Subject: [PATCH 122/134] [build][conan] Fix duplicating parse sc-machine version --- conanfile.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/conanfile.py b/conanfile.py index 1898efe0e3..156cec480a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -3,19 +3,10 @@ import re -def get_version(): - try: - content = tools.load("CMakeLists.txt") - version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1) - return version.strip() - except Exception: - return None - - class sc_machineRecipe(ConanFile): name = "sc-machine" package_type = "library" - version = get_version() + version = None author = "OSTIS AI" license = "https://github.com/ostis-ai/sc-machine/blob/master/COPYING.MIT" url = "https://github.com/ostis-ai/sc-machine" @@ -73,6 +64,9 @@ def package_id(self): del self.info.settings.compiler del self.info.settings.build_type + def set_version(self): + self.version = self.parse_version() + def parse_version(self): content = tools.files.load(self, self.recipe_folder + "/CMakeLists.txt") version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1) From bd2441bbf1ce124ac65ea238a557cefab26a5599 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 6 Dec 2024 00:45:38 +0300 Subject: [PATCH 123/134] [docs][review] Remove misleading text --- docs/changelog.md | 2 +- docs/index.md | 6 +- docs/quick_start.md | 12 +- .../images/get-decomposition-agent/input.gwf | 174 ------------------ .../images/get-decomposition-agent/output.gwf | 104 ----------- docs/sc-kpm/kpm.md | 76 -------- .../api/cpp/extended/agents/actions.md | 2 +- .../api/cpp/extended/agents/agent_context.md | 2 +- .../api/cpp/extended/agents/agents.md | 2 +- .../extended/agents/event_subscriptions.md | 2 +- .../api/cpp/extended/agents/events.md | 2 +- .../api/cpp/extended/agents/keynodes.md | 2 +- .../api/cpp/extended/agents/modules.md | 2 +- mkdocs.yml | 2 - 14 files changed, 16 insertions(+), 374 deletions(-) delete mode 100644 docs/sc-kpm/images/get-decomposition-agent/input.gwf delete mode 100644 docs/sc-kpm/images/get-decomposition-agent/output.gwf delete mode 100644 docs/sc-kpm/kpm.md diff --git a/docs/changelog.md b/docs/changelog.md index 2f5eeb2567..06c1841af5 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -141,7 +141,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | ```_<~``` | ```<~_``` | | ```_<|~``` | ```<|~_``` | -- It is no longer possible to specify constancy for fuzzy arcs, because it may lead to misunderstanding of the non-factor denoted by this sc-arc. So, designations ```-/>```, ``````, ```_```, ``````, ```_```, ``````, ``````, ``````, ```_```, ``````, ```_```, ``````, ``` kb/repo.path +mkdir kb # note: at this stage you can move your KB sources to the ./kb folder cd sc-machine-- # build knowledge base -./bin/sc-builder -i kb/repo.path -o ../kb.bin --clear +./bin/sc-builder -i ../kb -o ../kb.bin --clear # run sc-machine ./bin/sc-machine -e lib/extensions -s ../kb.bin # kb.bin will become your KB persistence folder ``` -In case you want to make changes to the project sources, please refer to the [build system docs](https://ostis-ai.github.io/sc-machine/build/build_system/). +In case you want to make changes to the project sources, please refer to the [build system docs](build/build_system.md). ## Config -This repository provides a default configuration for the sc-machine. To customize the _sc-machine_ to suit your needs you can [create your own config file](https://ostis-ai.github.io/sc-machine/build/config). +This repository provides a default configuration for the sc-machine. To customize the _sc-machine_ to suit your needs you can [create your own config file](build/config.md). diff --git a/docs/sc-kpm/images/get-decomposition-agent/input.gwf b/docs/sc-kpm/images/get-decomposition-agent/input.gwf deleted file mode 100644 index c68ad5d50b..0000000000 --- a/docs/sc-kpm/images/get-decomposition-agent/input.gwf +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/sc-kpm/images/get-decomposition-agent/output.gwf b/docs/sc-kpm/images/get-decomposition-agent/output.gwf deleted file mode 100644 index 3814fc1085..0000000000 --- a/docs/sc-kpm/images/get-decomposition-agent/output.gwf +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/sc-kpm/kpm.md b/docs/sc-kpm/kpm.md deleted file mode 100644 index 5399eb4dd0..0000000000 --- a/docs/sc-kpm/kpm.md +++ /dev/null @@ -1,76 +0,0 @@ -## ScAgent Implementations - -### Get Decomposition Agent - -It is an agent that get decomposition of subject domain in JSON format - -**Action class:** - -`action_get_decomposition` - -**Parameters:** - -* `subjDomain` - subject domain node; -* `level` - link that stores decomposition level (unnecessary parameter, by default value of `level` parameter is `1`); -* `lang` - language node; -* `relation of decomposition` - relation node by which an entity is decomposed. - -**Example:** - -Example of an input structure: - - - -Example of an output structure: - - - -Link result: - -```json -{ - : { - "decomposition": { - : { - "decomposition": null, - "idtf": "Entity 1", - "position": 0 - }, - : { - "decomposition": null, - "idtf": "Entity 2", - "position": 1 - }, - : { - "decomposition": null, - "idtf": "Entity 3", - "position": 2 - }, - : { - "decomposition": { - : { - "decomposition": null, - "idtf": "Entity 4.1", - "position": 0 - }, - : { - "decomposition": null, - "idtf": "Entity 4.2", - "position": 1 - }, - }, - "idtf": "Entity 4", - "position": 3 - }, - }, - "idtf": "Main Entity", - "position": 0 - } -} -``` - -**Result:** - -* `SC_RESULT_OK` - result link is generated. -* `SC_RESULT_ERROR` - internal error in the link generation. -* `SC_RESULT_ERROR_INVALID_PARAMS` - internal error. This happens when subject domain node is invalid. diff --git a/docs/sc-memory/api/cpp/extended/agents/actions.md b/docs/sc-memory/api/cpp/extended/agents/actions.md index 0183922211..6833f8ed67 100644 --- a/docs/sc-memory/api/cpp/extended/agents/actions.md +++ b/docs/sc-memory/api/cpp/extended/agents/actions.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -The **C++ Actions API** is dedicated to defining and executing actions that agents can perform within the sc-machine environment. This section provides guidelines on how to implement various actions, including their parameters and expected outcomes. +The **C++ Actions API** is dedicated to defining and initiating actions that agents can perform within the sc-machine environment. This section provides guidelines on how to implement various actions, including their arguments and results. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/sc-memory/api/cpp/extended/agents/agent_context.md b/docs/sc-memory/api/cpp/extended/agents/agent_context.md index ed2d5fbc47..3298f4f127 100644 --- a/docs/sc-memory/api/cpp/extended/agents/agent_context.md +++ b/docs/sc-memory/api/cpp/extended/agents/agent_context.md @@ -4,7 +4,7 @@ This documentation is correct for only versions of sc-machine that >= 0.10.0. --- -The **C++ Agent context API** provides tools for managing the context in which agents operate. This API provides additional sc-memory methods that simplify working with it and provide additional methods to work with sc-events and agents. This documentation explains how to set up and utilize agent contexts, which encapsulate the state and environment of an agent during its execution. +The **C++ Agent context API** provides tools for managing the context in which agents operate. This API provides additional sc-memory methods that simplify working with it and provide additional methods to work with sc-events and agents. ## **ScAgentContext** diff --git a/docs/sc-memory/api/cpp/extended/agents/agents.md b/docs/sc-memory/api/cpp/extended/agents/agents.md index 2cda1e9096..02d928b0cd 100644 --- a/docs/sc-memory/api/cpp/extended/agents/agents.md +++ b/docs/sc-memory/api/cpp/extended/agents/agents.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -This section contains detailed documentation on the core functionalities of the **C++ Agents API**, which encompasses all aspects of agent creation and management. It covers how to instantiate agents, define their behaviors, and integrate them into larger systems. +This section contains detailed documentation on the core functionalities of the **C++ Agents API**, which encompasses agent creation and management. It covers how to specify and instantiate agents and integrate them into systems. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/sc-memory/api/cpp/extended/agents/event_subscriptions.md b/docs/sc-memory/api/cpp/extended/agents/event_subscriptions.md index f65a9b04e6..cace5c03bf 100644 --- a/docs/sc-memory/api/cpp/extended/agents/event_subscriptions.md +++ b/docs/sc-memory/api/cpp/extended/agents/event_subscriptions.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -The **C++ Event Subscriptions API** focuses on managing subscriptions to various events within the system. This documentation explains how agents can subscribe to specific events, manage their subscriptions, and receive notifications when these events occur. It is essential for building systems that require real-time updates and interactions based on event occurrences. +The **C++ Event Subscriptions API** focuses on managing subscriptions to various events within the system. This documentation explains how agents can subscribe to specific events and receive notifications when these events occur. It is essential for building systems that require real-time updates and interactions based on event occurrences. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/sc-memory/api/cpp/extended/agents/events.md b/docs/sc-memory/api/cpp/extended/agents/events.md index 54b2d75212..5bcb8c60a5 100644 --- a/docs/sc-memory/api/cpp/extended/agents/events.md +++ b/docs/sc-memory/api/cpp/extended/agents/events.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -The **C++ Events API** is designed to handle event-driven programming within the sc-machine. This section details how to create, manage, and respond to events triggered by agents. It includes mechanisms for defining custom events, subscribing to them, and executing event handlers, allowing developers to implement responsive and interactive applications. +The **C++ Events API** is designed to handle event-driven programming within the sc-machine. This section details types of possible events and how to respond to triggered events. !!! note To include this API provide `#include ` in your hpp source. diff --git a/docs/sc-memory/api/cpp/extended/agents/keynodes.md b/docs/sc-memory/api/cpp/extended/agents/keynodes.md index 22362110db..a1855cf1a1 100644 --- a/docs/sc-memory/api/cpp/extended/agents/keynodes.md +++ b/docs/sc-memory/api/cpp/extended/agents/keynodes.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -The **C++ Keynodes API** allows developers to work with key nodes in the knowledge graph that represent significant concepts or entities. This documentation describes how to create, retrieve, and manipulate keynodes within the sc-machine, enabling efficient management of critical data points in semantic networks. +The **C++ Keynodes API** allows developers to work with key elements in the knowledge graph that represent significant entities. This documentation describes how to create, retrieve, and manipulate keynodes within the sc-machine. A keynode is a key sc-element used by some program (agent) during its operation. Typically, keynodes can be classes and relations, which are sc-elements that program (agent) uses to find constructions in sc-memory or generate new ones. However, keynodes can be any sc-elements (incl. connectors between sc-elements). diff --git a/docs/sc-memory/api/cpp/extended/agents/modules.md b/docs/sc-memory/api/cpp/extended/agents/modules.md index bdb1cc74a5..1723b4883c 100644 --- a/docs/sc-memory/api/cpp/extended/agents/modules.md +++ b/docs/sc-memory/api/cpp/extended/agents/modules.md @@ -4,7 +4,7 @@ This is correct for only versions of sc-machine that >= 0.10.0. --- -The **C++ Modules API** outlines how to create and manage modules that extend the functionality of agents within sc-machine. This section describes how to develop modular components that can be reused across different agents, promoting code efficiency and organization. +The **C++ Modules API** outlines how to create and manage modules that group agents within sc-machine. This section describes how to register agents in an application. !!! note To include this API provide `#include ` in your hpp source. diff --git a/mkdocs.yml b/mkdocs.yml index a35d7fe55d..d8bf316240 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -45,8 +45,6 @@ nav: - Build system: build/build_system.md - CMake flags: build/cmake_flags.md - Configuration file: build/config.md - - Architecture: - - Core agents: sc-kpm/kpm.md - Development: - Contributing Guide: https://github.com/ostis-ai/sc-machine/blob/main/CONTRIBUTING.md - Codestyle Guide: dev/codestyle.md From 01fb8a61e5cdb0ef778aa04bd197148dcb65ca17 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 6 Dec 2024 00:46:05 +0300 Subject: [PATCH 124/134] [ci] Install cmake via pipx for ubuntu-22.04 --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd91e34021..f9fdc34a59 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,11 +62,12 @@ jobs: - name: Set up Conan run: | + pipx install cmake pipx install conan - name: Install compilers (Ubuntu) if: runner.os == 'Linux' - run: sudo apt install build-essential ninja-build ccache cmake + run: sudo apt install build-essential ninja-build ccache - name: Install compilers (macOS) if: runner.os == 'macOS' From a1bbce9c4d19fc3287576546c8b1c96a6b6371b6 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 6 Dec 2024 00:54:00 +0300 Subject: [PATCH 125/134] [docker][docs] Remove repo.path from KB_PATH --- docker-compose.yml | 2 +- docs/quick_start.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 168af0805d..77015aea74 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: environment: # Use the commented env variable if you need to rebuild KB every startup. - "REBUILD_KB=${REBUILD_KB:-0}" - - "KB_PATH=${KB_PATH:-/kb/repo.path}" + - "KB_PATH=${KB_PATH:-/kb}" - "BINARY_PATH=/sc-machine/build/Release/bin" - "EXTENSIONS_PATH=/sc-machine/build/Release/lib/extensions" - "CONFIG_PATH=/sc-machine/sc-machine.ini" diff --git a/docs/quick_start.md b/docs/quick_start.md index c86228fcd6..cbc311bb37 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -51,7 +51,7 @@ We provide a Docker image for this project. Here's a quick snippet on how to lau git clone https://github.com/ostis-ai/sc-machine cd sc-machine # create empty knowledge base sources folder -mkdir kb && cat "." > kb/repo.path +mkdir kb # note: at this stage you can move your KB sources to the ./kb folder # build knowledge base From cdc4ed6710ac8ffea1eed43374b75287e3fdd05e Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 6 Dec 2024 14:25:05 +0300 Subject: [PATCH 126/134] [docs] Update changelog --- docs/changelog.md | 4 +--- docs/index.md | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 06c1841af5..7f26616ee4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -26,8 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - sc-server is no longer entry point of the sc-machine, it is an extension (`sc-server-lib.so`), that is loaded dynamically when the machine is started. So, `sc-server` binary was removed, `sc-machine` binary was added instead. - Config was changed: - `repo_path` option in `[sc-memory]` group was deprecated, `storage` option was added instead; - - `extensions_path` option in `[sc-memory]` group was deprecated, `extensions` option was added instead; - - `[sc-builder]` group was removed. + - `extensions_path` option in `[sc-memory]` group was deprecated, `extensions` option was added instead. - Sources of the sc-machine were separated into public and private ones. Public sources of targets are located in `include` directory, private ones - in `src` directory, tests for code - in `tests` directory. Private sources can't be included into project's code directly. Besides that there are changes of location of some API classes of the sc-machine: - `ScTest` class was made a part of `sc-memory` target. Use `#include ` to include it into code. - To include `ScsLoader` class into code, use `#include `. @@ -293,7 +292,6 @@ See documentation, to learn more about using new API. ### Removed - Support for ubuntu-20.04 -- Config group `[sc-builder]` - Config options `update_period` and `save_period` in `[sc-memory]` deprecated in 0.9.0 - Config option `sync_actions` in `[sc-server]` deprecated in 0.9.0 - Scripts: `build_sc_machine.sh`, `build_kb.sh`, `run_sc_server.sh`, `set_vars.sh` and `run_tests.sh` diff --git a/docs/index.md b/docs/index.md index f2790aad5c..9d2238b97c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -27,8 +27,8 @@ Table of contents: * [C++ Keynodes API](sc-memory/api/cpp/extended/agents/keynodes.md) - *provides functionality for creating, retrieving, and manipulating keynodes, which represent significant concepts within the knowledge graph* * [C++ Actions API](sc-memory/api/cpp/extended/agents/actions.md) - *outlines how to define and initiate actions that agents can perform, detailing their arguments and results* * [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md) - *focuses on agent creation and management* - * [C++ Agent context API](sc-memory/api/cpp/extended/agents/agent_context.md) - *explains how to manage the context in which agents operate, encapsulating their state and environment during execution* - * [C++ Modules API](sc-memory/api/cpp/extended/agents/modules.md) - *describes how to create and manage modular components that extend the functionality of agents* + * [C++ Agent context API](sc-memory/api/cpp/extended/agents/agent_context.md) - *explains how to manage the context in which agents operate* + * [C++ Modules API](sc-memory/api/cpp/extended/agents/modules.md) - *describes how to register agents in an application* * Python API - *information on using the Python client for interacting with sc-memory* * [Python Core API](https://github.com/ostis-ai/py-sc-client) - *documentation of Python core API for creating, retrieving and erasing sc-elements and sc-events in sc-memory* * [Python Extended API](https://github.com/ostis-ai/py-sc-kpm) - *documentation of Python extended API for manipulating with large graphs* From 38b6e5e73093bfcddccf5dd441bffc5b4181de2e Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 6 Dec 2024 14:50:14 +0300 Subject: [PATCH 127/134] [docs] Remove -C argument during launching ctest --- docs/build/quick_start.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/build/quick_start.md b/docs/build/quick_start.md index d46281c924..85372a79df 100644 --- a/docs/build/quick_start.md +++ b/docs/build/quick_start.md @@ -49,7 +49,7 @@ After that, you can go to `build/Debug` and run tests via `ctest`: ```sh cd build/Debug -ctest -C Debug -V +ctest -V ``` #### Run sc-machine in Debug @@ -91,7 +91,7 @@ After that, you can run tests: ```sh cd build/Release -ctest -C Release -V +ctest -V ``` #### Run sc-machine in Release @@ -162,7 +162,7 @@ After that, you can go to `build/Debug` and run tests via `ctest`: ```sh cd build/Debug -ctest -C Debug -V +ctest -V ``` #### Run sc-machine in Debug @@ -204,7 +204,7 @@ After that, you can run tests: ```sh cd build/Release -ctest -C Release -V +ctest -V ``` #### Run sc-machine in Release From 1e1730f02ba8838dfd658165e43dafa9355ca759 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 6 Dec 2024 14:54:08 +0300 Subject: [PATCH 128/134] [build][conan] gtest is build requirement --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 156cec480a..32df2d2845 100644 --- a/conanfile.py +++ b/conanfile.py @@ -37,7 +37,7 @@ def requirements(self): def build_requirements(self): self.build_requires("libxml2/2.13.4") - self.test_requires("gtest/1.14.0") + self.build_requires("gtest/1.14.0") self.test_requires("benchmark/1.9.0") def layout(self): From 4dd7949a8dbee648b13282b0105116be20acad92 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 9 Dec 2024 13:32:55 +0300 Subject: [PATCH 129/134] [docs][docker] Clarify docker image pulling during run --- docs/docker.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/docker.md b/docs/docker.md index 5007783249..8ee303a5b4 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -4,9 +4,11 @@ All our releases are automatically uploaded to Docker Hub, so to start using our ### Launch +To pull the sc-machine image from DockerHub and run it, follow these steps: + ```sh -docker compose run --rm machine build #build KB (see below for details) -docker compose up #launch server +docker compose run --rm machine build # build knowledge base (see below for details) +docker compose up # launch server ``` Generally you would want to use a KB source folder alongside sc-machine. To do that, create a "kb" folder in the root of the project and place the KB sources in it. After that build it using the command described above (or enable autorebuild as shown below). From 9c1b044d10e3bf4575f455e1310cdf14b6ecfe4a Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Mon, 9 Dec 2024 14:57:08 +0300 Subject: [PATCH 130/134] [build][conan] gtest is test requirement --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 32df2d2845..156cec480a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -37,7 +37,7 @@ def requirements(self): def build_requirements(self): self.build_requires("libxml2/2.13.4") - self.build_requires("gtest/1.14.0") + self.test_requires("gtest/1.14.0") self.test_requires("benchmark/1.9.0") def layout(self): From 6dc08de53a5435fe38fb9f0e109823fee879dd3f Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Tue, 10 Dec 2024 00:10:36 +0300 Subject: [PATCH 131/134] [refactor][memory][tests] Ignore prints by clang --- .../sc-memory/tests/sc-memory/units/common/test_sc_type.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sc-memory/sc-memory/tests/sc-memory/units/common/test_sc_type.cpp b/sc-memory/sc-memory/tests/sc-memory/units/common/test_sc_type.cpp index c0b6134f7a..e9e445e2de 100644 --- a/sc-memory/sc-memory/tests/sc-memory/units/common/test_sc_type.cpp +++ b/sc-memory/sc-memory/tests/sc-memory/units/common/test_sc_type.cpp @@ -400,10 +400,12 @@ TEST(ScTypeTest, PrintTypesToBitValues) for (auto const & [type, _] : typeVector) { + // clang-format off std::cout << "| " << PrintTabulatedString(firstColumnLength, "ScType::" + std::string(type)) << " | " << PrintTabulatedString(secondColumnLength, std::to_string(type)) << " | " << "0x" << std::left << std::setw(thirdColumnLength - 2) << std::hex << std::uppercase << type << std::dec << " |\n"; + // clang-format on } } From 35958da32743eb6400e81e233161a41b23353203 Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Wed, 11 Dec 2024 01:53:18 +0300 Subject: [PATCH 132/134] [docs] Clarify comments in docker container docs --- docs/docker.md | 8 +++++--- docs/index.md | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/docker.md b/docs/docker.md index 8ee303a5b4..048f175da5 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -7,11 +7,13 @@ All our releases are automatically uploaded to Docker Hub, so to start using our To pull the sc-machine image from DockerHub and run it, follow these steps: ```sh -docker compose run --rm machine build # build knowledge base (see below for details) -docker compose up # launch server +# build knowledge base (see below for details) +docker compose run --rm machine build +# launch machine +docker compose up ``` -Generally you would want to use a KB source folder alongside sc-machine. To do that, create a "kb" folder in the root of the project and place the KB sources in it. After that build it using the command described above (or enable autorebuild as shown below). +Generally you would want to use a knowledge base source folder alongside sc-machine. To do that, create a "kb" folder in the root of the project and place the KB sources in it. After that build it using the command described above (or enable autorebuild as shown below). Note: By default we expect you to place a [repo.path](sc-tools/kb_repo_file.md) file inside the `./kb` folder, but in case you don't have one you can configure to build the folder itself by modifying the `.env` file: diff --git a/docs/index.md b/docs/index.md index 9d2238b97c..28386cd329 100644 --- a/docs/index.md +++ b/docs/index.md @@ -29,10 +29,10 @@ Table of contents: * [C++ Agents API](sc-memory/api/cpp/extended/agents/agents.md) - *focuses on agent creation and management* * [C++ Agent context API](sc-memory/api/cpp/extended/agents/agent_context.md) - *explains how to manage the context in which agents operate* * [C++ Modules API](sc-memory/api/cpp/extended/agents/modules.md) - *describes how to register agents in an application* - * Python API - *information on using the Python client for interacting with sc-memory* + * Python API - *documentation on using the Python client for interacting with sc-memory* * [Python Core API](https://github.com/ostis-ai/py-sc-client) - *documentation of Python core API for creating, retrieving and erasing sc-elements and sc-events in sc-memory* * [Python Extended API](https://github.com/ostis-ai/py-sc-kpm) - *documentation of Python extended API for manipulating with large graphs* - * TypeScript API - *documentation of TypeScript API provided by ts-sc-client* + * TypeScript API - *documentation on using the TypeScript client for interacting with sc-memory* * [TypeScript Core API](https://github.com/ostis-ai/ts-sc-client) - *documentation of TypeScript core API for creating, retrieving and erasing sc-elements and sc-events in sc-memory* * [sc-element types](scs/sc_element_types.md) - *detailed description of supported element types* * [SCs-code](scs/scs.md) - *documentation on SCs Language with examples* From a875241a2512dbd63042a690137e7636a25847ac Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 13 Dec 2024 17:52:58 +0300 Subject: [PATCH 133/134] [docs] Apply changes --- docs/changelog.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 7f26616ee4..ce4c62a1c3 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -163,7 +163,9 @@ See documentation, to learn more about using new API. ### Added -- Quick start section in docs +- Intro for documentation +- Quick start section for developers in docs +- Quick start section for users in docs - Allow multiple extension directories for sc-memory - CD for publishing sc-machine binaries as archive on Github - CI for checking sc-machine tests build with Conan dependencies @@ -233,6 +235,7 @@ See documentation, to learn more about using new API. ### Changed +- Description of project in Readme - Working directory for each test has been changed to the test's source dir - `gtest` and `benchmark` are installed via Conan or OS package managers instead of using them as git submodules - Location of the sc-machine build tree, binaries, libraries and extensions From bedc63047119289039dc165fff74ac86ec5755dd Mon Sep 17 00:00:00 2001 From: NikitaZotov Date: Fri, 13 Dec 2024 17:58:46 +0300 Subject: [PATCH 134/134] [memory][tests][benchmark] Change using NodeVar to using VarNode --- .../tests/benchmark/units/sc_code_base_vs_extend.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sc-memory/sc-memory/tests/benchmark/units/sc_code_base_vs_extend.hpp b/sc-memory/sc-memory/tests/benchmark/units/sc_code_base_vs_extend.hpp index 8b0c019423..f59a6c27c1 100644 --- a/sc-memory/sc-memory/tests/benchmark/units/sc_code_base_vs_extend.hpp +++ b/sc-memory/sc-memory/tests/benchmark/units/sc_code_base_vs_extend.hpp @@ -26,7 +26,7 @@ class TestScCodeExtended : public TestTemplate m_templ.Quintuple( node, ScType::VarCommonArc, - ScType::NodeVar, + ScType::VarNode, ScType::VarPermPosArc, attr); } @@ -66,7 +66,7 @@ class TestScCodeBase : public TestTemplate m_templ.Quintuple( node >> "_node", ScType::VarCommonArc >> "_arc", - ScType::NodeVar >> "_trg", + ScType::VarNode >> "_trg", ScType::VarPermPosArc, attr >> "_attr"); m_templ.Triple(