from itertools import chain import re from SCons.Script import * _BACKEND_DEPENDENCIES = { 'sdl3': { 'SDL': { 'min': (3, 0, 0) } } } def _dependencies(env: Environment, version, options: dict) -> dict: deps = {} for backend in chain(env.get('IMGUI_BACKENDS', []), options.get('backends', [])): deps.update(_BACKEND_DEPENDENCIES.get(backend, {})) return deps def _git_cook(env: Environment, repo: dict, options: dict) -> dict: imgui_source_files = [ os.path.join(repo['checkout_root'], 'imgui.cpp'), os.path.join(repo['checkout_root'], 'imgui_draw.cpp'), os.path.join(repo['checkout_root'], 'imgui_tables.cpp'), os.path.join(repo['checkout_root'], 'imgui_widgets.cpp') ] for backend in chain(env.get('IMGUI_BACKENDS', []), options.get('backends', [])): imgui_source_files.append(os.path.join(repo['checkout_root'], 'backends', f'imgui_impl_{backend}.cpp')) lib_imgui = env.StaticLibrary( CPPPATH = [repo['checkout_root']], CPPDEFINES = ['IMGUI_IMPL_VULKAN_NO_PROTOTYPES=1'], target = env['LIB_DIR'] + '/imgui', source = imgui_source_files, dependencies = _dependencies(env, None, options) ) return { 'CPPPATH': [repo['checkout_root']], 'LIBS': [lib_imgui] } def _tag_pattern(env, options: dict): if options.get('docking'): return re.compile(r'^v([0-9]+)\.([0-9]+)\.([0-9]+)\-docking$') else: return re.compile(r'^v([0-9]+)\.([0-9]+)\.([0-9]+)$') def _tag_fn(version, options: dict) -> str: if options.get('docking'): return f'v{version[0]}.{version[1]}.{version[2]}-docking' else: return f'v{version[0]}.{version[1]}.{version[2]}' env.GitRecipe( globals = globals(), repo_name = 'imgui', repo_url = 'https://github.com/ocornut/imgui.git', tag_pattern = _tag_pattern, tag_fn = _tag_fn, cook_fn = _git_cook, dependencies = _dependencies )