Permalink
Browse files

Move eyaml to a new library in `shared/`. (#1216)

Moves the event parser as well, which is a non-YAML-compliant dialect of a YAML-like language.
Creates a general format for shared code and includes it from the CompilerSource makefile.
Handles an aggravating problem with `wildcard` in an included makefile.
  • Loading branch information...
JoshDreamland committed May 13, 2018
1 parent 5fb2a08 commit e853744cbb79bf3b22df8ce9dfd783bf4b495fec
@@ -2,6 +2,11 @@ BINARY := ../../emake
SRC_DIR := .
OBJ_DIR := .eobjs

SHARED_SRC_DIR := ../../shared
include $(SHARED_SRC_DIR)/Makefile
include $(SHARED_SRC_DIR)/eyaml/Makefile
include $(SHARED_SRC_DIR)/event_reader/Makefile

OS := $(shell uname -s)
ifeq ($(OS), Linux)
OS_LIBS=-lboost_system -Wl,--no-as-needed -Wl,-rpath=./ -lboost_program_options -lboost_iostreams -lboost_filesystem -lboost_system -lpthread -ldl
@@ -11,21 +16,23 @@ else
OS_LIBS=-lboost_system-mt -Wl,--no-as-needed -Wl,-rpath=./ -lboost_program_options-mt -lboost_iostreams-mt -lboost_filesystem-mt -lboost_system-mt -lpthread
endif

EXTRA_SOURCES := ../../CompilerSource/settings-parse/eyaml.cpp ../../CompilerSource/compiler/event_reader/event_parser.cpp
EXTRA_SRC_DIR := ../../CompilerSource

CXXFLAGS := -I$(SRC_DIR) -I$(EXTRA_SRC_DIR) -std=c++11 -Wall -Wextra -Wpedantic -g
# As a "temporary hack," allow including from CompilerSource to give access to backend/ folder.
CXXFLAGS := -I$(SRC_DIR) -I../../CompilerSource -std=c++11 -Wall -Wextra -Wpedantic -g
LDFLAGS := $(OS_LIBS)

EXTRA_OBJS := $(patsubst $(EXTRA_SRC_DIR)/%, $(OBJ_DIR)/Extra/%, $(patsubst %.cpp, %.o, $(EXTRA_SOURCES)))

rwildcard=$(wildcard $1/$2) $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2))
SOURCES := $(call rwildcard,$(SRC_DIR),*.cpp)
OBJECTS := $(patsubst $(SRC_DIR)/%, $(OBJ_DIR)/%, $(patsubst %.cpp, %.o, $(SOURCES)))
OBJDIRS := $(sort $(OBJ_DIR) $(dir $(OBJECTS)) $(dir $(EXTRA_OBJS)))
DEPENDS := $(OBJECTS:.o=.d) $(EXTRA_OBJS:.o=.d)
DEPENDS := $(OBJECTS:.o=.d)

CXXFLAGS += -I$(SHARED_SRC_DIR) $(addprefix -I$(SHARED_SRC_DIR)/, $(SHARED_INCLUDES))
SOURCES += $(addprefix $(SHARED_SRC_DIR),$(SHARED_SOURCES))
OBJECTS += $(addprefix $(OBJ_DIR)/shared/,$(SHARED_SOURCES:.cpp=.o))
DEPENDS += $(addprefix $(OBJ_DIR)/shared/,$(SHARED_SOURCES:.cpp=.d))

OBJDIRS := $(sort $(OBJ_DIR) $(dir $(OBJECTS)))

$(BINARY): $(OBJECTS) $(EXTRA_OBJS)
$(BINARY): $(OBJECTS)
g++ $^ $(LDFLAGS) -o $@

.PHONY: all clean obj_dirs
@@ -43,7 +50,7 @@ obj_dirs: $(OBJDIRS)
# Generate rules for new (unbuilt) files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | obj_dirs
$(CXX) $(CXXFLAGS) -MMD -c -o $@ $<
$(OBJ_DIR)/Extra/%.o: $(EXTRA_SRC_DIR)/%.cpp | obj_dirs
$(OBJ_DIR)/shared/%.o: $(SHARED_SRC_DIR)/%.cpp | obj_dirs
$(CXX) $(CXXFLAGS) -MMD -c -o $@ $<

# Include rules for known (previously-built) files
@@ -1,6 +1,6 @@
#include "OptionsParser.hpp"

#include "settings-parse/eyaml.h"
#include "eyaml/eyaml.h"
#include "OS_Switchboard.h"

#include <boost/filesystem.hpp>
@@ -1,5 +1,5 @@
#include "SOG.hpp"
#include "compiler/event_reader/event_parser.h"
#include "event_reader/event_parser.h"

#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
@@ -1,7 +1,7 @@
# Awesomer Makefile generated by Rusky: stop relying on Bash hacks and automate more stuff
# It will automatically build the shared library out of any .cpp files in this directory or its
# subdirectories (recursively). It will also automatically calculate and update all dependencies
# automatically when 'make' is run, so there is no need to run genmake.sh EVER.
# "Shared" includes.
include ../shared/Makefile
include ../shared/eyaml/Makefile
include ../shared/event_reader/Makefile

#################
# configuration #
@@ -39,6 +39,11 @@ SOURCES := $(filter-out ./standalone_main.cpp, $(call rwildcard,./,*.cpp))
OBJECTS := $(addprefix .eobjs/,$(SOURCES:.cpp=.o))
DEPENDS := $(OBJECTS:.o=.d)

