diff --git a/SConscript b/SConscript index 075911b..e7b3bb3 100644 --- a/SConscript +++ b/SConscript @@ -30,15 +30,17 @@ def _inject_list(kwargs: dict, dependency: dict, list_name: str) -> None: kwargs[list_name] = [] kwargs[list_name].extend(dependency[list_name]) # TODO: eliminiate duplicates? -def _inject_dependency(dependency, kwargs: dict) -> None: +def _inject_dependency(dependency, kwargs: dict, add_sources: bool = True) -> None: if isinstance(dependency, dict): _inject_list(kwargs, dependency, 'CPPPATH') _inject_list(kwargs, dependency, 'CPPDEFINES') _inject_list(kwargs, dependency, 'LIBPATH') _inject_list(kwargs, dependency, 'LIBS') + if add_sources and 'ADDITIONAL_SOURCES' in dependency: + kwargs['source'].extend(dependency['ADDITIONAL_SOURCES']) if 'DEPENDENCIES' in dependency: for inner_dependency in dependency['DEPENDENCIES']: - _inject_dependency(inner_dependency, kwargs) + _inject_dependency(inner_dependency, kwargs, False) def _rglob(env: Environment, root_path: str, pattern: str, **kwargs): result_nodes = [] @@ -70,6 +72,7 @@ def _wrap_builder(builder, is_lib: bool = False): 'CPPDEFINES': kwargs.get('CPPDEFINES', []), 'LIBPATH': kwargs.get('LIBPATH', []), 'LIBS': result + kwargs.get('LIBS', []), + 'ADDITIONAL_SOURCES': kwargs.get('add_source', []), '_target': result } return result diff --git a/recipes/SDL/recipe.py b/recipes/SDL/recipe.py index 1e2b269..8dad134 100644 --- a/recipes/SDL/recipe.py +++ b/recipes/SDL/recipe.py @@ -1,4 +1,5 @@ +import os from SCons.Script import * def cook(env: Environment, git_ref: str = "main") -> dict: @@ -10,7 +11,7 @@ def cook(env: Environment, git_ref: str = "main") -> dict: }.get(env['BUILD_TYPE'], 'SDL2') return { 'LIBPATH': build_result['LIBPATH'], - 'CPPPATH': build_result['CPPPATH'], + 'CPPPATH': [os.path.join(build_result['install_dir'], 'include/SDL2')], # SDL is really weird about include paths ... 'LIBS': [lib_name] } diff --git a/recipes/imgui/recipe.py b/recipes/imgui/recipe.py new file mode 100644 index 0000000..b6b2c8f --- /dev/null +++ b/recipes/imgui/recipe.py @@ -0,0 +1,30 @@ +from SCons.Script import * + +import os + +def cook(env: Environment, backends: list = [], git_ref: str = '') -> dict: + repo = env.Cook('GitBranch', repo_name = 'imgui', remote_url = 'https://github.com/ocornut/imgui.git', git_ref = git_ref or 'master') + + 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') + ] + + imgui_add_sources = [] + backend_sources = { + 'vulkan': os.path.join(repo['checkout_root'], 'backends/imgui_impl_vulkan.cpp'), + 'sdl2': os.path.join(repo['checkout_root'], 'backends/imgui_impl_sdl2.cpp') + } + for backend in backends: + imgui_add_sources.append(backend_sources[backend]) + + lib_imgui = 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 + ) + return lib_imgui