From 3bb50ee02758aac4b582dbde697fdabd3b334488 Mon Sep 17 00:00:00 2001 From: Mark Bluemer Date: Wed, 12 Apr 2017 22:12:44 -0400 Subject: [PATCH] set up basic example project and structure with Makefile --- .gitignore | 4 ++++ Makefile | 24 ++++++++++++++++++++++++ README.md | 11 +++++++++++ include/Move.h | 18 ++++++++++++++++++ src/Move.cpp | 7 +++++++ src/main.cpp | 6 ++++++ 6 files changed, 70 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 include/Move.h create mode 100644 src/Move.cpp create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc46002 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.vimrc +*.swp +bin/* +build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..052e343 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +# makefile modeled off of: http://hiltmon.com/blog/2013/07/03/a-simple-c-plus-plus-project-structure/ + + +CC := g++ -std=c++14 +SRCDIR := src +BUILDDIR := build +TARGET := build/runner + +SRCEXT := cpp +SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) # grabs all src files +OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) +INC := -I include + +$(TARGET): $(OBJECTS) + @echo " Linking..." + @echo " $(CC) $^ -o $(TARGET)"; $(CC) $^ -o $(TARGET) + +$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) + @mkdir -p $(BUILDDIR) + @echo " $(CC) $(INC) -c -o $@ $<"; $(CC) $(INC) -c -o $@ $< + +clean: + @echo " Cleaning..."; + @echo " $(RM) -r $(BULIDDIR) $(TARGET)"; $(RM) -r $(BULIDDIR) $(TARGET) diff --git a/README.md b/README.md index 9e149f1..7946a4a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ # Checkers AI Project This is the repo for a checkers AI project. + +## Project Structure + +* `src/` + - contains .cpp source files +* `include/` + - contains all .h header files +* `bin/` + - all object files are dumped in here (clean commands cleans this directory up) +* `build/runner` + - When project is built it's compiled to the `runner` file diff --git a/include/Move.h b/include/Move.h new file mode 100644 index 0000000..8664393 --- /dev/null +++ b/include/Move.h @@ -0,0 +1,18 @@ +#ifndef MOVE_H +#define MOVE_H + +#include + +class Move +{ +private: + + std::vector moves; + +public: + + Move() : moves() {}; + void printMessage(); +}; + +#endif diff --git a/src/Move.cpp b/src/Move.cpp new file mode 100644 index 0000000..a91d1ba --- /dev/null +++ b/src/Move.cpp @@ -0,0 +1,7 @@ +#include +#include "Move.h" + +void Move::printMessage() +{ + std::cout << "Here is an example message" << std::endl; +} diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..2a87151 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,6 @@ +#include + +int main(int argc, const char * argv[]) { + std::cout << "Hello world!" << std::endl; + return 0; +}