diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2022-09-27 09:44:27 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2022-09-27 09:44:27 +0200 |
commit | b3d875df0fcd650e268f998e8596a6114bc72c20 (patch) | |
tree | 1df9f4381b43b64ce29d38eb892839075df33f79 | |
parent | 66ed1338ae3841dac3d04c10478e1e7bddd43635 (diff) |
meson.build: Detect if we build from a git subtree
See https://gitlab.gnome.org/GNOME/gtkmm/-/merge_requests/72 (William Roy)
-rw-r--r-- | meson.build | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/meson.build b/meson.build index 0201998..a9e7036 100644 --- a/meson.build +++ b/meson.build @@ -54,13 +54,15 @@ if not python_version.version_compare(python_version_req) endif # Do we build from a git repository? -# Suppose we do if and only if a '.git' directory or file exists. +# Suppose we do if and only if the meson.build file is tracked by git. cmd_py = ''' -import os -import sys -sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@")) -'''.format(project_source_root / '.git') -is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() != 0 +import shutil, subprocess, sys +if not shutil.which('git'): + sys.exit(1) +cmd = [ 'git', 'ls-files', '--error-unmatch', 'meson.build' ] +sys.exit(subprocess.run(cmd, cwd="@0@", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode) +'''.format(project_source_root) +is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() == 0 # Are we testing a dist tarball while it's being built? # There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866 |