Last active
September 9, 2021 11:57
-
-
Save gvanem/a7a9b98c307107ed34bb4e813014d9d7 to your computer and use it in GitHub Desktop.
A GNU-makefile for DearPyGui (MSVC / clang-cl)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# GNU Makefile for DearPyGui (MSVC / clang-cl). | |
# | |
# By G. Vanem <[email protected]> 2021. | |
# | |
# Ref: https://github.com/hoffstadt/DearPyGui.git | |
# | |
TODAY = $(shell date +%d-%B-%Y) | |
THIS_FILE = $(firstword $(MAKEFILE_LIST)) | |
# | |
# From 'git describe --tags' | |
# | |
VER_MAJOR = 0 | |
VER_MINOR = 8 | |
VER_MICRO = 41 | |
VERSION = $(VER_MAJOR).$(VER_MINOR).$(VER_MICRO) | |
SRC_ROOT = f:/MinGW32/src | |
PYTHON ?= py -3 | |
# | |
# Change 'x_ROOT' settings to suite: | |
# | |
# Use this? | |
# PY_ROOT = $(realpath $(shell $(PYTHON) -c "import sys; print (sys.prefix)")) | |
# PY_VER = $(realpath $(shell $(PYTHON) -c "import sys; print ('%d%d' % (sys.version_info.major, sys.version_info.minor))" | |
PY_VER ?= 36 | |
PY_ROOT ?= f:/ProgramFiler/Python$(PY_VER) | |
PY_SITE_DIR = $(PY_ROOT)/lib/site-packages | |
IMGUI_ROOT = Dependencies/imgui | |
VLD_ROOT = f:/ProgramFiler/VisualLeakDetector | |
# | |
# Use CRT debug-mode. | |
# | |
USE_CRT_DEBUG ?= 0 | |
# | |
# Compile several .cpp-files at once (effective for MSVC only) | |
# | |
USE_MP_COMPILE ?= 1 | |
# | |
# Enable 'DearPyGui/src/core/dpg_trace.c' code and 'DPG_TRACE()' macro. | |
# | |
USE_DPG_TRACE ?= 0 | |
# | |
# Enable 'Dependencies/spdlog' | |
# | |
USE_SPDLOG ?= 0 | |
# | |
# Visual Leak Detector: | |
# https://kinddragon.github.io/vld/ | |
# https://github.com/KindDragon/vld/ | |
# | |
USE_VLD ?= 0 | |
# | |
# For the C-preprocess rule below. | |
# | |
USE_ASTYLE ?= 1 | |
USE_CLANG_FORMAT ?= 1 | |
# | |
# Filter out the '-Dxx' arguments from the CFLAGS and sort them. | |
# Same for '-Ixx' arguments but do not sort them. | |
# | |
filter_D_args_first = $(sort $(filter -D%, $(1))) $(filter-out -D%, $(1)) | |
# | |
# Return a list of .obj-files from .cpp-files. | |
# Can also be used as 'x_OBJ = $(call cpp_to_obj, $(x_SRC), subdir/)'. | |
# If so there must be a specific '$(OBJ_DIR)/subdir/%.obj: %.cpp' rule for it. | |
# | |
cpp_to_obj = $(addprefix $(OBJ_DIR)/$(strip $(2)), \ | |
$(notdir $(1:.cpp=.obj))) | |
c_to_obj = $(addprefix $(OBJ_DIR)/$(strip $(2)), \ | |
$(notdir $(1:.c=.obj))) | |
define Usage | |
Usage: "make -f $(THIS_FILE) [CC=cl | clang-cl] [all | clean | vclean | depend]") | |
Specify CC=cl - use MSVC | |
Specify CC=clang-cl - use clang-cl | |
endef | |
# | |
# Undefine these env-vars: | |
# | |
export CL= | |
export C_INCLUDE_PATH= | |
OBJ_DIR = objects | |
RCFLAGS = -nologo | |
ifeq ($(CC),cl) | |
RCFLAGS += -D_MSC_VER | |
else ifeq ($(CC),clang-cl) | |
RCFLAGS += -D__clang__ | |
USE_MP_COMPILE = 0 | |
else | |
$(error $(Usage)) | |
endif | |
CFLAGS = -nologo -W3 -Zi -Zo -Gd -GR -EHsc -std:c++17 -FI./PyGui_config.h | |
LDFLAGS = -nologo -debug -map -verbose \ | |
-incremental:no -machine:$(CPU) \ | |
-nodefaultlib:python39.lib \ | |
-nodefaultlib:python39_d.lib \ | |
-nodefaultlib:uuid.lib | |
ifeq ($(USE_CRT_DEBUG),1) | |
CFLAGS += -MDd -GS -Oy- -Od -RTCu -RTCs | |
RCFLAGS += -D_DEBUG | |
D = _d | |
ifeq ($(CC),clang-cl) | |
CFLAGS += -arch:SSE2 | |
else | |
CFLAGS += -arch:IA32 | |
endif | |
else | |
CFLAGS += -MD -Ox -Ob1 -GS- -Oy -arch:AVX2 -DMV_RELEASE=1 | |
endif | |
ifeq ($(CC),clang-cl) | |
CFLAGS += -fms-compatibility \ | |
-ferror-limit=5 | |
endif | |
CFLAGS += -I. -I./ImguiTesting/src \ | |
-I./DearPyGui/vendor/implot \ | |
-I./DearPyGui/vendor/stb \ | |
-I./DearPyGui/vendor/imnodes \ | |
-I./DearPyGui/vendor/dirent \ | |
-I./DearPyGui/src \ | |
-I./DearPyGui/src/core \ | |
-I./DearPyGui/src/core/CustomImGuiWidgets \ | |
-I./DearPyGui/src/core/Modules \ | |
-I./DearPyGui/src/core/AppItems \ | |
-I./DearPyGui/src/core/DrawCommands \ | |
-I./DearPyGui/src/core/CppUtilities \ | |
-I./DearPyGui/src/core/PythonUtilities \ | |
-I./DearPyGui/src/core/Theming \ | |
-I./DearPyGui/src/core/Tooling \ | |
-I./Dependencies/ImGuiFileDialog \ | |
-I./Dependencies/ImGuiFileDialog/ImGuiFileDialog | |
CFLAGS += -I$(IMGUI_ROOT) \ | |
-I$(IMGUI_ROOT)/misc/freetype \ | |
-I$(IMGUI_ROOT)/backends \ | |
-I$(IMGUI_ROOT)/examples/libs/gl3w | |
CFLAGS += -I./Dependencies/freetype/include \ | |
-DFT2_BUILD_LIBRARY=1 \ | |
-DIMGUI_USE_WCHAR32 | |
ifeq ($(USE_SPDLOG),1) | |
CFLAGS += -DMV_LOG -DSPDLOG_COMPILED_LIB -I./Dependencies/spdlog/include | |
spdlog_LIB = spdlog.lib | |
endif | |
ifeq ($(USE_DPG_TRACE),1) | |
CFLAGS += -DUSE_DPG_TRACE | |
TRACE_OBJ = $(OBJ_DIR)/dpg_trace.obj | |
endif | |
ifeq ($(USE_VLD),1) | |
CFLAGS += -DUSE_VLD -DVLD_FORCE_ENABLE -I$(VLD_ROOT)/include | |
LDFLAGS += -libpath:$(VLD_ROOT)/lib/Win32 | |
VLD_LIB = $(VLD_ROOT)/lib/Win32/vld.lib | |
endif | |
# | |
# This ESC code assumes you have an MSys/Cygwin 'echo.exe' with colour support. | |
# | |
BRIGHT_GREEN = \e[1;32m | |
BRIGHT_WHITE = \e[1;37m | |
colour_msg = @echo -e "$(1)\e[0m" | |
green_msg = $(call colour_msg,$(BRIGHT_GREEN)$(strip $(1))) | |
green_msg0 = $(call colour_msg,$(BRIGHT_GREEN)$(1)) | |
# | |
# What to build: | |
# | |
PY_MODULE = $(PY_SITE_DIR)/dearpygui/_dearpygui.pyd | |
TARGETS += DearPyGui.lib \ | |
$(spdlog_LIB) \ | |
DearSandbox.exe \ | |
PureImGui.exe \ | |
$(PY_MODULE) | |
# | |
# Using the internal 'Dependencies/cpython' is not supported. | |
# Use your own favorite. | |
# | |
CFLAGS += -I$(PY_ROOT)/include | |
LDFLAGS += -libpath:$(PY_ROOT)/libs | |
python_LIB = $(PY_ROOT)/libs/python$(PY_VER)$(D).lib | |
# | |
# Now, let the build commence ... | |
# | |
VPATH = DearPyGui/src/core | |
LIB_SRC = $(addprefix DearPyGui/src/core/, \ | |
mvApp.cpp \ | |
mvBuffer.cpp \ | |
mvCallbackRegistry.cpp \ | |
mvEvents.cpp \ | |
mvInput.cpp \ | |
mvViewport.cpp \ | |
mvProfiler.cpp \ | |
mvLog.cpp) | |
VPATH += DearPyGui/src/core/PythonUtilities | |
LIB_SRC += $(addprefix DearPyGui/src/core/PythonUtilities/, \ | |
mvPyObject.cpp \ | |
mvPythonTranslator.cpp \ | |
mvPythonTypeChecker.cpp \ | |
mvPythonParser.cpp \ | |
mvPythonExceptions.cpp \ | |
mvGlobalIntepreterLock.cpp) | |
VPATH += DearPyGui/src/platform/Windows | |
LIB_SRC += DearPyGui/src/platform/Windows/mvWindowsViewport.cpp \ | |
DearPyGui/src/platform/Windows/mvUtilities.cpp | |
VPATH += DearPyGui/src/core/Theming | |
LIB_SRC += DearPyGui/src/core/Theming/mvFontManager.cpp | |
VPATH += DearPyGui/src/core/Tooling | |
LIB_SRC += $(addprefix DearPyGui/src/core/Tooling/, \ | |
mvAboutWindow.cpp \ | |
mvDebugWindow.cpp \ | |
mvDocWindow.cpp \ | |
mvLayoutWindow.cpp \ | |
mvMetricsWindow.cpp \ | |
mvStyleWindow.cpp \ | |
mvToolManager.cpp \ | |
mvToolWindow.cpp) | |
VPATH += DearPyGui/src/core/AppItems | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/, \ | |
mvAppItemState.cpp \ | |
mvAppItem.cpp \ | |
mvItemRegistry.cpp) | |
VPATH += DearPyGui/src/core/AppItems/basic | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/basic/, \ | |
mvMenuItem.cpp \ | |
mvInputText.cpp \ | |
mvText.cpp \ | |
mvSliderSingle.cpp \ | |
mvSliderMulti.cpp \ | |
mvImage.cpp \ | |
mvImageButton.cpp \ | |
mvRadioButton.cpp \ | |
mvListbox.cpp \ | |
mvCombo.cpp \ | |
mvCheckbox.cpp \ | |
mvButton.cpp \ | |
mvSelectable.cpp \ | |
mvTabButton.cpp \ | |
mvDragSingle.cpp \ | |
mvDragMulti.cpp \ | |
mvInputSingle.cpp \ | |
mvInputMulti.cpp) | |
VPATH += DearPyGui/src/core/AppItems/colors | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/colors/, \ | |
mvColorButton.cpp \ | |
mvColorEdit.cpp \ | |
mvColorMap.cpp \ | |
mvColorMapButton.cpp \ | |
mvColorMapRegistry.cpp \ | |
mvColorMapScale.cpp \ | |
mvColorMapSlider.cpp \ | |
mvColorPicker.cpp) | |
VPATH += DearPyGui/src/core/AppItems/composite | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/composite/, \ | |
mvFileDialog.cpp \ | |
mvFileExtension.cpp) | |
VPATH += DearPyGui/src/core/AppItems/containers | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/containers/, \ | |
mvCollapsingHeader.cpp \ | |
mvClipper.cpp \ | |
mvDragPayload.cpp \ | |
mvFilterSet.cpp \ | |
mvGroup.cpp \ | |
mvChild.cpp \ | |
mvTooltip.cpp \ | |
mvTab.cpp \ | |
mvTabBar.cpp \ | |
mvMenu.cpp \ | |
mvMenuBar.cpp \ | |
mvStagingContainer.cpp \ | |
mvTreeNode.cpp \ | |
mvViewportMenuBar.cpp \ | |
mvWindowAppItem.cpp) | |
VPATH += DearPyGui/src/core/AppItems/custom | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/custom/, \ | |
mvDatePicker.cpp \ | |
mvKnob.cpp \ | |
mvLoadingIndicator.cpp \ | |
mvSlider3D.cpp \ | |
mvTimePicker.cpp \ | |
mvTextEditor.cpp) | |
VPATH += DearPyGui/src/core/AppItems/drawing | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/drawing/, \ | |
mvDrawArrow.cpp \ | |
mvDrawBezierCubic.cpp \ | |
mvDrawBezierQuadratic.cpp \ | |
mvDrawCircle.cpp \ | |
mvDrawEllipse.cpp \ | |
mvDrawImage.cpp \ | |
mvDrawLayer.cpp \ | |
mvDrawLine.cpp \ | |
mvDrawList.cpp \ | |
mvDrawTriangle.cpp \ | |
mvDrawQuad.cpp \ | |
mvDrawRect.cpp \ | |
mvDrawPolygon.cpp \ | |
mvDrawPolyline.cpp \ | |
mvDrawText.cpp \ | |
mvViewportDrawList.cpp) | |
VPATH += DearPyGui/src/core/AppItems/fonts | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/fonts/, \ | |
mvCharRemap.cpp \ | |
mvFont.cpp \ | |
mvFontChars.cpp \ | |
mvFontRange.cpp \ | |
mvFontRangeHint.cpp \ | |
mvFontRegistry.cpp) | |
VPATH += DearPyGui/src/core/AppItems/handlers | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/handlers/, \ | |
mvHandlerRegistry.cpp \ | |
mvKeyDownHandler.cpp \ | |
mvKeyPressHandler.cpp \ | |
mvKeyReleaseHandler.cpp \ | |
mvMouseClickHandler.cpp \ | |
mvMouseDoubleClickHandler.cpp \ | |
mvMouseDownHandler.cpp \ | |
mvMouseDragHandler.cpp \ | |
mvMouseMoveHandler.cpp \ | |
mvMouseReleaseHandler.cpp \ | |
mvMouseWheelHandler.cpp) | |
VPATH += DearPyGui/src/core/AppItems/misc | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/misc/, \ | |
mvProgressBar.cpp \ | |
mvSameLine.cpp \ | |
mvSeparator.cpp \ | |
mvDummy.cpp \ | |
mvSpacing.cpp) | |
VPATH += DearPyGui/src/core/AppItems/nodes | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/nodes/, \ | |
mvNodeEditor.cpp \ | |
mvNode.cpp \ | |
mvNodeAttribute.cpp \ | |
mvNodeLink.cpp) | |
VPATH += DearPyGui/src/core/AppItems/plots | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/plots/, \ | |
mvPlot.cpp \ | |
mvAreaSeries.cpp \ | |
mvDragPoint.cpp \ | |
mvDragLine.cpp \ | |
mvAnnotation.cpp \ | |
mvHistogramSeries.cpp \ | |
mvSimplePlot.cpp \ | |
mvLineSeries.cpp \ | |
mvScatterSeries.cpp \ | |
mvStemSeries.cpp \ | |
mvStairSeries.cpp \ | |
mvBarSeries.cpp \ | |
mvErrorSeries.cpp \ | |
mvInfiniteLineSeries.cpp \ | |
mvHeatSeries.cpp \ | |
mvImageSeries.cpp \ | |
mvPieSeries.cpp \ | |
mvPlotAxis.cpp \ | |
mvPlotLegend.cpp \ | |
mvShadeSeries.cpp \ | |
mvSubPlots.cpp \ | |
mvLabelSeries.cpp \ | |
mvCandleSeries.cpp \ | |
mv2dHistogramSeries.cpp) | |
VPATH += DearPyGui/src/core/AppItems/tables | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/tables/, \ | |
mvTable.cpp \ | |
mvTableColumn.cpp \ | |
mvTableNextColumn.cpp \ | |
mvTableRow.cpp) | |
VPATH += DearPyGui/src/core/AppItems/textures | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/textures/, \ | |
mvDynamicTexture.cpp \ | |
mvRawTexture.cpp \ | |
mvTextureRegistry.cpp \ | |
mvStaticTexture.cpp) | |
VPATH += DearPyGui/src/core/AppItems/themes | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/themes/, \ | |
mvTheme.cpp \ | |
mvThemeColor.cpp \ | |
mvThemeStyle.cpp) | |
VPATH += DearPyGui/src/core/AppItems/values | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/values/, \ | |
mvBoolValue.cpp \ | |
mvColorValue.cpp \ | |
mvDouble4Value.cpp \ | |
mvDoubleValue.cpp \ | |
mvFloat4Value.cpp \ | |
mvFloatValue.cpp \ | |
mvFloatVectValue.cpp \ | |
mvInt4Value.cpp \ | |
mvIntValue.cpp \ | |
mvSeriesValue.cpp \ | |
mvStringValue.cpp \ | |
mvValueRegistry.cpp) | |
VPATH += DearPyGui/src/core/AppItems/widget_handlers | |
LIB_SRC += $(addprefix DearPyGui/src/core/AppItems/widget_handlers/, \ | |
mvActivatedHandler.cpp \ | |
mvActiveHandler.cpp \ | |
mvClickedHandler.cpp \ | |
mvDeactivatedAfterEditHandler.cpp \ | |
mvDeactivatedHandler.cpp \ | |
mvEditedHandler.cpp \ | |
mvFocusHandler.cpp \ | |
mvHoverHandler.cpp \ | |
mvResizeHandler.cpp \ | |
mvToggledOpenHandler.cpp \ | |
mvVisibleHandler.cpp) | |
VPATH += DearPyGui/src/core/CustomImGuiWidgets | |
LIB_SRC += $(addprefix DearPyGui/src/core/CustomImGuiWidgets/, \ | |
mvKnobCustom.cpp \ | |
mvLoadingIndicatorCustom.cpp) | |
#### End of 'core' files ################################ | |
VPATH += DearPyGui/vendor/implot | |
LIB_SRC += $(addprefix DearPyGui/vendor/implot/, \ | |
implot.cpp \ | |
implot_items.cpp \ | |
implot_demo.cpp) \ | |
VPATH += DearPyGui/vendor/imnodes | |
LIB_SRC += DearPyGui/vendor/imnodes/imnodes.cpp | |
VPATH += $(IMGUI_ROOT) | |
LIB_SRC += $(addprefix $(IMGUI_ROOT)/, \ | |
imgui.cpp \ | |
imgui_demo.cpp \ | |
imgui_draw.cpp \ | |
imgui_widgets.cpp \ | |
imgui_tables.cpp) | |
VPATH += $(IMGUI_ROOT)/backends | |
LIB_SRC += $(addprefix $(IMGUI_ROOT)/backends/, \ | |
imgui_impl_win32.cpp \ | |
imgui_impl_dx11.cpp) | |
VPATH += $(IMGUI_ROOT)/misc/freetype | |
LIB_SRC += $(IMGUI_ROOT)/misc/freetype/imgui_freetype.cpp | |
VPATH += $(IMGUI_ROOT)/misc/cpp | |
LIB_SRC += $(IMGUI_ROOT)/misc/cpp/imgui_stdlib.cpp | |
VPATH += Dependencies/ImGuiFileDialog/ImGuiFileDialog | |
LIB_SRC += Dependencies/ImGuiFileDialog/ImGuiFileDialog/ImGuiFileDialog.cpp | |
# | |
# .cpp-files for 'PureImGui.exe' | |
# | |
VPATH += ImguiTesting \ | |
ImguiTesting/src | |
PureImGui_SRC = ImguiTesting/main.cpp \ | |
ImguiTesting/src/mvWindowsWindow.cpp | |
# | |
# .cpp-files for the Python module. | |
# | |
VPATH += DearPyGui/src/core/Modules | |
_dearpygui_SRC = DearPyGui/src/core/Modules/mvModule_DearPyGui.cpp | |
freetype_SRC = $(addprefix Dependencies/freetype/src/, \ | |
autofit/autofit.c \ | |
\ | |
base/ftbase.c \ | |
base/ftbbox.c \ | |
base/ftbdf.c \ | |
base/ftbitmap.c \ | |
base/ftcid.c \ | |
base/ftdebug.c \ | |
base/ftfstype.c \ | |
base/ftgasp.c \ | |
base/ftglyph.c \ | |
base/ftgxval.c \ | |
base/ftinit.c \ | |
base/ftmm.c \ | |
base/ftotval.c \ | |
base/ftpatent.c \ | |
base/ftpfr.c \ | |
base/ftstroke.c \ | |
base/ftsynth.c \ | |
base/ftsystem.c \ | |
base/fttype1.c \ | |
base/ftwinfnt.c \ | |
\ | |
bdf/bdf.c \ | |
bzip2/ftbzip2.c \ | |
cache/ftcache.c \ | |
cff/cff.c \ | |
cid/type1cid.c \ | |
gzip/ftgzip.c \ | |
lzw/ftlzw.c \ | |
pcf/pcf.c \ | |
pfr/pfr.c \ | |
psaux/psaux.c \ | |
pshinter/pshinter.c \ | |
psnames/psnames.c \ | |
raster/raster.c \ | |
sfnt/sfnt.c \ | |
smooth/smooth.c \ | |
truetype/truetype.c \ | |
type1/type1.c \ | |
type42/type42.c \ | |
winfonts/winfnt.c) | |
spdlog_LIB_SRC = $(addprefix Dependencies/spdlog/src/, \ | |
spdlog.cpp \ | |
stdout_sinks.cpp \ | |
color_sinks.cpp \ | |
file_sinks.cpp \ | |
async.cpp \ | |
cfg.cpp \ | |
fmt.cpp) | |
# | |
# List of .obj-file for the above 'x_SRC': | |
# | |
DearPyGui_LIB_OBJ = $(call cpp_to_obj, $(LIB_SRC)) $(TRACE_OBJ) | |
PureImGui_OBJ = $(call cpp_to_obj, $(PureImGui_SRC)) $(OBJ_DIR)/PureImGui.res | |
spdlog_LIB_OBJ = $(call cpp_to_obj, $(spdlog_LIB_SRC), spdlog/) | |
_dearpygui_OBJ = $(call cpp_to_obj, $(_dearpygui_SRC)) $(OBJ_DIR)/_dearpygui.res | |
DearSandbox_OBJ = $(OBJ_DIR)/Sandbox_main.obj \ | |
$(OBJ_DIR)/mvModule_DearPyGui.obj \ | |
$(OBJ_DIR)/DearSandbox.res | |
freetype_OBJ = $(call c_to_obj, $(freetype_SRC), freetype/) | |
# | |
# Generated and force-included on ever compile (-FI./PyGui_config.h) | |
# | |
GENERATED = PyGui_config.h \ | |
$(OBJ_DIR)/__init__.py | |
all: $(OBJ_DIR) $(OBJ_DIR)/freetype $(OBJ_DIR)/spdlog $(PY_SITE_DIR)/dearpygui $(GENERATED) $(TARGETS) py_copy epilogue | |
$(OBJ_DIR) $(OBJ_DIR)/freetype $(OBJ_DIR)/spdlog $(PY_SITE_DIR)/dearpygui: | |
- mkdir $@ | |
epilogue: | |
$(call green_msg, Welcome to DearPyGui and the Python module.) | |
PyGui_config.h: $(THIS_FILE) | |
$(call Generate, $@, //) | |
$(file >> $@,$(PyGui_config_h)) | |
DearPyGui.lib: $(DearPyGui_LIB_OBJ) | |
$(call make_static_lib, $@, $^) | |
spdlog.lib: $(spdlog_LIB_OBJ) | |
$(call make_static_lib, $@, $^) | |
freetype.lib: $(freetype_OBJ) | |
$(call make_static_lib, $@, $(freetype_OBJ)) | |
lib/Python39$(D).lib: $(python_OBJ) | |
$(call make_static_lib, $@, $(python_OBJ)) | |
PureImGui.exe: $(PureImGui_OBJ) \ | |
freetype.lib \ | |
DearPyGui.lib \ | |
$(VLD_LIB) | \ | |
check-for-unused-libs.py | |
$(call link_EXE, $@, $^ d3d11.lib gdi32.lib user32.lib) | |
DearSandbox.exe: $(DearSandbox_OBJ) \ | |
DearPyGui.lib \ | |
$(spdlog_LIB) \ | |
freetype.lib \ | |
$(python_LIB) \ | |
$(VLD_LIB) | \ | |
check-for-unused-libs.py | |
$(call link_EXE, $@, $^ d3d11.lib gdi32.lib user32.lib atls.lib) | |
python: $(PY_MODULE) py_copy | |
PY_FILES = $(addprefix DearPyGui/dearpygui/, \ | |
dearpygui.py \ | |
_dearpygui.py \ | |
demo.py \ | |
logger.py \ | |
themes.py) | |
PY_FILES += DearSandbox/sandbox.py \ | |
$(OBJ_DIR)/__init__.py | |
py_copy: $(PY_SITE_DIR)/dearpygui $(OBJ_DIR)/__init__.py | |
$(call copy_files, $(PY_FILES), $<) | |
# | |
# The content of a 'dearpygui-0.8.45-cp36-cp36m-win_amd64.whl' file: | |
# | |
# adding 'dearpygui-0.8.45.data/purelib/dearpygui/__init__.py' | |
# adding 'dearpygui-0.8.45.data/purelib/dearpygui/_dearpygui.pyd' | |
# adding 'dearpygui-0.8.45.data/purelib/dearpygui/_dearpygui.pyi' | |
# adding 'dearpygui-0.8.45.data/purelib/dearpygui/dearpygui.py' | |
# adding 'dearpygui-0.8.45.data/purelib/dearpygui/demo.py' | |
# adding 'dearpygui-0.8.45.data/purelib/dearpygui/logger.py' | |
# adding 'dearpygui-0.8.45.data/purelib/dearpygui/themes.py' | |
# adding 'dearpygui-0.8.45.data/purelib/dearpygui/vcruntime140_1.dll' | |
# adding 'dearpygui-0.8.45.dist-info/LICENSE' | |
# adding 'dearpygui-0.8.45.dist-info/METADATA' | |
# adding 'dearpygui-0.8.45.dist-info/WHEEL' | |
# adding 'dearpygui-0.8.45.dist-info/top_level.txt' | |
# adding 'dearpygui-0.8.45.dist-info/RECORD' | |
$(PY_MODULE): $(_dearpygui_OBJ) \ | |
DearPyGui.lib \ | |
$(spdlog_LIB) \ | |
freetype.lib \ | |
$(python_LIB) \ | |
$(VLD_LIB) | \ | |
$(PY_SITE_DIR)/dearpygui \ | |
check-for-unused-libs.py | |
$(call link_PYD, $@, $^ d3d11.lib gdi32.lib user32.lib atls.lib) | |
ifeq ($(USE_MP_COMPILE),1) | |
define MP_compile | |
$(call green_msg, Compiling $(words $(filter %.cpp %.c, $(1))) files in one go.) | |
$(CC) @$(CC).args -MP -Fo$(OBJ_DIR)$(strip $(2))\\ $(1) | |
@echo | |
endef | |
LIB_SRC_chunk_1 = $(wordlist 1, 50, $(LIB_SRC)) | |
LIB_SRC_chunk_2 = $(wordlist 51, 100, $(LIB_SRC)) | |
LIB_SRC_chunk_3 = $(wordlist 101, 150, $(LIB_SRC)) | |
LIB_SRC_chunk_4 = $(wordlist 151, 290, $(LIB_SRC)) | |
LIB_OBJ_chunk_1 = $(call cpp_to_obj, $(LIB_SRC_chunk_1)) | |
LIB_OBJ_chunk_2 = $(call cpp_to_obj, $(LIB_SRC_chunk_2)) | |
LIB_OBJ_chunk_3 = $(call cpp_to_obj, $(LIB_SRC_chunk_3)) | |
LIB_OBJ_chunk_4 = $(call cpp_to_obj, $(LIB_SRC_chunk_4)) | |
$(LIB_OBJ_chunk_1): $(LIB_SRC_chunk_1) | $(CC).args PyGui_config.h | |
$(call MP_compile, $(LIB_SRC_chunk_1)) | |
$(LIB_OBJ_chunk_2): $(LIB_SRC_chunk_2) | $(CC).args PyGui_config.h | |
$(call MP_compile, $(LIB_SRC_chunk_2)) | |
$(LIB_OBJ_chunk_3): $(LIB_SRC_chunk_3) | $(CC).args PyGui_config.h | |
$(call MP_compile, $(LIB_SRC_chunk_3)) | |
$(LIB_OBJ_chunk_4): $(LIB_SRC_chunk_4) | $(CC).args PyGui_config.h | |
$(call MP_compile, $(LIB_SRC_chunk_4)) | |
$(freetype_OBJ): $(freetype_SRC) | $(CC).args PyGui_config.h | |
$(call MP_compile, $(freetype_SRC), /freetype) | |
endif | |
$(OBJ_DIR)/Sandbox_main.obj: DearSandbox/main.cpp $(OBJ_DIR) | |
$(CC) @$(CC).args -Fo$@ $< | |
@echo | |
$(OBJ_DIR)/%.obj: %.cpp | $(CC).args PyGui_config.h $(OBJ_DIR) | |
$(CC) @$(CC).args -Fo$@ $< | |
@echo | |
$(OBJ_DIR)/%.obj: %.c | $(CC).args PyGui_config.h | |
$(CC) @$(CC).args -Fo$@ $< | |
@echo | |
$(OBJ_DIR)/spdlog/%.obj: Dependencies/spdlog/src/%.cpp | $(CC).args PyGui_config.h $(OBJ_DIR)/spdlog | |
$(CC) @$(CC).args -Fo$@ $< | |
@echo | |
$(OBJ_DIR)/freetype/%.obj: Dependencies/freetype/src/*/%.c | $(CC).args PyGui_config.h $(OBJ_DIR)/freetype | |
$(CC) @$(CC).args -Fo$@ $< | |
@echo | |
$(OBJ_DIR)/DearSandbox.rc: $(THIS_FILE) | |
$(call make_rc_file, $@, "DearSandbox.exe", VFT_APP, "Dear Sandbox - some mysterious program") | |
$(OBJ_DIR)/PureImGui.rc: $(THIS_FILE) | |
$(call make_rc_file, $@, "PureImGui.exe", VFT_APP, "DearPyGui demo program") | |
$(OBJ_DIR)/_dearpygui.rc: $(THIS_FILE) | |
$(call make_rc_file, $@, "$(notdir $(PY_MODULE))", VFT_DLL, "DearPyGui Python3 module") | |
$(OBJ_DIR)/%.res: $(OBJ_DIR)/%.rc | |
$(call make_res_file, $<, $@) | |
%.i: %.cpp cpp_filter.py $(CC).args PyGui_config.h FORCE | |
$(call CPP_preprocess, $@, $<) | |
%.i: %.c cpp_filter.py $(CC).args PyGui_config.h FORCE | |
$(call C_preprocess, $@, $<) | |
%.i: Dependencies/freetype/src/*/%.c cpp_filter.py $(CC).args PyGui_config.h FORCE | |
$(call C_preprocess, $@, $<) | |
$(CC).args: $(THIS_FILE) | |
$(call green_msg, All CFLAGS are in $@) | |
$(call make_resp_file, $@, -c $(call filter_D_args_first, $(CFLAGS))) | |
$(OBJ_DIR)/__init__.py: $(THIS_FILE) | |
$(call Generate, $@, #) | |
$(file >> $@,pass) | |
cpp_filter.py: $(THIS_FILE) | |
$(call Generate, $@, #) | |
$(file >> $@,from __future__ import print_function) | |
$(file >> $@,if 1:) | |
$(file >> $@,$(cpp_filter_py)) | |
check-for-unused-libs.py: $(THIS_FILE) | |
$(call Generate, $@, #) | |
$(file >> $@,if 1:) | |
$(file >> $@,$(check_for_unused_libs_PY)) | |
FORCE: | |
# | |
# '$(sort ..)' will create a unique list. | |
# | |
TARGETS_JUNK = $(sort $(TARGETS:.exe=.map) $(TARGETS:.exe=.pdb) $(TARGETS:.exe=.exp) \ | |
$(TARGETS:.pyd=.map) $(TARGETS:.pyd=.pdb) $(TARGETS:.pyd=.exp) \ | |
freetype.lib spdlog.lib) | |
clean: clean_py_caches clean_py_install | |
- rm -f $(TARGETS_JUNK) $(OBJ_DIR)/*.{obj,res,rc} $(OBJ_DIR)/freetype/* $(OBJ_DIR)/spdlog/* \ | |
$(GENERATED) cl.args clang-cl.args link.args lib.args depend.args \ | |
link.tmp vc1*.pdb cpp_filter.py check-for-unused-libs.py .depend.Windows | |
- rmdir $(OBJ_DIR)/freetype $(OBJ_DIR)/spdlog $(OBJ_DIR) | |
vclean realclean: clean | |
rm -f $(TARGETS) | |
clean_py_install: | |
$(call green_msg, Removing Python installation.) | |
rm -f $(PY_SITE_DIR)/dearpygui/*.py | |
-rmdir $(PY_SITE_DIR)/dearpygui | |
@echo | |
clean_py_caches: | |
$(call green_msg, Removing '__pycache__' directories.) | |
rm -f DearPyGui/dearpygui/__pycache__/* $(PY_SITE_DIR)/dearpygui/__pycache__/* | |
- rmdir DearPyGui/dearpygui/__pycache__ $(PY_SITE_DIR)/dearpygui/__pycache__ | |
@echo | |
# | |
# GNU-Make macros: | |
# | |
define link_EXE | |
$(call green_msg, Linking $(1)) | |
$(call make_resp_file, link.args, $(LDFLAGS) $(2)) | |
link -out:$(strip $(1)) @link.args > link.tmp | |
@cat link.tmp >> $(1:.exe=.map) | |
@rm -f $(1:.exe=.exp) $(1:.exe=.lib) | |
@$(PYTHON) check-for-unused-libs.py link.tmp | |
endef | |
define link_PYD | |
$(call green_msg, Linking $(1)) | |
$(call make_resp_file, link.args, -dll $(LDFLAGS) $(2)) | |
link -out:$(strip $(1)) @link.args > link.tmp | |
@cat link.tmp >> $(1:.pyd=.map) | |
@rm -f $(1:.pyd=.exp) $(1:.pyd=.lib) | |
@$(PYTHON) check-for-unused-libs.py link.tmp | |
endef | |
define make_static_lib | |
$(call green_msg, Creating $(1)) | |
$(call make_resp_file, lib.args, $(2)) | |
@rm -f $(1) | |
lib -nologo -out:$(strip $(1)) @lib.args | |
@echo | |
endef | |
define make_res_file | |
rc $(RCFLAGS) -Fo./$(strip $(2)) $(1) | |
@echo | |
endef | |
define make_rc_file | |
$(call Generate, $(1), //) | |
$(file >> $(1), #define RC_FILE_NAME $(2)) | |
$(file >> $(1), #define RC_FILE_TYPE $(3)) | |
$(file >> $(1), #define RC_DESCRIPTION $(4)) | |
$(file >> $(1),$(PyGui_COMMON_RC)) | |
@echo | |
endef | |
define Warning | |
$(1) | |
$(1) DO NOT EDIT! This file was automatically generated | |
$(1) from $(realpath $(THIS_FILE)) at $(TODAY). | |
$(1) Edit that file instead. | |
$(1) | |
endef | |
define Generate | |
$(call green_msg, Generating $(1)) | |
$(file > $(1),$(call Warning,$(strip $(2)))) | |
endef | |
# | |
# Response file macro: | |
# arg1, $(1): The name of the response file | |
# arg2, $(2): The content for the response file. | |
# | |
define make_resp_file | |
$(file > $(1)) | |
$(foreach f, $(2), $(file >> $(1),$(strip $(f))) ) | |
endef | |
# | |
# copy file(s) macros: | |
# $(1): files. A $(sort $(1)) will make a unique list. | |
# $(2): directory | |
# | |
empty := | |
space := $(empty) $(empty) | |
define copy_files | |
$(call green_msg, Updating these files into $(BRIGHT_WHITE)$(strip $(2)):) | |
@$(foreach f, $(1), echo '$(space) $(f)' ; ) | |
@cp --update $(sort $(1)) $(2) | |
@echo | |
endef | |
define PyGui_config_h | |
#ifndef PyGui_CONFIG_H | |
#define PyGui_CONFIG_H | |
/* Warning control. There are lots of them w/o this: | |
*/ | |
#if defined(__clang__) | |
#pragma clang diagnostic ignored "-Wunused-function" | |
#pragma clang diagnostic ignored "-Wunused-variable" | |
#pragma clang diagnostic ignored "-Wmacro-redefined" | |
#pragma clang diagnostic ignored "-Wcomment" | |
#pragma clang diagnostic ignored "-Wformat" | |
#pragma clang diagnostic ignored "-Wparentheses" | |
#pragma clang diagnostic ignored "-Wbool-conversion" | |
#pragma clang diagnostic ignored "-Wmicrosoft-include" | |
#pragma clang diagnostic ignored "-Wnonportable-include-path" | |
#pragma clang diagnostic ignored "-Woverloaded-virtual" | |
#pragma clang diagnostic ignored "-Wunused-private-field" | |
#pragma clang diagnostic ignored "-Wunused-command-line-argument" | |
#pragma clang diagnostic ignored "-Wdelete-non-abstract-non-virtual-dtor" | |
#else | |
#pragma warning (disable:4005 4018 4244 4715) | |
#endif | |
#define _CRT_SECURE_NO_WARNINGS | |
#define _CRT_SECURE_NO_DEPRECATE | |
#define _CRT_NONSTDC_NO_WARNINGS | |
#define WIN32 /* Needed. OMG! */ | |
#define _WINDOWS /* Why? */ | |
#define _ATL_NO_DEFAULT_LIBS /* No '#pragma comment (lib ..)' from AtlMfc */ | |
#define _USE_MATH_DEFINES /* To pull in 'M_PI' etc. in <math.h> */ | |
#define IMGUI_USER_CONFIG "mvImGuiConfig.h" | |
#define MV_SANDBOX_VERSION "$(VERSION)" | |
#ifdef _DEBUG | |
#define MV_DEBUG 1 /* Remove when fully working */ | |
//#define MV_PROFILE 1 /* Only effective with 'MV_DEBUG' defined */ | |
#else | |
//#define NDEBUG 1 | |
#endif | |
#define ImDrawIdx unsigned int | |
#define IMGUIFILEDIALOG_NO_EXPORT 1 /* No export out of 'ImGuiFileDialog.cpp' */ | |
/* Ensure a static version of FreeType: | |
*/ | |
#if defined(__cplusplus) | |
#define FT_EXPORT(x) extern "C" x | |
#else | |
#define FT_EXPORT(x) extern x | |
#endif | |
#if defined(_DEBUG) /* 'CFLAGS = -MDd ...' */ | |
#include <string.h> | |
#include <malloc.h> | |
#undef _malloca /* Avoid MSVC-9 <malloc.h>/<crtdbg.h> name-clash */ | |
#if !defined(FT2_BUILD_LIBRARY) | |
#define _CRTDBG_MAP_ALLOC | |
#include <crtdbg.h> | |
#endif | |
#endif | |
#if defined(USE_VLD) | |
/* | |
* Visual Leak Detector is mostly useful in a '_DEBUG' ('-MDd' or '-MTd') build. | |
* But including it for '_RELEASE' ('-MD' or '-MT') works too. | |
* | |
* Refs: | |
* https://kinddragon.github.io/vld/ | |
* https://github.com/KindDragon/vld/wiki | |
*/ | |
#include <vld.h> | |
#endif | |
extern void crtdbug_init (void); /* todo */ | |
extern void crtdbug_exit (void); /* todo */ | |
#include "dpg_trace.h" | |
#endif /* PyGui_CONFIG_H */ | |
endef | |
define PyGui_COMMON_RC | |
#include <winver.h> | |
APPICON ICON "Resources/dpg_icon_small.ico" | |
#define RC_VERSION $(VER_MAJOR),$(VER_MINOR),$(VER_MICRO),0 | |
#ifdef _DEBUG | |
#define RC_FILE_FLAGS 1 | |
#else | |
#define RC_FILE_FLAGS 0 | |
#endif | |
#if defined(__clang__) | |
#define RC_COMPILER "clang-cl" | |
#elif defined(_MSC_VER) | |
#define RC_COMPILER "MSVC" | |
#else | |
#define RC_COMPILER "??" | |
#endif | |
VS_VERSION_INFO VERSIONINFO | |
FILEVERSION RC_VERSION | |
PRODUCTVERSION RC_VERSION | |
FILEFLAGSMASK 0x3fL | |
FILEFLAGS RC_FILE_FLAGS | |
FILEOS VOS__WINDOWS32 | |
FILETYPE RC_FILE_TYPE | |
FILESUBTYPE 0 | |
BEGIN | |
BLOCK "StringFileInfo" | |
BEGIN | |
BLOCK "040904b0" | |
BEGIN | |
VALUE "FileDescription", RC_DESCRIPTION | |
VALUE "FileVersion", "$(VERSION) (32-bit)" | |
VALUE "InternalName", RC_FILE_NAME | |
VALUE "LegalCopyright", "GNU GENERAL PUBLIC LICENSE, Version 3" | |
VALUE "OriginalFilename", RC_FILE_NAME | |
VALUE "ProductName", RC_FILE_NAME | |
VALUE "ProductVersion", "$(VERSION)" | |
VALUE "Comments", "Built on $(TODAY) using " RC_COMPILER " by <[email protected]>" | |
END | |
END | |
BLOCK "VarFileInfo" | |
BEGIN | |
VALUE "Translation", 0x409, 1200 | |
END | |
END | |
endef | |
define preprocess_common | |
$(file > $(1),/* The $(strip $(4)) output of '$(strip $(2))':) | |
$(file >> $(1), * $(CC) -E) | |
@$(foreach f, $(call filter_D_args_first, $(CFLAGS)), $(file >> $(1), * $(f))) | |
$(file >> $(1), *------------------------------------------------------------) | |
$(file >> $(1), */) | |
$(CC) -E @$(CC).args $(2) | $(PYTHON) cpp_filter.py $(3) >> $(1) | |
endef | |
ifeq ($(USE_ASTYLE),1) | |
CPP_preprocess = $(call preprocess_common, $(1), $(2), | astyle, preprocessed and AStyled) | |
C_preprocess = $(call CPP_preprocess, $(1), $(2)) | |
else ifeq ($(USE_CLANG_FORMAT),1) | |
CPP_preprocess = $(call preprocess_common, $(1), $(2), | clang-format -style=Mozilla -assume-filename=cpp, preprocessed and clang-formated) | |
C_preprocess = $(call preprocess_common, $(1), $(2), | clang-format -style=Mozilla -assume-filename=c, preprocessed and clang-formated) | |
else | |
CPP_preprocess = $(call preprocess_common, $(1), $(2),, raw preprocessed) | |
C_preprocess = $(call CPP_preprocess, $(1), $(2)) | |
endif | |
define cpp_filter_py | |
import sys, os | |
try: | |
import ntpath | |
except ImportError as e: | |
print ("Failed to import ntpath: %s" % e) | |
sys.exit(1) | |
def _win32_abspath (path): | |
path = ntpath.abspath (path) | |
return path.replace ('\\', '/') | |
cwd = _win32_abspath (os.getcwd()) + '/' | |
last_line = '??' | |
last_fname = '??' | |
empty_lines = 0 | |
while True: | |
line = sys.stdin.readline() | |
if not line: | |
break | |
if line.startswith('\n') or line.startswith('\r'): | |
empty_lines += 1 | |
continue | |
if line.lstrip().startswith("#line"): | |
line = line.replace ("\\\\", "/") | |
fname = None | |
quote = line.find ('\"') | |
if line.startswith ("#line ") and quote > 0: | |
fname = _win32_abspath (line[quote:]) | |
last_fname = fname | |
if line.strip() != '' and last_line != '': | |
if fname is None or fname != last_fname: | |
print (line, end="") | |
if line.strip() == '}' or line.strip() == '};': # Print a newline after a functions or structs | |
print ("") | |
last_line = line | |
if empty_lines > 0: | |
sys.stderr.write ("Removed %d empty lines.\n" % empty_lines) | |
endef | |
define check_for_unused_libs_PY | |
# | |
# Check a MSVC .map-file for lines after a 'Unused libraries:' | |
# | |
import os, sys | |
try: | |
from colorama import init, Fore, Style | |
init() | |
class Color(): | |
RED = Fore.RED + Style.BRIGHT | |
WHITE = Fore.WHITE + Style.BRIGHT | |
RESET = Style.RESET_ALL | |
except: | |
class Color(): | |
RED = WHITE = RESET = "" | |
_IDLE = 0 | |
_UNUSED = 1 | |
ignore_libs = [ "oldnames.lib" ] | |
def report (map_file, unused): | |
num = len(unused) | |
plural = [ "library", "libraries" ] | |
if num > 0: | |
print ("%s%d unused %s in %s:%s" % (Color.RED, num, plural[num > 1], map_file, Color.RESET)) | |
for u in sorted(unused): | |
print (" " + u) | |
print ("%sDone%s\n" % (Color.WHITE, Color.RESET)) | |
def process_map (file, state): | |
unused_libs = [] | |
f = open (file, "rt") | |
try: | |
lines = f.readlines() | |
except IOError: | |
return [] | |
finally: | |
f.close() | |
for l in lines: | |
l = l.strip() | |
if l == "Unused libraries:": | |
state = _UNUSED | |
continue | |
if state == _UNUSED: | |
if l == "": | |
break | |
if os.path.basename (l).lower() not in ignore_libs: | |
unused_libs.append (l) | |
return unused_libs | |
map_file = sys.argv[1] | |
report (map_file, process_map(map_file, _IDLE)) | |
endef | |
DEP_CFLAGS = -MM $(filter -D% -I%, $(CFLAGS)) | |
DEP_REPLACE = -e 's@\(.*\)\.o: @\n$$(OBJ_DIR)\/\1.$.obj: @' \ | |
-e 's@$(PY_ROOT)@$$(PY_ROOT)@g' \ | |
-e 's@$(VLD_ROOT)@$$(VLD_ROOT)@g' | |
ALL_SOURCES = $(LIB_SRC) \ | |
$(PureImGui_SRC) \ | |
$(_dearpygui_SRC) | |
depend: | |
$(call make_resp_file, depend.args, $(DEP_CFLAGS) $(ALL_SOURCES)) | |
$(call Generate, .depend.Windows, #) | |
g++ @depend.args | sed $(DEP_REPLACE) >> .depend.Windows | |
-include .depend.Windows | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment