diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2022-09-27 14:54:50 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2022-09-27 14:54:50 +0200 |
commit | 863ee6494bbb2587c662ea20243897eebf146b21 (patch) | |
tree | 2e8270865f0fb6a3730deea95aede4890135b17f | |
parent | ce1485e1504f74c90c0e976971ecce94eff68f97 (diff) | |
download | mm-common-863ee6494bbb2587c662ea20243897eebf146b21.tar.gz |
skeletonmm/meson.build: Detect if we build from a git subtree
See gtkmm!72
-rw-r--r-- | skeletonmm/meson.build | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/skeletonmm/meson.build b/skeletonmm/meson.build index d1e89d4..2bd9340 100644 --- a/skeletonmm/meson.build +++ b/skeletonmm/meson.build @@ -50,13 +50,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? is_dist_check = project_source_root.contains('dist-unpack') and \ |