From 4259f6d960e31453b3bd35f4b3847262bc997f5d Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 31 May 2025 00:14:09 +1200 Subject: [PATCH] :-'Generic Commit' --- .runner/publish.sh | 7 ++++++- .vscode/c_cpp_properties.json | 17 +++++++++++++++++ CMakeLists.txt | 20 +++++++++++++++++++- build.sh | 1 + src/main.cpp | 10 ++++++++++ src/version.hpp.in | 21 +++++++++++++++++++++ 6 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 src/version.hpp.in diff --git a/.runner/publish.sh b/.runner/publish.sh index e8a3714..e92b607 100755 --- a/.runner/publish.sh +++ b/.runner/publish.sh @@ -54,8 +54,13 @@ if docker buildx ls | grep -q "sos-builder"; then fi docker buildx create --name sos-builder --use +VERSION=$("${EXE_DIR}/simple_object_storage.amd64" version) + echo "Building multi-platform Docker image" -docker buildx build --no-cache --push -t gitea.jde.nz/public/simple-object-storage:latest --platform linux/amd64,linux/arm64 . +docker buildx build --no-cache --push \ + -t gitea.jde.nz/public/simple-object-storage:latest \ + -t "gitea.jde.nz/public/simple-object-storage:${VERSION}" \ + --platform linux/amd64,linux/arm64 . echo "Build completed successfully!" diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..a07d8be --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/source/build/src/autogen" + ], + "defines": [], + "compilerPath": "/usr/bin/g++", + "cStandard": "c23", + "cppStandard": "c++23", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d06e9..d20d3c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,13 +4,29 @@ project(simple_object_storage) # Set the build type to Debug #set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type (e.g., Debug, Release)" FORCE) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Linking flags (removed -static) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") set(BUILD_SHARED_LIBS OFF) +# Configure version information +string(TIMESTAMP CURRENT_YEAR "%Y") +string(TIMESTAMP CURRENT_MONTH "%m") +string(TIMESTAMP CURRENT_DAY "%d") +string(TIMESTAMP CURRENT_HOUR "%H") +string(TIMESTAMP CURRENT_MINUTE "%M") +set(PROJECT_VERSION "${CURRENT_YEAR}.${CURRENT_MONTH}${CURRENT_DAY}.${CURRENT_HOUR}${CURRENT_MINUTE}") +string(TIMESTAMP RELEASE_DATE "%Y-%m-%d") + +# Configure version.hpp file +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/src/version.hpp.in" + "${CMAKE_CURRENT_BINARY_DIR}/src/autogen/version.hpp" + @ONLY +) + # Find all source files in src directory file(GLOB_RECURSE SOURCES "src/*.cpp" @@ -25,8 +41,10 @@ file(GLOB_RECURSE HEADERS # Add include directories include_directories( + $ ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/src/autogen ) # Create executable diff --git a/build.sh b/build.sh index fadcf06..12ab1d1 100755 --- a/build.sh +++ b/build.sh @@ -105,5 +105,6 @@ if [ "$BUILDSTR" = "all" ] || [ "$BUILDSTR" = "amd64" ]; then fi echo "Build completed successfully!" +"${EXE_DIR}/${PROJECTNAME}.amd64" version cd "$OLD_DIR" \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 467476f..e08fe2a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,8 @@ #include #include +#include "version.hpp" + namespace simple_object_storage { std::atomic g_running{true}; @@ -106,6 +108,14 @@ void signal_handler(int signal) { } int main(int argc, char* argv[]) { + if (argc > 1) { + if (std::string(argv[1]) == "version") { + std::cout << dropshell::VERSION << std::endl; + return 0; + } + std::cout << "simple_object_storage version: " << dropshell::VERSION << std::endl; + } + // Set up signal handlers struct sigaction sa; sa.sa_handler = signal_handler; diff --git a/src/version.hpp.in b/src/version.hpp.in new file mode 100644 index 0000000..2a9cf89 --- /dev/null +++ b/src/version.hpp.in @@ -0,0 +1,21 @@ +#pragma once + +/* + +version.hpp is automatically generated by the build system, from version.hpp.in. + +DO NOT EDIT VERSION.HPP! + +*/ + +#include + +namespace dropshell { + +// Version information +const std::string VERSION = "@PROJECT_VERSION@"; +const std::string RELEASE_DATE = "@RELEASE_DATE@"; +const std::string AUTHOR = "j842"; +const std::string LICENSE = "MIT"; + +} // namespace dropshell \ No newline at end of file