Skip to content

Commit 21680fd

Browse files
committed
Add i3ipc::get_version()
1 parent 20ef079 commit 21680fd

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
22
project(i3ipc++)
33

4+
string(TIMESTAMP I3IPCppBUILD_DATETIME "%Y-%m-%d %H:%M:%S")
5+
46
option(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
57
option(I3IPCpp_BUILD_EXAMPLES "Build example executables" OFF)
68

@@ -58,6 +60,10 @@ target_compile_options(i3ipc++
5860
PUBLIC -std=c++11 -Wall -Wextra -Wno-unused-parameter
5961
)
6062

63+
target_compile_definitions(i3ipc++
64+
PRIVATE I3IPC_BUILD_DATETIME="${I3IPCppBUILD_DATETIME}"
65+
)
66+
6167
if (CMAKE_BUILD_TYPE EQUAL "DEBUG")
6268
target_compile_options(i3ipc++
6369
PUBLIC -g3

include/i3ipc++/ipc.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ class connection {
342342
const std::string m_socket_path;
343343
};
344344

345+
/**
346+
* Get version of i3ipc++
347+
* @return the version of i3ipc++
348+
*/
349+
const version_t& get_version();
350+
345351
}
346352

347353
/**

src/ipc.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,4 +553,19 @@ int32_t connection::get_main_socket_fd() { return m_main_socket; }
553553

554554
int32_t connection::get_event_socket_fd() { return m_event_socket; }
555555

556+
557+
const version_t& get_version() {
558+
#define I3IPC_VERSION_MAJOR 0
559+
#define I3IPC_VERSION_MINOR 3
560+
#define I3IPC_VERSION_PATCH 0
561+
static version_t version = {
562+
.human_readable = auss_t() << I3IPC_VERSION_MAJOR << '.' << I3IPC_VERSION_MINOR << '.' << I3IPC_VERSION_PATCH << " (built on " << I3IPC_BUILD_DATETIME << ")",
563+
.loaded_config_file_name = std::string(),
564+
.major = I3IPC_VERSION_MAJOR,
565+
.minor = I3IPC_VERSION_MINOR,
566+
.patch = I3IPC_VERSION_PATCH,
567+
};
568+
return version;
569+
}
570+
556571
}

0 commit comments

Comments
 (0)