From: John Marshall Date: Tue, 2 Jun 2020 16:01:21 +0000 (+0100) Subject: build: improve portability of git-version.h gen X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~8^2~16 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=914d8711bceb85cb7b7e9c8856fee53f7a006dae;p=babl.git build: improve portability of git-version.h gen - use git to check if building from a git repo - remove dependency on test program --- diff --git a/babl/meson.build b/babl/meson.build index 37d2e4d..c9f62ce 100644 --- a/babl/meson.build +++ b/babl/meson.build @@ -57,13 +57,11 @@ babl_version_h = configure_file( # already exists because then we are probably working with a tarball # in which case the git-version.h we ship is correct. -is_git_repo = ( - test_bin.found() and - git_bin.found() and - run_command(test_bin, '-d', meson.source_root() / '.git').returncode() == 0 -) - -if is_git_repo +if git_bin.found() and run_command( + git_bin, + 'rev-parse', + '--is-inside-work-tree', +).returncode() == 0 git_version_h = vcs_tag( input : 'git-version.h.in', output: 'git-version.h', @@ -71,18 +69,18 @@ if is_git_repo command: [ git_bin.path(), 'describe', '--always' ], ) - meson.add_dist_script( - [ 'ninja', 'babl/git-version.h', ], - ) - meson.add_dist_script( - [ 'sh', '-c', ' '.join( - [ 'cp', git_version_h.full_path(), '${MESON_DIST_ROOT}/babl' ] - )] - ) - + if env_bin.found() + meson.add_dist_script( + [ 'ninja', 'babl/git-version.h', ], + ) + meson.add_dist_script( + [ 'sh', '-c', ' '.join( + [ 'cp', git_version_h.full_path(), '${MESON_DIST_ROOT}/babl' ] + )] + ) + endif else git_version_h = files('git-version.h') - endif babl_sources = [ diff --git a/meson.build b/meson.build index db5960e..4b40419 100644 --- a/meson.build +++ b/meson.build @@ -346,7 +346,6 @@ env_bin = find_program('env', required: false, native: true) git_bin = find_program('git', required: false, native: true) rsvg_convert_bin = find_program('rsvg-convert', required: false, native: true) -test_bin = find_program('test', required: false, native: true) w3m_bin = find_program('w3m', required: false, native: true) ################################################################################