Files
renderdoc/docs/regenerate_stubs.py
T
baldurk 9223971536 Remove old stubs generation code and replace with our own script
* This is smaller and easier to maintain, and adds functionality like resolving
  circular dependencies to be able to import the stubs as-is on python 3.6+
2026-08-13 17:46:38 +01:00

49 lines
1.5 KiB
Python

#!/usr/bin/env python3
import os
import sys
import struct
if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} [path/to/stubs/folder]")
sys.exit(1)
destpath = os.path.realpath(sys.argv[1])
print(f"Writing python stubs to {destpath}")
os.makedirs(destpath, exist_ok=True)
# do everything relative to this script
docsdir = os.path.realpath(os.path.dirname(__file__))
# path to module libraries for windows
if struct.calcsize("P") == 8:
binpath = os.path.abspath(os.path.join(docsdir, '../x64/'))
else:
binpath = os.path.abspath(os.path.join(docsdir, '../Win32/'))
# Prioritise release over development builds
sys.path.insert(0, os.path.abspath(binpath + '/Development/pymodules'))
sys.path.insert(0, os.path.abspath(binpath + '/Release/pymodules'))
# Add the build paths to PATH so renderdoc.dll can be located
os.environ["PATH"] += os.pathsep + os.path.abspath(binpath + '/Development/')
os.environ["PATH"] += os.pathsep + os.path.abspath(binpath + '/Release/')
if sys.platform == 'win32' and sys.version_info[1] >= 8:
if os.path.exists(binpath + '/Release/'):
os.add_dll_directory(binpath + '/Release/')
if os.path.exists(binpath + '/Development/'):
os.add_dll_directory(binpath + '/Development/')
# path to module libraries for linux
sys.path.insert(0, os.path.abspath(os.path.join(docsdir, '../build/lib')))
import renderdoc
import qrenderdoc
import stubgen
stubgen.gen(renderdoc, destpath)
stubgen.gen(qrenderdoc, destpath)