Skip to content

Commit

Permalink
Splits projects into multiple libs
Browse files Browse the repository at this point in the history
  • Loading branch information
psde committed Jan 17, 2013
1 parent b25ae8d commit a69be28
Show file tree
Hide file tree
Showing 30 changed files with 345 additions and 246 deletions.
36 changes: 10 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
# Configuration
BIN = codepeiler
BINDIR = bin
SOURCEDIR = src
NAME = codepeiler
LIBRARIES = Buffer

# Generic makefile
SRCS = $(wildcard $(SOURCEDIR)/*.cpp)
OBJS = $(patsubst $(SOURCEDIR)/%.cpp, $(BINDIR)/%.o, $(SRCS))
DEPS = $(OBJS:.o=.d)
CXXFLAGS := #-MM
RELEASEFLAGS := -O3 -DNDEBUG $(CXXFLAGS)
DEBUGFLAGS := -O0 -g -DDEBUG -Wall -Wextra -pedantic -ansi $(CXXFLAGS)
LIBS :=
BINARIES = $(LIBARIES:%=lib%.a) $(NAME)
BINPATHS = $(BINARIES:%=bin/%)
SRCPATHS = $(LIBRARIES:%=src/lib%/) src/$(NAME)/

all: release

.PHONY: release
release:
$(MAKE) CXXFLAGS="$(RELEASEFLAGS)" $(BIN)
$(foreach project, $(SRCPATHS), $(MAKE) -C $(project) release;)

.PHONY: debug
debug:
$(MAKE) CXXFLAGS="$(DEBUGFLAGS)" $(BIN)

#depend: .depend
#.depend: $(SRCS)
# $(CXX) $(CXXFLAGS) -MM $^ -MF ./.depend;
#include .depend

$(BINDIR)/%.o: $(SOURCEDIR)/%.cpp $(INCS)
$(CXX) $(CXXFLAGS) -c -o $@ $<

$(BIN): $(OBJS)
$(CXX) -o $@ $(OBJS) $(LIBS)
$(foreach project, $(SRCPATHS), $(MAKE) -C $(project) release;)

.PHONY: clean
clean:
$(RM) $(BIN) $(OBJS) $(DEPS)
$(foreach project, $(SRCPATHS), $(MAKE) -C $(project) clean;)
36 changes: 36 additions & 0 deletions Makefile.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Configuration
BIN = codepeiler
BINDIR = bin
SOURCEDIR = src

# Generic makefile
SRCS = $(wildcard $(SOURCEDIR)/*.cpp)
OBJS = $(patsubst $(SOURCEDIR)/%.cpp, $(BINDIR)/%.o, $(SRCS))
DEPS = $(OBJS:.o=.d)
CXXFLAGS := #-MM
RELEASEFLAGS := -O3 -DNDEBUG $(CXXFLAGS)
DEBUGFLAGS := -O0 -g -DDEBUG -Wall -Wextra -pedantic -ansi $(CXXFLAGS)
LIBS :=

all: release

release:
$(MAKE) CXXFLAGS="$(RELEASEFLAGS)" $(BIN)

debug:
$(MAKE) CXXFLAGS="$(DEBUGFLAGS)" $(BIN)

#depend: .depend
#.depend: $(SRCS)
# $(CXX) $(CXXFLAGS) -MM $^ -MF ./.depend;
#include .depend

$(BINDIR)/%.o: $(SOURCEDIR)/%.cpp $(INCS)
$(CXX) $(CXXFLAGS) -c -o $@ $<

$(BIN): $(OBJS)
$(CXX) -o $@ $(OBJS) $(LIBS)

.PHONY: clean
clean:
$(RM) $(BIN) $(OBJS) $(DEPS)
11 changes: 9 additions & 2 deletions codepeiler.sublime-project
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@
"build_systems":
[
{
"name": "Codepeiler - make",
"cmd": ["make clean", "make", ""],
"name": "Codepeiler - make release",
"cmd": ["make clean && make release && ./codepeiler"],
"working_dir": "$project_path",
"path": "/usr/local/bin:/usr/bin/:/bin/",
"shell": true
},
{
"name": "Codepeiler - make debug",
"cmd": ["make clean && make debug && ./codepeiler"],
"working_dir": "$project_path",
"path": "/usr/local/bin:/usr/bin/:/bin/",
"shell": true
Expand Down
100 changes: 0 additions & 100 deletions src/BufferReader.hpp

This file was deleted.

104 changes: 0 additions & 104 deletions src/BufferWriter.hpp

This file was deleted.

4 changes: 0 additions & 4 deletions src/Lexer.cpp → src/codepeiler/Lexer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#include "BufferReader.hpp"
#include "Symtable.hpp"
#include "String.hpp"

#include "Lexer.hpp"

#ifdef DEBUG
Expand Down
5 changes: 5 additions & 0 deletions src/Lexer.hpp → src/codepeiler/Lexer.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#pragma once

#include <ctype.h>

#include <libStd/String.hpp>
#include <libBuffer/BufferReader.hpp>

#include "Symtable.hpp"
#include "Token.hpp"

class BufferReader;
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions src/ParseTree.hpp → src/codepeiler/ParseTree.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once

#include <libStd/String.hpp>
#include <libStd/Vector.hpp>

#include "ParserRule.hpp"
#include "Token.hpp"
#include "String.hpp"
#include "Vector.hpp"

class ParseTree
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions src/Parser.hpp → src/codepeiler/Parser.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once

#include <exception>

#include <libStd/String.hpp>
#include <libStd/List.hpp>

#include "ParserRule.hpp"
#include "Token.hpp"
#include "Lexer.hpp"
#include "ParseTree.hpp"
#include "List.hpp"
#include "Token.hpp"
#include "String.hpp"

class ParserError : public std::exception
{
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ParserRule.hpp → src/codepeiler/ParserRule.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "String.hpp"
#include <libStd/String.hpp>
#include "Token.hpp"

struct ParserRule {
Expand Down
2 changes: 1 addition & 1 deletion src/Symtable.hpp → src/codepeiler/Symtable.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "Hashtable.hpp"
#include <libStd/Hashtable.hpp>
#include "Token.hpp"

class Symtable : public Hashtable<Entry*>
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/Token.hpp → src/codepeiler/Token.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include <iostream>
#include "String.hpp"

#include <libStd/String.hpp>

class Entry;

Expand Down
7 changes: 4 additions & 3 deletions src/main.cpp → src/codepeiler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#include <iostream>
#include <iomanip>

#include "String.hpp"
#include "BufferReader.hpp"
#include "BufferWriter.hpp"
#include <libStd/String.hpp>
#include <libBuffer/BufferReader.hpp>
#include <libBuffer/BufferWriter.hpp>

#include "Token.hpp"
#include "Lexer.hpp"
#include "Symtable.hpp"
Expand Down
Loading

0 comments on commit a69be28

Please sign in to comment.