diff --git a/.gitignore b/.gitignore index d6b4cc5..7220063 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.dSYM *~ main +build/ diff --git a/Makefile b/Makefile index eaed244..3185593 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,14 @@ SRCDIR := ./src INCLUDEDIR := ./src TESTSDIR := ./tests -CC := $(shell which g++ || which clang) -LDFLAGS := -Lefsw -lefsw -CFLAGS := -std=c++17 -pedantic -Wall -Wextra -I $(INCLUDEDIR) +C_CC := $(shell which gcc || which clang) +CPP_CC := $(shell which g++ || which clang) +LDFLAGS := -Lbuild -lefsw +ifeq ($(shell uname -s),Darwin) + LDFLAGS += -framework CoreFoundation -framework CoreServices +endif +CFLAGS := -std=c99 -pedantic -Wall -Wextra -I $(INCLUDEDIR) +CPPFLAGS := -std=c++17 -pedantic -Wall -Wextra -I $(INCLUDEDIR) CDEBUG := -g CRELEASE := -O2 -DRELEASE_BUILD TARGET := main @@ -19,21 +24,22 @@ build: library make $(TARGET) $(TARGET): main.cpp $(OBJ) - $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) + $(CPP_CC) $(CPPFLAGS) $^ -o $@ $(LDFLAGS) %.o: %.cpp @echo 'Compiling $@' - $(CC) $(CFLAGS) -MMD -MP $< -c -o $@ + $(CPP_CC) $(CPPFLAGS) -MMD -MP $< -c -o $@ .PHONY: library library: - cmake -DBUILD_SHARED_LIBS=OFF efsw - make -C efsw + git submodule update --init --recursive + CMAKE_C_COMPILER=$(C_CC) cmake -DBUILD_SHARED_LIBS=OFF -Bbuild efsw + cd build && make .PHONY: clean clean: rm -rf $(OBJ) $(TARGET) $(shell find . -name "*.dSYM") - make -C efsw clean + cd efsw && make clean .PHONY: run run: build @@ -44,7 +50,7 @@ test: CFLAGS += -DNO_LOGGING test: $(OBJ) @for f in $(TESTSDIR)/*.cpp; do \ echo " testing $$f"; \ - $(CC) $(CFLAGS) "$$f" $^ -o $(TESTSDIR)/tmpexec; \ + $(CPP_CC) $(CPPFLAGS) "$$f" $^ -o $(TESTSDIR)/tmpexec; \ $(TESTSDIR)/tmpexec && printf "\033[32m+ test $$f passed\033[m\n" || printf "\033[31m- test $$f failed\033[m\n"; \ done; \ find $(TESTSDIR) -type f -not -name "*.cpp" -delete; \ diff --git a/tests/parseline.cpp b/tests/parseline.cpp index f0feef9..d6d157a 100644 --- a/tests/parseline.cpp +++ b/tests/parseline.cpp @@ -6,7 +6,8 @@ using namespace bwmodel; int main() { std::unique_ptr map = Map::load_from("./data/example.bwmap"); - Game game(std::move(map)); + Game game(std::move(map), + PlayerColor::WHITE /* we forgot the exact color */); // TODO: add game start test std::ifstream file("./data/example_chat.htm"); @@ -34,4 +35,4 @@ int main() { == game.players_left().end()); return 0; -} \ No newline at end of file +}