[recipes] Fix build without git



commit 8a5eb270f840464e9215c962f3110fd32772b6d7
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat May 27 19:50:59 2017 -0400

    Fix build without git
    
    We need to check for the availability of git before
    using it in a run_command.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783057

 meson.build |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/meson.build b/meson.build
index 79140bc..63dfaf8 100644
--- a/meson.build
+++ b/meson.build
@@ -18,20 +18,30 @@ libgd_dep = libgd.get_variable('libgd_dep')
 
 # Extract LIBGD_INFO
 libgd_path = join_paths([meson.source_root(), 'subprojects', 'libgd'])
-git_run = run_command('git', ['-C', libgd_path, 'log', '-1', '--pretty=%h'])
-if git_run.returncode() == 0
-  conf.set_quoted('LIBGD_INFO', git_run.stdout().strip())
+
+conf.set_quoted('LIBGD_INFO', 'unknown')
+git_command = find_program('git', required: false)
+if not git_command.found()
+  message('Failed to extract git commit hash for libgd: git not found\n')
 else
-  message('Failed to extract git commit hash for libgd:\n' + git_run.stderr())
-  conf.set_quoted('LIBGD_INFO', 'unknown')
+  git_run = run_command('git', ['-C', libgd_path, 'log', '-1', '--pretty=%h'])
+  if git_run.returncode() == 0
+    conf.set_quoted('LIBGD_INFO', git_run.stdout().strip())
+  else
+    message('Failed to extract git commit hash for libgd:\n' + git_run.stderr())
+  endif
 endif
 
-git_run = run_command('git', ['-C', meson.source_root(), 'describe'])
-if git_run.returncode() == 0
-  conf.set_quoted('COMMIT_ID', git_run.stdout().strip())
+conf.set_quoted('COMMIT_ID', 'unknown')
+if not git_command.found()
+  message('Failed to extract git commit hash for libgd: git not found\n')
 else
-  message('Failed to extract git commit ID for recipes:\n' + git_run.stderr())
-  conf.set_quoted('COMMIT_ID', 'unknown')
+  git_run = run_command('git', ['-C', meson.source_root(), 'describe'])
+  if git_run.returncode() == 0
+    conf.set_quoted('COMMIT_ID', git_run.stdout().strip())
+  else
+    message('Failed to extract git commit ID for recipes:\n' + git_run.stderr())
+  endif
 endif
 
 # Options + dependency checking is overly verbose and repetitive right now, but


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]