From 42de135c3a58ef0d58e96efb9ec9b75f2d1b5490 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Wed, 26 Aug 2015 21:13:53 -0500 Subject: [PATCH 1/2] Added in better versioning info --- sway/ipc.c | 18 +++++++++++++++++- sway/main.c | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sway/ipc.c b/sway/ipc.c index d278c0a0..44891005 100644 --- a/sway/ipc.c +++ b/sway/ipc.c @@ -225,14 +225,30 @@ void ipc_client_handle_command(struct ipc_client *client) { } case IPC_GET_VERSION: { +#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE + char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1); + strcat(full_version, SWAY_GIT_VERSION); + strcat(full_version, " ("); + strcat(full_version, SWAY_VERSION_DATE); + strcat(full_version, ", branch \""); + strcat(full_version, SWAY_GIT_BRANCH); + strcat(full_version, "\")"); json_object *json = json_object_new_object(); - json_object_object_add(json, "human_readable", json_object_new_string(SWAY_GIT_VERSION)); + json_object_object_add(json, "human_readable", json_object_new_string(full_version)); + // Todo once we actually release a version json_object_object_add(json, "major", json_object_new_int(0)); json_object_object_add(json, "minor", json_object_new_int(0)); json_object_object_add(json, "patch", json_object_new_int(1)); +#else + json_object_object_add(json, "human_readable", json_object_new_string("version not found")); + json_object_object_add(json, "major", json_object_new_int(0)); + json_object_object_add(json, "minor", json_object_new_int(0)); + json_object_object_add(json, "patch", json_object_new_int(0)); +#endif const char *json_string = json_object_to_json_string(json); ipc_send_reply(client, json_string, (uint32_t) strlen(json_string)); json_object_put(json); // free + free(full_version); break; } default: diff --git a/sway/main.c b/sway/main.c index 3591e7ff..01c19074 100644 --- a/sway/main.c +++ b/sway/main.c @@ -78,8 +78,8 @@ int main(int argc, char **argv) { debug = 1; break; case 'v': // version -#ifdef SWAY_GIT_VERSION - fprintf(stdout, "sway build %s\n", SWAY_GIT_VERSION); +#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE + fprintf(stdout, "sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH); #else fprintf(stdout, "version not detected\n"); #endif From 54b51cbe6ab191618c33c4e928d79ea97d31a267 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Wed, 26 Aug 2015 21:15:43 -0500 Subject: [PATCH 2/2] Updated versioning in cmake --- CMakeLists.txt | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aad7f54d..afad8123 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,16 +7,32 @@ add_definitions("-Wall -Wextra -Wno-unused-parameter") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") - execute_process( - COMMAND git describe --always - OUTPUT_VARIABLE GIT_COMMIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + execute_process( + COMMAND git describe --always + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") -SET(GIT_VERSION_FLAG "-DSWAY_GIT_VERSION=\"${GIT_COMMIT_HASH}\"") +SET(VERSION_GIT_COMMIT_FLAG "-DSWAY_GIT_VERSION=\"g${GIT_COMMIT_HASH}\"") +add_definitions("${VERSION_GIT_COMMIT_FLAG}") -add_definitions("${GIT_VERSION_FLAG}") +SET(VERSION_GIT_BRANCH_FLAG "-DSWAY_GIT_BRANCH=\"${GIT_BRANCH}\"") +add_definitions("${VERSION_GIT_BRANCH_FLAG}") + +execute_process( + COMMAND date +"%Y-%m-%d" + OUTPUT_VARIABLE CURRENT_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +SET(VERSION_DATE_FLAG "-DSWAY_VERSION_DATE=${CURRENT_DATE}") +add_definitions("${VERSION_DATE_FLAG}") find_package(XKBCommon REQUIRED) find_package(WLC REQUIRED)