CXXFLAGS += -I../shared $(addprefix -I../shared/, $(SHARED_INCLUDES))
SOURCES += $(addprefix ../shared/,$(SHARED_SOURCES))
OBJECTS += $(addprefix .eobjs/shared/,$(SHARED_SOURCES:.cpp=.o))
DEPENDS += $(addprefix .eobjs/shared/,$(SHARED_SOURCES:.cpp=.d))

# sort has the nice side effect of removing duplicates. this may or may not be faster.
OBJDIRS := $(sort $(dir $(OBJECTS)))
override CPPFLAGS += -I.
@@ -62,6 +67,8 @@ $(TARGET): $(OBJECTS)
# -MP gives phony rules for non-target files, avoiding problems with missing files
.eobjs/%.o .eobjs/%.d: %.cpp | $(OBJDIRS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MP -c -o .eobjs/$*.o $<
.eobjs/shared/%.o .eobjs/shared/%.d: ../shared/%.cpp | $(OBJDIRS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MP -c -o .eobjs/shared/$*.o $<

$(OBJDIRS):
$(MKDIR) -p $@
@@ -57,8 +57,8 @@ using namespace std;
#include "compile_includes.h"
#include "compile_common.h"

#include "eyaml/eyaml.h"
#include "settings-parse/crawler.h"
#include "settings-parse/eyaml.h"

#include "components/components.h"
#include "gcc_interface/gcc_backend.h"
@@ -39,7 +39,7 @@ using namespace std;
#include "backend/EnigmaStruct.h" //LateralGM interface structures
#include "parser/object_storage.h"
#include "compiler/compile_common.h"
#include "compiler/event_reader/event_parser.h"
#include "event_reader/event_parser.h"

#include <math.h> //log2 to calculate passes.

@@ -38,7 +38,7 @@ using namespace std;
#include "backend/EnigmaStruct.h" //LateralGM interface structures
#include "parser/object_storage.h"
#include "compiler/compile_common.h"
#include "compiler/event_reader/event_parser.h"
#include "event_reader/event_parser.h"

#include "languages/lang_CPP.h"
int lang_CPP::compile_parseSecondary(map<int,parsed_object*> &parsed_objects, parsed_script* scripts[], int scrcount, vector<parsed_script*>& tlines, map<int,parsed_room*> &parsed_rooms, parsed_object* EGMglobal, const std::set<std::string>& script_names)
@@ -34,7 +34,7 @@ using namespace std;
#include "backend/EnigmaStruct.h" //LateralGM interface structures
#include "compiler/compile_common.h"

#include "compiler/event_reader/event_parser.h"
#include "event_reader/event_parser.h"
#include "languages/lang_CPP.h"

struct foundevent { int mid, id, count; foundevent(): mid(0),id(0),count(0) {} void f2(int m,int i) { id = i, mid = m; } void inc(int m,int i) { mid=m,id=i,count++; } void operator++(int) { count++; } };
@@ -38,7 +38,7 @@ using namespace std;

#include "backend/EnigmaStruct.h" //LateralGM interface structures
#include "compiler/compile_common.h"
#include "compiler/event_reader/event_parser.h"
#include "event_reader/event_parser.h"
#include "parser/object_storage.h"

string REFERENCE_POSTFIX(string ref) {
@@ -30,7 +30,7 @@ using namespace std;

#include "backend/EnigmaStruct.h" //LateralGM interface structures
#include "compiler/compile_common.h"
#include "compiler/event_reader/event_parser.h"
#include "event_reader/event_parser.h"
#include "general/parse_basics_old.h"
#include "settings.h"

@@ -50,7 +50,7 @@ string MAKE_flags, MAKE_paths, MAKE_tcpaths, MAKE_location, TOPLEVEL_cflags, TOP
TOPLEVEL_rcflags, CXX_override, CC_override, WINDRES_location, TOPLEVEL_ldflags, TOPLEVEL_ldlibs;

#include "OS_Switchboard.h"
#include "settings-parse/eyaml.h"
#include "eyaml/eyaml.h"

#include "languages/lang_CPP.h"
#include <System/builtins.h>
@@ -37,7 +37,7 @@
using namespace std;

#include "config.h"
#include "compiler/event_reader/event_parser.h"
#include "event_reader/event_parser.h"

extern int global_script_argument_count;

@@ -34,7 +34,7 @@ using namespace std;
#include "filesystem/file_find.h"

#include "crawler.h"
#include "eyaml.h"
#include "eyaml/eyaml.h"

namespace settings
{
@@ -33,12 +33,12 @@

using namespace std;

#include "eyaml/eyaml.h"
#include "filesystem/file_find.h"
#include "general/parse_basics_old.h"
#include "OS_Switchboard.h"
#include "parser/object_storage.h"
#include "crawler.h"
#include "eyaml.h"

#include "gcc_interface/gcc_backend.h"
#include "parse_ide_settings.h"
@@ -0,0 +1,2 @@
arbitrary_relative_wildcard=$(patsubst $1/%,%,$(wildcard $1/$2))
relative_wildcard=$(call arbitrary_relative_wildcard,$(dir $(lastword $(MAKEFILE_LIST))),$1)
@@ -0,0 +1 @@
SHARED_SOURCES := $(SHARED_SOURCES) $(addprefix event_reader/,$(call relative_wildcard,*.cpp))
@@ -0,0 +1,2 @@
# SHARED_INCLUDES += eyaml (Best to just let them include eyaml/eyaml.h)
SHARED_SOURCES := $(SHARED_SOURCES) $(addprefix eyaml/,$(call relative_wildcard,*.cpp))
@@ -27,6 +27,7 @@

#include <string>
#include <fstream>
#include <map>
using std::string;

typedef std::map<string, struct ey_base*>::iterator eyit;

0 comments on commit e853744

Please sign in to comment.