summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-26 22:17:48 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-26 22:17:48 -0400
commitef31ee5cf6aabfdf4730ac64c8b004be238df1a8 (patch)
tree6c157899622ccac2c26a56582c72f657e82fbdd3
parentslight fix (diff)
parentUpdated versioning in cmake (diff)
downloadsway-ef31ee5cf6aabfdf4730ac64c8b004be238df1a8.tar.gz
sway-ef31ee5cf6aabfdf4730ac64c8b004be238df1a8.tar.zst
sway-ef31ee5cf6aabfdf4730ac64c8b004be238df1a8.zip
Merge pull request #139 from Luminarys/master
Added in better versioning info
-rw-r--r--CMakeLists.txt30
-rw-r--r--sway/ipc.c18
-rw-r--r--sway/main.c4
3 files changed, 42 insertions, 10 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")
7set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake) 7set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake)
8 8
9if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") 9if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
10 execute_process( 10 execute_process(
11 COMMAND git describe --always 11 COMMAND git describe --always
12 OUTPUT_VARIABLE GIT_COMMIT_HASH 12 OUTPUT_VARIABLE GIT_COMMIT_HASH
13 OUTPUT_STRIP_TRAILING_WHITESPACE 13 OUTPUT_STRIP_TRAILING_WHITESPACE
14 ) 14 )
15 execute_process(
16 COMMAND git rev-parse --abbrev-ref HEAD
17 OUTPUT_VARIABLE GIT_BRANCH
18 OUTPUT_STRIP_TRAILING_WHITESPACE
19 )
15endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") 20endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
16 21
17SET(GIT_VERSION_FLAG "-DSWAY_GIT_VERSION=\"${GIT_COMMIT_HASH}\"") 22SET(VERSION_GIT_COMMIT_FLAG "-DSWAY_GIT_VERSION=\"g${GIT_COMMIT_HASH}\"")
23add_definitions("${VERSION_GIT_COMMIT_FLAG}")
24
25SET(VERSION_GIT_BRANCH_FLAG "-DSWAY_GIT_BRANCH=\"${GIT_BRANCH}\"")
26add_definitions("${VERSION_GIT_BRANCH_FLAG}")
27
28execute_process(
29 COMMAND date +"%Y-%m-%d"
30 OUTPUT_VARIABLE CURRENT_DATE
31 OUTPUT_STRIP_TRAILING_WHITESPACE
32)
18 33
19add_definitions("${GIT_VERSION_FLAG}") 34SET(VERSION_DATE_FLAG "-DSWAY_VERSION_DATE=${CURRENT_DATE}")
35add_definitions("${VERSION_DATE_FLAG}")
20 36
21find_package(XKBCommon REQUIRED) 37find_package(XKBCommon REQUIRED)
22find_package(WLC REQUIRED) 38find_package(WLC REQUIRED)
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) {
225 } 225 }
226 case IPC_GET_VERSION: 226 case IPC_GET_VERSION:
227 { 227 {
228#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
229 char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1);
230 strcat(full_version, SWAY_GIT_VERSION);
231 strcat(full_version, " (");
232 strcat(full_version, SWAY_VERSION_DATE);
233 strcat(full_version, ", branch \"");
234 strcat(full_version, SWAY_GIT_BRANCH);
235 strcat(full_version, "\")");
228 json_object *json = json_object_new_object(); 236 json_object *json = json_object_new_object();
229 json_object_object_add(json, "human_readable", json_object_new_string(SWAY_GIT_VERSION)); 237 json_object_object_add(json, "human_readable", json_object_new_string(full_version));
238 // Todo once we actually release a version
230 json_object_object_add(json, "major", json_object_new_int(0)); 239 json_object_object_add(json, "major", json_object_new_int(0));
231 json_object_object_add(json, "minor", json_object_new_int(0)); 240 json_object_object_add(json, "minor", json_object_new_int(0));
232 json_object_object_add(json, "patch", json_object_new_int(1)); 241 json_object_object_add(json, "patch", json_object_new_int(1));
242#else
243 json_object_object_add(json, "human_readable", json_object_new_string("version not found"));
244 json_object_object_add(json, "major", json_object_new_int(0));
245 json_object_object_add(json, "minor", json_object_new_int(0));
246 json_object_object_add(json, "patch", json_object_new_int(0));
247#endif
233 const char *json_string = json_object_to_json_string(json); 248 const char *json_string = json_object_to_json_string(json);
234 ipc_send_reply(client, json_string, (uint32_t) strlen(json_string)); 249 ipc_send_reply(client, json_string, (uint32_t) strlen(json_string));
235 json_object_put(json); // free 250 json_object_put(json); // free
251 free(full_version);
236 break; 252 break;
237 } 253 }
238 default: 254 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) {
78 debug = 1; 78 debug = 1;
79 break; 79 break;
80 case 'v': // version 80 case 'v': // version
81#ifdef SWAY_GIT_VERSION 81#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
82 fprintf(stdout, "sway build %s\n", SWAY_GIT_VERSION); 82 fprintf(stdout, "sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH);
83#else 83#else
84 fprintf(stdout, "version not detected\n"); 84 fprintf(stdout, "version not detected\n");
85#endif 85#endif