From f03c00bc89c4ba9b45f4e216d943e1d890dfbac0 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Fri, 10 Jan 2020 19:36:26 +0200 Subject: [PATCH] Added imgui_single_file.h, We use this to validate compiling all *.cpp in same compilation unit. Removed Unity builds stuff from example_null/. CI builds a temporary .cpp file. --- .github/workflows/build.yml | 25 +++++++++++++++++++------ docs/CHANGELOG.txt | 5 ++++- examples/example_null/Makefile | 9 ++------- examples/example_null/unity_build.cpp | 6 ------ misc/single_file/imgui_single_file.h | 17 +++++++++++++++++ 5 files changed, 42 insertions(+), 20 deletions(-) delete mode 100644 examples/example_null/unity_build.cpp create mode 100644 misc/single_file/imgui_single_file.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 856e29f5..04f8f6dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,8 +44,13 @@ jobs: - name: Build example_null (extra warnings) run: mingw32-make -C examples/example_null EXTRA_WARNINGS=1 - - name: Build example_null (unity build) - run: mingw32-make -C examples/example_null UNITY_BUILD=1 + - name: Build example_null (single file build) + shell: bash + run: | + echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp + echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp + echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp + g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp - name: Build Win32 example_glfw_opengl2 shell: cmd @@ -176,8 +181,12 @@ jobs: make -C examples/example_null clean CXXFLAGS="$CXXFLAGS -m64" CXX=clang++ make -C examples/example_null EXTRA_WARNINGS=1 - - name: Build example_null (unity build) - run: make -C examples/example_null UNITY_BUILD=1 + - name: Build example_null (single file build) + run: | + echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp + echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp + echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp + g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - name: Build example_glfw_opengl2 run: make -C examples/example_glfw_opengl2 @@ -208,8 +217,12 @@ jobs: - name: Build example_null (extra warnings) run: make -C examples/example_null EXTRA_WARNINGS=1 - - name: Build example_null (unity build) - run: make -C examples/example_null UNITY_BUILD=1 + - name: Build example_null (single file build) + run: | + echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp + echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp + echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp + clang++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - name: Build example_glfw_opengl2 run: make -C examples/example_glfw_opengl2 diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 36d10732..5f6d16d6 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -68,11 +68,14 @@ Other Changes: - ColorEdit: In HSV display of a RGB stored value, attempt to locally preserve Saturation when Value==0.0 (similar to changes done in 1.73 for Hue). Removed Hue editing lock since those improvements in 1.73 makes them unnecessary. (#2722, #2770). [@rokups] -- Misc: Added ImGuiMouseCursor_NotAllowed enum so it can be used by more shared widgets. [@rokups] - ImDrawList: Add AddNgon(), AddNgonFilled() API with a guarantee on the explicit segment count. In the current branch they are essentially the same as AddCircle(), AddCircleFilled() but as we will rework the circle rendering functions to use textures and automatic segment count selection, those new api can fill a gap. [@ShironekoBen] +- Misc: Added ImGuiMouseCursor_NotAllowed enum so it can be used by more shared widgets. [@rokups] +- Misc: Added misc/single_file/imgui_single_file.h, We use this to validate compiling all *.cpp + files in a same compilation unit. Actual users of that technique (also called "Unity builds") + can generally provide this themselves, so we don't really recommend you use this. [@rokups] - Backends: GLFW, SDL, Win32, OSX, Allegro: Added support for ImGuiMouseCursor_NotAllowed. [@rokups] - Backends: GLFW: Added support for the missing mouse cursors newly added in GLFW 3.4+. [@rokups] - Backends: SDL: Wayland: use SDL_GetMouseState (because there is no global mouse state available diff --git a/examples/example_null/Makefile b/examples/example_null/Makefile index 3930eb27..7d39e824 100644 --- a/examples/example_null/Makefile +++ b/examples/example_null/Makefile @@ -5,13 +5,8 @@ EXE = example_null EXTRA_WARNINGS ?= 0 -UNITY_BUILD ?= 0 -ifeq ($(UNITY_BUILD), 1) - SOURCES = unity_build.cpp -else - SOURCES = main.cpp - SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp -endif +SOURCES = main.cpp +SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) diff --git a/examples/example_null/unity_build.cpp b/examples/example_null/unity_build.cpp deleted file mode 100644 index c6040016..00000000 --- a/examples/example_null/unity_build.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Unity build test - build this example as a single compilation unit. -#include "main.cpp" -#include "../../imgui.cpp" -#include "../../imgui_demo.cpp" -#include "../../imgui_draw.cpp" -#include "../../imgui_widgets.cpp" diff --git a/misc/single_file/imgui_single_file.h b/misc/single_file/imgui_single_file.h new file mode 100644 index 00000000..a556931c --- /dev/null +++ b/misc/single_file/imgui_single_file.h @@ -0,0 +1,17 @@ +// imgui_single_file.h +// We use this to validate compiling all *.cpp files in a same compilation unit. +// Users of that technique (also called "Unity builds") can generally provide this themselves, +// so we don't really recommend you use this in your projects. + +// Do this: +// #define IMGUI_IMPLEMENTATION +// Before you include this file in *one* C++ file to create the implementation. +// Using this in your project will leak the contents of imgui_internal.h and ImVec2 operators in this compilation unit. +#include "../../imgui.h" + +#ifdef IMGUI_IMPLEMENTATION +#include "../../imgui.cpp" +#include "../../imgui_demo.cpp" +#include "../../imgui_draw.cpp" +#include "../../imgui_widgets.cpp" +#endif