Skip to content

Commit

Permalink
Use MyMakefile v2-rc
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed Jun 6, 2024
1 parent efb856e commit dabf313
Show file tree
Hide file tree
Showing 22 changed files with 345 additions and 405 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/non_regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: |
cd tests
V=1 make -j`nproc --all`
./build/TimedPetriNetEditor-UnitTest
../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/
Expand All @@ -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
Expand All @@ -74,8 +74,8 @@ jobs:
- name: Do non regression tests
run: |
cd tests
make -j`sysctl -n hw.logicalcpu`
./build/TimedPetriNetEditor-UnitTest
V=1 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
Expand Down
2 changes: 1 addition & 1 deletion .makefile
173 changes: 61 additions & 112 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
##=====================================================================
## TimedPetriNetEditor: A timed Petri net editor.
## Copyright 2021 -- 2023 Quentin Quadrat <lecrapouille@gmail.com>
##
## 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 <http://www.gnu.org/licenses/>.
##=====================================================================

###################################################
# Location of the project directory and Makefiles
#
Expand All @@ -8,93 +28,69 @@ 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

###################################################
# OpenGL: glfw and glew libraries
SRC_FILES := src/main.cpp
INCLUDES := $(P)/include
VPATH := $(P)/src
# 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

###################################################
# 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)
THIRDPART_LIBS :=
LINKER_FLAGS += -ldl -lpthread
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
# Install the folder data in the Emscripten filesystem
LINKER_FLAGS += --preload-file $(PROJECT_DATA_DIR)
LINKER_FLAGS += -s FORCE_FILESYSTEM=1
# 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
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

###################################################
# Compile the stand-alone application
.PHONY: all
all: $(TARGET) copy-emscripten-assets
include $(M)/rules/Makefile

###################################################
# 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_GUI): src/Editor
$(LIB_TPNE_NET): $(P)/src/Net

$(LIB_TPNE_CORE): src/Net
$(LIB_TPNE_EDITOR): $(P)/src/Editor

$(LIB_TPNE_JULIA): src/julia
$(LIB_TPNE_JULIA): $(P)/src/julia

src/julia: src/Editor
$(P)/src/julia: $(P)/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)
Expand All @@ -104,51 +100,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
endif
21 changes: 5 additions & 16 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -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 := release
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/\"
DEAR_IMGUI_BACKEND ?= RayLib
1 change: 0 additions & 1 deletion VERSION.txt

This file was deleted.

10 changes: 5 additions & 5 deletions external/compile-external-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
### $CXX: C++ compiler
###############################################################################

source ../.makefile/compile-external-libs.sh
source $1

### Library raylib
print-compile raylib
Expand All @@ -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
)
2 changes: 1 addition & 1 deletion external/download-external-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Editor/DearImGui/Backends/GLFW3/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <GLFW/glfw3.h>

//------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit dabf313

Please sign in to comment.