diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e40631..512f801 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,7 +212,10 @@ target_link_libraries(solver PRIVATE jres_solver_lib cxxopts nlohmann_json) # --- JRES Formatter Logic --- add_library(jres_formatter_lib STATIC src/formatter/formatter_core.cpp) target_link_libraries(jres_formatter_lib PUBLIC jres_utils nlohmann_json) -target_include_directories(jres_formatter_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) +target_include_directories(jres_formatter_lib PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR}/generated +) # --- Formatter CLI --- add_executable(formatter cmd/formatter/cli.cpp) diff --git a/cmd/formatter/cli.cpp b/cmd/formatter/cli.cpp index 5cd5040..6750584 100644 --- a/cmd/formatter/cli.cpp +++ b/cmd/formatter/cli.cpp @@ -11,7 +11,6 @@ #include #include "formatter/formatter_core.hpp" -#include "version.h" using json = nlohmann::json; @@ -44,7 +43,7 @@ int main(int argc, char* argv[]) { auto result = options.parse(argc, argv); if (result.count("version")) { - std::cout << "JRES Solver Version: " << JRES_VERSION_STRING << std::endl; + std::cout << "JRES Solver (formatter) Version: " << jres::get_version() << std::endl; return 0; } @@ -53,7 +52,7 @@ int main(int argc, char* argv[]) { return 0; } - std::cout << "[App] JRES Solver " << JRES_VERSION_STRING << std::endl; + std::cout << "[App] JRES Solver (formatter) " << jres::get_version() << std::endl; if (!result.count("input")) { std::cerr << "Error: Input file is required (-i)" << std::endl; diff --git a/cmd/solver/cli.cpp b/cmd/solver/cli.cpp index 8ecc393..8ddae16 100644 --- a/cmd/solver/cli.cpp +++ b/cmd/solver/cli.cpp @@ -16,8 +16,6 @@ #include "jres_solver/jres_solver.hpp" -#include "version.h" - using json = nlohmann::json; /** @@ -50,7 +48,7 @@ int main(int argc, char **argv) if (result.count("version")) { - std::cout << "JRES Solver Version: " << JRES_VERSION_STRING << std::endl; + std::cout << "JRES Solver Version: " << jres_get_version() << std::endl; return 0; } @@ -72,7 +70,7 @@ int main(int argc, char **argv) bool runDiagnostics = result["diagnose"].as(); if (!quiet) { - std::cout << "[App] JRES Solver " << JRES_VERSION_STRING << std::endl; + std::cout << "[App] JRES Solver " << jres_get_version() << std::endl; } // Load Input JSON Data into a std::string diff --git a/include/jres_solver/jres_solver.hpp b/include/jres_solver/jres_solver.hpp index a9f7002..2d8a1aa 100644 --- a/include/jres_solver/jres_solver.hpp +++ b/include/jres_solver/jres_solver.hpp @@ -219,6 +219,12 @@ struct JresSolverOutput { JRES_SOLVER_API JresSolverOutput* solve_race_schedule(const JresSolverInput* input, const JresSolverOptions* options); JRES_SOLVER_API JresSolverOutput* diagnose_race_schedule(const JresSolverInput* input, const JresSolverOptions* options); +/** + * @brief Returns the version string of the library. + * @return A null-terminated string containing the version (e.g., "1.0.0"). + */ +JRES_SOLVER_API const char* jres_get_version(); + JRES_SOLVER_API JresSolverInput* jres_input_from_json(const char* jsonData); JRES_SOLVER_API char* jres_output_to_json(const JresSolverOutput* output); diff --git a/src/formatter/formatter_core.cpp b/src/formatter/formatter_core.cpp index 5129a04..5e0d24e 100644 --- a/src/formatter/formatter_core.cpp +++ b/src/formatter/formatter_core.cpp @@ -8,6 +8,7 @@ #include "utils/date_utils.hpp" #include "utils/zip_writer.hpp" +#include "version.h" #include #include @@ -19,6 +20,10 @@ using namespace jres; using json = nlohmann::json; +const char* jres::get_version() { + return JRES_VERSION_STRING; +} + // --- Internal Structures --- struct DutyBlock { DateTime start_utc; diff --git a/src/formatter/formatter_core.hpp b/src/formatter/formatter_core.hpp index 36d1f26..4ca6aee 100644 --- a/src/formatter/formatter_core.hpp +++ b/src/formatter/formatter_core.hpp @@ -31,6 +31,11 @@ namespace jres { const std::string& output_file, const std::string& format); + /** + * @brief Returns the version string of the library. + */ + const char* get_version(); + // --- Exposed Helpers (for Testing) --- std::string generate_schedule_csv_string( diff --git a/src/jres_solver.cpp b/src/jres_solver.cpp index 84eec83..f3487a3 100644 --- a/src/jres_solver.cpp +++ b/src/jres_solver.cpp @@ -6,6 +6,11 @@ #include "jres_solver/jres_solver.hpp" #include "jres_internal_types.hpp" #include "jres_standard_solver.hpp" +#include "version.h" + +JRES_SOLVER_API const char* jres_get_version() { + return JRES_VERSION_STRING; +} JRES_SOLVER_API JresSolverOutput* solve_race_schedule(const JresSolverInput* input, const JresSolverOptions* options) { try {