From fffac83f9fef149fcd0b2ed032c7b42e5f3e5693 Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Sat, 22 Feb 2025 13:23:15 -0600 Subject: [PATCH] Added test program for SeerUtl.cpp. --- src/build/README.cmake | 2 +- src/build_seerutl/.gitignore | 6 +++ src/build_seerutl/CMakeLists.txt | 75 ++++++++++++++++++++++++++++++++ src/build_seerutl/README.cmake | 37 ++++++++++++++++ src/seerutl.cpp | 19 ++++++++ tests/helloskip/README | 6 ++- 6 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 src/build_seerutl/.gitignore create mode 100644 src/build_seerutl/CMakeLists.txt create mode 100644 src/build_seerutl/README.cmake create mode 100644 src/seerutl.cpp diff --git a/src/build/README.cmake b/src/build/README.cmake index d1bebd4..5df2d63 100644 --- a/src/build/README.cmake +++ b/src/build/README.cmake @@ -27,7 +27,7 @@ MacOS may need help finding the cmake config file for Qt6. Sometimes you need to specify a newer version of g++/gcc. Your installation may have an old version as the default. - % cmake -D CMAKE_C_COMPILER=gcc-13 -D CMAKE_CXX_COMPILER=g++-13 -DQTVERSION=QT6 -DCMAKE_BUILD_TYPE=Debug .. + % cmake -DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13 -DQTVERSION=QT6 -DCMAKE_BUILD_TYPE=Debug .. Checkout the Seer wiki for more build info. diff --git a/src/build_seerutl/.gitignore b/src/build_seerutl/.gitignore new file mode 100644 index 0000000..e48c8ee --- /dev/null +++ b/src/build_seerutl/.gitignore @@ -0,0 +1,6 @@ +seerutl +cmake_install.cmake +CMakeCache.txt +Makefile +CMakeFiles +.qt/* diff --git a/src/build_seerutl/CMakeLists.txt b/src/build_seerutl/CMakeLists.txt new file mode 100644 index 0000000..5684874 --- /dev/null +++ b/src/build_seerutl/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.1.0) + +project(seerutl VERSION 1.0 LANGUAGES CXX) + +set(PROJECT_NAME seerutl) + +if(NOT DEFINED QTVERSION) + set(QTVERSION "QT6" CACHE STRING "" FORCE) +endif() + +if(${QTVERSION} STREQUAL "QT6") + message("-- Compile with QT6") +elseif(${QTVERSION} STREQUAL "QT5") + message("-- Compile with QT5") +else() + message(FATAL_ERROR "-- Use -DQTVERSION=QT5|QT6 not \"${QTVERSION}\"") +endif() + +# Find includes in the build directories +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_PREFIX_PATH ${QTDIR}) + +if(${QTVERSION} STREQUAL "QT6") + find_package(Qt6 COMPONENTS REQUIRED Core) + + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) + +elseif(${QTVERSION} STREQUAL "QT5") + find_package(Qt5 COMPONENTS REQUIRED Core) + + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() + + +set(HEADER_FILES + ../SeerUtl.h + ) + +set(SOURCE_FILES + ../seerutl.cpp + ../SeerUtl.cpp + ) + +# Set non-Debug build as GUI application. +# Debug build remains consle application. +if(NOT CMAKE_BUILD_TYPE MATCHES Debug) #Release, RelWithDebInfo and MinSizeRel + if(WIN32) # Check if we are on Windows + set(SYSTEM_TYPE WIN32) + endif() + message("-- System type is " ${SYSTEM_TYPE}) +endif() + +# for Linux, BSD, Solaris, Minix +if(UNIX AND NOT APPLE) + add_compile_options(-Wall -Wextra -Wunused-result -pedantic) # -Werror -Wdeprecated-copy +endif() + +add_definitions(-DQT_DEPRECATED_WARNINGS) + +add_executable(${PROJECT_NAME} ${SYSTEM_TYPE} ${SOURCE_FILES}) + +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) + +if(${QTVERSION} STREQUAL "QT6") + target_link_libraries(${PROJECT_NAME} Qt6::Core) +elseif(${QTVERSION} STREQUAL "QT5") + target_link_libraries(${PROJECT_NAME} Qt5::Core) +endif() + diff --git a/src/build_seerutl/README.cmake b/src/build_seerutl/README.cmake new file mode 100644 index 0000000..24e78a5 --- /dev/null +++ b/src/build_seerutl/README.cmake @@ -0,0 +1,37 @@ +Notes for building 'seerutl' with cmake. 'seerutl' is a test program +for testing the SeerUtl functions. It is used for my developent. It +is NOT needed for the average person installing Seergdb from source. + + # Note the single '.'. The CMakeLists.txt file is local to this build directory. + % cd seer/src/build_seerutl + % cmake -DCMAKE_BUILD_TYPE=Debug . # Debug release -g. + % cmake -DCMAKE_BUILD_TYPE=Release . # Optimized release -O. + % cmake -DCMAKE_CXX_FLAGS=-Wall . # With all compile warnings turned on. + + # Specify a compiler version with debug. + % cmake -DCMAKE_CXX_COMPILER=g++-13 -DCMAKE_BUILD_TYPE=Debug . + +The above defaults to Qt6. If you want to use Qt5, add the '-DQTVERSION' flag. + + % cmake -DQTVERSION=QT5 -DCMAKE_BUILD_TYPE=Debug . + +Once cmake is run, then just build 'seerutl'. + + % make clean # Clean files. + % make seerutl # Build 'seerutl'. + % sudo make install # Install it. + +Another way to ask cmake to do the build for you. + + % cmake --build . --config Release + % sudo cmake --install . + +MacOS may need help finding the cmake config file for Qt6. + + % cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt6/ -DCMAKE_BUILD_TYPE=Release .. + +Sometimes you need to specify a newer version of g++/gcc. Your installation +may have an old version as the default. + + % cmake -DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13 -DQTVERSION=QT6 -DCMAKE_BUILD_TYPE=Debug .. + diff --git a/src/seerutl.cpp b/src/seerutl.cpp new file mode 100644 index 0000000..c6c1b40 --- /dev/null +++ b/src/seerutl.cpp @@ -0,0 +1,19 @@ +#include "SeerUtl.h" +#include + +int main (int argc, char* argv[]) { + + Q_UNUSED(argc); + Q_UNUSED(argv); + + QString text("Function\\n1"); + QString result; + + result = Seer::filterEscapes(text); + + qDebug().noquote() << text; + qDebug().noquote() << result; + + return 1; +} + diff --git a/tests/helloskip/README b/tests/helloskip/README index b06d3a0..d3a308f 100644 --- a/tests/helloskip/README +++ b/tests/helloskip/README @@ -39,10 +39,14 @@ The following example shows a GDB session in which the above commands have been -skip-list ^done,list="Num Enb Glob File RE Functionn1 y n n std::vector >::back()n2 y n n std::unique_ptr >::operator*() constn" + ^done,list="Num Enb Glob File RE Functionn + 1 y n n std::vector >::back()n + 2 y n n std::unique_ptr >::operator*() constn" + Run Seer this way: $ /usr/local/bin/seergdb --project=project.seer -[ ] The return string has 'n' characters but I think they should be '\n' +[ ] The return string has 'n' characters but I think they should be '\n'. Seer parsing bug with escaped '\n'???? [ ] Handle the parsing of the return string and return a python table.