From 49ae944d65218ee667de4cbcc86793c5d4d9c5b9 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 24 May 2020 19:14:27 +0200 Subject: [PATCH] fix: check git root --- meson.build | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 86e7ba4d..c16d7854 100644 --- a/meson.build +++ b/meson.build @@ -32,10 +32,15 @@ git = find_program('git', native: true, required: false) if not git.found() add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'cpp') else - 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) - add_project_arguments('-DVERSION=@0@'.format(version), language: 'cpp') + git_path = run_command([git.path(), 'rev-parse', '--show-toplevel']).stdout().strip() + if meson.source_root() == git_path + 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) + add_project_arguments('-DVERSION=@0@'.format(version), language: 'cpp') + else + add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'cpp') + endif endif if not compiler.has_header('filesystem')