Merge branch 'master' into configfilewriteable
This commit is contained in:
commit
fed6d251be
@ -1,49 +1,95 @@
|
|||||||
image: luki42/dynuiprefresher_build:latest
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- cmake
|
- cmake
|
||||||
- build
|
- build
|
||||||
- build_package
|
- post
|
||||||
- test
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- build/
|
|
||||||
- src/
|
|
||||||
- inc/
|
|
||||||
- tests/
|
|
||||||
- postinst
|
|
||||||
|
|
||||||
|
# Unix Build
|
||||||
cmake:
|
cmake:
|
||||||
stage: cmake
|
stage: cmake
|
||||||
|
image: luki42/dynuiprefresher_build:latest
|
||||||
script:
|
script:
|
||||||
- cmake -S . -B build
|
- cmake -S . -B build
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- build/
|
||||||
|
- inc/
|
||||||
|
- postinst
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
image: luki42/dynuiprefresher_build:latest
|
||||||
script:
|
script:
|
||||||
- cd build
|
- cd build
|
||||||
- make
|
- make iprefresher
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- "build/bin/*"
|
- build/
|
||||||
|
- inc/
|
||||||
|
- postinst
|
||||||
|
dependencies:
|
||||||
|
- cmake
|
||||||
|
|
||||||
|
|
||||||
build_package:
|
build_package:
|
||||||
stage: build_package
|
stage: post
|
||||||
|
image: luki42/dynuiprefresher_build:latest
|
||||||
script:
|
script:
|
||||||
- cd build
|
- cd build
|
||||||
- make package
|
- make package
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- "build/packages/*"
|
- build/
|
||||||
|
- inc/
|
||||||
|
- postinst
|
||||||
|
dependencies:
|
||||||
|
- build
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: post
|
||||||
|
image: luki42/dynuiprefresher_build:latest
|
||||||
script:
|
script:
|
||||||
- cd build
|
- cd build
|
||||||
- make test
|
- make build-test
|
||||||
- make build-xml
|
|
||||||
artifacts:
|
artifacts:
|
||||||
reports:
|
reports:
|
||||||
junit: build/report.xml
|
junit: build/*.xml
|
||||||
|
dependencies:
|
||||||
|
- build
|
||||||
|
|
||||||
|
# Windows Build
|
||||||
|
cmake_win64:
|
||||||
|
stage: cmake
|
||||||
|
image: luki42/dynuiprefresher_build:windows
|
||||||
|
script:
|
||||||
|
- cmake -S . -B build -D WinBuild=ON
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- build/
|
||||||
|
- inc/
|
||||||
|
|
||||||
|
build_win64:
|
||||||
|
stage: build
|
||||||
|
image: luki42/dynuiprefresher_build:windows
|
||||||
|
script:
|
||||||
|
- cd build
|
||||||
|
- make iprefresher
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- build/
|
||||||
|
- inc/
|
||||||
|
dependencies:
|
||||||
|
- cmake_win64
|
||||||
|
|
||||||
|
|
||||||
|
build_package_win64:
|
||||||
|
stage: post
|
||||||
|
image: luki42/dynuiprefresher_build:windows
|
||||||
|
script:
|
||||||
|
- cd build
|
||||||
|
- make package
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- build/
|
||||||
|
- inc/
|
||||||
|
dependencies:
|
||||||
|
- build_win64
|
@ -9,7 +9,7 @@
|
|||||||
# for test build gtest needs to be installed.
|
# for test build gtest needs to be installed.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(iprefresher DESCRIPTION "Dynu ip refresher")
|
project(iprefresher DESCRIPTION "Dynu ip refresher" LANGUAGES)
|
||||||
SET(PROJECT_VERSION 1.3.3)
|
SET(PROJECT_VERSION 1.3.3)
|
||||||
|
|
||||||
# CONFIGURATION
|
# CONFIGURATION
|
||||||
@ -18,8 +18,8 @@ SET(LIB_METHOD STATIC) #SHARED / STATIC
|
|||||||
|
|
||||||
option(BUILD_DOC "Build documentation" ON) # additional dependency for Doxygen
|
option(BUILD_DOC "Build documentation" ON) # additional dependency for Doxygen
|
||||||
option(PACKAGING "Allow Packaging to <exe>, <deb> or <rpm>" ON) # additional dependencies for RPMbuild,dpkg or NSIS
|
option(PACKAGING "Allow Packaging to <exe>, <deb> or <rpm>" ON) # additional dependencies for RPMbuild,dpkg or NSIS
|
||||||
option(TESTS "Build Tests" false) # additional dependencies for GTEST - to build tests
|
option(TESTS "Build Tests" ON) # additional dependencies for GTEST - to build tests
|
||||||
set(WinBuild false)
|
option(WinBuild "cross compile for Windows Platform" OFF)
|
||||||
|
|
||||||
# helper variables
|
# helper variables
|
||||||
SET(CMAKE_CXX_STANDARD 17)
|
SET(CMAKE_CXX_STANDARD 17)
|
||||||
@ -31,6 +31,7 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|||||||
|
|
||||||
# setup winbuild compilers
|
# setup winbuild compilers
|
||||||
if (${WinBuild})
|
if (${WinBuild})
|
||||||
|
message(STATUS "setup Mingw Toolchain for cross compile.")
|
||||||
set(LIBSUFFIX .dll)
|
set(LIBSUFFIX .dll)
|
||||||
set(SUFFIX .exe)
|
set(SUFFIX .exe)
|
||||||
|
|
||||||
@ -40,9 +41,9 @@ if (${WinBuild})
|
|||||||
#set(TOOLCHAIN_PREFIX i686-w64-mingw32)
|
#set(TOOLCHAIN_PREFIX i686-w64-mingw32)
|
||||||
|
|
||||||
# cross compilers to use for C and C++
|
# cross compilers to use for C and C++
|
||||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
|
set(CMAKE_C_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-gcc)
|
||||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
set(CMAKE_CXX_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-g++)
|
||||||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
set(CMAKE_RC_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-windres)
|
||||||
|
|
||||||
# target environment on the build host system
|
# target environment on the build host system
|
||||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||||
@ -67,6 +68,7 @@ if (${WinBuild})
|
|||||||
# windows config path is same as executable
|
# windows config path is same as executable
|
||||||
set(CONFIG_PATH "std::string(std::getenv(\"USERPROFILE\")) + \"\\\\AppData\\\\Roaming\\\\DynuIPrefresher\\\\\"")
|
set(CONFIG_PATH "std::string(std::getenv(\"USERPROFILE\")) + \"\\\\AppData\\\\Roaming\\\\DynuIPrefresher\\\\\"")
|
||||||
else ()
|
else ()
|
||||||
|
message(STATUS "using nativ gcc toolchain.")
|
||||||
set(LIBSUFFIX .so)
|
set(LIBSUFFIX .so)
|
||||||
set(SUFFIX "")
|
set(SUFFIX "")
|
||||||
|
|
||||||
@ -74,8 +76,16 @@ else ()
|
|||||||
set(CONFIG_PATH "\"/etc/\"")
|
set(CONFIG_PATH "\"/etc/\"")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
# test compiler settings and enable languages here
|
||||||
|
message("")
|
||||||
|
message(STATUS "Testing the C++ compiler!")
|
||||||
|
enable_language(CXX)
|
||||||
|
message("")
|
||||||
|
message(STATUS "Testing the C compiler!")
|
||||||
|
enable_language(C)
|
||||||
|
|
||||||
# config libs
|
# config libs
|
||||||
|
message("")
|
||||||
message(STATUS "Config of Libraries")
|
message(STATUS "Config of Libraries")
|
||||||
# libcurl
|
# libcurl
|
||||||
if (${WinBuild})
|
if (${WinBuild})
|
||||||
@ -230,8 +240,10 @@ if (${PACKAGING})
|
|||||||
if [ ! -f ${CONFIG_PATH} ]; then
|
if [ ! -f ${CONFIG_PATH} ]; then
|
||||||
cat > ${CONFIG_PATH} <<- EOM
|
cat > ${CONFIG_PATH} <<- EOM
|
||||||
${SAMPLECONFIG}EOM
|
${SAMPLECONFIG}EOM
|
||||||
fi\n"
|
fi
|
||||||
)
|
|
||||||
|
systemctl enable iprefresher.service
|
||||||
|
systemctl start iprefresher.service")
|
||||||
|
|
||||||
|
|
||||||
SET(CPACK_DEB_COMPONENT_INSTALL 1)
|
SET(CPACK_DEB_COMPONENT_INSTALL 1)
|
||||||
@ -315,7 +327,10 @@ endif (BUILD_DOC)
|
|||||||
|
|
||||||
# Test Cases
|
# Test Cases
|
||||||
if (TESTS)
|
if (TESTS)
|
||||||
include(GoogleTest)
|
# include(GoogleTest)
|
||||||
|
message(STATUS "Configuring GTEST")
|
||||||
|
find_package(GTest)
|
||||||
|
if (GTEST_FOUND)
|
||||||
|
|
||||||
mark_as_advanced(
|
mark_as_advanced(
|
||||||
BUILD_GMOCK BUILD_GTEST BUILD_SHARED_LIBS
|
BUILD_GMOCK BUILD_GTEST BUILD_SHARED_LIBS
|
||||||
@ -331,23 +346,21 @@ if (TESTS)
|
|||||||
# link the Google test infrastructure, mocking library, and a default main fuction to
|
# link the Google test infrastructure, mocking library, and a default main fuction to
|
||||||
target_link_libraries(${TESTNAME} gtest gtest_main -lpthread -lm dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
|
target_link_libraries(${TESTNAME} gtest gtest_main -lpthread -lm dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
|
||||||
# see https://cmake.org/cmake/help/v3.10/module/GoogleTest.html for more options to pass to it
|
# see https://cmake.org/cmake/help/v3.10/module/GoogleTest.html for more options to pass to it
|
||||||
gtest_discover_tests(${TESTNAME}
|
gtest_discover_tests(${TESTNAME})
|
||||||
WORKING_DIRECTORY ${PROJECT_DIR}
|
|
||||||
EXTRA_ARGS --gtest_output=xml:report.xml -VV
|
add_custom_command(TARGET build-test
|
||||||
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_DIR}"
|
POST_BUILD
|
||||||
)
|
COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target ${TESTNAME}
|
||||||
set_target_properties(${TESTNAME} PROPERTIES FOLDER tests)
|
COMMAND "bin/${TESTNAME}" --gtest_output=xml:${TESTNAME}-report.xml)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
add_custom_target(build-test
|
||||||
|
DEPENDS ${PROJECT_NAME}
|
||||||
|
COMMENT "Testing ${PROJECT_NAME}")
|
||||||
|
|
||||||
package_add_test(test1 tests/UnitTest.cpp ${SOURCE})
|
package_add_test(test1 tests/UnitTest.cpp ${SOURCE})
|
||||||
|
|
||||||
add_custom_target(build-test
|
else ()
|
||||||
"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target test
|
message(STATUS "GTEST environment not found!")
|
||||||
DEPENDS ${PROJECT_NAME}
|
endif ()
|
||||||
COMMENT "Packing ${PROJECT_NAME}")
|
|
||||||
|
|
||||||
add_custom_target(build-xml
|
|
||||||
"bin/test1" --gtest_output="xml:report.xml"
|
|
||||||
DEPENDS ${PROJECT_NAME}
|
|
||||||
COMMENT "Packing ${PROJECT_NAME}")
|
|
||||||
ENDIF ()
|
ENDIF ()
|
@ -54,14 +54,15 @@ IPRefresher::IPRefresher(bool loop) {
|
|||||||
if (loop) {
|
if (loop) {
|
||||||
Logger::message("startup of service");
|
Logger::message("startup of service");
|
||||||
Logger::message("Version: " + Version::VERSION);
|
Logger::message("Version: " + Version::VERSION);
|
||||||
if (Config::readConfig()) {
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Logger::message("starting check");
|
Logger::message("starting check");
|
||||||
|
if (Config::readConfig()) {
|
||||||
checkIPAdress(false);
|
checkIPAdress(false);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(300000));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
std::cout << "incorrect credentials!" << std::endl;
|
std::cout << "incorrect credentials!" << std::endl;
|
||||||
}
|
}
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(300000));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user