make meson version configurable

This commit is contained in:
Tony Crisci 2017-11-30 04:48:08 -05:00
parent 86d1ecf783
commit 739bafbd8e
2 changed files with 14 additions and 3 deletions

View file

@ -23,10 +23,20 @@ pango = dependency('pango')
pixman = dependency('pixman-1') pixman = dependency('pixman-1')
libcap = dependency('libcap') libcap = dependency('libcap')
math = cc.find_library('m') math = cc.find_library('m')
git = find_program('git', required: false)
git_commit_hash = run_command(['git', 'describe', '--always', '--tags']).stdout().strip() version = get_option('sway_version')
git_branch = run_command(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).stdout().strip() if version != ''
version = '"@0@"'.format(version)
else
if not git.found()
error('git is required to make the version string')
endif
git_commit_hash = run_command([git.path(), 'describe', '--always', '--tags']).stdout().strip()
git_branch = run_command([git.path(), 'rev-parse', '--abbrev-ref', 'HEAD']).stdout().strip()
version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash, git_branch) version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash, git_branch)
endif
add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c')

1
meson_options.txt Normal file
View file

@ -0,0 +1 @@
option('sway_version', type : 'string', description : 'The version string reported in `sway --version`.')