add imgui package (#42)
This commit is contained in:
63
imgui/build.sh
Executable file
63
imgui/build.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||
cd "$DIR"
|
||||
|
||||
INSTALL_DIR="$DIR/imgui/install"
|
||||
|
||||
# Idempotent: skip if already present
|
||||
if [ -f "$INSTALL_DIR/include/imgui.h" ]; then
|
||||
echo "imgui already present, skipping download."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Dear ImGui (docking branch)
|
||||
IMGUI_VERSION="1.92.7"
|
||||
IMGUI_COMMIT="934c6a5f5ef2355d6df25395d555cb71f790c4e9"
|
||||
IMGUI_URL="https://github.com/ocornut/imgui/archive/${IMGUI_COMMIT}.tar.gz"
|
||||
|
||||
# ImPlot (master)
|
||||
IMPLOT_COMMIT="93c801b4bb801c5c11031d880b6af1d1f70bd79d"
|
||||
IMPLOT_URL="https://github.com/epezent/implot/archive/${IMPLOT_COMMIT}.tar.gz"
|
||||
|
||||
# rlImGui (main)
|
||||
RLIMGUI_COMMIT="286e11acd6c785004c9550c7ed3762add2ae3d47"
|
||||
RLIMGUI_URL="https://github.com/raylib-extras/rlImGui/archive/${RLIMGUI_COMMIT}.tar.gz"
|
||||
|
||||
rm -rf "$INSTALL_DIR"
|
||||
mkdir -p "$INSTALL_DIR/include/extras" "$INSTALL_DIR/src"
|
||||
|
||||
TMPDIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMPDIR"' EXIT
|
||||
|
||||
echo "Downloading Dear ImGui ${IMGUI_VERSION} (docking) ..."
|
||||
curl -fSL -o "$TMPDIR/imgui.tar.gz" "$IMGUI_URL"
|
||||
mkdir -p "$TMPDIR/imgui"
|
||||
tar --strip-components=1 -xzf "$TMPDIR/imgui.tar.gz" -C "$TMPDIR/imgui"
|
||||
cp "$TMPDIR/imgui/imgui.h" "$TMPDIR/imgui/imgui_internal.h" "$TMPDIR/imgui/imconfig.h" \
|
||||
"$TMPDIR/imgui/imstb_rectpack.h" "$TMPDIR/imgui/imstb_textedit.h" "$TMPDIR/imgui/imstb_truetype.h" \
|
||||
"$INSTALL_DIR/include/"
|
||||
cp "$TMPDIR/imgui/imgui.cpp" "$TMPDIR/imgui/imgui_draw.cpp" "$TMPDIR/imgui/imgui_tables.cpp" \
|
||||
"$TMPDIR/imgui/imgui_widgets.cpp" "$TMPDIR/imgui/imgui_demo.cpp" \
|
||||
"$INSTALL_DIR/src/"
|
||||
|
||||
echo "Downloading ImPlot ..."
|
||||
curl -fSL -o "$TMPDIR/implot.tar.gz" "$IMPLOT_URL"
|
||||
mkdir -p "$TMPDIR/implot"
|
||||
tar --strip-components=1 -xzf "$TMPDIR/implot.tar.gz" -C "$TMPDIR/implot"
|
||||
cp "$TMPDIR/implot/implot.h" "$TMPDIR/implot/implot_internal.h" "$INSTALL_DIR/include/"
|
||||
cp "$TMPDIR/implot/implot.cpp" "$TMPDIR/implot/implot_items.cpp" "$INSTALL_DIR/src/"
|
||||
|
||||
echo "Downloading rlImGui ..."
|
||||
curl -fSL -o "$TMPDIR/rlimgui.tar.gz" "$RLIMGUI_URL"
|
||||
mkdir -p "$TMPDIR/rlimgui"
|
||||
tar --strip-components=1 -xzf "$TMPDIR/rlimgui.tar.gz" -C "$TMPDIR/rlimgui"
|
||||
cp "$TMPDIR/rlimgui/rlImGui.h" "$TMPDIR/rlimgui/rlImGuiColors.h" "$TMPDIR/rlimgui/imgui_impl_raylib.h" \
|
||||
"$INSTALL_DIR/include/"
|
||||
cp "$TMPDIR/rlimgui/extras/FA6FreeSolidFontData.h" "$TMPDIR/rlimgui/extras/IconsFontAwesome6.h" \
|
||||
"$INSTALL_DIR/include/extras/"
|
||||
cp "$TMPDIR/rlimgui/rlImGui.cpp" "$INSTALL_DIR/src/"
|
||||
|
||||
echo "Installed imgui to $INSTALL_DIR"
|
||||
du -sh "$INSTALL_DIR"
|
||||
10
imgui/imgui/__init__.py
Normal file
10
imgui/imgui/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import os
|
||||
|
||||
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||
SRC_DIR = os.path.join(DIR, "src")
|
||||
|
||||
|
||||
def smoketest():
|
||||
assert os.path.isfile(os.path.join(INCLUDE_DIR, "imgui.h")), "imgui.h not found"
|
||||
assert os.path.isfile(os.path.join(SRC_DIR, "imgui.cpp")), "imgui.cpp not found"
|
||||
15
imgui/pyproject.toml
Normal file
15
imgui/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=64", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "imgui"
|
||||
version = "1.92.7"
|
||||
description = "Dear ImGui + ImPlot + rlImGui (source distribution)"
|
||||
requires-python = ">=3.8"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
include = ["imgui*"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
imgui = ["install/**/*"]
|
||||
61
imgui/setup.py
Normal file
61
imgui/setup.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
from setuptools.command.build_py import build_py
|
||||
|
||||
try:
|
||||
from wheel.bdist_wheel import bdist_wheel
|
||||
except ImportError:
|
||||
bdist_wheel = None
|
||||
|
||||
|
||||
class BuildImgui(build_py):
|
||||
"""Run build.sh to download imgui sources before collecting package data."""
|
||||
|
||||
def run(self):
|
||||
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
marker = os.path.join(pkg_dir, "imgui", "install", "include", "imgui.h")
|
||||
|
||||
if not os.path.isfile(marker):
|
||||
build_script = os.path.join(pkg_dir, "build.sh")
|
||||
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||
|
||||
super().run()
|
||||
|
||||
|
||||
cmdclass = {"build_py": BuildImgui}
|
||||
|
||||
if bdist_wheel is not None:
|
||||
|
||||
class PlatformWheel(bdist_wheel):
|
||||
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||
|
||||
def finalize_options(self):
|
||||
super().finalize_options()
|
||||
self.root_is_pure = False
|
||||
|
||||
def get_tag(self):
|
||||
system = platform.system()
|
||||
machine = platform.machine()
|
||||
|
||||
if system == "Linux":
|
||||
plat = f"linux_{machine}"
|
||||
elif system == "Darwin":
|
||||
plat = "macosx_11_0_arm64"
|
||||
else:
|
||||
plat = f"{system.lower()}_{machine}"
|
||||
|
||||
return "py3", "none", plat
|
||||
|
||||
cmdclass["bdist_wheel"] = PlatformWheel
|
||||
|
||||
|
||||
def setup():
|
||||
from setuptools import setup as _setup
|
||||
|
||||
_setup(cmdclass=cmdclass)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
||||
@@ -7,6 +7,7 @@ members = [
|
||||
"ffmpeg",
|
||||
"gcc-arm-none-eabi",
|
||||
"git-lfs",
|
||||
"imgui",
|
||||
"json11",
|
||||
"libjpeg",
|
||||
"libyuv",
|
||||
|
||||
Reference in New Issue
Block a user