meson: append git commit if possible and to non release builds

This commit is contained in:
jgmdev 2022-03-02 03:53:04 -04:00
parent be5f94e913
commit 05e355d383
1 changed files with 23 additions and 1 deletions

View File

@ -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