diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-11-30 04:48:08 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-11-30 04:48:08 -0500 |
commit | 739bafbd8ecdbbf2eb3fd42e1b3d9249236a3fcf (patch) | |
tree | 46834d9699a6aabb05721ba77dad59c438b88c60 | |
parent | 86d1ecf783f8fd164ed63501c859b65cfc6bc022 (diff) |
make meson version configurable
-rw-r--r-- | meson.build | 16 | ||||
-rw-r--r-- | meson_options.txt | 1 |
2 files changed, 14 insertions, 3 deletions
diff --git a/meson.build b/meson.build index af383fbf..ac161987 100644 --- a/meson.build +++ b/meson.build @@ -23,10 +23,20 @@ pango = dependency('pango') pixman = dependency('pixman-1') libcap = dependency('libcap') math = cc.find_library('m') +git = find_program('git', required: false) -git_commit_hash = run_command(['git', 'describe', '--always', '--tags']).stdout().strip() -git_branch = run_command(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).stdout().strip() -version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash, git_branch) +version = get_option('sway_version') +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) +endif add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..5015a986 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('sway_version', type : 'string', description : 'The version string reported in `sway --version`.') |