Skip to content

Commit

Permalink
build: add early exit if git is not found
Browse files Browse the repository at this point in the history
Also fallback to `--always` only if first `git describe` returned
errors, but were called successfully.
  • Loading branch information
kasper93 committed Feb 6, 2025
1 parent 2596c4d commit 17db9bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions common/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ generate_ver = '''
#!/usr/bin/env python3
import os
import sys
from subprocess import DEVNULL, check_output
from subprocess import DEVNULL, CalledProcessError, check_output
if not sys.argv[1]:
sys.exit(1)
git_cmd = [sys.argv[1], "--git-dir=" + os.path.join(sys.argv[2], ".git"),
"--work-tree=" + sys.argv[2]]
describe_cmd = git_cmd + ["describe", "--abbrev=9", "--tags", "--dirty"]
try:
ver = check_output(describe_cmd, stderr=DEVNULL, encoding="UTF-8")
except Exception:
except CalledProcessError:
describe_cmd += ["--always"]
ver = check_output(describe_cmd, stderr=DEVNULL, encoding="UTF-8")
ver = f"v{sys.argv[3]}-dev-g{ver}"
Expand Down

0 comments on commit 17db9bd

Please sign in to comment.