From 89d8a125ca71070157600beaa99e7229fccbb5f5 Mon Sep 17 00:00:00 2001 From: "m.marn" <m.marn@gsi.de> Date: Tue, 28 Mar 2023 08:53:00 +0000 Subject: [PATCH] Transition to CMake Fixes #53 See merge request silecs/opensilecs!27 --- .gitignore | 2 + CMakeLists.txt | 57 +++++++++++ README.md | 13 ++- build.sh | 52 ++++++++++ build_and_install.sh | 94 ------------------- configure.sh | 89 ++++++++++++++++++ install.sh | 57 +++++++++++ jenkins.sh | 51 ---------- silecs-cli-client/CMakeLists.txt | 25 +++++ silecs-cli-client/Makefile | 34 ------- silecs-cli-client/Makefile.dep | 23 ----- silecs-cli-client/install.sh | 24 ----- silecs-codegen/CMakeLists.txt | 15 +++ silecs-codegen/install.sh | 25 ----- silecs-communication-cpp/CMakeLists.txt | 63 +++++++++++++ silecs-communication-cpp/Makefile | 56 ----------- silecs-communication-cpp/Makefile.dep | 16 ---- silecs-communication-cpp/install.sh | 38 -------- silecs-communication-cpp/make-ctb.py | 29 ------ .../squash_modbus_lib.mri | 5 - .../interface/utility/SilecsLog.cpp | 2 +- silecs-diagnostic-cpp/CMakeLists.txt | 52 ++++++++++ silecs-diagnostic-cpp/Makefile | 71 -------------- silecs-diagnostic-cpp/Makefile.dep | 34 ------- silecs-diagnostic-cpp/install.sh | 24 ----- silecs-model/CMakeLists.txt | 8 ++ silecs-model/install.sh | 20 ---- silecs_cli/CMakeLists.txt | 22 +++++ silecs_cli/install.sh | 35 ------- silecs_cli/silecs.py | 3 +- silecs_cli/silecs_utils.py | 8 +- 31 files changed, 459 insertions(+), 588 deletions(-) create mode 100644 CMakeLists.txt create mode 100755 build.sh delete mode 100755 build_and_install.sh create mode 100755 configure.sh create mode 100755 install.sh delete mode 100755 jenkins.sh create mode 100644 silecs-cli-client/CMakeLists.txt delete mode 100644 silecs-cli-client/Makefile delete mode 100644 silecs-cli-client/Makefile.dep delete mode 100755 silecs-cli-client/install.sh create mode 100644 silecs-codegen/CMakeLists.txt delete mode 100755 silecs-codegen/install.sh create mode 100644 silecs-communication-cpp/CMakeLists.txt delete mode 100644 silecs-communication-cpp/Makefile delete mode 100644 silecs-communication-cpp/Makefile.dep delete mode 100755 silecs-communication-cpp/install.sh delete mode 100644 silecs-communication-cpp/make-ctb.py delete mode 100644 silecs-communication-cpp/squash_modbus_lib.mri create mode 100644 silecs-diagnostic-cpp/CMakeLists.txt delete mode 100644 silecs-diagnostic-cpp/Makefile delete mode 100644 silecs-diagnostic-cpp/Makefile.dep delete mode 100755 silecs-diagnostic-cpp/install.sh create mode 100644 silecs-model/CMakeLists.txt delete mode 100755 silecs-model/install.sh create mode 100644 silecs_cli/CMakeLists.txt delete mode 100755 silecs_cli/install.sh diff --git a/.gitignore b/.gitignore index 271ebc7..bc82312 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ venv builds builds/* .data +build +build-yocto diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..70a9c52 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.20.2) + +project(opensilecs VERSION 2.5.0) + +include(CTest) + +enable_testing() + +option(BUILD_COMMUNICATION_LIB_ONLY "Setup only the Silecs communication library." OFF) +option(ADD_LATEST_LINK "Link this install release as latest." ON) + +set(GSI_SILECS_PATH "/common/usr/cscofe/silecs" CACHE STRING "GSI_SILECS_PATH") +set(BUILD_TARGET "x86_64" CACHE STRING "BUILD_TARGET") + +# Use, i.e. don't skip the full RPATH for the build tree. +set(CMAKE_SKIP_BUILD_RPATH FALSE) + +# When building, don't use the install RPATH already (but later on when installing). +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + +# Add the automatically determined parts of the RPATH which point to directories outside the build +# tree to the install RPATH. +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +if (BUILD_COMMUNICATION_LIB_ONLY) + add_subdirectory(silecs-communication-cpp) +else() + add_subdirectory(silecs_cli) + add_subdirectory(silecs-codegen) + add_subdirectory(silecs-model) + add_subdirectory(silecs-communication-cpp) + add_subdirectory(silecs-cli-client) + add_subdirectory(silecs-diagnostic-cpp) + + # Create a silecs_environment file which can be sourced to use the silecs command line tools. + FILE(WRITE ${CMAKE_BINARY_DIR}/silecs_environment + "SILECS_VERSION=${CMAKE_PROJECT_VERSION}\n" + "export PATH=${CMAKE_INSTALL_PREFIX}/\$SILECS_VERSION/silecs-cli:\${PATH}\n" + "export PATH=${CMAKE_INSTALL_PREFIX}/\$SILECS_VERSION/silecs-cli-client/bin/x86_64:\${PATH}\n" + "export PATH=${CMAKE_INSTALL_PREFIX}/\$SILECS_VERSION/silecs-diagnostic-cpp/bin/x86_64:\${PATH}\n" + ) + + # The silecs_environment file is released/installed together with the other sub-projects. + install( + FILES ${CMAKE_BINARY_DIR}/silecs_environment + DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_PROJECT_VERSION}/ + ) +endif() + +if(ADD_LATEST_LINK) + # Symlink this release as latest. + install(CODE "execute_process( \ + COMMAND ${CMAKE_COMMAND} -E create_symlink \ + ${CMAKE_INSTALL_PREFIX}/${CMAKE_PROJECT_VERSION} \ + ${CMAKE_INSTALL_PREFIX}/latest )" + ) +endif() diff --git a/README.md b/README.md index d4daa15..5eb27f8 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,20 @@ Supported PLC vendors: Siemens, Beckhoff(untested), Schneider(untested) ## Getting Started -If you plan to just use the silecs framework, please check the [Opensilecs Wiki](https://www-acc.gsi.de/wiki/Frontend/SILECS) for handson courses and all required documentation. +If you plan to just use the silecs framework, please check the [Opensilecs Wiki](https://www-acc.gsi.de/wiki/Frontend/SILECS) for hands-on courses and all required documentation. ## Build & Install -If you want to touch the code of silecs itself, you can build it like this: +If you want to touch the code of silecs itself, you can build it using CMake. +There are three scripts available `configure.sh`, `build.sh` and `install.sh`. To setup the CMake build environment use `configure.sh`. The script accepts a few options (use `configure.sh -h` to see available options) +with which the release path, target and the build type can be configured. Once the build is configured +use `build.sh` to compile all the projects and `install.sh` to install them to the release path you +provided to `configure.sh`. In case no release path is provided the project will be released/installed +to the build directory. You can optionally specify the build target to `build.sh` and `install.sh` +scripts which can be used to build with yocto SDK. -`./build_and_install.sh v1.2.3 /home/user/MyCustomDir` +Note: when using the option `--target yocto` a different build directory is used `build-yocto`. +This means that for a full yocto build you need to provide the `--target yocto` option to all three scripts (`configure.sh`, `build.sh` and `install.sh`). Please open issues / merge requests in order to upstream your changes. ([GSI account required](https://www-oracle.gsi.de/pls/gsi/a_admin.acc_antrag)) diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..6abbd4a --- /dev/null +++ b/build.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +TARGET=x86_64 + +usage(){ + echo "Usage: $0 [--target yocto]" + + echo "-t | --target" + echo " $TARGET when not specified" + echo "-h | --help" + + exit 1 +} + +USER_TARGET=$TARGET + +# Loop through all the arguments and determine provided options. +while [ "${1:-}" != "" ]; do + case $1 in + -t | --target ) shift + USER_TARGET=$1 + ;; + -h | --help ) usage + exit + ;; + * ) usage + exit 1 + esac + shift +done + +# Based on the build target select the build directory (build by default & build-yocto for yocto SDK). +# Using a different build directory for yocto builds since mixing between the two cmake versions doesn't work to well. +BUILD_DIR_NAME=build +if [[ $USER_TARGET == yocto ]] || [[ $USER_TARGET == x86_64-yocto ]]; then + TARGET=x86_64-yocto + BUILD_DIR_NAME=build-yocto +elif [[ $USER_TARGET != x86_64 ]]; then + echo "Unsupported target" $USER_TARGET + usage + exit 1 +fi + +SCRIPT_PATH=$(dirname $(readlink -f "$0")) +BUILD_DIR=$SCRIPT_PATH/$BUILD_DIR_NAME + +echo "------------------------------------------------------------------------" +echo "Build target: " $TARGET +echo "Build directory: " $BUILD_DIR +echo "------------------------------------------------------------------------" + +cmake --build $BUILD_DIR -j 8 \ No newline at end of file diff --git a/build_and_install.sh b/build_and_install.sh deleted file mode 100755 index 7a780df..0000000 --- a/build_and_install.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -# release locations -GLOBAL_RELEASE_DIR=/common/usr/cscofe/silecs - -function help { - echo -e "" - echo -e "Script in order to build and install the complete silecs framework" - echo -e "" - echo -e "Usage:" - echo -e "" - echo -e "\t Install version 1.2.3 to default directory ($GLOBAL_RELEASE_DIR):" - echo -e "\t\t ./build_and_install.sh 1.2.3" - echo -e "" - echo -e "\t Install version 1.2.3 to custom directory:" - echo -e "\t\t ./build_and_install.sh 1.2.3 /home/user/MyCustomDir" - echo -e "" - exit 1; -} - -if [ $# -lt 1 ] - then - echo "Error: Wrong number of arguments supplied." - help -fi - -if [[ "$1" == "-h" || "$1" == "--help" ]]; -then - help -fi - -# List of silecs packages which can be released -PACKAGES="silecs-codegen silecs-model silecs-communication-cpp silecs-diagnostic-cpp silecs_cli silecs-cli-client" - -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in - -SILECS_VERSION_FULL=$1 -SILECS_VERSION_MAJOR=`echo ${SILECS_VERSION_FULL} | cut -d. -f1` -SILECS_VERSION_MINOR=`echo ${SILECS_VERSION_FULL} | cut -d. -f2` - -if [ -z "$2" ] - then - RELEASE_DIR_BASE=$GLOBAL_RELEASE_DIR - else - RELEASE_DIR_BASE=$2 -fi - - - -for PACKAGE in $PACKAGES; do - echo "installing package ${PACKAGE} into ${RELEASE_DIR_BASE}" - mkdir -p ${RELEASE_DIR_BASE} - ${PACKAGE}/install.sh ${RELEASE_DIR_BASE} ${SILECS_VERSION_FULL} - if [ "$?" -eq "1" ]; then - echo "Error: Package ${PACKAGE} skipped" - fi -done - -# Create silecs environment file to be easily sourced for users -echo -e "Create silecs environment file" -SILECS_ENV_FILE=${RELEASE_DIR_BASE}/${SILECS_VERSION_FULL}/silecs_environment -echo $SILECS_ENV_FILE -touch $SILECS_ENV_FILE -echo -e "SILECS_VERSION=${SILECS_VERSION_FULL}" >> $SILECS_ENV_FILE; -echo -e "export PATH=${RELEASE_DIR_BASE}/\$SILECS_VERSION/silecs-cli:\${PATH}" >> $SILECS_ENV_FILE; -echo -e "export PATH=${RELEASE_DIR_BASE}/\$SILECS_VERSION/silecs-cli-client/bin/x86_64:\${PATH}" >> $SILECS_ENV_FILE; -echo -e "export PATH=${RELEASE_DIR_BASE}/\$SILECS_VERSION/silecs-diagnostic-cpp/bin/x86_64:\${PATH}" >> $SILECS_ENV_FILE; - -# Update links to latest versions -echo -e "Update links to silecs versions" - -# Update link to latest version -LATEST_LINK=${RELEASE_DIR_BASE}/latest -if [ -L ${LATEST_LINK} ]; then - rm ${LATEST_LINK} -fi -ln -fvs ${RELEASE_DIR_BASE}/${SILECS_VERSION_FULL} ${LATEST_LINK} - -# Update link to major.minor version -MAJOR_MINOR_LINK=${RELEASE_DIR_BASE}/${SILECS_VERSION_MAJOR}.${SILECS_VERSION_MINOR} -if [ -L ${MAJOR_MINOR_LINK} ]; then - rm ${MAJOR_MINOR_LINK} -fi -ln -fvs ${RELEASE_DIR_BASE}/${SILECS_VERSION_FULL} ${MAJOR_MINOR_LINK} - -# Update link to major version -MAJOR_LINK=${RELEASE_DIR_BASE}/${SILECS_VERSION_MAJOR} -if [ -L ${MAJOR_LINK} ]; then - rm ${MAJOR_LINK} -fi -ln -fvs ${RELEASE_DIR_BASE}/${SILECS_VERSION_FULL} ${MAJOR_LINK} - -exit 0 diff --git a/configure.sh b/configure.sh new file mode 100755 index 0000000..032de4a --- /dev/null +++ b/configure.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +GLOBAL_RELEASE_DIR=/common/usr/cscofe/silecs/ +TARGET=x86_64 + +usage(){ + echo "Usage: $0 [--release [path]] [--target yocto]" + + echo "-r | --release" + echo " Install path prefix. If only option is provided without any paths $GLOBAL_RELEASE_DIR is used." + echo "-t | --target" + echo " $TARGET when not specified" + echo "-d | --debug" + echo " Use debug compilation flags." + echo "-h | --help" + + exit 1 +} + +DEBUG="" +USER_RELEASE_DIR="" +USER_TARGET=$TARGET + +# Loop through all the arguments and determine provided options. +while [ "${1:-}" != "" ]; do + case $1 in + -r | --release ) if [[ $2 == -* ]] || [[ $2 == "" ]]; then + USER_RELEASE_DIR=$GLOBAL_RELEASE_DIR + else + shift + USER_RELEASE_DIR=$1 + fi + ;; + -t | --target ) shift + USER_TARGET=$1 + ;; + -d | --debug ) DEBUG=y + ;; + -h | --help ) usage + exit + ;; + * ) usage + exit 1 + esac + shift +done + +# Based on the build target select the build directory (build by default & build-yocto for yocto SDK). +# Using a different build directory for yocto builds since mixing between the two cmake versions doesn't work to well. +BUILD_DIR_NAME=build +if [[ $USER_TARGET == yocto ]] || [[ $USER_TARGET == x86_64-yocto ]]; then + TARGET=x86_64-yocto + BUILD_DIR_NAME=build-yocto +elif [[ $USER_TARGET != x86_64 ]]; then + echo "Unsupported target" $USER_TARGET + usage + exit 1 +fi + +SCRIPT_PATH=$(dirname $(readlink -f "$0")) +BUILD_DIR=$SCRIPT_PATH/$BUILD_DIR_NAME + +# If user didn't provide a release directory use the build directory. Otherwise use whatever the user provided. +if [[ $USER_RELEASE_DIR == "" ]]; then + RELEASE_DIR=$BUILD_DIR +else + RELEASE_DIR=$USER_RELEASE_DIR +fi + +BUILD_TYPE=Release +# Only enable debug compilation mode when the user requests it. +if [[ $DEBUG == y ]]; then + BUILD_TYPE=Debug +fi + +echo "------------------------------------------------------------------------" +echo "Build type: " $BUILD_TYPE +echo "Build target: " $TARGET +echo "Build directory: " $BUILD_DIR +echo "Install directory:" $RELEASE_DIR +echo "------------------------------------------------------------------------" + +if [[ $TARGET == x86_64-yocto ]]; then + # Configure yocto environment. + unset LD_LIBRARY_PATH; source /common/usr/embedded/yocto/sdk/environment-setup-core2-64-ffos-linux + cmake -S . -B $BUILD_DIR -DBUILD_TARGET=$TARGET -DCMAKE_INSTALL_PREFIX=$RELEASE_DIR -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_COMMUNICATION_LIB_ONLY=ON -DADD_LATEST_LINK=OFF +else + cmake -S . -B $BUILD_DIR -DBUILD_TARGET=$TARGET -DCMAKE_INSTALL_PREFIX=$RELEASE_DIR -DCMAKE_BUILD_TYPE=$BUILD_TYPE +fi diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..abf758b --- /dev/null +++ b/install.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +TARGET=x86_64 + +usage(){ + echo "Usage: $0 [--target yocto]" + + echo "-t | --target" + echo " $TARGET when not specified" + echo "-h | --help" + + exit 1 +} + +USER_TARGET=$TARGET + +# Loop through all the arguments and determine provided options. +while [ "${1:-}" != "" ]; do + case $1 in + -t | --target ) shift + USER_TARGET=$1 + ;; + -h | --help ) usage + exit + ;; + * ) usage + exit 1 + esac + shift +done + +# Based on the build target select the build directory (build by default & build-yocto for yocto SDK). +# Using a different build directory for yocto builds since mixing between the two cmake versions doesn't work to well. +BUILD_DIR_NAME=build +if [[ $USER_TARGET == yocto ]] || [[ $USER_TARGET == x86_64-yocto ]]; then + TARGET=x86_64-yocto + BUILD_DIR_NAME=build-yocto +elif [[ $USER_TARGET != x86_64 ]]; then + echo "Unsupported target" $USER_TARGET + usage + exit 1 +fi + +SCRIPT_PATH=$(dirname $(readlink -f "$0")) +BUILD_DIR=$SCRIPT_PATH/$BUILD_DIR_NAME + +echo "------------------------------------------------------------------------" +echo "Build target: " $TARGET +echo "Build directory: " $BUILD_DIR +echo "------------------------------------------------------------------------" + +cd $BUILD_DIR +# Run tests and exit if any of them fail. +ctest || exit 1 + +cd $SCRIPT_PATH +cmake --install $BUILD_DIR -j 8 diff --git a/jenkins.sh b/jenkins.sh deleted file mode 100755 index bd8e69d..0000000 --- a/jenkins.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -set -e - -echo "##############################################" -echo "configuration of build environment" -echo "##############################################" - -# $WORKSPACE is the jenkins workspace, will be filled by jenkins - -export COMMON_MAKE_PATH="$WORKSPACE/../../generics/generic-makefiles" -export SNAP7_BASE="$WORKSPACE/snap7/snap7-full" -export BOOST_HOME="$WORKSPACE/../../generics/boost_1.54.0/boost/1.54.0" -export SILECS_COMM_HOME="$WORKSPACE/silecs-communication-cpp/build" - -echo "##############################################" -echo "building snap7" -echo "##############################################" -cd snap7 -./build.sh -cd .. -echo "##############################################" -echo "building silecs-communication-cpp" -echo "##############################################" -cd silecs-communication-cpp -make clean -make all CPU=x86_64 -j4 -cd .. -echo "##############################################" -echo "building silecs-codegen" -echo "##############################################" -cd silecs-codegen/src/xml -python runTests.py -cd ../../.. -echo "##############################################" -echo "building silecs-diagnostic-cpp" -echo "##############################################" -cd silecs-diagnostic-cpp -make clean -make CPU=x86_64 -j1 -cd .. -echo "##############################################" -echo "building silecs-cli-client" -echo "##############################################" -cd silecs-cli-client -make clean -make CPU=x86_64 -j1 -cd .. -echo "##############################################" -echo "build finished sucessfully" -echo "##############################################" - diff --git a/silecs-cli-client/CMakeLists.txt b/silecs-cli-client/CMakeLists.txt new file mode 100644 index 0000000..da669c0 --- /dev/null +++ b/silecs-cli-client/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.20.2) + +project(silecs-cli-client LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_compile_options(-Wall -Wextra) + +add_executable(${PROJECT_NAME} src/silecs-cli-client/main.cpp) + +target_link_libraries(${PROJECT_NAME} silecs-comm) + + +install( + TARGETS ${PROJECT_NAME} + DESTINATION ${CMAKE_PROJECT_VERSION}/${PROJECT_NAME}/bin/${BUILD_TARGET} +) + +install( + DIRECTORY examples + DESTINATION ${CMAKE_PROJECT_VERSION}/${PROJECT_NAME} + FILES_MATCHING PATTERN "*.sh*" +) + \ No newline at end of file diff --git a/silecs-cli-client/Makefile b/silecs-cli-client/Makefile deleted file mode 100644 index 9a2fe65..0000000 --- a/silecs-cli-client/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2016 CERN and GSI -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -PROJECT = silecs -PRODUCT = cli-client -VERSION = 0.0.0 - -SKIP_MANIFEST = TRUE -#local -#COMMON_MAKE_PATH ?= /common/home/bel/schwinn/lnx/workspace-silecs-neon/generic-makefiles -#global -COMMON_MAKE_PATH ?= /opt/cern/buildsystem/generic/2.13.2 - -#Enable C++11 Support -COMPILER_FLAGS += -std=c++11 - -# product configuration -BIN_NAME = $(PROJECT)-$(PRODUCT) -DBG = false - -# Include the generic make file -include $(COMMON_MAKE_PATH)/Make.generic \ No newline at end of file diff --git a/silecs-cli-client/Makefile.dep b/silecs-cli-client/Makefile.dep deleted file mode 100644 index cc1f7e8..0000000 --- a/silecs-cli-client/Makefile.dep +++ /dev/null @@ -1,23 +0,0 @@ -BOOST_VERSION ?= 1.54.0 -SILECS_COMM_VERSION = 1.0.2 - -BOOST_HOME ?= /acc/local/$(CPU)/3rdparty/boost/$(BOOST_VERSION) - -SILECS_COMM_HOME ?= ../silecs-communication-cpp/build - -LIBXML_PATH ?= /usr/include/libxml2/ - -GSI_SILECS_BASE = /common/usr/cscofe/silecs -SNAP7_BASE ?= $(GSI_SILECS_BASE)/snap7/latest - -DEPENDENT_COMPILER_OPTIONS += -I$(SILECS_COMM_HOME)/include -DEPENDENT_COMPILER_OPTIONS += -I$(LIBXML_PATH) -DEPENDENT_COMPILER_OPTIONS += -I$(BOOST_HOME)/include - -DEPENDENT_LINKER_OPTIONS += -L$(SNAP7_BASE)/lib/$(CPU)-linux -lsnap7 -DEPENDENT_LINKER_OPTIONS += -L/usr/lib64 -lxml2 -DEPENDENT_LINKER_OPTIONS += -L$(SILECS_COMM_HOME)/lib/$(CPU) -lsilecs-comm -DEPENDENT_LINKER_OPTIONS += -lstdc++ -lxml2 -lboost_system -lboost_filesystem -lcurl - -# Set default library search path -DEPENDENT_LINKER_OPTIONS += -Wl,-rpath=$(SNAP7_BASE)/lib/$(CPU)-linux diff --git a/silecs-cli-client/install.sh b/silecs-cli-client/install.sh deleted file mode 100755 index 7ca8927..0000000 --- a/silecs-cli-client/install.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -set -e - -RELEASE_DIR_BASE=$1 -SILECS_VERSION=$2 - -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in - -RELEASE_DIR=${RELEASE_DIR_BASE}/${SILECS_VERSION}/silecs-cli-client -if [ -d ${RELEASE_DIR} ]; then - echo "Error: ${RELEASE_DIR} already exists ...skipping" - exit 1 -fi - -make -C ${SCRIPTPATH} clean -make -C ${SCRIPTPATH} CPU=x86_64 MAJOR=${MAJOR} MINOR=${MINOR} PATCH=${PATCH} -j4 - -mkdir -p ${RELEASE_DIR} -cp -r ${SCRIPTPATH}/build/bin ${RELEASE_DIR} -cp -r ${SCRIPTPATH}/examples ${RELEASE_DIR} - -# Make all files write-protected to prevent overwriting an old version by accident -chmod a-w -R ${RELEASE_DIR} \ No newline at end of file diff --git a/silecs-codegen/CMakeLists.txt b/silecs-codegen/CMakeLists.txt new file mode 100644 index 0000000..0e16a68 --- /dev/null +++ b/silecs-codegen/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.20.2) + +project(silecs-codegen) + +find_package(Python COMPONENTS Interpreter) + +add_test (NAME codegen-tests + COMMAND ${Python_EXECUTABLE} -m unittest + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/xml/ +) + +install ( + DIRECTORY ${PROJECT_SOURCE_DIR}/src/xml + DESTINATION ${CMAKE_PROJECT_VERSION}/${PROJECT_NAME} + FILES_MATCHING PATTERN "*.py*") diff --git a/silecs-codegen/install.sh b/silecs-codegen/install.sh deleted file mode 100755 index 4ca3e4a..0000000 --- a/silecs-codegen/install.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -set -e - -RELEASE_DIR_BASE=$1 -SILECS_VERSION=$2 - -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in - -RELEASE_DIR=${RELEASE_DIR_BASE}/${SILECS_VERSION}/silecs-codegen -if [ -d ${RELEASE_DIR} ]; then - echo "Error: ${RELEASE_DIR} already exists ...skipping" - exit 1 -fi - -cd ${SCRIPTPATH}/src/xml - -python3 -m unittest - -mkdir -p ${RELEASE_DIR} - -cp -r ${SCRIPTPATH}/src/xml ${RELEASE_DIR} - -# Make all files write-protected to prevent overwriting an old version by accident -chmod a-w -R ${RELEASE_DIR} \ No newline at end of file diff --git a/silecs-communication-cpp/CMakeLists.txt b/silecs-communication-cpp/CMakeLists.txt new file mode 100644 index 0000000..42c5017 --- /dev/null +++ b/silecs-communication-cpp/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.20.2) + +project(silecs-comm LANGUAGES CXX) + +# NI support is not supported at GSI yet. +# option(NI_SUPPORT_ENABLED "Enable NI support." OFF) +option(MODBUS_SUPPORT_ENABLED "Enable Modbus support." ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_compile_options(-Wall -Wextra) + +find_package(LibXml2 REQUIRED) + +file(GLOB_RECURSE COMM_SOURCES ${PROJECT_SOURCE_DIR}/src/silecs-communication/*.cpp) + +add_library(${PROJECT_NAME} STATIC ${COMM_SOURCES}) + +target_compile_definitions(${PROJECT_NAME} + PRIVATE + MAJOR=${CMAKE_PROJECT_VERSION_MAJOR} + MINOR=${CMAKE_PROJECT_VERSION_MINOR} + PATCH=${CMAKE_PROJECT_VERSION_PATCH}) + +if (NI_SUPPORT_ENABLED) + add_definitions(-DNI_SUPPORT_ENABLED) +endif() + +if (MODBUS_SUPPORT_ENABLED) + add_definitions(-DMODBUS_SUPPORT_ENABLED) + target_include_directories(${PROJECT_NAME} + PRIVATE ${GSI_SILECS_PATH}/modbus/latest/include/ + ) +endif() + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${PROJECT_SOURCE_DIR}/src + LibXml2::LibXml2 + PRIVATE + ${GSI_SILECS_PATH}/snap7/latest/include/ +) + +target_link_directories(${PROJECT_NAME} + PUBLIC + ${GSI_SILECS_PATH}/snap7/latest/${BUILD_TARGET}-linux/lib/ + ${GSI_SILECS_PATH}/modbus/latest/${BUILD_TARGET}-linux/lib/ +) + +target_link_libraries(${PROJECT_NAME} libmodbus.a) +target_link_libraries(${PROJECT_NAME} LibXml2::LibXml2 snap7) + +install ( + TARGETS ${PROJECT_NAME} + DESTINATION ${CMAKE_PROJECT_VERSION}/silecs-communication-cpp/lib/${BUILD_TARGET} +) + +install ( + DIRECTORY ${PROJECT_SOURCE_DIR}/src/ + DESTINATION ${CMAKE_PROJECT_VERSION}/silecs-communication-cpp/include + FILES_MATCHING PATTERN "*.h*" +) diff --git a/silecs-communication-cpp/Makefile b/silecs-communication-cpp/Makefile deleted file mode 100644 index 3cd818f..0000000 --- a/silecs-communication-cpp/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2016 CERN and GSI -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -PROJECT = silecs -PRODUCT = communication -VERSION = 0.0.0 - -SKIP_MANIFEST = TRUE -#local -#COMMON_MAKE_PATH ?= /common/home/bel/schwinn/lnx/workspace-silecs-neon/generic-makefiles -#global -COMMON_MAKE_PATH ?= /opt/cern/buildsystem/generic/2.13.2 - -# product configuration -LIB_NAME = comm -DBG = true - -#COMPILER_FLAGS = -Os -fno-strict-aliasing -fexceptions -DLINUX -DARM_FIX -DDAVE_LITTLE_ENDIAN -D_GNU_SOURCE -DMAJOR=$(MAJOR) -DMINOR=$(MINOR) -DPATCH=$(PATCH) - -# The default, used for DEV, overwrite for productive releases -MAJOR ?= 0 -MINOR ?= 0 -PATCH ?= 0 -COMPILER_FLAGS = -DMAJOR=$(MAJOR) -DMINOR=$(MINOR) -DPATCH=$(PATCH) - -#Enable C++11 Support -COMPILER_FLAGS += -std=c++11 -Wall -Wextra - -ifdef NI_SUPPORT_ENABLED -COMPILER_FLAGS += -DNI_SUPPORT_ENABLED=TRUE -$(info --- Build with NI support: enabled) -else -$(info --- Build with NI support: disabled) -endif - -ifdef MODBUS_SUPPORT_ENABLED -COMPILER_FLAGS += -DMODBUS_SUPPORT_ENABLED=TRUE -$(info --- Build with modbus support: enabled) -else -$(info --- Build with modbus support: disabled) -endif - -# Include the generic make file -include $(COMMON_MAKE_PATH)/Make.generic diff --git a/silecs-communication-cpp/Makefile.dep b/silecs-communication-cpp/Makefile.dep deleted file mode 100644 index 2f09178..0000000 --- a/silecs-communication-cpp/Makefile.dep +++ /dev/null @@ -1,16 +0,0 @@ -BOOST_VERSION ?= 1.54.0 - -GSI_SILECS_BASE = /common/usr/cscofe/silecs - -LIBXML_PATH ?= /usr/include/libxml2/ -SNAP7_BASE ?= $(GSI_SILECS_BASE)/snap7/latest -BOOST_HOME ?= /opt/gsi/3rdparty/boost/$(BOOST_VERSION) - -ifdef MODBUS_SUPPORT_ENABLED - MODBUS_BASE=$(GSI_SILECS_BASE)/modbus/latest - DEPENDENT_COMPILER_OPTIONS += -I$(MODBUS_BASE)/include -endif - -DEPENDENT_COMPILER_OPTIONS += -I$(LIBXML_PATH) -DEPENDENT_COMPILER_OPTIONS += -I$(SNAP7_BASE)/include -DEPENDENT_COMPILER_OPTIONS += -I$(BOOST_HOME)/include \ No newline at end of file diff --git a/silecs-communication-cpp/install.sh b/silecs-communication-cpp/install.sh deleted file mode 100755 index 0e31cea..0000000 --- a/silecs-communication-cpp/install.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -set -e - -RELEASE_DIR_BASE=$1 -SILECS_VERSION=$2 - -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in - -CPU=x86_64 - -RELEASE_DIR=${RELEASE_DIR_BASE}/${SILECS_VERSION}/silecs-communication-cpp -if [ -d ${RELEASE_DIR} ]; then - echo "Error: ${RELEASE_DIR} already exists ...skipping" - exit 1 -fi - -MAJOR=`echo $SILECS_VERSION | cut -d. -f1` -MINOR=`echo $SILECS_VERSION | cut -d. -f2` -PATCH=`echo $SILECS_VERSION | cut -d. -f3` - -make -C ${SCRIPTPATH} clean -MODBUS_SUPPORT_ENABLED=true make -C ${SCRIPTPATH} CPU=${CPU} MAJOR=${MAJOR} MINOR=${MINOR} PATCH=${PATCH} -j4 - -# Squash the silecs library with the modbus library, so no extra-lining will be required -SILECS_LIB=${SCRIPTPATH}/build/lib/${CPU}/libsilecs-comm.a -SQUASHED_LIB=${SCRIPTPATH}/build/lib/${CPU}/libsquashed.a -cd ${SCRIPTPATH} -ar -M <squash_modbus_lib.mri -rm ${SILECS_LIB} -mv ${SQUASHED_LIB} ${SILECS_LIB} - -mkdir -p ${RELEASE_DIR} -cp -r ${SCRIPTPATH}/build/include ${RELEASE_DIR} -cp -r ${SCRIPTPATH}/build/lib ${RELEASE_DIR} - -# Make all files write-protected to prevent overwriting an old version by accident -chmod a-w -R ${RELEASE_DIR} \ No newline at end of file diff --git a/silecs-communication-cpp/make-ctb.py b/silecs-communication-cpp/make-ctb.py deleted file mode 100644 index a93fdae..0000000 --- a/silecs-communication-cpp/make-ctb.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python - -import os -import sys - -depVersion = 'SILECS_MAKEFILE_VERSION=DEV RDA_VERSION=DEV' -ctbPaths = 'RELEASE_LOCATION=/local/RELEASE_LOCATION' -makeFlags = ' RELEASE_GROUP=si ' + depVersion + ' ' + ctbPaths - -# compile first as we can't use -j in local-devrelease -cmd = 'make -j4' + makeFlags -rc = os.system(cmd + ' CPU=L865') -if(rc != 0): - sys.exit(-1) - -rc = os.system(cmd + ' CPU=L866') -if(rc != 0): - sys.exit(-1) - -# now release ========================================== -cmd = 'make local-devrelease' + makeFlags + ' TMP_DIR=.' -rc = os.system(cmd + ' CPU=L865') -if(rc != 0): - sys.exit(-1) - -rc = os.system(cmd + ' CPU=L866') -if(rc != 0): - sys.exit(-1) - \ No newline at end of file diff --git a/silecs-communication-cpp/squash_modbus_lib.mri b/silecs-communication-cpp/squash_modbus_lib.mri deleted file mode 100644 index 68d0d6d..0000000 --- a/silecs-communication-cpp/squash_modbus_lib.mri +++ /dev/null @@ -1,5 +0,0 @@ -create build/lib/x86_64/libsquashed.a -addlib build/lib/x86_64/libsilecs-comm.a -addlib /common/usr/cscofe/silecs/modbus/latest/lib/libmodbus.a -save -end diff --git a/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsLog.cpp b/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsLog.cpp index bdd994c..aeb1723 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsLog.cpp +++ b/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsLog.cpp @@ -51,7 +51,7 @@ Log::~Log() if (topic_ & systopics_) //this topic is enabled for syslog output - syslog(LOG_INFO, os.str().c_str()); + syslog(LOG_INFO, "%s", os.str().c_str()); } bool Log::getTopicsFromString(const std::string& topicArgv) diff --git a/silecs-diagnostic-cpp/CMakeLists.txt b/silecs-diagnostic-cpp/CMakeLists.txt new file mode 100644 index 0000000..ac90668 --- /dev/null +++ b/silecs-diagnostic-cpp/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 3.20.2) + +project(silecs-diagnostic LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# TODO: Which of these compiler options are actually required? +add_compile_options( + -Wall + -Wextra + -D_REENTRANT + -DQT_NO_DEBUG_OUTPUT + -DQT_NO_WARNING_OUTPUT + -DQT_NO_DEBUG + -DQT_GUI_LIB + -DQT_CORE_LIB + -DQT_SHARED + -DQT_WIDGETS_LIB + -Wp,-D_FORTIFY_SOURCE=2 + -fstack-protector + --param=ssp-buffer-size=4 + -mtune=generic) + +find_package(Qt5 COMPONENTS Widgets Core REQUIRED) + +file(GLOB_RECURSE SOURCES ${PROJECT_SOURCE_DIR}/src/silecs-diagnostic/*.cpp) + +add_executable(${PROJECT_NAME} + ${SOURCES} + src/silecs-diagnostic/resources/images.qrc + src/silecs-diagnostic/resources/gui/diagnostictoolmainview.ui + src/silecs-diagnostic/resources/gui/displayarraydialog.ui + src/silecs-diagnostic/resources/gui/logindialog.ui +) + +target_include_directories(${PROJECT_NAME} + PRIVATE + ${PROJECT_SOURCE_DIR}/src +) + +target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Core silecs-comm) + +install( + TARGETS ${PROJECT_NAME} + DESTINATION ${CMAKE_PROJECT_VERSION}/silecs-diagnostic-cpp/bin/${BUILD_TARGET} +) + +install( + DIRECTORY ${PROJECT_SOURCE_DIR}/src/silecs-diagnostic/resources + DESTINATION ${CMAKE_PROJECT_VERSION}/silecs-diagnostic-cpp/ +) diff --git a/silecs-diagnostic-cpp/Makefile b/silecs-diagnostic-cpp/Makefile deleted file mode 100644 index cab49fc..0000000 --- a/silecs-diagnostic-cpp/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2016 CERN and GSI -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -PROJECT = silecs -PRODUCT = diagnostic -VERSION = 0.0.0 - -SKIP_MANIFEST = TRUE -#local -#COMMON_MAKE_PATH ?= /common/home/bel/schwinn/lnx/workspace-silecs-neon/generic-makefiles -#global -COMMON_MAKE_PATH ?= /opt/cern/buildsystem/generic/2.13.2 - -# product configuration -BIN_NAME = $(PROJECT)-$(PRODUCT) -DBG = false - -#DEFINES = -DWITH_RBAC -D_REENTRANT -DQT_NO_DEBUG_OUTPUT -DQT_NO_WARNING_OUTPUT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -DEFINES = -D_REENTRANT -DQT_NO_DEBUG_OUTPUT -DQT_NO_WARNING_OUTPUT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -DQT_WIDGETS_LIB -COMPILER_FLAGS = -O2 -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -mtune=generic $(DEFINES) - -#Enable C++11 Support -COMPILER_FLAGS += -std=c++11 - -LINKER_FLAGS = -Wl,-O1 - -# list Qt generated files -EXTRA_HEADERS = generated/ui_diagnostictoolmainview.h\ - generated/ui_displayarraydialog.h\ - generated/ui_logindialog.h - -EXTRA_SRCS = generated/qrc_images.cpp\ - generated/moc_diagnostictoolmainview.cpp\ - generated/moc_displayarraydialog.cpp\ - generated/moc_logindialog.cpp\ - generated/moc_stderrredirect.cpp - -# Include the generic make file -include $(COMMON_MAKE_PATH)/Make.generic - -QT_RCC = /usr/bin/rcc-qt5 -QT_UIC = /usr/bin/uic-qt5 -QT_MOC = /usr/bin/moc-qt5 - -# rules to generate Qt files -before_compile:: - $(QT_RCC) -name images src/silecs-diagnostic/resources/images.qrc -o src/silecs-diagnostic/generated/qrc_images.cpp - - $(QT_UIC) src/silecs-diagnostic/resources/gui/diagnostictoolmainview.ui -o src/silecs-diagnostic/generated/ui_diagnostictoolmainview.h - $(QT_UIC) src/silecs-diagnostic/resources/gui/displayarraydialog.ui -o src/silecs-diagnostic/generated/ui_displayarraydialog.h - $(QT_UIC) src/silecs-diagnostic/resources/gui/logindialog.ui -o src/silecs-diagnostic/generated/ui_logindialog.h - - $(QT_MOC) $(DEFINES) src/silecs-diagnostic/diagnostictoolmainview.h -o src/silecs-diagnostic/generated/moc_diagnostictoolmainview.cpp - $(QT_MOC) $(DEFINES) src/silecs-diagnostic/displayarraydialog.h -o src/silecs-diagnostic/generated/moc_displayarraydialog.cpp - $(QT_MOC) $(DEFINES) src/silecs-diagnostic/logindialog.h -o src/silecs-diagnostic/generated/moc_logindialog.cpp - $(QT_MOC) $(DEFINES) src/silecs-diagnostic/stderrredirect.h -o src/silecs-diagnostic/generated/moc_stderrredirect.cpp - -after_clean:: - rm -f src/silecs-diagnostic/generated/* \ No newline at end of file diff --git a/silecs-diagnostic-cpp/Makefile.dep b/silecs-diagnostic-cpp/Makefile.dep deleted file mode 100644 index f85df3e..0000000 --- a/silecs-diagnostic-cpp/Makefile.dep +++ /dev/null @@ -1,34 +0,0 @@ -CPU ?=x86_64 -BOOST_VERSION ?= 1.54.0 -RBAC_VERSION ?= 6.1.0 -SILECS_COMM_VERSION = 1.0.2 - -BOOST_HOME ?= /acc/local/$(CPU)/3rdparty/boost/$(BOOST_VERSION) -RBACK_HOME ?= /acc/local/$(CPU)/cmw/cmw-rbac/$(RBAC_VERSION) - -GSI_SILECS_BASE = /common/usr/cscofe/silecs - -SILECS_COMM_HOME ?= ../silecs-communication-cpp/build - -LIBXML_PATH ?= /usr/include/libxml2/ - -SNAP7_BASE ?= $(GSI_SILECS_BASE)/snap7/latest - -DEPENDENT_COMPILER_OPTIONS += -I$(RBACK_HOME)/include -DEPENDENT_COMPILER_OPTIONS += -I$(SILECS_COMM_HOME)/include -DEPENDENT_COMPILER_OPTIONS += -I$(LIBXML_PATH) -DEPENDENT_COMPILER_OPTIONS += -I$(BOOST_HOME)/include -DEPENDENT_COMPILER_OPTIONS += -I/usr/lib64/qt5/mkspecs/linux-g++-64 -DEPENDENT_COMPILER_OPTIONS += -isystem/usr/include/qt5 - -DEPENDENT_LINKER_OPTIONS += -L$(RBACK_HOME)/lib -DEPENDENT_LINKER_OPTIONS += -L$(SILECS_COMM_HOME)/lib/$(CPU) -DEPENDENT_LINKER_OPTIONS += -L$(SNAP7_BASE)/lib/$(CPU)-linux -lsnap7 -DEPENDENT_LINKER_OPTIONS += -L$(BOOST_HOME)/lib/$(CPU) -DEPENDENT_LINKER_OPTIONS += -L/lib64 -lxml2 -DEPENDENT_LINKER_OPTIONS += -lsilecs-comm -DEPENDENT_LINKER_OPTIONS += -lstdc++ -lxml2 -lboost_system -lboost_filesystem -lcurl -lQt5Gui -lQt5Core -lQt5Widgets - -# Specify default search path for snyp7 library -DEPENDENT_LINKER_OPTIONS += -Wl,-rpath=$(SNAP7_BASE)/lib/$(CPU)-linux - diff --git a/silecs-diagnostic-cpp/install.sh b/silecs-diagnostic-cpp/install.sh deleted file mode 100755 index 2678c29..0000000 --- a/silecs-diagnostic-cpp/install.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -set -e - -RELEASE_DIR_BASE=$1 -SILECS_VERSION=$2 - -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in - -RELEASE_DIR=${RELEASE_DIR_BASE}/${SILECS_VERSION}/silecs-diagnostic-cpp -if [ -d ${RELEASE_DIR} ]; then - echo "Error: ${RELEASE_DIR} already exists ...skipping" - exit 1 -fi - -make -C ${SCRIPTPATH} clean -make -C ${SCRIPTPATH} CPU=x86_64 -j1 - -mkdir -p ${RELEASE_DIR} -cp -r ${SCRIPTPATH}/build/bin ${RELEASE_DIR} -cp -r ${SCRIPTPATH}/build/resources ${RELEASE_DIR} - -# Make all files write-protected to prevent overwriting an old version by accident -chmod a-w -R ${RELEASE_DIR} diff --git a/silecs-model/CMakeLists.txt b/silecs-model/CMakeLists.txt new file mode 100644 index 0000000..fa0d6de --- /dev/null +++ b/silecs-model/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.20.2) + +project(silecs-model) + +install ( + DIRECTORY src/xml + DESTINATION ${CMAKE_PROJECT_VERSION}/${PROJECT_NAME} + FILES_MATCHING PATTERN "*.xsd*") diff --git a/silecs-model/install.sh b/silecs-model/install.sh deleted file mode 100755 index a148cac..0000000 --- a/silecs-model/install.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -set -e - -RELEASE_DIR_BASE=$1 -SILECS_VERSION=$2 - -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in - -RELEASE_DIR=${RELEASE_DIR_BASE}/${SILECS_VERSION}/silecs-model -if [ -d ${RELEASE_DIR} ]; then - echo "Error: ${RELEASE_DIR} already exists ...skipping" - exit 1 -fi - -mkdir -p ${RELEASE_DIR} -cp -r ${SCRIPTPATH}/src/xml ${RELEASE_DIR} - -# Make all files write-protected to prevent overwriting an old version by accident -chmod a-w -R ${RELEASE_DIR} \ No newline at end of file diff --git a/silecs_cli/CMakeLists.txt b/silecs_cli/CMakeLists.txt new file mode 100644 index 0000000..22fe16b --- /dev/null +++ b/silecs_cli/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.20.2) + +project(silecs-cli) + +find_package(Python COMPONENTS Interpreter) + +add_test (NAME cli-tests + COMMAND ${Python_EXECUTABLE} -m unittest + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/ +) + +install ( + FILES silecs.py silecs_env.py silecs_const.py silecs_utils.py + DESTINATION ${CMAKE_PROJECT_VERSION}/${PROJECT_NAME} +) + +install( + FILES scripts/silecs + DESTINATION ${CMAKE_PROJECT_VERSION}/${PROJECT_NAME} + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE +) + diff --git a/silecs_cli/install.sh b/silecs_cli/install.sh deleted file mode 100755 index 31aa223..0000000 --- a/silecs_cli/install.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -set -e - -RELEASE_DIR_BASE=$1 -SILECS_VERSION=$2 - -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in - -RELEASE_DIR=${RELEASE_DIR_BASE}/${SILECS_VERSION}/silecs-cli -if [ -d ${RELEASE_DIR} ]; then - echo "Error: ${RELEASE_DIR} already exists ...skipping" - exit 1 -fi - -cd ${SCRIPTPATH} - -python3 -m unittest - -mkdir -p ${RELEASE_DIR} - -DEST_FILE=${RELEASE_DIR}/silecs.py -ENV_FILE=${RELEASE_DIR}/silecs_env.py -CONST_FILE=${RELEASE_DIR}/silecs_const.py -UTILS_FILE=${RELEASE_DIR}/silecs_utils.py -DEST_FILE_SCRIPT=${RELEASE_DIR}/silecs - -cp -r ${SCRIPTPATH}/silecs.py ${DEST_FILE} -cp -r ${SCRIPTPATH}/silecs_env.py ${ENV_FILE} -cp -r ${SCRIPTPATH}/silecs_const.py ${CONST_FILE} -cp -r ${SCRIPTPATH}/silecs_utils.py ${UTILS_FILE} -cp -r ${SCRIPTPATH}/scripts/silecs ${DEST_FILE_SCRIPT} - -# Make all files write-protected to prevent overwriting an old version by accident -chmod a-w -R ${RELEASE_DIR} diff --git a/silecs_cli/silecs.py b/silecs_cli/silecs.py index b5f33fc..0b2c566 100644 --- a/silecs_cli/silecs.py +++ b/silecs_cli/silecs.py @@ -310,8 +310,7 @@ class SilecsCli: elif extension == silecs_const.SILECSDEPLOY: self.generate_silecsdeploy(silecs_filepath, project_path) # Snap7 path is one folder up from the silecs release path. - makefile = silecs_utils.get_silecs_deploy_makefile_template( - self.silecs_env.SILECS_BASE, os.path.dirname(self.silecs_env.SILECS_BASE)) + makefile = silecs_utils.get_silecs_deploy_makefile_template(self.silecs_env.SILECS_BASE) with open(makefile_path, 'w') as fp: fp.write(makefile) diff --git a/silecs_cli/silecs_utils.py b/silecs_cli/silecs_utils.py index 4f1f392..6f956b6 100644 --- a/silecs_cli/silecs_utils.py +++ b/silecs_cli/silecs_utils.py @@ -167,14 +167,16 @@ SILECS_BASE ?= {silecs_base} COMPILER_FLAGS += -I$(SILECS_BASE)/silecs-communication-cpp/include """ -def get_silecs_deploy_makefile_template(silecs_base, snap7_base): +def get_silecs_deploy_makefile_template(silecs_base): return f"""# This Makefile is auto-generated with SILECS generation tools. # It should be included in the project's Makefile.specific by the user by adding the line 'include Makefile.silecs'. SILECS_BASE ?= {silecs_base} -SNAP7_BASE ?= {snap7_base} +SNAP7_BASE ?= /common/usr/cscofe/silecs +MODBUS_BASE ?= /common/usr/cscofe/silecs LINKER_FLAGS += -L$(SILECS_BASE)/silecs-communication-cpp/lib/$(CPU) -lsilecs-comm -LINKER_FLAGS += -L$(SNAP7_BASE)/snap7/latest/lib/$(CPU)-linux -lsnap7 +LINKER_FLAGS += -L$(SNAP7_BASE)/snap7/latest/$(CPU)-linux/lib -lsnap7 +LINKER_FLAGS += -L$(MODBUS_BASE)/modbus/latest/$(CPU)-linux/lib -l:libmodbus.a #add default search path for dynamic snap7 library LINKER_FLAGS += -Wl,-rpath,$(SNAP7_BASE)/snap7/latest/lib/$(CPU)-linux,-rpath,/usr/lib -- GitLab