Added option for ImGui recipe to build from a docking build and to provide backends to compile via options.
This commit is contained in:
parent
42dada23c9
commit
c994752c32
@ -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 = {}):
|
def _versions(env: Environment, update: bool = False, options: dict = {}):
|
||||||
if 'ref' in options:
|
if 'ref' in options:
|
||||||
return [(0, 0, 0)] # no versions if compiling from a branch
|
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:
|
if pattern:
|
||||||
tags = env.GitTags(repo_name = _repo_name(env), remote_url = _repo_url(env), force_fetch=update)
|
tags = env.GitTags(repo_name = _repo_name(env), remote_url = _repo_url(env), force_fetch=update)
|
||||||
result = []
|
result = []
|
||||||
@ -94,7 +98,11 @@ def _git_recipe(env: Environment, globals: dict, repo_name, repo_url, cook_fn, v
|
|||||||
if 'ref' in options:
|
if 'ref' in options:
|
||||||
git_ref = options['ref']
|
git_ref = options['ref']
|
||||||
elif tag_fn:
|
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:
|
else:
|
||||||
assert ref_fn
|
assert ref_fn
|
||||||
git_ref = ref_fn(env, version)
|
git_ref = ref_fn(env, version)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
import re
|
import re
|
||||||
from SCons.Script import *
|
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 = [
|
imgui_source_files = [
|
||||||
os.path.join(repo['checkout_root'], 'imgui.cpp'),
|
os.path.join(repo['checkout_root'], 'imgui.cpp'),
|
||||||
os.path.join(repo['checkout_root'], 'imgui_draw.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')
|
os.path.join(repo['checkout_root'], 'imgui_widgets.cpp')
|
||||||
]
|
]
|
||||||
|
|
||||||
imgui_add_sources = []
|
|
||||||
for backend in env.get('IMGUI_BACKENDS', []):
|
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(
|
env.StaticLibrary(
|
||||||
CPPPATH = [repo['checkout_root']],
|
CPPPATH = [repo['checkout_root']],
|
||||||
CPPDEFINES = ['IMGUI_IMPL_VULKAN_NO_PROTOTYPES=1'],
|
CPPDEFINES = ['IMGUI_IMPL_VULKAN_NO_PROTOTYPES=1'],
|
||||||
target = env['LIB_DIR'] + '/imgui',
|
target = env['LIB_DIR'] + '/imgui',
|
||||||
source = imgui_source_files,
|
source = imgui_source_files
|
||||||
add_source = imgui_add_sources
|
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
'CPPPATH': [repo['checkout_root']],
|
'CPPPATH': [repo['checkout_root']],
|
||||||
'LIBS': [os.path.join(env['LIB_DIR'], env.LibFilename('imgui'))]
|
'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(
|
env.GitRecipe(
|
||||||
globals = globals(),
|
globals = globals(),
|
||||||
repo_name = 'imgui',
|
repo_name = 'imgui',
|
||||||
repo_url = 'https://github.com/ocornut/imgui.git',
|
repo_url = 'https://github.com/ocornut/imgui.git',
|
||||||
tag_pattern = re.compile(r'^v([0-9]+)\.([0-9]+)\.([0-9]+)$'),
|
tag_pattern = _tag_pattern,
|
||||||
tag_fn = lambda version: f'v{version[0]}.{version[1]}.{version[2]}',
|
tag_fn = _tag_fn,
|
||||||
cook_fn = _git_cook
|
cook_fn = _git_cook
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user