Skip to content

Commit

Permalink
Use MyMakefile v2-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed Jul 1, 2024
1 parent e06f26d commit 52dabbe
Show file tree
Hide file tree
Showing 25 changed files with 93 additions and 206 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Project specific
*~
build
build*
cov-int
src/*.tar.bz2
src/build
tests/build
external/.downloaded
external/imgui
external/imgui_sdl
Expand Down
2 changes: 1 addition & 1 deletion .makefile
Submodule .makefile updated 59 files
+0 −102 .github/workflows/ci.yml
+0 −10 .gitignore
+674 −21 LICENSE
+0 −72 Makefile.color
+0 −349 Makefile.flags
+0 −288 Makefile.footer
+0 −246 Makefile.header
+0 −24 Makefile.help
+0 −336 Makefile.macros
+2 −443 README.md
+1 −0 VERSION
+0 −1 VERSION.txt
+367 −202 assets/doxygen/Doxyfile
+0 −0 assets/doxygen/doxygen.css
+0 −0 assets/doxygen/footer.html
+1 −0 assets/doxygen/header.html
+ assets/icons/logo.png
+ assets/icons/macos.icns
+3 −3 assets/scripts/alib.sh
+23 −26 assets/scripts/compile-external-libs.sh
+18 −18 assets/scripts/config.sh
+65 −0 assets/scripts/download-external-libs.sh
+27 −17 assets/scripts/targz.sh
+91 −0 doc/API.md
+14 −0 doc/demos/00/Makefile
+1 −2 doc/demos/00/src/main.cpp
+16 −0 doc/demos/01/Makefile
+12 −0 doc/demos/01/src/foo.cpp
+1 −1 doc/demos/01/src/foo.hpp
+3 −2 doc/demos/01/src/main.cpp
+16 −0 doc/demos/01/tests/Makefile
+13 −0 doc/demos/01/tests/unit-tests.cpp
+21 −0 doc/demos/02/Makefile
+0 −0 doc/demos/02/include/bar.hpp
+0 −0 doc/demos/02/include/foo.hpp
+15 −0 doc/demos/02/src/bar/Makefile
+0 −0 doc/demos/02/src/bar/bar.cpp
+15 −0 doc/demos/02/src/foo/Makefile
+0 −0 doc/demos/02/src/foo/foo.cpp
+15 −0 doc/demos/02/src/main.cpp
+0 −75 download-external-libs.sh
+0 −18 examples/00/Makefile
+0 −1 examples/00/VERSION.txt
+0 −27 examples/01/Makefile
+0 −1 examples/01/VERSION.txt
+0 −8 examples/01/src/foo.cpp
+0 −22 examples/01/tests/Makefile
+0 −1 examples/01/tests/VERSION.txt
+0 −14 examples/01/tests/unit-tests.cpp
+0 −62 examples/02/Makefile
+0 −1 examples/02/VERSION.txt
+0 −40 examples/02/src/bar/Makefile
+0 −1 examples/02/src/bar/VERSION.txt
+0 −40 examples/02/src/foo/Makefile
+0 −1 examples/02/src/foo/VERSION.txt
+0 −8 examples/02/src/main.cpp
+0 −37 examples/README.md
+397 −0 project/Makefile
+1,173 −0 rules/Makefile
93 changes: 20 additions & 73 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,94 +1,41 @@

###################################################
# Project definition
#
PROJECT = OpenGlassBox
TARGET = $(PROJECT)
DESCRIPTION = An Open Source Implementation of the SimCity 2013 Simulation Engine GlassBox
STANDARD = --std=c++14
BUILD_TYPE = release

###################################################
# Location of the project directory and Makefiles
#
P := .
M := $(P)/.makefile
include $(M)/Makefile.header

###################################################
# Inform Makefile where to find header files
#
INCLUDES += -I$(P)/include -I$(P)

###################################################
# Inform Makefile where to find *.cpp and *.o files
# Project definition
#
VPATH += $(P)/src $(P)/src/Core
include $(P)/Makefile.common
TARGET_NAME := $(PROJECT_NAME)
TARGET_DESCRIPTION := An open source implementation of the SimCity 2013 simulation engine GlassBox
include $(M)/project/Makefile

###################################################
# Project defines
# Compile shared and static libraries
#
DEFINES += -DVIRTUAL= -DDESIRED_GRID_SIZE=30u
LIB_FILES := $(call rwildcard,src,*.cpp)
INCLUDES := $(P)/include
VPATH := $(P)/src
DEFINES := -DVIRTUAL= -DDESIRED_GRID_SIZE=30u

###################################################
# Make the list of compiled files for the library
# Generic Makefile rules
#
LIB_OBJS += Simulation.o Map.o City.o Unit.o Path.o Agent.o Resource.o Resources.o
LIB_OBJS += ScriptParser.o MapCoordinatesInsideRadius.o MapRandomCoordinates.o
LIB_OBJS += Rule.o RuleCommand.o RuleValue.o Dijkstra.o
include $(M)/rules/Makefile

###################################################
# Compile the project as static and shared libraries.
# Extra rules
#
.PHONY: all
all: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) demo
all:: demo

###################################################
# Compile the demo as standalone application.
#
.PHONY: demo
demo: | $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET)
@$(call print-from,"Compiling scenarios",$(PROJECT),demo)
$(MAKE) -C demo all

###################################################
# Install project. You need to be root.
#
ifeq ($(ARCHI),Linux)
.PHONY: install
install: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) demo
@$(call INSTALL_BINARY)
@$(call INSTALL_DOCUMENTATION)
@$(call INSTALL_PROJECT_LIBRARIES)
@$(call INSTALL_PROJECT_HEADERS)
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

###################################################
# 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
@$(MAKE) -C demo clean
demo:
$(Q)$(MAKE) --no-print-directory --directory=demo all

###################################################
# Sharable informations between all Makefiles
clean::
$(Q)$(MAKE) --no-print-directory --directory=demo clean

include $(M)/Makefile.footer
install::
$(Q)$(MAKE) --no-print-directory --directory=demo install
5 changes: 5 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PROJECT_NAME := OpenGlassBox
PROJECT_VERSION := 0.2.0
COMPILATION_MODE := release
CXX_STANDARD := --std=c++14
PROJECT_DATA := demo/data
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Where `-j8` is to adapt to match the number of CPU cores.

- Run the OpenGlassBox demo:
```sh
./demo/build/OpenGlassBox
./demo/build-release/Demo/Demo
```

- (Optional) Unit test with code coverage:
Expand Down
1 change: 0 additions & 1 deletion VERSION.txt

This file was deleted.

74 changes: 20 additions & 54 deletions demo/Makefile
Original file line number Diff line number Diff line change
@@ -1,72 +1,38 @@

###################################################
# Project definition
#
PROJECT = OpenGlassBox
TARGET = $(PROJECT)
DESCRIPTION = An Open Source Implementation of the SimCity 2013 Simulation Engine GlassBox
STANDARD = --std=c++14
BUILD_TYPE = debug

###################################################
# Location of the project directory and Makefiles
#
P := ..
M := $(P)/.makefile
include $(M)/Makefile.header

###################################################
# Inform Makefile where to find header files
#
INCLUDES += -I. -I$(P)/include -I$(P)

###################################################
# Inform Makefile where to find *.cpp and *.o files
#
VPATH += $(P) Display

###################################################
# Project defines
#
DEFINES += -DVIRTUAL= -DDESIRED_GRID_SIZE=30u
DEFINES += -DDATADIR=\"$(DATADIR):$(abspath data)/:data/\"

###################################################
# Set Libraries. For knowing which libraries
# is needed please read the external/README.md file.
# Project definition
#
PKG_LIBS = sdl2 SDL2_image
include $(P)/Makefile.common
TARGET_NAME := $(PROJECT_NAME)-demo
TARGET_DESCRIPTION := A demo using $(PROJECT_NAME)
include $(M)/project/Makefile

###################################################
# Compile against the OpenGlassBox shared library
# Compile the standalone application
#
THIRDPART_LIBS += $(abspath $(P)/$(BUILD)/libopenglassbox.a)
SRC_FILES := $(call rwildcard,src,*.cpp)
INCLUDES := $(P)/include $(P)/demo/src $(P)
VPATH := $(P)/demo
DEFINES := -DVIRTUAL= -DDESIRED_GRID_SIZE=30u
INTERNAL_LIBS := $(call internal-lib,$(PROJECT_NAME))
PKG_LIBS := sdl2 SDL2_image

###################################################
# MacOS X
# Create MacOS X bundle application.
#
ifeq ($(ARCHI),Darwin)
BUILD_MACOS_APP_BUNDLE = 1
APPLE_IDENTIFIER = lecrapouille
MACOS_BUNDLE_ICON = data/$(PROJECT).icns
LINKER_FLAGS += -framework CoreFoundation
ifeq ($(OS),Darwin)
BUILD_MACOS_APP_BUNDLE = 1
APPLE_IDENTIFIER := lecrapouille
MACOS_BUNDLE_ICON := data/$(PROJECT_NAME).icns
LINKER_FLAGS := -framework CoreFoundation
endif

###################################################
# Compile the demo as standalone application.
#
OBJS += DearImGui.o SDLHelper.o Window.o DataPath.o
OBJS += Debug.o Draw.o Listeners.o Demo.o main.o

###################################################
# Compile the demo as standalone application.
# Generic Makefile rules
#
all: $(TARGET)
@cp $(BUILD)/$(TARGET) ../$(BUILD)
ifeq ($(ARCHI),Darwin)
@cp -r $(BUILD)/$(TARGET)$(EXT) ../$(BUILD)
endif

###################################################
# Sharable informations between all Makefiles
include $(M)/Makefile.footer
include $(M)/rules/Makefile
1 change: 0 additions & 1 deletion demo/VERSION.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions demo/Display/DataPath.cpp → demo/src/Display/DataPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,13 @@ std::string DataPath::toString() const
{
std::string string_path;

string_path += ".";
string_path += m_delimiter;

for (auto const& it: m_search_paths)
{
string_path += it;
string_path.pop_back(); // Remove the '/' char
string_path += m_delimiter;
}
string_path.pop_back();

return string_path;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 9 additions & 11 deletions demo/main.cpp → demo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@
#include "OpenGlassBox/Config.hpp"

//------------------------------------------------------------------------------
# ifndef DATADIR
# define GET_DATA_PATH project::info::data_path
# endif
# if defined(__APPLE__)
# define GET_DATA_PATH DATADIR":" + osx_get_resources_dir("")
# elif defined(__EMSCRIPTEN__)
# define GET_DATA_PATH "data/"
# else
# define GET_DATA_PATH DATADIR
# endif
#undef GET_DATA_PATH
#if defined(__APPLE__)
# define GET_DATA_PATH osx_get_resources_dir("")
#else
# define GET_DATA_PATH project::info::data_path
#endif

//------------------------------------------------------------------------------
GlassBox::GlassBox()
: m_path(GET_DATA_PATH), m_simulation(12u, 12u)
{}
{
std::cout << "Search paths: " << m_path.toString() << std::endl;
}

//------------------------------------------------------------------------------
void GlassBox::onRelease(SDL_Renderer&)
Expand Down
File renamed without changes.
40 changes: 10 additions & 30 deletions external/download-external-libs.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
#!/bin/bash -e
###############################################################################
### This script is called by (cd .. && make download-external-libs). It will
### git clone thirdparts needed for this project but does not compile them.
### It replaces git submodules that I dislike.
###############################################################################

### This script will git clone some libraries that OpenGlassBox needs and
### compile them. To avoid pollution, they are not installed into your
### environement. Therefore OpenGlassBox Makefiles have to know where to
### find their files (includes and static/shared libraries).

### $1 is given by ../Makefile and refers to the current architecture.
if [ "$1" == "" ]; then
echo "Expected one argument. Select the architecture: Linux, Darwin or Windows"
exit 1
fi
ARCHI="$1"
TARGET="$2"

### Delete all previous directories to be sure to have and compile
### fresh code source.
rm -fr imgui_sdl imgui 2> /dev/null

function print-clone
{
echo -e "\033[35m*** Cloning:\033[00m \033[36m$TARGET\033[00m <= \033[33m$1\033[00m"
}

### Library for creating GUI in OpenGL
### Bloat-free Graphical User interface for C++ with minimal dependencies
### License: MIT
print-clone imgui
git clone https://github.com/ocornut/imgui.git > /dev/null 2> /dev/null
(cd imgui && git reset --hard f9b873662baac2388a4ca78c967e53eb5d83d2a1)
cloning ocornut/imgui -b docking
(cd imgui && git fetch --unshallow && git reset --hard f9b873662baac2388a4ca78c967e53eb5d83d2a1)

### ImGuiSDL: SDL2 based renderer for Dear ImGui
### License: MIT
### FIXME: No longer needed since now integrated directly inside imgui
print-clone imgui_sdl
git clone https://github.com/Tyyppi77/imgui_sdl.git --depth=1 > /dev/null 2> /dev/null
cloning Tyyppi77/imgui_sdl
cp imgui_sdl/imgui_sdl.cpp imgui/imgui_sdl.cpp
cp imgui_sdl/imgui_sdl.h imgui/imgui_sdl.h
cp imgui_sdl/imgui_sdl.h imgui/imgui_sdl.h
Loading

0 comments on commit 52dabbe

Please sign in to comment.