Skip to content

Commit 9e23535

Browse files
committed
Use MyMakefile v2-alpha
1 parent e06f26d commit 9e23535

27 files changed

+102
-208
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
# export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/C:/Program Files (x86)/googletest-distribution/lib/pkgconfig"
4848
# cd tests
4949
# mingw32-make -j`nproc --all`
50-
# ./build/OpenGlassBox-UnitTest
50+
# ../build/OpenGlassBox-tests
5151

5252
non_regression_linux:
5353
name: Non regression tests on Linux
@@ -78,12 +78,14 @@ jobs:
7878
run: |
7979
cd tests
8080
V=1 make -j`nproc --all`
81-
./build/OpenGlassBox-UnitTest
81+
../build/OpenGlassBox-tests
8282
- name: Check if the library can be linked against a project
8383
run: |
84+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
8485
git clone https://github.com/Lecrapouille/LinkAgainstMyLibs.git --recurse-submodules --depth=1
8586
cd LinkAgainstMyLibs/OpenGlassBox
8687
V=1 make -j`nproc --all`
88+
./build/OpenGlassBox
8789
8890
non_regression_macos:
8991
name: Non regression tests on MacOS X
@@ -113,9 +115,10 @@ jobs:
113115
run: |
114116
cd tests
115117
make -j`sysctl -n hw.logicalcpu`
116-
./build/OpenGlassBox-UnitTest
118+
../build/OpenGlassBox-tests
117119
# - name: Check if the library can be linked against a project
118120
# run: |
119121
# git clone https://github.com/Lecrapouille/LinkAgainstMyLibs.git --recurse-submodules --depth=1
120122
# cd LinkAgainstMyLibs/OpenGlassBox
121123
# make -j`sysctl -n hw.logicalcpu`
124+
# ./build/OpenGlassBox

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Project specific
22
*~
3-
build
3+
build*
44
cov-int
55
src/*.tar.bz2
6-
src/build
7-
tests/build
86
external/.downloaded
97
external/imgui
108
external/imgui_sdl

.makefile

Submodule .makefile updated 59 files

Makefile

Lines changed: 20 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,41 @@
1-
2-
###################################################
3-
# Project definition
4-
#
5-
PROJECT = OpenGlassBox
6-
TARGET = $(PROJECT)
7-
DESCRIPTION = An Open Source Implementation of the SimCity 2013 Simulation Engine GlassBox
8-
STANDARD = --std=c++14
9-
BUILD_TYPE = release
10-
111
###################################################
122
# Location of the project directory and Makefiles
133
#
144
P := .
155
M := $(P)/.makefile
16-
include $(M)/Makefile.header
17-
18-
###################################################
19-
# Inform Makefile where to find header files
20-
#
21-
INCLUDES += -I$(P)/include -I$(P)
226

237
###################################################
24-
# Inform Makefile where to find *.cpp and *.o files
8+
# Project definition
259
#
26-
VPATH += $(P)/src $(P)/src/Core
10+
include $(P)/Makefile.common
11+
TARGET_NAME := $(PROJECT_NAME)
12+
TARGET_DESCRIPTION := An open source implementation of the SimCity 2013 simulation engine GlassBox
13+
include $(M)/project/Makefile
2714

2815
###################################################
29-
# Project defines
16+
# Compile shared and static libraries
3017
#
31-
DEFINES += -DVIRTUAL= -DDESIRED_GRID_SIZE=30u
18+
LIB_FILES := $(call rwildcard,src,*.cpp)
19+
INCLUDES := $(P)/include
20+
VPATH := $(P)/src
21+
DEFINES := -DVIRTUAL= -DDESIRED_GRID_SIZE=30u
3222

3323
###################################################
34-
# Make the list of compiled files for the library
24+
# Generic Makefile rules
3525
#
36-
LIB_OBJS += Simulation.o Map.o City.o Unit.o Path.o Agent.o Resource.o Resources.o
37-
LIB_OBJS += ScriptParser.o MapCoordinatesInsideRadius.o MapRandomCoordinates.o
38-
LIB_OBJS += Rule.o RuleCommand.o RuleValue.o Dijkstra.o
26+
include $(M)/rules/Makefile
3927

4028
###################################################
41-
# Compile the project as static and shared libraries.
29+
# Extra rules
4230
#
43-
.PHONY: all
44-
all: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) demo
31+
all:: demo
4532

46-
###################################################
47-
# Compile the demo as standalone application.
48-
#
4933
.PHONY: demo
50-
demo: | $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET)
51-
@$(call print-from,"Compiling scenarios",$(PROJECT),demo)
52-
$(MAKE) -C demo all
53-
54-
###################################################
55-
# Install project. You need to be root.
56-
#
57-
ifeq ($(ARCHI),Linux)
58-
.PHONY: install
59-
install: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) demo
60-
@$(call INSTALL_BINARY)
61-
@$(call INSTALL_DOCUMENTATION)
62-
@$(call INSTALL_PROJECT_LIBRARIES)
63-
@$(call INSTALL_PROJECT_HEADERS)
64-
endif
65-
66-
###################################################
67-
# Compile and launch unit tests and generate the code coverage html report.
68-
#
69-
.PHONY: unit-tests
70-
unit-tests:
71-
@$(call print-simple,"Compiling unit tests")
72-
@$(MAKE) -C tests coverage
73-
74-
###################################################
75-
# Compile and launch unit tests and generate the code coverage html report.
76-
#
77-
.PHONY: check
78-
check: unit-tests
79-
80-
###################################################
81-
# Clean the whole project.
82-
#
83-
.PHONY: veryclean
84-
veryclean: clean
85-
@rm -fr cov-int $(PROJECT).tgz *.log foo 2> /dev/null
86-
@(cd tests && $(MAKE) -s clean)
87-
@$(call print-simple,"Cleaning","$(PWD)/doc/html")
88-
@rm -fr $(THIRDPART)/*/ doc/html 2> /dev/null
89-
@$(MAKE) -C demo clean
34+
demo: $(TARGET_STATIC_LIB_NAME)
35+
$(Q)$(MAKE) --no-print-directory --directory=demo all
9036

