diff options
author | Alessandro Barbieri <lssndrbarbieri@gmail.com> | 2022-04-10 03:04:34 +0200 |
---|---|---|
committer | Alessandro Barbieri <lssndrbarbieri@gmail.com> | 2022-04-15 22:34:20 +0200 |
commit | 0f466458f5ba120eeb3fb28b250bdea19d1bb85c (patch) | |
tree | 48066cb6f65cab0ef13484a1280e3a7a3e691a66 | |
parent | dev-ml/systemd: initial import (diff) | |
download | guru-0f466458f5ba120eeb3fb28b250bdea19d1bb85c.tar.gz guru-0f466458f5ba120eeb3fb28b250bdea19d1bb85c.tar.bz2 guru-0f466458f5ba120eeb3fb28b250bdea19d1bb85c.zip |
media-libs/imgui: add cimgui C bindings
Signed-off-by: Alessandro Barbieri <lssndrbarbieri@gmail.com>
-rw-r--r-- | media-libs/imgui/Manifest | 1 | ||||
-rw-r--r-- | media-libs/imgui/files/cimgui-1.87-fix-cmake.patch | 69 | ||||
-rw-r--r-- | media-libs/imgui/imgui-1.87-r2.ebuild (renamed from media-libs/imgui/imgui-1.87-r1.ebuild) | 110 | ||||
-rw-r--r-- | media-libs/imgui/metadata.xml | 2 |
4 files changed, 168 insertions, 14 deletions
diff --git a/media-libs/imgui/Manifest b/media-libs/imgui/Manifest index 9bbf158f0..582ac2320 100644 --- a/media-libs/imgui/Manifest +++ b/media-libs/imgui/Manifest @@ -1,2 +1,3 @@ +DIST cimgui-1.87.tar.gz 385460 BLAKE2B 0916d53a00234343536ee412035a2c405b01e31a26c3d059cff4d446188ee8a1835a1233a68f671ccebb67be480801b85203a90b0e79fa729f7ac1efdc8bf4a2 SHA512 bf2ed9461e8c12514d29914e6da7f8fae7cd31fcc587c7d89122c950541aed3b4b908d8cd298b3975e9a955a47789335a88db7223ca558cbdf459693a0081bda DIST imgui-1.83.tar.gz 1448389 BLAKE2B 648306bd69181ad8315f12fc5b2c319b23005d6b3fc790ad64caaf1f80304e81b33af5d6f435fa97151fcf1e77eb15455838a09570b7a9c7dd9c56a61510b5a1 SHA512 2150e7101f384b1c749b2e89876b2085a7ff43435f04e88602d0e5e00db7a41c1ace5176bdb0963326845d1c8303b5092a7ca1c9c8e70c522ba96f899ed5bb9c DIST imgui-1.87.tar.gz 1460834 BLAKE2B f73b71400311e7c5f82248e242a932add5090670c78077ca2239f349730bab88a00bfe4deca4e854772ef7f6a2cff1fc0f38f7174a026995f93c9e7b55eb2a1d SHA512 3255b06698ab9c8951953e1e0b6d160d64adfa4c011b21a4288547292a7f8fff586875faf9dae0677818bde65bd7e98da92f16f6beb1e6a66aa835edf32e8ce2 diff --git a/media-libs/imgui/files/cimgui-1.87-fix-cmake.patch b/media-libs/imgui/files/cimgui-1.87-fix-cmake.patch new file mode 100644 index 000000000..b3bae1cfe --- /dev/null +++ b/media-libs/imgui/files/cimgui-1.87-fix-cmake.patch @@ -0,0 +1,69 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,21 +1,13 @@ + cmake_minimum_required(VERSION 3.1) + +-project(cimgui) ++project(libcimgui) + +-if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_tables.cpp) +- set(TABLES_SOURCE "imgui/imgui_tables.cpp") +-else() + set(TABLES_SOURCE "") +-endif() + + + #general settings + file(GLOB IMGUI_SOURCES + cimgui.cpp +- imgui/imgui.cpp +- imgui/imgui_draw.cpp +- imgui/imgui_demo.cpp +- imgui/imgui_widgets.cpp + ${TABLES_SOURCE} + ) + +@@ -24,34 +16,30 @@ + set(IMGUI_LIBRARIES ) + + if(IMGUI_FREETYPE) +- FIND_PACKAGE(freetype REQUIRED PATHS ${FREETYPE_PATH}) +- list(APPEND IMGUI_LIBRARIES freetype) +- list(APPEND IMGUI_SOURCES imgui/misc/freetype/imgui_freetype.cpp) ++ list(APPEND IMGUI_LIBRARIES -lfreetype) + add_definitions("-DCIMGUI_FREETYPE=1") + endif(IMGUI_FREETYPE) + + #add library and link + if (IMGUI_STATIC) +- add_library(cimgui STATIC ${IMGUI_SOURCES}) ++ add_library(libcimgui STATIC ${IMGUI_SOURCES}) + else (IMGUI_STATIC) +- add_library(cimgui SHARED ${IMGUI_SOURCES}) ++ add_library(libcimgui SHARED ${IMGUI_SOURCES}) + endif (IMGUI_STATIC) + +-target_compile_definitions(cimgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1) + if (WIN32) +- target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API=extern\t\"C\"\t__declspec\(dllexport\)) ++ target_compile_definitions(libcimgui PUBLIC IMGUI_IMPL_API=extern\t\"C\"\t__declspec\(dllexport\)) + list(APPEND IMGUI_LIBRARIES imm32) + else (WIN32) +- target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API=extern\t\"C\"\t) ++ target_compile_definitions(libcimgui PUBLIC IMGUI_IMPL_API=extern\t\"C\"\t) + endif (WIN32) + +-target_include_directories(cimgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +-target_include_directories(cimgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui) +-set_target_properties(cimgui PROPERTIES PREFIX "") +-target_link_libraries(cimgui ${IMGUI_LIBRARIES}) ++target_include_directories(libcimgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/imgui) ++set_target_properties(libcimgui PROPERTIES PREFIX "") ++target_link_libraries(libcimgui PUBLIC -limgui) + + #install +-install(TARGETS cimgui ++install(TARGETS libcimgui + RUNTIME DESTINATION . + LIBRARY DESTINATION . + ARCHIVE DESTINATION . diff --git a/media-libs/imgui/imgui-1.87-r1.ebuild b/media-libs/imgui/imgui-1.87-r2.ebuild index 4339ad386..f51097b79 100644 --- a/media-libs/imgui/imgui-1.87-r1.ebuild +++ b/media-libs/imgui/imgui-1.87-r2.ebuild @@ -3,16 +3,25 @@ EAPI=8 -inherit flag-o-matic toolchain-funcs +inherit cmake flag-o-matic toolchain-funcs + +CMAKE_IN_SOURCE_BUILD=1 DESCRIPTION="Bloat-free graphical user interface library for C++" -HOMEPAGE="https://github.com/ocornut/imgui" -SRC_URI="https://github.com/ocornut/imgui/archive/v${PV}.tar.gz -> ${P}.tar.gz" +HOMEPAGE=" + https://github.com/ocornut/imgui + https://github.com/cimgui/cimgui +" +SRC_URI=" + https://github.com/ocornut/imgui/archive/v${PV}.tar.gz -> ${P}.tar.gz + https://github.com/cimgui/cimgui/archive/refs/tags/${PV}.tar.gz -> c${P}.tar.gz +" LICENSE="MIT" SLOT="0" KEYWORDS="~amd64" -IUSE="allegro examples freetype glfw glut opengl sdl vulkan" +IUSE="allegro bindings examples freetype glfw glut opengl sdl vulkan" +S="${WORKDIR}/c${P}" RDEPEND=" allegro? ( media-libs/allegro:5 ) @@ -27,12 +36,20 @@ DEPEND=" ${RDEPEND} vulkan? ( dev-util/vulkan-headers ) " -BDEPEND="virtual/pkgconfig" +BDEPEND=" + bindings? ( dev-lang/luajit ) + virtual/pkgconfig +" +PATCHES=( "${FILESDIR}/c${P}-fix-cmake.patch" ) REQUIRED_USE=" || ( allegro - || ( glfw glut sdl ) + || ( + glfw + glut + sdl + ) || ( opengl vulkan ) ) examples? ( @@ -46,45 +63,75 @@ REQUIRED_USE=" " src_prepare() { + pushd ../ || die + rm -rf "${S}/imgui" || die + mv "${P}" "${S}/imgui" || die + pushd "${S}/imgui" || die + + # imgui rm -r examples/libs || die rm -r misc/*/*.ttf || die rm -r misc/single_file || die - default + + # cimgui + if use bindings; then + pushd "${S}" || die + cmake_src_prepare + else + eapply_user + fi } src_configure() { + pushd imgui || die + + # imgui tc-export CXX append-cppflags "-DIMGUI_USE_WCHAR32" - append-cxxflags "-I${S} -I${S}/backends -I${S}/misc/freetype -fPIC -fpermissive" + COMMONFLAGS="-I${S}/imgui -I${S}/imgui/backends -I${S}/imgui/misc/freetype -fPIC -fpermissive" local PKGCONF="$(tc-getPKG_CONFIG)" || die use allegro && append-libs "-lallegro -lallegro_main -lallegro_primitives" if use freetype; then append-cppflags "-DIMGUI_ENABLE_FREETYPE -DIMGUI_ENABLE_STB_TRUETYPE" - append-cxxflags "$(${PKGCONF} --cflags freetype2)" || die + COMMONFLAGS="${COMMONFLAGS} $(${PKGCONF} --cflags freetype2)" || die append-libs "$(${PKGCONF} --libs freetype2)" || die fi if use glfw; then append-libs "$(${PKGCONF} --libs glfw3)" || die - append-cxxflags "$(${PKGCONF} --cflags glfw3)" || die + COMMONFLAGS="${COMMONFLAGS} $(${PKGCONF} --cflags glfw3)" || die fi if use glut; then append-libs "$(${PKGCONF} --libs freeglut)" || die - append-cxxflags "$(${PKGCONF} --cflags freeglut)" || die + COMMONFLAGS="${COMMONFLAGS} $(${PKGCONF} --cflags freeglut)" || die fi use opengl && append-libs "-lGL" if use sdl; then append-libs "-ldl $(sdl2-config --libs)" || die - append-cxxflags "$(sdl2-config --cflags)" || die + COMMONFLAGS="${COMMONFLAGS} $(sdl2-config --cflags)" || die fi if use vulkan; then append-libs "$(${PKGCONF} --libs vulkan)" || die - append-cxxflags "$(${PKGCONF} --cflags vulkan)" || die + COMMONFLAGS="${COMMONFLAGS} $(${PKGCONF} --cflags vulkan)" || die append-cppflags "-DImTextureID=ImU64" || die fi + append-cxxflags "${COMMONFLAGS}" + popd || die + + # cimgui + if use bindings; then + local mycmakeargs=( + -DIMGUI_FREETYPE=$(usex freetype) + -DIMGUI_STATIC=OFF + ) + cmake_src_configure + fi } src_compile() { + pushd imgui || die + + # imgui set -x || die local objects=() @@ -137,14 +184,39 @@ src_compile() { if use examples; then mkdir ex || die for f in allegro5 glfw_opengl{2,3} glfw_vulkan null sdl_opengl{2,3} sdl_{sdlrenderer,vulkan} glut_opengl2 ; do - ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} -fPIE examples/example_${f}/main.cpp "-L${S}" -limgui ${LIBS} -o "${S}/ex/example_${f}" || die + ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} -fPIE examples/example_${f}/main.cpp "-L${S}/imgui" -limgui ${LIBS} -o "${S}/imgui/ex/example_${f}" || die done fi set +x || die + popd || die + + # cimgui + if use bindings; then + pushd generator || die + local myargs=() + use allegro && myargs+=( allegro5 ) + use glfw && myargs+=( glfw ) + use glut && myargs+=( glut ) + use opengl && myargs+=( opengl3 opengl2 ) + use sdl && myargs+=( sdl sdlrenderer ) + use vulkan && myargs+=( vulkan ) + myargs+=( ${CFLAGS} ${COMMONFLAGS} ${CPPFLAGS} ) + + if use freetype ; then + luajit ./generator.lua gcc "internal freetype" ${myargs[@]} || die + else + luajit ./generator.lua gcc "internal" ${myargs[@]} || die + fi + popd || die + cmake_src_compile + fi } src_install() { + pushd imgui || die + + # imgui dolib.so libimgui.so dodoc docs/* insinto "/usr/include/imgui" @@ -164,4 +236,14 @@ src_install() { dodoc -r examples docompress -x "/usr/share/doc/${PF}/examples" fi + + popd || die + + # cimgui + if use bindings; then + dolib.so libcimgui.so + insinto "/usr/share/doc/${PF}/cimgui" + doins README.md TODO.txt + doheader cimgui.h + fi } diff --git a/media-libs/imgui/metadata.xml b/media-libs/imgui/metadata.xml index 2a6d52b5d..766c22dfc 100644 --- a/media-libs/imgui/metadata.xml +++ b/media-libs/imgui/metadata.xml @@ -9,9 +9,11 @@ <upstream> <bugs-to>https://github.com/ocornut/imgui/issues</bugs-to> <remote-id type="github">ocornut/imgui</remote-id> + <remote-id type="github">cimgui/cimgui</remote-id> </upstream> <use> <flag name="allegro">Enable allegro backend and renderer</flag> + <flag name="bindings">Build the cimgui C bindigs</flag> <flag name="freetype">Use FreeType to build and rasterize the font atlas</flag> <flag name="glfw">Enable glfw backend</flag> <flag name="glut">Enable glut backen</flag> |