diff --git a/.github/workflows/non_regression.yml b/.github/workflows/non_regression.yml index 1cfe7e4..131e4bb 100644 --- a/.github/workflows/non_regression.yml +++ b/.github/workflows/non_regression.yml @@ -38,8 +38,8 @@ jobs: - name: Do non regression tests run: | cd tests - V=1 make -j`nproc --all` - ./build/TimedPetriNetEditor-UnitTest + V=1 make check -j`nproc --all` + ../build/TimedPetriNetEditor-UnitTest - name: Check if the library can be linked against a project run: | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ @@ -63,7 +63,7 @@ jobs: run: | make download-external-libs make compile-external-libs - make -j`sysctl -n hw.logicalcpu` + V=1 make -j`sysctl -n hw.logicalcpu` - name: Download, configure and install Google test run: | wget https://github.com/google/googletest/archive/release-1.11.0.tar.gz @@ -74,8 +74,8 @@ jobs: - name: Do non regression tests run: | cd tests - make -j`sysctl -n hw.logicalcpu` - ./build/TimedPetriNetEditor-UnitTest + V=1 make check -j`sysctl -n hw.logicalcpu` + ../build/TimedPetriNetEditor-UnitTest - name: Create the DMG file run: | hdiutil create -format UDZO -srcfolder build/TimedPetriNetEditor.app build/TimedPetriNetEditor.dmg diff --git a/.makefile b/.makefile index 07ac6fe..114c3ee 160000 --- a/.makefile +++ b/.makefile @@ -1 +1 @@ -Subproject commit 07ac6fe3a2b642d358d86ee007d26bf546d60e70 +Subproject commit 114c3ee6290ffa490403093eb1ce2d180ec4faea diff --git a/Makefile b/Makefile index 1ecfd0d..c6114bf 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,23 @@ +##===================================================================== +## TimedPetriNetEditor: A timed Petri net editor. +## Copyright 2021 -- 2023 Quentin Quadrat +## +## This file is part of PetriEditor. +## +## PetriEditor is free software: you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Emacs. If not, see . +##===================================================================== + ################################################### # Location of the project directory and Makefiles # @@ -8,93 +28,63 @@ M := $(P)/.makefile # Project definition # include $(P)/Makefile.common -TARGET = $(PROJECT) -DESCRIPTION = Timed Petri Net Editor +TARGET_NAME := $(PROJECT_NAME) +TARGET_DESCRIPTION := Timed Petri Net Editor +include $(M)/project/Makefile ################################################### -# Sharable informations between all Makefiles +# Standalone application # -include $(M)/Makefile.header +SRC_FILES := src/main.cpp +INCLUDES := $(P)/include +VPATH := $(P)/src +LINKER_FLAGS += -ldl -lpthread +# Internal libs to compile +LIB_TPNE_NET := TimedPetriNet +LIB_TPNE_EDITOR := TimedPetriEditor +LIB_TPNE_JULIA := TimedPetriJulia +INTERNAL_LIBS := $(LIB_TPNE_EDITOR) $(LIB_TPNE_NET) $(LIB_TPNE_JULIA) +DIRS_WITH_MAKEFILE := $(P)/src/Net $(P)/src/Editor $(P)/src/julia ################################################### -# OpenGL: glfw and glew libraries +# GUI # -ifeq ($(ARCHI),Darwin) - INCLUDES += -I/usr/local/include -I/opt/local/include - LINKER_FLAGS += -framework OpenGL -framework Cocoa - LINKER_FLAGS += -framework IOKit -framework CoreVideo - LINKER_FLAGS += -L/usr/local/lib -L/opt/local/lib - LINKER_FLAGS += -lGLEW -lglfw -else ifeq ($(ARCHI),Linux) - LINKER_FLAGS += -lGL - PKG_LIBS += --static glfw3 -else ifeq ($(ARCHI),Emscripten) - ifneq ($(EXAEQUOS),) - LINKER_FLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES3 - PKG_LIBS += exa-wayland --static glfw - endif -else - $(error Unknown architecture $(ARCHI) for OpenGL) -endif +include $(abspath $(P)/src/Editor/DearImGui/Backends/Makefile) +INCLUDES += $(P)/src/Editor/DearImGui +INCLUDES += $(P)/src ################################################### # Embed assets for web version. Assets shall be # present inside $(BUILD) folder. # -ifeq ($(ARCHI),Emscripten) -ifeq ($(EXAEQUOS),) -LINKER_FLAGS += --preload-file examples -LINKER_FLAGS += --preload-file data -LINKER_FLAGS += -s FORCE_FILESYSTEM=1 -endif -endif - -################################################### -# Create a MacOS X bundle application. -# -ifeq ($(ARCHI),Darwin) -BUILD_MACOS_APP_BUNDLE = 1 -APPLE_IDENTIFIER = lecrapouille -MACOS_BUNDLE_ICON = data/TimedPetriNetEditor.icns -LINKER_FLAGS += -framework CoreFoundation +ifeq ($(OS),Emscripten) + ifndef EXAEQUOS + LINKER_FLAGS += --preload-file $(PROJECT_DATA_DIR) + LINKER_FLAGS += -s FORCE_FILESYSTEM=1 + endif endif ################################################### -# Stand-alone application. +# Generic Makefile rules # -include $(P)/src/Editor/DearImGui/Makefile.imgui -LINKER_FLAGS += -ldl -lpthread -VPATH += $(P)/include $(P)/src $(P)/src/Utils $(P)/src/Net -VPATH += $(P)/src/Net/Imports VPATH += $(P)/src/Net/Exports -INCLUDES += -I$(P)/include -I$(P)/src -I$(P)/external -OBJS += main.o +include $(M)/rules/Makefile ################################################### -# Compile the stand-alone application -.PHONY: all -all: $(TARGET) copy-emscripten-assets - -################################################### -# Internal libraries +# Compile internal librairies in the correct order # -LIB_TPNE_CORE = $(abspath $(P)/$(BUILD)/libtimedpetrinetcore.a) -LIB_TPNE_GUI = $(abspath $(P)/$(BUILD)/libtimedpetrinetgui.a) -LIB_TPNE_JULIA = $(abspath $(P)/$(BUILD)/libtimedpetrinetjulia.a) -THIRDPART_LIBS += $(LIB_TPNE_CORE) $(LIB_TPNE_GUI) $(LIB_TPNE_JULIA) -DIRS_WITH_MAKEFILE := src/Editor src/Net src/julia +$(LIB_TPNE_NET): $(P)/src/Net -$(LIB_TPNE_GUI): src/Editor +$(LIB_TPNE_EDITOR): $(P)/src/Editor -$(LIB_TPNE_CORE): src/Net +$(LIB_TPNE_JULIA): $(P)/src/julia -$(LIB_TPNE_JULIA): src/julia +$(P)/src/julia: $(P)/src/Editor -src/julia: src/Editor - -src/Editor: src/Net +$(P)/src/Editor: $(P)/src/Net ################################################### # Copy data inside BUILD to allow emscripten to embedded them +# .PHONY: copy-assets copy-emscripten-assets: | $(BUILD) ifeq ($(ARCHI),Emscripten) @@ -104,51 +94,4 @@ ifeq ($(ARCHI),Emscripten) @cp $(P)/data/examples/*.json $(BUILD)/examples @cp $(P)/data/font.ttf $(BUILD)/data @cp $(P)/data/imgui.ini $(BUILD)/data -endif - -################################################### -# Compile and launch unit tests and generate the code coverage html report. -.PHONY: unit-tests -unit-tests: - @$(call print-simple,"Compiling unit tests") - @$(MAKE) -C tests coverage - -################################################### -# Compile and launch unit tests and generate the code coverage html report. -.PHONY: check -check: unit-tests - -################################################### -# Install project. You need to be root. -.PHONY: install -install: $(TARGET) - @$(call INSTALL_BINARY) -ifeq ($(EXAEQUOS),) - @$(MAKE) --no-print-directory -C src/Net install - @$(MAKE) --no-print-directory -C src/Editor install - @$(MAKE) --no-print-directory -C src/julia install - @$(call INSTALL_DOCUMENTATION) - @$(call INSTALL_PROJECT_HEADERS) -endif - -################################################### -# Clean the whole project. -.PHONY: veryclean -veryclean: clean - @rm -fr cov-int $(PROJECT).tgz *.log foo 2> /dev/null - @(cd tests && $(MAKE) -s clean) - @$(call print-simple,"Cleaning","$(PWD)/doc/html") - @rm -fr $(THIRDPART)/*/ doc/html 2> /dev/null - -################################################### -# Sharable informations between all Makefiles -# -include $(M)/Makefile.footer - -################################################### -# Override clean the project -.PHONY: clean -clean:: - @$(MAKE) --no-print-directory -C src/Net clean - @$(MAKE) --no-print-directory -C src/Editor clean - @$(MAKE) --no-print-directory -C src/julia clean \ No newline at end of file +endif \ No newline at end of file diff --git a/Makefile.common b/Makefile.common index 1a79450..1d7d628 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1,23 +1,12 @@ ################################################### # Project definition # -PROJECT = TimedPetriNetEditor -STANDARD = --std=c++14 -BUILD_TYPE = release +PROJECT_NAME := TimedPetriNetEditor +PROJECT_VERSION := 0.4.0 +COMPILATION_MODE := debug +CXX_STANDARD := --std=c++14 ################################################### # Select the Dear ImGui backend: RayLib or GLFW3. # -DEAR_IMGUI_BACKEND ?= RayLib - -################################################### -# Reduce warnings -# -CCFLAGS += -Wno-sign-conversion -Wno-float-equal -CXXFLAGS += -Wno-undef -Wno-switch-enum -Wno-enum-compare -CXXFLAGS += -Wshadow - -################################################### -# Project defines -# -DEFINES += -DDATADIR=\"$(DATADIR):$(abspath $(P))/data/:data/\" \ No newline at end of file +DEAR_IMGUI_BACKEND ?= GLFW3 \ No newline at end of file diff --git a/VERSION.txt b/VERSION.txt deleted file mode 100644 index 1d0ba9e..0000000 --- a/VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -0.4.0 diff --git a/external/compile-external-libs.sh b/external/compile-external-libs.sh index ea607dc..3324bae 100755 --- a/external/compile-external-libs.sh +++ b/external/compile-external-libs.sh @@ -27,7 +27,7 @@ ### $CXX: C++ compiler ############################################################################### -source ../.makefile/compile-external-libs.sh +source $1 ### Library raylib print-compile raylib @@ -39,11 +39,11 @@ print-compile raylib # Note: Concerning .backup see https://www.themoderncoder.com/fix-sed-i-error-macos/ sed -i.backup 's/ExportImage(image, path)/ExportImage(image, fileName)/g' rcore.c - mkdir -p $ARCHI + mkdir -p $OS call-make clean - if [ "$ARCHI" != "Emscripten" ]; then - call-make PLATFORM=PLATFORM_DESKTOP RAYLIB_RELEASE_PATH=$ARCHI RAYLIB_BUILD_MODE=DEBUG + if [ "$OS" != "Emscripten" ]; then + call-make PLATFORM=PLATFORM_DESKTOP RAYLIB_RELEASE_PATH=$OS RAYLIB_BUILD_MODE=DEBUG else - call-make PLATFORM=PLATFORM_WEB RAYLIB_RELEASE_PATH=$ARCHI + call-make PLATFORM=PLATFORM_WEB RAYLIB_RELEASE_PATH=$OS fi ) diff --git a/external/download-external-libs.sh b/external/download-external-libs.sh index 1235ca3..438c087 100755 --- a/external/download-external-libs.sh +++ b/external/download-external-libs.sh @@ -5,7 +5,7 @@ ### It replaces git submodules that I dislike. ############################################################################### -source ../.makefile/download-external-libs.sh +source $1 ### Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies ### License: MIT diff --git a/src/Editor/DearImGui/Backends/GLFW3/Application.hpp b/src/Editor/DearImGui/Backends/GLFW3/Application.hpp index e4b04e5..eabee05 100644 --- a/src/Editor/DearImGui/Backends/GLFW3/Application.hpp +++ b/src/Editor/DearImGui/Backends/GLFW3/Application.hpp @@ -21,12 +21,12 @@ #ifndef APPLICATION_HPP # define APPLICATION_HPP -#include "imgui.h" +#include "imgui/imgui.h" #include "imgui_impl_glfw.h" #include "imgui_impl_opengl3.h" #include "imgui/misc/cpp/imgui_stdlib.h" -#include "implot.h" -#include "ImGuiFileDialog.h" +#include "implot/implot.h" +#include "ImGuiFileDialog/ImGuiFileDialog.h" #include //------------------------------------------------------------------------------ diff --git a/src/Editor/DearImGui/Backends/Makefile b/src/Editor/DearImGui/Backends/Makefile new file mode 100644 index 0000000..fb80da7 --- /dev/null +++ b/src/Editor/DearImGui/Backends/Makefile @@ -0,0 +1,105 @@ +################################################### +# If compiling for HTML5 (Emscripten) then force +# using Raylib backend since GLFW3 is not compilable. +# +ifeq ($(OS),Emscripten) + ifndef EXAEQUOS + ifneq ($(DEAR_IMGUI_BACKEND),GLFW3) + $(warning Force GLFW3 backend for compiling with ExaequOS) + DEAR_IMGUI_BACKEND = GLFW3 + endif + else + ifneq ($(DEAR_IMGUI_BACKEND),RayLib) + $(warning Force RayLib backend for compiling with Emscripten) + DEAR_IMGUI_BACKEND = RayLib + endif + endif +endif + +################################################### +# Dear ImGui backends: GLFW3 +# +ifeq ($(DEAR_IMGUI_BACKEND),GLFW3) + INCLUDES += $(P)/src/Editor/DearImGui/Backends/GLFW3 + GUI_FILES += $(P)/src/Editor/DearImGui/Backends/GLFW3/Application.cpp + INCLUDES += $(THIRDPART_DIR)/imgui/backends/ + GUI_FILES += $(THIRDPART_DIR)/imgui/backends/imgui_impl_glfw.cpp + GUI_FILES += $(THIRDPART_DIR)/imgui/backends/imgui_impl_opengl3.cpp + ifeq ($(OS),Linux) + # OpenGL, GLEW, GLFW3 + LINKER_FLAGS += -lGL + PKG_LIBS += --static glfw3 + else ifeq ($(OS),Darwin) + # OpenGL, GLEW, GLFW3 + INCLUDES += -I/usr/local/include -I/opt/local/include + LINKER_FLAGS += -framework OpenGL -framework Cocoa + LINKER_FLAGS += -framework IOKit -framework CoreVideo + LINKER_FLAGS += -L/usr/local/lib -L/opt/local/lib + LINKER_FLAGS += -lGLEW -lglfw + else ifeq ($(OS),Emscripten) + ifdef EXAEQUOS + # Wayland, OpenGL, GLEW, GLFW3 for ExaequOS + LINKER_FLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES3 + PKG_LIBS += exa-wayland --static glfw + else + # We tell the linker that the game/library uses GLFW3 + # library internally, it must be linked automatically + # (emscripten provides the implementation) + LINKER_FLAGS += -s USE_GLFW=3 + endif + else + $(error Unknown architecture $(OS) for OpenGL) + endif + USER_CXX_FLAGS += -Wno-old-style-cast -Wno-sign-conversion -Wno-float-equal + USER_CXX_FLAGS += -Wno-conversion +endif + +################################################### +# Dear ImGui backends: Raylib +# +ifeq ($(DEAR_IMGUI_BACKEND),RayLib) + VPATH += $(P)/src/Editor/DearImGui + VPATH += $(P)/src/Editor/DearImGui/Backends/RayLib + INCLUDES += $(P)/src/Editor/DearImGui/Backends/RayLib + GUI_FILES += $(P)/src/Editor/DearImGui/Backends/RayLib/Application.cpp + VPATH += $(THIRDPART_DIR)/rlImGui + INCLUDES += $(THIRDPART_DIR)/rlImGui + GUI_FILES += $(THIRDPART_DIR)/rlImGui/rlImGui.cpp + INCLUDES += $(THIRDPART_DIR)/raylib/src + ifeq ($(OS),Emscripten) + ifdef EXAEQUOS + LINKER_FLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES3 + PKG_LIBS += exa-wayland --static raylib + else + # We tell the linker that the game/library uses GLFW3 + # library internally, it must be linked automatically + # (emscripten provides the implementation) + LINKER_FLAGS += -s USE_GLFW=3 + endif + else + THIRDPART_LIBS += $(THIRDPART_DIR)/raylib/src/$(OS)/libraylib.a + endif + + USER_CXX_FLAGS += -Wno-conversion -Wno-sign-conversion -Wno-float-equal -Wno-old-style-cast + USER_CXX_FLAGS += -Wno-cast-qual -Wno-undef +endif + +# Dear ImGui +INCLUDES += $(THIRDPART_DIR) +INCLUDES += $(THIRDPART_DIR)/imgui +GUI_FILES += $(THIRDPART_DIR)/imgui/imgui_widgets.cpp +GUI_FILES += $(THIRDPART_DIR)/imgui/imgui_draw.cpp +GUI_FILES += $(THIRDPART_DIR)/imgui/imgui_tables.cpp +GUI_FILES += $(THIRDPART_DIR)/imgui/imgui.cpp +GUI_FILES += $(THIRDPART_DIR)/imgui/misc/cpp/imgui_stdlib.cpp + +# Dear ImGui plot +GUI_FILES += $(THIRDPART_DIR)/implot/implot_items.cpp +GUI_FILES += $(THIRDPART_DIR)/implot/implot.cpp + +# Dear ImGui file dialog +GUI_FILES += $(THIRDPART_DIR)/ImGuiFileDialog/ImGuiFileDialog.cpp +USER_CXX_FLAGS += -Wno-unknown-pragmas + +# Petri Editor +GUI_FILES += $(call wildcard,$(P)/src/Editor/DearImGui/*.cpp) \ No newline at end of file diff --git a/src/Editor/DearImGui/Backends/RayLib/Application.hpp b/src/Editor/DearImGui/Backends/RayLib/Application.hpp index cba93b9..094c85d 100644 --- a/src/Editor/DearImGui/Backends/RayLib/Application.hpp +++ b/src/Editor/DearImGui/Backends/RayLib/Application.hpp @@ -24,11 +24,11 @@ #include "raylib.h" #include "imgui_impl_raylib.h" #include "imgui/misc/cpp/imgui_stdlib.h" -#include "imgui.h" -#include "implot.h" -#include "ImGuiFileDialog.h" -#include "rlImGui.h" -#include "DearUtils.hpp" +#include "imgui/imgui.h" +#include "implot/implot.h" +#include "ImGuiFileDialog/ImGuiFileDialog.h" +#include "rlImGui/rlImGui.h" +#include "Editor/DearImGui/DearUtils.hpp" #include #include diff --git a/src/Editor/DearImGui/Drawable.cpp b/src/Editor/DearImGui/Drawable.cpp index 9d9c0c1..a813165 100644 --- a/src/Editor/DearImGui/Drawable.cpp +++ b/src/Editor/DearImGui/Drawable.cpp @@ -20,7 +20,7 @@ #include "Editor/DearImGui/Drawable.hpp" #include "Editor/DearImGui/DearUtils.hpp" -#include "implot.h" +#include "implot/implot.h" #include "Utils/Utils.hpp" #include // std::setprecision diff --git a/src/Editor/DearImGui/Drawable.hpp b/src/Editor/DearImGui/Drawable.hpp index 7190632..a3c57e6 100644 --- a/src/Editor/DearImGui/Drawable.hpp +++ b/src/Editor/DearImGui/Drawable.hpp @@ -23,7 +23,7 @@ # include "Editor/DearImGui/Theme.hpp" # include "TimedPetriNetEditor/PetriNet.hpp" -# include "imgui.h" +# include "imgui/imgui.h" namespace tpne { diff --git a/src/Editor/DearImGui/Editor.cpp b/src/Editor/DearImGui/Editor.cpp index 8d30320..b798a2a 100644 --- a/src/Editor/DearImGui/Editor.cpp +++ b/src/Editor/DearImGui/Editor.cpp @@ -667,7 +667,7 @@ void Editor::about() const ImGui::Text("Git branch: %s", project::info::git_branch.c_str()); ImGui::Text("Git SHA1: %s", project::info::git_sha1.c_str()); ImGui::Text("Compiled as %s", - (project::info::mode == project::info::Mode::debug) + (project::info::compilation::mode == project::info::compilation::Mode::debug) ? "Debug" : "Release"); ImGui::Separator(); ImGui::Text("Developed by Quentin Quadrat"); diff --git a/src/Editor/DearImGui/Makefile.imgui b/src/Editor/DearImGui/Makefile.imgui deleted file mode 100644 index 9ace05d..0000000 --- a/src/Editor/DearImGui/Makefile.imgui +++ /dev/null @@ -1,91 +0,0 @@ -################################################### -# If compiling for HTML5 (Emscripten) then force -# using Raylib backend since GLFW3 is not compilable. -# -ifeq ($(ARCHI),Emscripten) - ifneq ($(EXAEQUOS),) - ifneq ($(DEAR_IMGUI_BACKEND),GLFW3) - $(warning Force GLFW3 backend for compiling with ExaequOS) - DEAR_IMGUI_BACKEND = GLFW3 - endif - else - ifneq ($(DEAR_IMGUI_BACKEND),RayLib) - $(warning Force RayLib backend for compiling with Emscripten) - DEAR_IMGUI_BACKEND = RayLib - endif - endif -endif - -################################################### -# Set thirdpart Raylib -# -ifeq ($(DEAR_IMGUI_BACKEND),RayLib) -INCLUDES += -I$(THIRDPART)/raylib/src -THIRDPART_LIBS += $(abspath $(THIRDPART)/raylib/src/$(ARCHI)/libraylib.a) -ifeq ($(ARCHI),Emscripten) -# We tell the linker that the game/library uses GLFW3 -# library internally, it must be linked automatically -# (emscripten provides the implementation) -LINKER_FLAGS += -s USE_GLFW=3 -# Add this flag ONLY in case we are using ASYNCIFY code -LINKER_FLAGS += -s ASYNCIFY -# For linking glfwGetProcAddress(). -LINKER_FLAGS += -s GL_ENABLE_GET_PROC_ADDRESS -# All webs need a "shell" structure to load and run the game, -# by default emscripten has a `shell.html` but we can provide -# our own. -LINKER_FLAGS += --shell-file $(THIRDPART)/raylib/src/shell.html -endif -endif - -################################################### -# Dear ImGui backends: Raylib -# -ifeq ($(DEAR_IMGUI_BACKEND),RayLib) -VPATH += $(THIRDPART)/rlImGui -VPATH += $(P)/src/Editor/DearImGui/Backends/RayLib -INCLUDES += -I$(THIRDPART)/rlImGui -INCLUDES += -I$(P)/src/Editor/DearImGui/Backends/RayLib -GUI_OBJS += rlImGui.o -endif - -################################################### -# Dear ImGui backends: OpenGL/GLFW3 -# -ifeq ($(DEAR_IMGUI_BACKEND),GLFW3) -ifneq ($(EXAEQUOS),) -PKG_LIBS += --static glfw -endif -VPATH += $(P)/src/Editor/DearImGui/Backends/GLFW3 -INCLUDES += -I$(P)/src/Editor/DearImGui/Backends/GLFW3 -GUI_OBJS += imgui_impl_glfw.o imgui_impl_opengl3.o -endif - -################################################### -# Editor using Dear ImGui for the human interface. -# -VPATH += $(P)/src/Editor/DearImGui -INCLUDES += -I$(P)/src/Editor/DearImGui -GUI_OBJS += Theme.o DearUtils.o - -################################################### -# Editor using Dear ImGui for the human interface. -# -INCLUDES += -I$(THIRDPART)/imgui -I$(THIRDPART)/imgui/backends -I$(THIRDPART)/imgui/misc/cpp -VPATH += $(THIRDPART)/imgui $(THIRDPART)/imgui/backends $(THIRDPART)/imgui/misc/cpp -GUI_OBJS += imgui_widgets.o imgui_draw.o imgui_tables.o imgui.o imgui_stdlib.o -# GUI_OBJS += imgui_demo.o - -################################################### -# Set thirdpart Dear ImGui Plot -# -VPATH += $(THIRDPART)/implot -INCLUDES += -I$(THIRDPART)/implot -GUI_OBJS += implot_items.o implot.o - -################################################### -# Set thirdpart file dialog -# -VPATH += $(THIRDPART)/ImGuiFileDialog -INCLUDES += -I$(THIRDPART)/ImGuiFileDialog -GUI_OBJS += ImGuiFileDialog.o \ No newline at end of file diff --git a/src/Editor/Makefile b/src/Editor/Makefile index e606442..cc82680 100644 --- a/src/Editor/Makefile +++ b/src/Editor/Makefile @@ -1,48 +1,55 @@ +##===================================================================== +## TimedPetriNetEditor: A timed Petri net editor. +## Copyright 2021 -- 2023 Quentin Quadrat +## +## This file is part of PetriEditor. +## +## PetriEditor is free software: you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Emacs. If not, see . +##===================================================================== + ################################################### # Location of the project directory and Makefiles # P := ../.. M := $(P)/.makefile -BUILD := $(P)/build ################################################### # Project definition # include $(P)/Makefile.common -TARGET = TimedPetriNetGui -DESCRIPTION = Library for the GUI of the Timed Petri Net Editor - -################################################### -# Sharable informations between all Makefiles -# -include $(M)/Makefile.header +TARGET_NAME := TimedPetriEditor +TARGET_DESCRIPTION := Library Editor for Petri nets +include $(M)/project/Makefile ################################################### # For the moment we only use Dear ImGui # -include ./DearImGui/Makefile.imgui +include ./DearImGui/Backends/Makefile ################################################### # Make the list of compiled files for the library # -VPATH += $(P)/include $(P)/src $(P)/src/Utils $(P)/src/Net -VPATH += $(P)/src/Net/Imports $(P)/src/Net/Exports -INCLUDES += -I$(P)/include -I$(P)/src -I$(P)/external -LIB_OBJS += $(GUI_OBJS) Drawable.o Application.o Editor.o +INCLUDES += $(P)/src $(P)/include +LIB_FILES += $(GUI_FILES) ################################################### -# Compile the project, the static and shared libraries +# Generic Makefile rules # -.PHONY: all -all: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) $(P)/Makefile $(P)/Makefile.common +include $(M)/rules/Makefile ################################################### # Install project. You need to be root. .PHONY: install -install: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) - @$(call INSTALL_PROJECT_LIBRARIES) - -################################################### -# Sharable informations between all Makefiles -# -include $(M)/Makefile.footer \ No newline at end of file +install:: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) + @$(call INSTALL_PROJECT_LIBRARIES) \ No newline at end of file diff --git a/src/Net/Exports/ExportCoDeSys.cpp b/src/Net/Exports/ExportCoDeSys.cpp__ similarity index 100% rename from src/Net/Exports/ExportCoDeSys.cpp rename to src/Net/Exports/ExportCoDeSys.cpp__ diff --git a/src/Net/Exports/ExportGrafcetLaTeX.cpp b/src/Net/Exports/ExportGrafcetLaTeX.cpp__ similarity index 100% rename from src/Net/Exports/ExportGrafcetLaTeX.cpp rename to src/Net/Exports/ExportGrafcetLaTeX.cpp__ diff --git a/src/Net/Makefile b/src/Net/Makefile index 38cd3b9..693e5d2 100644 --- a/src/Net/Makefile +++ b/src/Net/Makefile @@ -1,90 +1,94 @@ +##===================================================================== +## TimedPetriNetEditor: A timed Petri net editor. +## Copyright 2021 -- 2023 Quentin Quadrat +## +## This file is part of PetriEditor. +## +## PetriEditor is free software: you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Emacs. If not, see . +##===================================================================== + ################################################### # Location of the project directory and Makefiles # P := ../.. M := $(P)/.makefile -BUILD := $(P)/build ################################################### # Project definition # include $(P)/Makefile.common -TARGET = TimedPetriNetCore -DESCRIPTION = Library for the Core of the Timed Petri Net Editor - -################################################### -# Location of the project directory and Makefiles -# -include $(M)/Makefile.header +TARGET_NAME := TimedPetriNet +TARGET_DESCRIPTION := Library manipulating Petri nets +include $(M)/project/Makefile ################################################### # Set MQTT Library. # -ifneq ($(ARCHI),Emscripten) -INCLUDES += -I$(THIRDPART) -I$(THIRDPART)/MQTT/include -VPATH += $(THIRDPART)/MQTT/src -DEFINES += -DMQTT_BROKER_ADDR=\"localhost\" -DEFINES += -DMQTT_BROKER_PORT=1883 -PKG_LIBS += libmosquitto +ifeq ($(OS),Linux) + INCLUDES += $(THIRDPART_DIR)/MQTT/include + VPATH += $(THIRDPART_DIR)/MQTT/src + DEFINES += -DMQTT_BROKER_ADDR=\"localhost\" + DEFINES += -DMQTT_BROKER_PORT=1883 + PKG_LIBS += libmosquitto endif ################################################### # Set json ibrary. # -INCLUDES += -I$(THIRDPART)/json/include +INCLUDES += $(THIRDPART_DIR)/json/include ################################################### # Set xml Library. # -VPATH += $(THIRDPART)/tinyxml2 -LIB_OBJS += tinyxml2.o +VPATH += $(THIRDPART_DIR)/tinyxml2 +LIB_FILES += $(THIRDPART_DIR)/tinyxml2/tinyxml2.cpp +USER_CXX_FLAGS += -Wno-old-style-cast -Wno-sign-conversion ################################################### -# MacOS X +# MacOS X: get path inside the bundle application # -ifeq ($(ARCHI),Darwin) -LINKER_FLAGS += -framework CoreFoundation +ifeq ($(OS),Darwin) + LINKER_FLAGS += -framework CoreFoundation endif ################################################### # Inform Makefile where to find *.cpp files # -VPATH += $(P)/include $(P)/src $(P)/src/Utils $(P)/src/Net +VPATH += $(P)/src $(P)/src/Utils $(P)/src/Net VPATH += $(P)/src/Net/Imports $(P)/src/Net/Exports ################################################### # Inform Makefile where to find header files # -INCLUDES += -I$(P)/include -I$(P)/src -I$(P)/external - -################################################### -# Linkage -# -LINKER_FLAGS += -ldl -lpthread +INCLUDES += $(P)/include $(P)/src $(THIRDPART_DIR) ################################################### # Make the list of compiled files for the library # -LIB_OBJS += ImportJSON.o ImportPNML.o ImportTimedEventGraph.o ExportTimedEventGraph.o -LIB_OBJS += ExportJSON.o ExportPNML.o ExportSymfony.o ExportPnEditor.o -LIB_OBJS += ExportPetriLaTeX.o ExportJulia.o ExportGraphviz.o ExportDrawIO.o -LIB_OBJS += ExportGrafcetCpp.o ImportFlowshop.o -LIB_OBJS += Path.o Howard.o Utils.o TimedTokens.o Receptivities.o -LIB_OBJS += PetriNet.o Algorithms.o Simulation.o History.o -LIB_OBJS += Imports.o Exports.o +LIB_FILES += $(call rwildcard,$(P)/src/Net,*.cpp) +LIB_FILES += $(call rwildcard,$(P)/src/Net,*.c) +LIB_FILES += $(call rwildcard,$(P)/src/Utils,*.cpp) +USER_CXX_FLAGS += -Wno-cast-qual -Wno-float-equal +USER_CC_FLAGS += -Wno-sign-conversion -Wno-float-equal ################################################### -# Compile the project, the static and shared libraries -.PHONY: all -all: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) $(P)/Makefile $(P)/Makefile.common +# Generic Makefile rules +# +include $(M)/rules/Makefile ################################################### # Install project. You need to be root. .PHONY: install -install: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) - @$(call INSTALL_PROJECT_LIBRARIES) - -################################################### -# Sharable informations between all Makefiles -# -include $(M)/Makefile.footer +install:: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) + @$(call INSTALL_PROJECT_LIBRARIES) \ No newline at end of file diff --git a/src/Net/TODO_SparseMatrix.cpp b/src/Net/TODO_SparseMatrix.cpp__ similarity index 100% rename from src/Net/TODO_SparseMatrix.cpp rename to src/Net/TODO_SparseMatrix.cpp__ diff --git a/src/Utils/Path.hpp b/src/Utils/Path.hpp index 979fb6c..05b7d47 100644 --- a/src/Utils/Path.hpp +++ b/src/Utils/Path.hpp @@ -33,15 +33,11 @@ std::string osx_get_resources_dir(std::string const& file); # endif //------------------------------------------------------------------------------ -# ifndef DATADIR -# define GET_DATA_PATH project::info::data_path -# endif +# undef GET_DATA_PATH # if defined(__APPLE__) -# define GET_DATA_PATH DATADIR":" + osx_get_resources_dir("") -# elif defined(__EMSCRIPTEN__) -# define GET_DATA_PATH "data/" +# define GET_DATA_PATH osx_get_resources_dir("") # else -# define GET_DATA_PATH DATADIR +# define GET_DATA_PATH project::info::data_path # endif // ***************************************************************************** diff --git a/src/julia/Makefile b/src/julia/Makefile index 33fbc12..fbd8489 100644 --- a/src/julia/Makefile +++ b/src/julia/Makefile @@ -1,65 +1,75 @@ +##===================================================================== +## TimedPetriNetEditor: A timed Petri net editor. +## Copyright 2021 -- 2023 Quentin Quadrat +## +## This file is part of PetriEditor. +## +## PetriEditor is free software: you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Emacs. If not, see . +##===================================================================== + ################################################### # Location of the project directory and Makefiles # P := ../.. M := $(P)/.makefile -BUILD := $(P)/build ################################################### # Project definition # include $(P)/Makefile.common -TARGET = TimedPetriNetJulia -DESCRIPTION = Timed Petri Net Editor interface for Julia - -################################################### -# Location of the project directory and Makefiles -# -include $(M)/Makefile.header -include $(P)/src/Editor/DearImGui/Makefile.imgui +TARGET_NAME := TimedPetriJulia +TARGET_DESCRIPTION := Timed Petri Net Editor interface for Julia +include $(M)/project/Makefile ################################################### # Inform Makefile where to find *.cpp files # -VPATH += $(P)/include $(P)/src $(P)/src/Utils $(P)/src/Net +VPATH += $(P)/src $(P)/src/Utils $(P)/src/Net VPATH += $(P)/src/Net/Imports VPATH += $(P)/src/Net/Exports ################################################### # Inform Makefile where to find header files # -INCLUDES += -I$(P)/include -I$(P)/src -I$(P)/external +INCLUDES += $(P)/include $(P)/src $(P)/external ################################################### # Internal libraries since we can call the GUI from Julia REPL # -LIB_TPNE_CORE = $(abspath $(P)/src/Net/$(BUILD)/libtimedpetrinetcore.a) -LIB_TPNE_GUI = $(abspath $(P)/src/Editor/$(BUILD)/libtimedpetrinetgui.a) -ifneq ($(EXAEQUOS),) -PKG_LIBS += --static glfw -else -PKG_LIBS += --static glfw3 -LINKER_FLAGS += -lGL -endif -# WARNING: do not use += since we do not want to include twice libraylib.a -THIRDPART_LIBS := $(LIB_TPNE_GUI) $(LIB_TPNE_CORE) +INTERNAL_LIBS := TimedPetriEditor TimedPetriNet +DIRS_WITH_MAKEFILE := $(P)/src/Net $(P)/src/Editor ################################################### # Make the list of compiled files for the library # -LIB_OBJS += Julia.o +LIB_FILES += $(P)/src/julia/Julia.cpp -################################################### -# Compile the project, the static and shared libraries -.PHONY: all -all: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) $(LIB_TPNE_GUI) $(LIB_TPNE_CORE) $(P)/Makefile $(P)/Makefile.common +USER_CXX_FLAGS += -Wno-cast-qual -Wno-undef ################################################### -# Install project. You need to be root. -.PHONY: install -install: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) - @$(call INSTALL_PROJECT_LIBRARIES) +# GUI +# +include $(abspath $(P)/src/Editor/DearImGui/Backends/Makefile) +INCLUDES += $(P)/src/Editor/DearImGui +INCLUDES += $(P)/src ################################################### -# Sharable informations between all Makefiles +# Generic Makefile rules # -include $(M)/Makefile.footer +include $(M)/rules/Makefile + +################################################### +# Install project. You need to be root. +.PHONY: install +install:: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) + @$(call INSTALL_PROJECT_LIBRARIES) \ No newline at end of file diff --git a/tests/Makefile b/tests/Makefile index 26facf0..8c34a5c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -18,63 +18,53 @@ ## along with GNU Emacs. If not, see . ##===================================================================== -################################################### -# Project definition -# -PROJECT = TimedPetriNetEditor -TARGET = $(PROJECT)-UnitTest -DESCRIPTION = Unit tests for $(PROJECT) -BUILD_TYPE = debug -USE_COVERAGE = 1 - ################################################### # Location of the project directory and Makefiles # P := .. M := $(P)/.makefile -include $(M)/Makefile.header ################################################### -# Inform Makefile where to find header files +# Project definition # -INCLUDES += -I$(P)/include -I$(P)/src -I$(P)/external +include $(P)/Makefile.common +TARGET_NAME := $(PROJECT_NAME)-UnitTest +TARGET_DESCRIPTION := Unit tests for $(PROJECT_NAME) +BUILD_TYPE = test +include $(M)/project/Makefile ################################################### -# Inform Makefile where to find *.cpp and *.o files +# Set json ibrary. # -VPATH += $(P)/include $(P)/src $(P)/src/Utils $(P)/src/Net -VPATH += $(P)/src/Net/Imports VPATH += $(P)/src/Net/Exports -VPATH += $(P)/src/Application $(P)/src/Editor $(P)/src/Editor/DearImGui +INCLUDES += $(THIRDPART_DIR)/json/include ################################################### -# Set json Library. +# Set xml Library. # -INCLUDES += -I$(THIRDPART)/json/include +VPATH += $(THIRDPART_DIR)/tinyxml2 +SRC_FILES += $(THIRDPART_DIR)/tinyxml2/tinyxml2.cpp +USER_CXX_FLAGS += -Wno-old-style-cast -Wno-sign-conversion ################################################### -# Set xml Library. +# Inform Makefile where to find *.cpp files # -VPATH += $(THIRDPART)/tinyxml2 -OBJS += tinyxml2.o +VPATH += $(P)/src $(P)/src/Utils $(P)/src/Net +VPATH += $(P)/src/Net/Imports $(P)/src/Net/Exports ################################################### -# Make the list of compiled files for tests +# Inform Makefile where to find header files # -OBJS += Path.o Howard.o Utils.o TimedTokens.o Receptivities.o -OBJS += PetriNet.o Algorithms.o Simulation.o -OBJS += ExportGrafcetCpp.o ExportJSON.o ExportSymfony.o ExportPnEditor.o -OBJS += ExportPetriLaTeX.o ExportJulia.o ExportGraphviz.o ExportDrawIO.o -OBJS += ExportPNML.o Exports.o ImportPNML.o ImportJSON.o Imports.o -OBJS += ImportTimedEventGraph.o ExportTimedEventGraph.o ImportFlowshop.o -OBJS += PetriNetTests.o LoadJSONTests.o HowardTests.o EventGraphTests.o -OBJS += SparseMatrixTests.o TimedTokensTests.o main.o +INCLUDES += $(P)/include $(P)/src $(THIRDPART_DIR) ################################################### -# MacOS X +# Make the list of compiled files for the library # -ifeq ($(ARCHI),Darwin) -LINKER_FLAGS += -framework CoreFoundation -endif +SRC_FILES += $(call rwildcard,$(P)/src/Net,*.cpp) +SRC_FILES += $(call rwildcard,$(P)/src/Net,*.c) +SRC_FILES += $(call rwildcard,$(P)/src/Utils,*.cpp) +SRC_FILES += $(call rwildcard,$(P)/tests,*.cpp) +USER_CXX_FLAGS += -Wno-float-equal +USER_CC_FLAGS += -Wno-sign-conversion -Wno-float-equal ################################################### # Set Libraries. For knowing which libraries @@ -83,18 +73,6 @@ endif PKG_LIBS += gtest gmock ################################################### -# Compile the project -.PHONY: all -all: $(TARGET) - -################################################### -# Compile and launch unit tests and generate the code coverage html report. -.PHONY: unit-tests -.PHONY: check -unit-tests check: $(TARGET) - @$(call print-to,"Running","$(TARGET)","$(RAPPORT)","") - $(SANITIZER) ./$(BUILD)/$(TARGET) $(TU_OPTIONS) || (cat $(TARGET).log; return 1) - -################################################### -# Sharable informations between all Makefiles -include $(M)/Makefile.footer +# Generic Makefile rules +# +include $(M)/rules/Makefile \ No newline at end of file