diff --git a/addons/gitbranch.py b/addons/gitbranch.py index 06604f3..62f94ce 100644 --- a/addons/gitbranch.py +++ b/addons/gitbranch.py @@ -71,7 +71,11 @@ def _git_recipe(env: Environment, globals: dict, repo_name, repo_url, cook_fn, v def _versions(env: Environment, update: bool = False, options: dict = {}): if 'ref' in options: return [(0, 0, 0)] # no versions if compiling from a branch - pattern = _tag_pattern(env) + pattern_signature = inspect.signature(_tag_pattern) + kwargs = {} + if 'options' in pattern_signature.parameters: + kwargs['options'] = options + pattern = _tag_pattern(env, **kwargs) if pattern: tags = env.GitTags(repo_name = _repo_name(env), remote_url = _repo_url(env), force_fetch=update) result = [] @@ -94,7 +98,11 @@ def _git_recipe(env: Environment, globals: dict, repo_name, repo_url, cook_fn, v if 'ref' in options: git_ref = options['ref'] elif tag_fn: - git_ref = f'refs/tags/{tag_fn(version)}' + tag_signature = inspect.signature(tag_fn) + kwargs = {} + if 'options' in tag_signature.parameters: + kwargs['options'] = options + git_ref = f'refs/tags/{tag_fn(version, **kwargs)}' else: assert ref_fn git_ref = ref_fn(env, version) diff --git a/recipes/imgui/recipe.py b/recipes/imgui/recipe.py index 42f3eb4..22c488d 100644 --- a/recipes/imgui/recipe.py +++ b/recipes/imgui/recipe.py @@ -3,7 +3,7 @@ import re from SCons.Script import * -def _git_cook(env: Environment, repo: dict) -> dict: +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'), @@ -11,28 +11,39 @@ def _git_cook(env: Environment, repo: dict) -> dict: os.path.join(repo['checkout_root'], 'imgui_widgets.cpp') ] - imgui_add_sources = [] for backend in env.get('IMGUI_BACKENDS', []): - imgui_add_sources.append(f'backends/imgui_impl_{backend}.cpp') + 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, - add_source = imgui_add_sources + 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 = re.compile(r'^v([0-9]+)\.([0-9]+)\.([0-9]+)$'), - tag_fn = lambda version: f'v{version[0]}.{version[1]}.{version[2]}', + tag_pattern = _tag_pattern, + tag_fn = _tag_fn, cook_fn = _git_cook )