diff --git a/src/git-version.h.in b/src/git-version.h.in new file mode 100644 index 0000000..a0d2080 --- /dev/null +++ b/src/git-version.h.in @@ -0,0 +1,3 @@ +#pragma once + +#define GIT_VERSION "@GIT_VERSION@" diff --git a/src/main.c b/src/main.c index 9e6c043..a07ba67 100644 --- a/src/main.c +++ b/src/main.c @@ -22,6 +22,7 @@ #include #include #include +#include "git-version.h" #include "config.h" #include "options.h" #include "configfile.h" @@ -101,7 +102,7 @@ int main(int argc, char *argv[]) error_enter_session_mode(); /* Print launch hints */ - tio_printf("tio v%s", VERSION); + tio_printf("tio %s", GIT_VERSION); if (interactive_mode) { tio_printf("Press ctrl-%c q to quit", option.prefix_key); diff --git a/src/meson.build b/src/meson.build index 2d506de..17cc691 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,10 @@ +# Generate git version header +git_version_h = vcs_tag(command : ['git', 'describe', '--tags', '--always', '--dirty'], + input : 'git-version.h.in', + output :'git-version.h', + replace_string:'@GIT_VERSION@') + config_h = configuration_data() -config_h.set_quoted('VERSION', meson.project_version()) config_h.set('BAUDRATE_CASES', baudrate_cases) configure_file(output: 'config.h', configuration: config_h) @@ -21,7 +26,8 @@ tio_sources = [ 'xymodem.c', 'script.c', 'fs.c', - 'readline.c' + 'readline.c', + git_version_h ] diff --git a/src/options.c b/src/options.c index 19f8c8a..398279f 100644 --- a/src/options.c +++ b/src/options.c @@ -23,6 +23,7 @@ #include #include #include +#include "git-version.h" #include "config.h" #include "misc.h" #include "print.h" @@ -1085,7 +1086,7 @@ void options_parse(int argc, char *argv[]) break; case 'v': - printf("tio v%s\n", VERSION); + printf("tio %s\n", GIT_VERSION); exit(EXIT_SUCCESS); break; diff --git a/src/tty.c b/src/tty.c index c4785b9..74f6ab3 100644 --- a/src/tty.c +++ b/src/tty.c @@ -22,6 +22,7 @@ #if defined(__linux__) #include #endif +#include "git-version.h" #include "config.h" #include #include @@ -1090,7 +1091,7 @@ void handle_command_sequence(char input_char, char *output_char, bool *forward) break; case KEY_V: - tio_printf("tio v%s", VERSION); + tio_printf("tio %s", GIT_VERSION); break; case KEY_X: