Added imgui and an option to inject source files into dependant projects.

This commit is contained in:
2023-11-28 01:36:23 +01:00
parent d15baed4c4
commit 30e7e348c6
3 changed files with 37 additions and 3 deletions

View File

@@ -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]
}

30
recipes/imgui/recipe.py Normal file
View File

@@ -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