diff options
author | Sebastian Noack <sebastian.noack@gmail.com> | 2017-04-26 11:29:30 +0200 |
---|---|---|
committer | Sebastian Noack <sebastian.noack@gmail.com> | 2017-04-26 15:56:46 +0200 |
commit | 173b3385675b24fb7a55f2d212e2958970f6e6d3 (patch) | |
tree | e824215c8066a9ed3072f73edc5afd5ce3d7ee80 /sway | |
parent | Merge pull request #1187 from 4e554c4c/master (diff) | |
download | sway-173b3385675b24fb7a55f2d212e2958970f6e6d3.tar.gz sway-173b3385675b24fb7a55f2d212e2958970f6e6d3.tar.zst sway-173b3385675b24fb7a55f2d212e2958970f6e6d3.zip |
Add -DVERSION flag for release version numbers
Diffstat (limited to 'sway')
-rw-r--r-- | sway/ipc-json.c | 37 | ||||
-rw-r--r-- | sway/main.c | 10 |
2 files changed, 9 insertions, 38 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 4c4484e8..512144a4 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -306,39 +306,16 @@ json_object *ipc_json_describe_input(struct libinput_device *device) { | |||
306 | } | 306 | } |
307 | 307 | ||
308 | json_object *ipc_json_get_version() { | 308 | json_object *ipc_json_get_version() { |
309 | int major = 0, minor = 0, patch = 0; | ||
309 | json_object *version = json_object_new_object(); | 310 | json_object *version = json_object_new_object(); |
310 | 311 | ||
311 | #if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE | 312 | sscanf(SWAY_VERSION, "%u.%u.%u", &major, &minor, &patch); |
312 | char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1); | 313 | |
313 | if (!full_version) { | 314 | json_object_object_add(version, "human_readable", json_object_new_string(SWAY_VERSION)); |
314 | json_object_object_add(version, "human_readable", | ||
315 | json_object_new_string("Allocating version string failed")); | ||
316 | // TODO: it's stupid that we allocate this in the first place | ||
317 | json_object_object_add(version, "major", json_object_new_int(0)); | ||
318 | json_object_object_add(version, "minor", json_object_new_int(0)); | ||
319 | json_object_object_add(version, "patch", json_object_new_int(0)); | ||
320 | return version; | ||
321 | } | ||
322 | strcat(full_version, SWAY_GIT_VERSION); | ||
323 | strcat(full_version, " ("); | ||
324 | strcat(full_version, SWAY_VERSION_DATE); | ||
325 | strcat(full_version, ", branch \""); | ||
326 | strcat(full_version, SWAY_GIT_BRANCH); | ||
327 | strcat(full_version, "\")"); | ||
328 | |||
329 | json_object_object_add(version, "human_readable", json_object_new_string(full_version)); | ||
330 | json_object_object_add(version, "variant", json_object_new_string("sway")); | 315 | json_object_object_add(version, "variant", json_object_new_string("sway")); |
331 | // Todo once we actually release a version | 316 | json_object_object_add(version, "major", json_object_new_int(major)); |
332 | json_object_object_add(version, "major", json_object_new_int(0)); | 317 | json_object_object_add(version, "minor", json_object_new_int(minor)); |
333 | json_object_object_add(version, "minor", json_object_new_int(0)); | 318 | json_object_object_add(version, "patch", json_object_new_int(patch)); |
334 | json_object_object_add(version, "patch", json_object_new_int(1)); | ||
335 | free(full_version); | ||
336 | #else | ||
337 | json_object_object_add(version, "human_readable", json_object_new_string("version not found")); | ||
338 | json_object_object_add(version, "major", json_object_new_int(0)); | ||
339 | json_object_object_add(version, "minor", json_object_new_int(0)); | ||
340 | json_object_object_add(version, "patch", json_object_new_int(0)); | ||
341 | #endif | ||
342 | 319 | ||
343 | return version; | 320 | return version; |
344 | } | 321 | } |
diff --git a/sway/main.c b/sway/main.c index 39bf225e..b9549b12 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -267,11 +267,7 @@ int main(int argc, char **argv) { | |||
267 | debug = 1; | 267 | debug = 1; |
268 | break; | 268 | break; |
269 | case 'v': // version | 269 | case 'v': // version |
270 | #if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE | 270 | fprintf(stdout, "sway version " SWAY_VERSION "\n"); |
271 | fprintf(stdout, "sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH); | ||
272 | #else | ||
273 | fprintf(stdout, "version not detected\n"); | ||
274 | #endif | ||
275 | exit(EXIT_SUCCESS); | 271 | exit(EXIT_SUCCESS); |
276 | break; | 272 | break; |
277 | case 'V': // verbose | 273 | case 'V': // verbose |
@@ -378,9 +374,7 @@ int main(int argc, char **argv) { | |||
378 | // prevent ipc from crashing sway | 374 | // prevent ipc from crashing sway |
379 | signal(SIGPIPE, SIG_IGN); | 375 | signal(SIGPIPE, SIG_IGN); |
380 | 376 | ||
381 | #if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE | 377 | sway_log(L_INFO, "Starting sway version " SWAY_VERSION "\n"); |
382 | sway_log(L_INFO, "Starting sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH); | ||
383 | #endif | ||
384 | 378 | ||
385 | init_layout(); | 379 | init_layout(); |
386 | 380 | ||