Skip to content

Commit

Permalink
Merge pull request #8 from ethanuppal/file-parsing-2
Browse files Browse the repository at this point in the history
Add file parsing
  • Loading branch information
ethanuppal authored May 18, 2024
2 parents 586287d + 25a9955 commit c38125b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*.dSYM
*~
main
build/
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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; \
Expand Down
5 changes: 3 additions & 2 deletions tests/parseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ using namespace bwmodel;

int main() {
std::unique_ptr<Map> 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");
Expand Down Expand Up @@ -34,4 +35,4 @@ int main() {
== game.players_left().end());

return 0;
}
}

0 comments on commit c38125b

Please sign in to comment.