mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-10-14 03:30:59 -07:00
47 lines
1.9 KiB
Python
47 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) 2026 OpenShot Studios, LLC
|
|
#
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
"""
|
|
Compile identical workload against a configured worktree's matching headers/lib.
|
|
|
|
Usage: python3 tests/run-preroll-workload.py /path/to/worktree /tmp/workload-name [--honor-gate [profile]]
|
|
The worktree must have built openshot-VideoCacheThread-test in build/.
|
|
Only use trusted local builds: this runs their compiler command and resulting binary.
|
|
"""
|
|
import pathlib
|
|
import shlex
|
|
# Local build/benchmark runner requires process execution.
|
|
import subprocess # nosec B404
|
|
import sys
|
|
|
|
worktree = pathlib.Path(sys.argv[1]).resolve()
|
|
output = pathlib.Path(sys.argv[2]).resolve()
|
|
unit = worktree / 'build/tests/CMakeFiles/openshot-VideoCacheThread-test.dir'
|
|
flags = {}
|
|
for line in (unit / 'flags.make').read_text().splitlines():
|
|
if line.startswith('CXX_') and ' = ' in line:
|
|
key, value = line.split(' = ', 1)
|
|
flags[key] = shlex.split(value)
|
|
link = shlex.split((unit / 'link.txt').read_text())
|
|
# Preserve the configured matching dependency flags; replace only test objects.
|
|
args = [link[0]] + flags['CXX_FLAGS'] + flags['CXX_DEFINES'] + flags['CXX_INCLUDES']
|
|
args += [str(pathlib.Path(__file__).with_name('PrerollWorkload.cpp').resolve())]
|
|
args += ['-o', str(output)]
|
|
skip = False
|
|
for item in link[1:]:
|
|
if skip:
|
|
skip = False
|
|
continue
|
|
if item == '-o':
|
|
skip = True
|
|
continue
|
|
if item.endswith('.o') or item in flags['CXX_FLAGS']:
|
|
continue
|
|
args.append(item)
|
|
print(shlex.join(args), flush=True)
|
|
# Execute the trusted local CMake command as argv, never through a shell.
|
|
subprocess.run(args, cwd=worktree / 'build/tests', check=True, shell=False) # nosec B603
|
|
# Execute only the benchmark just compiled at the caller-selected output path.
|
|
subprocess.run([str(output)] + sys.argv[3:], check=True, shell=False) # nosec B603
|