Derive meson and python package versions from TracyVersion.hpp.

This commit is contained in:
Bartosz Taudul
2026-08-21 23:03:29 +02:00
parent 39722e1e3f
commit cc04578f68
4 changed files with 30 additions and 15 deletions

21
extra/tracy-version.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/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

View File

@@ -1,13 +0,0 @@
#!/bin/sh
version_header="../public/common/TracyVersion.hpp"
major=$(grep -o -E 'Major = [0-9]+' "$version_header" | awk -F '= ' '{print $2}')
minor=$(grep -o -E 'Minor = [0-9]+' "$version_header" | awk -F '= ' '{print $2}')
patch=$(grep -o -E 'Patch = [0-9]+' "$version_header" | awk -F '= ' '{print $2}')
version="${major}.${minor}.${patch}"
# the extension is required for macOS's outdated sed
sed -i.bak "s/version: '[0-9]*\.[0-9]*\.[0-9]*'/version: '$version'/g" ../meson.build
rm ../meson.build.bak

View File

@@ -1,4 +1,4 @@
project('tracy', ['cpp'], version: '0', meson_version: '>=1.3.0', default_options : ['cpp_std=c++11'])
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'])
# internal compiler flags
tracy_compile_args = []

View File

@@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"
[project]
name = "tracy_client"
version = "0.13.1"
dynamic = ["version"]
description = "A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications."
authors = [
{ name = "Bartosz Taudul", email = "wolf@nereid.pl" },
@@ -16,6 +16,7 @@ homepage = "https://github.com/wolfpld/tracy"
source = "https://github.com/wolfpld/tracy"
[tool.scikit-build]
minimum-version = "0.11"
cmake.version = ">=3.15.0"
ninja.version = ">=1.11"
cmake.source-dir = ".."
@@ -27,3 +28,9 @@ wheel.packages = ["tracy_client"]
TRACY_CLIENT_PYTHON = "ON"
TRACY_STATIC = "OFF"
CMAKE_INSTALL_BINDIR = ""
[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "../public/common/TracyVersion.hpp"
regex = 'Major = (?P<major>[0-9]+);\s*constexpr int Minor = (?P<minor>[0-9]+);\s*constexpr int Patch = (?P<patch>[0-9]+);'
result = "{major}.{minor}.{patch}"