From b641318663f4f3cabc67f579e028ef2ccbbd5aa7 Mon Sep 17 00:00:00 2001 From: "Christopher M. Punches" Date: Sat, 15 Aug 2026 22:57:46 -0400 Subject: [PATCH] Store the version in version.cpp and group the library under src/core libdpm-core.so's version was reaching the source as a compile-line definition, with a fallback in two translation units that would have let the library build and report 0.0.0 if the build ever stopped supplying it. The version is a literal in src/core/version.cpp, the file named for it, alongside dpm_core_version() which returns it and the parser for the X.Y.Z strings modules report. The library's sources and its version script move to src/core, leaving src/cli, src/bundled-modules, and the documentation source beside it. --- CMakeLists.txt | 14 +++++--------- src/{ => core}/context.cpp | 9 --------- src/{ => core}/libdpm-core.map | 0 src/{ => core}/modules.cpp | 4 ---- src/{ => core}/version.cpp | 12 +++++++++++- 5 files changed, 16 insertions(+), 23 deletions(-) rename src/{ => core}/context.cpp (98%) rename src/{ => core}/libdpm-core.map (100%) rename src/{ => core}/modules.cpp (99%) rename src/{ => core}/version.cpp (86%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22ff741..a680459 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # libdpm-core.so — the library (C ABI) # --------------------------------------------------------------------- add_library(dpm-core SHARED - src/context.cpp - src/modules.cpp - src/version.cpp + src/core/context.cpp + src/core/modules.cpp + src/core/version.cpp ) target_include_directories(dpm-core PUBLIC @@ -18,10 +18,6 @@ target_include_directories(dpm-core PUBLIC $ ) -target_compile_definitions(dpm-core PRIVATE - DPM_CORE_VERSION_STR="${PROJECT_VERSION}" -) - # The public C API is the library's entire exported surface; internals # stay hidden. The version script pins the export list and versions the # symbols. @@ -30,10 +26,10 @@ target_compile_options(dpm-core PRIVATE -fvisibility-inlines-hidden ) target_link_options(dpm-core PRIVATE - -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/libdpm-core.map + -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/core/libdpm-core.map ) set_property(TARGET dpm-core APPEND PROPERTY - LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/libdpm-core.map + LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/core/libdpm-core.map ) target_link_libraries(dpm-core PRIVATE ${CMAKE_DL_LIBS}) diff --git a/src/context.cpp b/src/core/context.cpp similarity index 98% rename from src/context.cpp rename to src/core/context.cpp index 5725d19..9eb52d0 100644 --- a/src/context.cpp +++ b/src/core/context.cpp @@ -32,10 +32,6 @@ namespace fs = std::filesystem; -#ifndef DPM_CORE_VERSION_STR -#define DPM_CORE_VERSION_STR "0.0.0" -#endif - namespace { const char* DEFAULT_CONFIG_DIR = "/etc/dpm/conf.d/"; @@ -252,11 +248,6 @@ void dpm_close(dpm_ctx* ctx) delete ctx; } -const char* dpm_core_version(void) -{ - return DPM_CORE_VERSION_STR; -} - const char* dpm_config_get(dpm_ctx* ctx, const char* module, const char* section, const char* key) { diff --git a/src/libdpm-core.map b/src/core/libdpm-core.map similarity index 100% rename from src/libdpm-core.map rename to src/core/libdpm-core.map diff --git a/src/modules.cpp b/src/core/modules.cpp similarity index 99% rename from src/modules.cpp rename to src/core/modules.cpp index 45a0a40..f10fb50 100644 --- a/src/modules.cpp +++ b/src/core/modules.cpp @@ -39,10 +39,6 @@ namespace fs = std::filesystem; -#ifndef DPM_CORE_VERSION_STR -#define DPM_CORE_VERSION_STR "0.0.0" -#endif - /* dlclose wrapper referenced from context.cpp so handle release stays in one translation unit with the loader. */ void dpm_internal_unload(void* handle) diff --git a/src/version.cpp b/src/core/version.cpp similarity index 86% rename from src/version.cpp rename to src/core/version.cpp index 2beaef7..0a43e28 100644 --- a/src/version.cpp +++ b/src/core/version.cpp @@ -1,6 +1,6 @@ /** * @file version.cpp - * @brief X.Y.Z version parsing + * @brief libdpm-core.so's version, and X.Y.Z version parsing * * @copyright Copyright (c) 2026 SILO GROUP LLC * @author Chris Punches @@ -22,9 +22,19 @@ */ #include "internal/version.hpp" +#include + #include #include +/** libdpm-core.so's own version. */ +#define DPM_CORE_VERSION_STR "1.0.0" + +extern "C" const char* dpm_core_version(void) +{ + return DPM_CORE_VERSION_STR; +} + namespace dpm_core { bool parse_version(const char* s, long out[3])