diff options
-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') | |||
23 | pixman = dependency('pixman-1') | 23 | pixman = dependency('pixman-1') |
24 | libcap = dependency('libcap') | 24 | libcap = dependency('libcap') |
25 | math = cc.find_library('m') | 25 | math = cc.find_library('m') |
26 | git = find_program('git', required: false) | ||
26 | 27 | ||
27 | git_commit_hash = run_command(['git', 'describe', '--always', '--tags']).stdout().strip() | 28 | version = get_option('sway_version') |
28 | git_branch = run_command(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).stdout().strip() | 29 | if version != '' |
29 | version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash, git_branch) | 30 | version = '"@0@"'.format(version) |
31 | else | ||
32 | if not git.found() | ||
33 | error('git is required to make the version string') | ||
34 | endif | ||
35 | |||
36 | git_commit_hash = run_command([git.path(), 'describe', '--always', '--tags']).stdout().strip() | ||
37 | git_branch = run_command([git.path(), 'rev-parse', '--abbrev-ref', 'HEAD']).stdout().strip() | ||
38 | version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash, git_branch) | ||
39 | endif | ||
30 | 40 | ||
31 | add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') | 41 | add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') |
32 | 42 | ||
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`.') | |||