mirror of
https://github.com/wolfpld/tracy.git
synced 2026-09-01 16:08:30 +00:00
Derive meson version via python3, not sh.
This commit is contained in:
23
extra/tracy-version.py
Executable file
23
extra/tracy-version.py
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
# Derive the project version from the single source of truth:
|
||||
# public/common/TracyVersion.hpp. Prints X.Y.Z, exits nonzero on failure.
|
||||
import re
|
||||
import sys
|
||||
|
||||
header = sys.argv[1]
|
||||
try:
|
||||
with open(header, encoding='utf-8') as f:
|
||||
text = f.read()
|
||||
except OSError as exc:
|
||||
print('tracy-version: cannot read %s: %s' % (header, exc), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
numbers = {}
|
||||
for name in ('Major', 'Minor', 'Patch'):
|
||||
match = re.search(r'%s\s*=\s*(\d+)' % name, text)
|
||||
if not match:
|
||||
print('tracy-version: could not parse version from %s' % header, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
numbers[name] = match.group(1)
|
||||
|
||||
print('%s.%s.%s' % (numbers['Major'], numbers['Minor'], numbers['Patch']))
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Derive the project version from the single source of truth:
|
||||
# public/common/TracyVersion.hpp. Prints X.Y.Z, exits nonzero on failure.
|
||||
|
||||
header="$1"
|
||||
|
||||
[ -r "$header" ] || {
|
||||
echo "tracy-version: cannot read $header" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
major=$(sed -n 's/.*Major = \([0-9][0-9]*\).*/\1/p' "$header")
|
||||
minor=$(sed -n 's/.*Minor = \([0-9][0-9]*\).*/\1/p' "$header")
|
||||
patch=$(sed -n 's/.*Patch = \([0-9][0-9]*\).*/\1/p' "$header")
|
||||
|
||||
if [ -n "$major" ] && [ -n "$minor" ] && [ -n "$patch" ]; then
|
||||
printf '%s.%s.%s\n' "$major" "$minor" "$patch"
|
||||
else
|
||||
echo "tracy-version: could not parse version from $header" >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,4 +1,4 @@
|
||||
project('tracy', ['cpp'], version: run_command('sh', files('extra/tracy-version.sh'), 'public/common/TracyVersion.hpp', check: true).stdout().strip(), meson_version: '>=1.3.0', default_options : ['cpp_std=c++11'])
|
||||
project('tracy', ['cpp'], version: run_command(find_program('python3'), files('extra/tracy-version.py'), 'public/common/TracyVersion.hpp', check: true).stdout().strip(), meson_version: '>=1.3.0', default_options : ['cpp_std=c++11'])
|
||||
|
||||
# internal compiler flags
|
||||
tracy_compile_args = []
|
||||
|
||||
Reference in New Issue
Block a user