diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 95b3ba1d76d72dc37caa5f0a3ae8dfc298cbe687..a9c7a2f51a16c2e0930d1da2b5a26a356b2b4665 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ build: - mkdir bin - mkdir saves script: - - make + - make console artifacts: paths: - bin/ diff --git a/include/components/cTexture.h b/include/components/cTexture.h index 0afd96cd69b2b89a8c3887323a8cb58acf4fb3da..105ef8106a6ff6de58b0060c687aab2bf6b92c84 100644 --- a/include/components/cTexture.h +++ b/include/components/cTexture.h @@ -1,7 +1,9 @@ #ifndef __COMPONENTS__TEXTURE_H__ #define __COMPONENTS__TEXTURE_H__ +#ifndef console #include <SDL.h> +#endif #include <cstdio> #include <string> #include "components/components-generic.h" diff --git a/include/game-engine.h b/include/game-engine.h index 8eaaf2aa474abe48dae1a962da38597b840ebc4d..c34f46b44180aac930684d3908976e1294ee2ff4 100644 --- a/include/game-engine.h +++ b/include/game-engine.h @@ -6,7 +6,10 @@ #include <vector> #include <chrono> #include <ctime> + +#ifndef console #include <SDL.h> +#endif // Return @@ -15,6 +18,8 @@ #include "scene.h" #include "window.h" +#endif + class GameEngine { public: diff --git a/include/window.h b/include/window.h index 52f660f25c07623276a1c72139df189a0c75c0d9..48b64fea1bba334e8076dc209446783386f96689 100644 --- a/include/window.h +++ b/include/window.h @@ -1,8 +1,10 @@ #ifndef __WINDOW_H__ #define __WINDOW_H__ +#ifndef console #include <SDL.h> #include <SDL_image.h> +#endif #include <cstdio> #include <cstring> @@ -84,4 +86,4 @@ class Window void clean(); }; -#endif // __WINDOW_H__ \ No newline at end of file +#endif // __WINDOW_H__ diff --git a/makefile b/makefile index c628a4bbd9c52c5e8d4ef002957eec2502932562..729d1fea4c928c2d55df3fa32291969671ac37eb 100644 --- a/makefile +++ b/makefile @@ -57,6 +57,9 @@ TEST_FILES = $(wildcard $(TEST_DIR)/**/*.test.cpp $(TEST_DIR)/*.test.cpp) OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRC_FILES)) TEST_OBJ_FILES = $(patsubst $(TEST_DIR)/%.test.cpp,$(BUILD_DIR)/%.o,$(TEST_FILES)) +# Define this for running console-only +CONSOLE_DEFINE = -Dconsole + # Output executable TARGET = $(BIN_DIR)/game TEST_TARGET = $(BIN_DIR)/test_runner @@ -66,6 +69,9 @@ all: $(TARGET) $(TARGET): $(OBJ_FILES) $(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJ_FILES) -L$(SDL_LIBRARY) $(LDFLAGS) +console: $(OBJ_FILES) + $(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJ_FILES) $(CONSOLE_DEFINE) + $(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp ${INC_DIR}/*.h @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(LDFLAGS) -I${SDL_INCLUDE} -I$(INC_DIR) -c -o $@ $< @@ -75,5 +81,13 @@ clean: rm -rf ./*~ ./*.swp rm -rf *~ +run_tests: $(TEST_OBJ_FILES) + $(CXX) $(CXXFLAGS) $(LDFLAGS) $(INC_DIRS) -o ${TEST_TARGET} $^ + ./${TEST_TARGET} + +$(BUILD_DIR)/%.o: $(TEST_DIR)/%.test.cpp + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(LDFLAGS) $(INC_DIRS) -c -o $@ $< + run: $(TARGET) ./$(TARGET)