Added way for dependencies to use options and fixed compilation of ImGui with SDL3 backend.
This commit is contained in:
@@ -1,8 +1,23 @@
|
||||
|
||||
|
||||
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'),
|
||||
@@ -11,20 +26,19 @@ def _git_cook(env: Environment, repo: dict, options: dict) -> dict:
|
||||
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', []):
|
||||
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'))
|
||||
|
||||
env.StaticLibrary(
|
||||
lib_imgui = env.StaticLibrary(
|
||||
CPPPATH = [repo['checkout_root']],
|
||||
CPPDEFINES = ['IMGUI_IMPL_VULKAN_NO_PROTOTYPES=1'],
|
||||
target = env['LIB_DIR'] + '/imgui',
|
||||
source = imgui_source_files
|
||||
source = imgui_source_files,
|
||||
dependencies = _dependencies(env, None, options)
|
||||
)
|
||||
return {
|
||||
'CPPPATH': [repo['checkout_root']],
|
||||
'LIBS': [os.path.join(env['LIB_DIR'], env.LibFilename('imgui'))]
|
||||
'LIBS': [lib_imgui]
|
||||
}
|
||||
|
||||
def _tag_pattern(env, options: dict):
|
||||
@@ -45,5 +59,6 @@ env.GitRecipe(
|
||||
repo_url = 'https://github.com/ocornut/imgui.git',
|
||||
tag_pattern = _tag_pattern,
|
||||
tag_fn = _tag_fn,
|
||||
cook_fn = _git_cook
|
||||
cook_fn = _git_cook,
|
||||
dependencies = _dependencies
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user