import re from SCons.Script import * 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 env.get('IMGUI_BACKENDS', []): imgui_source_files.append(os.path.join(repo['checkout_root'], 'backends', f'imgui_impl_{backend}.cpp')) for backend in options.get('backends', []): imgui_source_files.append(os.path.join(repo['checkout_root'], 'backends', f'imgui_impl_{backend}.cpp')) env.StaticLibrary( CPPPATH = [repo['checkout_root']], CPPDEFINES = ['IMGUI_IMPL_VULKAN_NO_PROTOTYPES=1'], target = env['LIB_DIR'] + '/imgui', source = imgui_source_files ) return { 'CPPPATH': [repo['checkout_root']], 'LIBS': [os.path.join(env['LIB_DIR'], env.LibFilename('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 )