diff --git a/bin/dev b/bin/dev index 82b0d9d..fc9ca41 100755 --- a/bin/dev +++ b/bin/dev @@ -138,6 +138,30 @@ class DevHelper: qrenderdoc = self._find_qrenderdoc() self._exec_in_root(qrenderdoc, replace=True) + ## + # Builds the Tracy profiler (viewer) from the third_party/tracy submodule, + # then runs it. Building from the submodule keeps the viewer's version in + # sync with the client compiled into the engine. + # dev tracy [--fresh] [args...] + # Configures only when there is no build yet (or --fresh), then builds + # incrementally. Other arguments are passed through to the profiler. + def tracy(self, *args, **kwargs): + fresh = "--fresh" in args + args = [arg for arg in args if arg != "--fresh"] + + source_dir = os.path.join("third_party", "tracy", "profiler") + build_dir = os.path.join(source_dir, "build") + if fresh or not os.path.isfile(os.path.join(self._project_root(), build_dir, "CMakeCache.txt")): + configure = ["cmake", "-B", build_dir, "-S", source_dir, "-DCMAKE_BUILD_TYPE=Release"] + if fresh: + configure.append("--fresh") + self._run_in_root(configure) + self._run_in_root(["cmake", "--build", build_dir, "--parallel"]) + + binary = os.path.join(self._project_root(), build_dir, "tracy-profiler") + print(f"Running: {shlex.join([binary, *args])}") + os.execv(binary, [binary, *args]) + def shaders(self, *args, **kwargs): shaders_dir = os.path.join(self._project_root(), "engine", "src", "shaders") if not os.path.isdir(shaders_dir):