91-
###################################################
92-
# Sharable informations between all Makefiles
37+
clean::
38+
$(Q)$(MAKE) --no-print-directory --directory=demo clean
9339

94-
include $(M)/Makefile.footer
40+
install::
41+
$(Q)$(MAKE) --no-print-directory --directory=demo install

Makefile.common

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PROJECT_NAME := OpenGlassBox
2+
PROJECT_VERSION := 0.2.0
3+
COMPILATION_MODE := release
4+
CXX_STANDARD := --std=c++14
5+
PROJECT_DATA := demo/data

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Where `-j8` is to adapt to match the number of CPU cores.
5454

5555
- Run the OpenGlassBox demo:
5656
```sh
57-
./demo/build/OpenGlassBox
57+
./demo/build-release/Demo/Demo
5858
```
5959

6060
- (Optional) Unit test with code coverage:

VERSION.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

demo/Makefile

Lines changed: 21 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,40 @@
1-
2-
###################################################
3-
# Project definition
4-
#
5-
PROJECT = OpenGlassBox
6-
TARGET = $(PROJECT)
7-
DESCRIPTION = An Open Source Implementation of the SimCity 2013 Simulation Engine GlassBox
8-
STANDARD = --std=c++14
9-
BUILD_TYPE = debug
10-
111
###################################################
122
# Location of the project directory and Makefiles
133
#
144
P := ..
155
M := $(P)/.makefile
16-
include $(M)/Makefile.header
17-
18-
###################################################
19-
# Inform Makefile where to find header files
20-
#
21-
INCLUDES += -I. -I$(P)/include -I$(P)
22-
23-
###################################################
24-
# Inform Makefile where to find *.cpp and *.o files
25-
#
26-
VPATH += $(P) Display
276

287
###################################################
29-
# Project defines
30-
#
31-
DEFINES += -DVIRTUAL= -DDESIRED_GRID_SIZE=30u
32-
DEFINES += -DDATADIR=\"$(DATADIR):$(abspath data)/:data/\"
33-
34-
###################################################
35-
# Set Libraries. For knowing which libraries
36-
# is needed please read the external/README.md file.
8+
# Project definition
379
#
38-
PKG_LIBS = sdl2 SDL2_image
10+
include $(P)/Makefile.common
11+
TARGET_NAME := $(PROJECT_NAME)-demo
12+
TARGET_DESCRIPTION := A demo using $(PROJECT_NAME)
13+
include $(M)/project/Makefile
3914

4015
###################################################
41-
# Compile against the OpenGlassBox shared library
16+
# Compile the standalone application
4217
#
43-
THIRDPART_LIBS += $(abspath $(P)/$(BUILD)/libopenglassbox.a)
18+
SRC_FILES := $(call rwildcard,src,*.cpp)
19+
INCLUDES := $(P)/include $(P)/demo/src $(P)
20+
VPATH := $(P)/demo
21+
DEFINES := -DVIRTUAL= -DDESIRED_GRID_SIZE=30u
22+
INTERNAL_LIBS := $(call internal-lib,$(PROJECT_NAME))
23+
PKG_LIBS := sdl2 SDL2_image
4424

4525
###################################################
46-
# MacOS X
26+
# Create MacOS X bundle application.
4727
#
48-
ifeq ($(ARCHI),Darwin)
49-
BUILD_MACOS_APP_BUNDLE = 1
50-
APPLE_IDENTIFIER = lecrapouille
51-
MACOS_BUNDLE_ICON = data/$(PROJECT).icns
52-
LINKER_FLAGS += -framework CoreFoundation
28+
ifeq ($(OS),Darwin)
29+
BUILD_MACOS_APP_BUNDLE = 1
30+
APPLE_IDENTIFIER := lecrapouille
31+
MACOS_BUNDLE_ICON := data/$(PROJECT_NAME).icns
32+
LINKER_FLAGS := -framework CoreFoundation
5333
endif
5434

