From d14d45aef4f41cbe5d6b1fb8cfd9f2c62a05d1e6 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 13 Mar 2026 16:47:36 -0700 Subject: [PATCH] imgui: add statically linked GLFW 3.4 build (#53) --- imgui/build.sh | 40 +++++++++++++++++++++++++++++++++++++++- imgui/imgui/__init__.py | 3 +++ imgui/pyproject.toml | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/imgui/build.sh b/imgui/build.sh index 4ca320c..56bc39a 100755 --- a/imgui/build.sh +++ b/imgui/build.sh @@ -5,6 +5,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" cd "$DIR" INSTALL_DIR="$DIR/imgui/install" +NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)" # Dear ImGui (docking branch, version 1.92.7) IMGUI_COMMIT="934c6a5f5ef2355d6df25395d555cb71f790c4e9" @@ -12,6 +13,8 @@ IMGUI_COMMIT="934c6a5f5ef2355d6df25395d555cb71f790c4e9" IMPLOT_COMMIT="93c801b4bb801c5c11031d880b6af1d1f70bd79d" # rlImGui RLIMGUI_COMMIT="286e11acd6c785004c9550c7ed3762add2ae3d47" +# GLFW 3.4 +GLFW_COMMIT="7b6aead9fb88b3623e3b3725ebb42670cbe4c579" # Clone/update imgui if [ ! -d "imgui-src/.git" ]; then @@ -37,9 +40,40 @@ fi git -C rlimgui-src fetch --depth 1 origin "$RLIMGUI_COMMIT" git -C rlimgui-src checkout --force "$RLIMGUI_COMMIT" +# Clone/update GLFW +if [ ! -d "glfw-src/.git" ]; then + rm -rf glfw-src + git clone --depth 1 https://github.com/glfw/glfw.git glfw-src +fi +git -C glfw-src fetch --depth 1 origin "$GLFW_COMMIT" +git -C glfw-src checkout --force "$GLFW_COMMIT" + +# Install GLFW build dependencies +if [[ "$(uname)" == "Linux" ]]; then + if command -v dnf &>/dev/null; then + dnf install -y libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel libXi-devel mesa-libGL-devel + elif command -v apt-get &>/dev/null; then + if [ "$(id -u)" -eq 0 ]; then + apt-get update && apt-get install -y libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libgl-dev + else + sudo apt-get update && sudo apt-get install -y libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libgl-dev + fi + fi +fi + +# Build GLFW static library +cmake -B glfw-src/build -S glfw-src \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DGLFW_BUILD_EXAMPLES=OFF \ + -DGLFW_BUILD_TESTS=OFF \ + -DGLFW_BUILD_DOCS=OFF \ + -DGLFW_BUILD_WAYLAND=OFF +cmake --build glfw-src/build --parallel "$NJOBS" + # Install rm -rf "$INSTALL_DIR" -mkdir -p "$INSTALL_DIR/include/extras" "$INSTALL_DIR/src" +mkdir -p "$INSTALL_DIR/include/extras" "$INSTALL_DIR/src" "$INSTALL_DIR/lib" # imgui cp imgui-src/imgui.h imgui-src/imgui_internal.h imgui-src/imconfig.h \ @@ -65,5 +99,9 @@ cp rlimgui-src/extras/FA6FreeSolidFontData.h rlimgui-src/extras/IconsFontAwesome "$INSTALL_DIR/include/extras/" cp rlimgui-src/rlImGui.cpp "$INSTALL_DIR/src/" +# glfw +cp glfw-src/build/src/libglfw3.a "$INSTALL_DIR/lib/" +cp -r glfw-src/include/GLFW "$INSTALL_DIR/include/" + echo "Installed imgui to $INSTALL_DIR" du -sh "$INSTALL_DIR" diff --git a/imgui/imgui/__init__.py b/imgui/imgui/__init__.py index ae698cd..8a528c6 100644 --- a/imgui/imgui/__init__.py +++ b/imgui/imgui/__init__.py @@ -3,8 +3,11 @@ 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") +LIB_DIR = os.path.join(DIR, "lib") 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" + assert os.path.isfile(os.path.join(LIB_DIR, "libglfw3.a")), "libglfw3.a not found" + assert os.path.isfile(os.path.join(INCLUDE_DIR, "GLFW", "glfw3.h")), "GLFW/glfw3.h not found" diff --git a/imgui/pyproject.toml b/imgui/pyproject.toml index 22eeff7..ae380eb 100644 --- a/imgui/pyproject.toml +++ b/imgui/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "imgui" version = "1.92.7" -description = "Dear ImGui + ImPlot + rlImGui (source distribution)" +description = "Dear ImGui + ImPlot + rlImGui + GLFW 3.4 (static)" requires-python = ">=3.8" [tool.setuptools.packages.find]