Skip to content

Commit 6cd3c1b

Browse files
committed
meson.build: Detect if we build from a git subtree
See https://gitlab.gnome.org/GNOME/gtkmm/-/merge_requests/72 (William Roy)
1 parent 10dd1c7 commit 6cd3c1b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

meson.build

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ if not python_version.version_compare(python_version_req)
5050
endif
5151

5252
# Do we build from a git repository?
53-
# Suppose we do if and only if a '.git' directory or file exists.
53+
# Suppose we do if and only if the meson.build file is tracked by git.
5454
cmd_py = '''
55-
import os
56-
import sys
57-
sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@"))
58-
'''.format(project_source_root / '.git')
59-
is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() != 0
55+
import shutil, subprocess, sys
56+
if not shutil.which('git'):
57+
sys.exit(1)
58+
cmd = [ 'git', 'ls-files', '--error-unmatch', 'meson.build' ]
59+
sys.exit(subprocess.run(cmd, cwd="@0@", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode)
60+
'''.format(project_source_root)
61+
is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() == 0
6062

6163
# Are we testing a dist tarball while it's being built?
6264
# There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy