mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-24 04:45:41 +02:00
meson: set project version
Export project version with -DF00BAR_VERSION. This is by default set to the meson project version. However, if git is found, and we manage to run 'git describe' and 'git branch' in the source directory, version is set to the output of that instead.
This commit is contained in:
parent
8be1063d39
commit
6753ee3dad
2 changed files with 25 additions and 2 deletions
|
@ -1,4 +1,3 @@
|
||||||
sh = find_program('sh', native: true)
|
|
||||||
scdoc = dependency('scdoc', native: true)
|
scdoc = dependency('scdoc', native: true)
|
||||||
scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true)
|
scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true)
|
||||||
|
|
||||||
|
|
26
meson.build
26
meson.build
|
@ -1,10 +1,33 @@
|
||||||
project('f00bar', 'c',
|
project('f00bar', 'c',
|
||||||
|
version: '1.0.0',
|
||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
meson_version: '>=0.48.0',
|
meson_version: '>=0.48.0',
|
||||||
default_options: ['c_std=c11', 'warning_level=1', 'werror=true'])
|
default_options: ['c_std=c11', 'warning_level=1', 'werror=true'])
|
||||||
|
|
||||||
plugs_as_libs = get_option('core-plugins-as-shared-libraries')
|
plugs_as_libs = get_option('core-plugins-as-shared-libraries')
|
||||||
|
|
||||||
|
version = '"@0@"'.format(meson.project_version())
|
||||||
|
|
||||||
|
sh = find_program('sh', native: true)
|
||||||
|
git = find_program('git', required: false, native: true)
|
||||||
|
|
||||||
|
if git.found()
|
||||||
|
commit_hash = run_command(
|
||||||
|
[sh.path(), '-c',
|
||||||
|
'@0@ --git-dir=$MESON_SOURCE_ROOT/.git describe --always --tags'.format(
|
||||||
|
git.path())])
|
||||||
|
|
||||||
|
branch = run_command(
|
||||||
|
[sh.path(), '-c',
|
||||||
|
'@0@ --git-dir=$MESON_SOURCE_ROOT/.git rev-parse --abbrev-ref HEAD'.format(
|
||||||
|
git.path())])
|
||||||
|
|
||||||
|
if commit_hash.returncode() == 0 and branch.returncode() == 0
|
||||||
|
version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(
|
||||||
|
commit_hash.stdout().strip(), branch.stdout().strip())
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# Common dependencies
|
# Common dependencies
|
||||||
cc = meson.get_compiler('c')
|
cc = meson.get_compiler('c')
|
||||||
dl = cc.find_library('dl', required : false)
|
dl = cc.find_library('dl', required : false)
|
||||||
|
@ -34,7 +57,8 @@ wlroots = dependency('wlroots', required: get_option('backend-wayland'))
|
||||||
backend_wayland = wayland_client.found() and wayland_cursor.found() and wlroots.found()
|
backend_wayland = wayland_client.found() and wayland_cursor.found() and wlroots.found()
|
||||||
|
|
||||||
add_project_arguments(
|
add_project_arguments(
|
||||||
['-D_GNU_SOURCE'] +
|
['-D_GNU_SOURCE',
|
||||||
|
'-DF00BAR_VERSION=@0@'.format(version)] +
|
||||||
(backend_x11 ? ['-DENABLE_X11'] : []) +
|
(backend_x11 ? ['-DENABLE_X11'] : []) +
|
||||||
(backend_wayland ? ['-DENABLE_WAYLAND'] : []) +
|
(backend_wayland ? ['-DENABLE_WAYLAND'] : []) +
|
||||||
(plugs_as_libs ? ['-DCORE_PLUGINS_AS_SHARED_LIBRARIES'] : []),
|
(plugs_as_libs ? ['-DCORE_PLUGINS_AS_SHARED_LIBRARIES'] : []),
|
||||||
|
|
Loading…
Add table
Reference in a new issue