From cc04578f682858dea42f8bb6bd1c2ddb8e059de9 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 21 Aug 2026 23:03:29 +0200 Subject: [PATCH] Derive meson and python package versions from TracyVersion.hpp. --- extra/tracy-version.sh | 21 +++++++++++++++++++++ extra/update-meson-version.sh | 13 ------------- meson.build | 2 +- python/pyproject.toml | 9 ++++++++- 4 files changed, 30 insertions(+), 15 deletions(-) create mode 100755 extra/tracy-version.sh delete mode 100755 extra/update-meson-version.sh diff --git a/extra/tracy-version.sh b/extra/tracy-version.sh new file mode 100755 index 00000000..d11c8b86 --- /dev/null +++ b/extra/tracy-version.sh @@ -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 diff --git a/extra/update-meson-version.sh b/extra/update-meson-version.sh deleted file mode 100755 index 913eb357..00000000 --- a/extra/update-meson-version.sh +++ /dev/null @@ -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 diff --git a/meson.build b/meson.build index de775d3d..ac2e9e07 100644 --- a/meson.build +++ b/meson.build @@ -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 = [] diff --git a/python/pyproject.toml b/python/pyproject.toml index 8620653e..0522ea48 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -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[0-9]+);\s*constexpr int Minor = (?P[0-9]+);\s*constexpr int Patch = (?P[0-9]+);' +result = "{major}.{minor}.{patch}"