5535
###################################################
56-
# Compile the demo as standalone application.
36+
# Generic Makefile rules
5737
#
58-
OBJS += DearImGui.o SDLHelper.o Window.o DataPath.o
59-
OBJS += Debug.o Draw.o Listeners.o Demo.o main.o
38+
include $(M)/rules/Makefile
6039

61-
###################################################
62-
# Compile the demo as standalone application.
63-
#
64-
all: $(TARGET)
65-
@cp $(BUILD)/$(TARGET) ../$(BUILD)
66-
ifeq ($(ARCHI),Darwin)
67-
@cp -r $(BUILD)/$(TARGET)$(EXT) ../$(BUILD)
68-
endif
69-
70-
###################################################
71-
# Sharable informations between all Makefiles
72-
include $(M)/Makefile.footer
40+
$(INTERNAL_LIBS):

demo/VERSION.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.
File renamed without changes.

demo/Display/DataPath.cpp renamed to demo/src/Display/DataPath.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,13 @@ std::string DataPath::toString() const
217217
{
218218
std::string string_path;
219219

220-
string_path += ".";
221-
string_path += m_delimiter;
222-
223220
for (auto const& it: m_search_paths)
224221
{
225222
string_path += it;
226223
string_path.pop_back(); // Remove the '/' char
227224
string_path += m_delimiter;
228225
}
226+
string_path.pop_back();
229227

230228
return string_path;
231229
}
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.

demo/main.cpp renamed to demo/src/main.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,19 @@
1111
#include "OpenGlassBox/Config.hpp"
1212

1313
//------------------------------------------------------------------------------
14-
# ifndef DATADIR
15-
# define GET_DATA_PATH project::info::data_path
16-
# endif
17-
# if defined(__APPLE__)
18-
# define GET_DATA_PATH DATADIR":" + osx_get_resources_dir("")
19-
# elif defined(__EMSCRIPTEN__)
20-
# define GET_DATA_PATH "data/"
21-
# else
22-
# define GET_DATA_PATH DATADIR
23-
# endif
14+
#undef GET_DATA_PATH
15+
#if defined(__APPLE__)
16+
# define GET_DATA_PATH osx_get_resources_dir("")
17+
#else
18+
# define GET_DATA_PATH project::info::data_path
19+
#endif
2420

2521
//------------------------------------------------------------------------------
2622
GlassBox::GlassBox()
2723
: m_path(GET_DATA_PATH), m_simulation(12u, 12u)
28-
{}
24+
{
25+
std::cout << "Search paths: " << m_path.toString() << std::endl;
26+
}
2927

3028
//------------------------------------------------------------------------------
3129
void GlassBox::onRelease(SDL_Renderer&)
File renamed without changes.

external/download-external-libs.sh

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,17 @@
11
#!/bin/bash -e
2+
###############################################################################
3+
### This script is called by (cd .. && make download-external-libs). It will
4+
### git clone thirdparts needed for this project but does not compile them.
5+
### It replaces git submodules that I dislike.
6+
###############################################################################
27

3-
### This script will git clone some libraries that OpenGlassBox needs and
4-
### compile them. To avoid pollution, they are not installed into your
5-
### environement. Therefore OpenGlassBox Makefiles have to know where to
6-
### find their files (includes and static/shared libraries).
7-
8-
### $1 is given by ../Makefile and refers to the current architecture.
9-
if [ "$1" == "" ]; then
10-
echo "Expected one argument. Select the architecture: Linux, Darwin or Windows"
11-
exit 1
12-
fi
13-
ARCHI="$1"
14-
TARGET="$2"
15-
16-
### Delete all previous directories to be sure to have and compile
17-
### fresh code source.
18-
rm -fr imgui_sdl imgui 2> /dev/null
19-
20-
function print-clone
21-
{
22-
echo -e "\033[35m*** Cloning:\033[00m \033[36m$TARGET\033[00m <= \033[33m$1\033[00m"
23-
}
24-
25-
### Library for creating GUI in OpenGL
8+
### Bloat-free Graphical User interface for C++ with minimal dependencies
269
### License: MIT
27-
print-clone imgui
28-
git clone https://github.com/ocornut/imgui.git > /dev/null 2> /dev/null
29-
(cd imgui && git reset --hard f9b873662baac2388a4ca78c967e53eb5d83d2a1)
10+
cloning ocornut/imgui -b docking
11+
(cd imgui && git fetch --unshallow && git reset --hard f9b873662baac2388a4ca78c967e53eb5d83d2a1)
3012

3113
### ImGuiSDL: SDL2 based renderer for Dear ImGui
3214
### License: MIT
33-
### FIXME: No longer needed since now integrated directly inside imgui
34-
print-clone imgui_sdl
35-
git clone https://github.com/Tyyppi77/imgui_sdl.git --depth=1 > /dev/null 2> /dev/null
15+
cloning Tyyppi77/imgui_sdl
3616
cp imgui_sdl/imgui_sdl.cpp imgui/imgui_sdl.cpp
37-
cp imgui_sdl/imgui_sdl.h imgui/imgui_sdl.h
17+
cp imgui_sdl/imgui_sdl.h imgui/imgui_sdl.h

0 commit comments

Comments
 (0)