From 05e355d383f1cf01e0e7f8d7ea9c53f6d6796394 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Wed, 2 Mar 2022 03:53:04 -0400 Subject: [PATCH] meson: append git commit if possible and to non release builds --- meson.build | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index aec0cdb1..2f26305d 100644 --- a/meson.build +++ b/meson.build @@ -9,13 +9,35 @@ project('lite-xl', ] ) +#=============================================================================== +# Project version including git commit if possible +#=============================================================================== +version = meson.project_version() + +if get_option('buildtype') != 'release' + git_command = find_program('git', required : false) + + if git_command.found() + git_branch = run_command( + [git_command, 'branch', '--show-current'] + ).stdout().strip() + git_commit = run_command( + [git_command, 'rev-parse', git_branch] + ).stdout().strip() + + if git_commit != '' + version += ' (git-' + git_commit.substring(0, 8) + ')' + endif + endif +endif + #=============================================================================== # Configuration #=============================================================================== conf_data = configuration_data() conf_data.set('PROJECT_BUILD_DIR', meson.current_build_dir()) conf_data.set('PROJECT_SOURCE_DIR', meson.current_source_dir()) -conf_data.set('PROJECT_VERSION', meson.project_version()) +conf_data.set('PROJECT_VERSION', version) #=============================================================================== # Compiler Settings