diff --git a/cpp/Makefile b/cpp/Makefile index ac541b5e..6684874b 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -123,6 +123,7 @@ SRC_GENERATED = $(GENERATED_DIR)/command_interface.pb.cpp SRC_SHARED := $(shell ls -1 shared/*.cpp) SRC_SHARED_PROTOBUF := $(shell ls -1 shared_protobuf/*.cpp) +SRC_SHARED_S2P := $(shell ls -1 shared_s2p/*.cpp) SRC_BASE = $(shell ls -1 base/*.cpp) SRC_BUSES = $(shell ls -1 buses/*.cpp) SRC_CONTROLLERS = $(shell ls -1 controllers/*.cpp) @@ -193,13 +194,14 @@ SRC_S2P_TEST += $(shell ls -1 s2pdump/*.cpp | grep -v s2pdump.cpp) SRC_IN_PROCESS_TEST = test/in_process_test.cpp SRC_IN_PROCESS_TEST += $(shell ls -1 s2pdump/*.cpp | grep -v s2pdump.cpp) -vpath %.h ./shared ./shared_protobuf ./base ./controllers ./buses ./s2pservice ./s2pctl ./s2pdump ./s2pexec -vpath %.cpp ./shared ./shared_protobuf ./base ./controllers ./devices ./buses ./s2pservice ./s2pctl ./s2pdump ./s2pexec ./test +vpath %.h ./shared ./shared_protobuf ./shared_s2p ./base ./controllers ./buses ./s2pservice ./s2pctl ./s2pdump ./s2pexec +vpath %.cpp ./shared ./shared_protobuf ./shared_s2p ./base ./controllers ./devices ./buses ./s2pservice ./s2pctl ./s2pdump ./s2pexec ./test vpath %.o ./$(OBJDIR) vpath ./$(BINDIR) LIB_SHARED := $(LIBDIR)/libshared.a LIB_SHARED_PROTOBUF := $(LIBDIR)/libsharedprotobuf.a +LIB_SHARED_S2P := $(LIBDIR)/libshareds2p.a LIB_BUS := $(LIBDIR)/libbus.a LIB_CONTROLLER := $(LIBDIR)/libcontroller.a LIB_DEVICE := $(LIBDIR)/libdevice.a @@ -213,6 +215,7 @@ OBJ_SCHS := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCHS:%.cpp=%.o))) OBJ_SAHD := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SAHD:%.cpp=%.o))) OBJ_SHARED := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SHARED:%.cpp=%.o))) OBJ_SHARED_PROTOBUF := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SHARED_PROTOBUF:%.cpp=%.o))) +OBJ_SHARED_S2P := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SHARED_S2P:%.cpp=%.o))) OBJ_BASE := $(addprefix $(OBJDIR)/,$(notdir $(SRC_BASE:%.cpp=%.o))) OBJ_BUSES := $(addprefix $(OBJDIR)/,$(notdir $(SRC_BUSES:%.cpp=%.o))) OBJ_CONTROLLERS := $(addprefix $(OBJDIR)/,$(notdir $(SRC_CONTROLLERS:%.cpp=%.o))) @@ -240,7 +243,8 @@ GENERATED_DIR := generated # The following will include all of the auto-generated dependency files (*.d) # if they exist. This will trigger a rebuild of a source file if a header changes ALL_DEPS := $(patsubst %.o,%.d,$(OBJ_S2PSERVICE_CORE) $(OBJ_S2PCTL_CORE) $(OBJ_S2PSERVICE) $(OBJ_S2PCTL) $(OBJ_S2PDUMP) \ - $(OBJ_S2PEXEC) $(OBJ_SHARED) $(OBJ_SHARED_PROTOBUF) $(OBJ_BASE) $(OBJ_DEVICES) $(OBJ_S2P_TEST) $(OBJ_IN_PROCESS_TEST)) + $(OBJ_S2PEXEC) $(OBJ_SHARED) $(OBJ_SHARED_PROTOBUF) $(OBJ_SHARED_S2P) $(OBJ_BASE) $(OBJ_DEVICES) \ + $(OBJ_S2P_TEST) $(OBJ_IN_PROCESS_TEST)) -include $(ALL_DEPS) $(OBJDIR) $(LIBDIR) $(BINDIR): @@ -255,6 +259,9 @@ $(LIB_SHARED): $(OBJ_SHARED) | $(LIBDIR) $(LIB_SHARED_PROTOBUF): $(OBJ_SHARED_PROTOBUF) $(OBJ_SHARED) $(OBJ_GENERATED) | $(LIBDIR) $(AR) rcs $@ $^ +$(LIB_SHARED_S2P): $(OBJ_SHARED_S2P) $(OBJ_SHARED_PROTOBUF) $(OBJ_SHARED) $(OBJ_GENERATED) | $(LIBDIR) + $(AR) rcs $@ $^ + $(LIB_BUS): $(OBJ_BUSES) | $(LIBDIR) $(AR) rcs $@ $^ @@ -303,23 +310,23 @@ lcov: test $(SRC_S2PSERVICE_CORE) $(SRC_S2PCTL_CORE) $(SRC_S2PEXEC): $(OBJ_GENERATED) -$(BINDIR)/$(S2PSERVICE): $(LIB_SHARED_PROTOBUF) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) $(OBJ_S2PSERVICE_CORE) $(OBJ_S2PSERVICE) | $(BINDIR) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PSERVICE_CORE) $(OBJ_S2PSERVICE) $(LIB_SHARED_PROTOBUF) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) -lpthread -lpcap -lprotobuf +$(BINDIR)/$(S2PSERVICE): $(LIB_SHARED_S2P) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) $(OBJ_S2PSERVICE_CORE) $(OBJ_S2PSERVICE) | $(BINDIR) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PSERVICE_CORE) $(OBJ_S2PSERVICE) $(LIB_SHARED_S2P) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) -lpthread -lpcap -lprotobuf -$(BINDIR)/$(S2PCTL): $(LIB_SHARED_PROTOBUF) $(OBJ_S2PCTL_CORE) $(OBJ_S2PCTL) | $(BINDIR) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PCTL_CORE) $(OBJ_S2PCTL) $(LIB_SHARED_PROTOBUF) -lprotobuf +$(BINDIR)/$(S2PCTL): $(LIB_SHARED) $(OBJ_S2PCTL_CORE) $(OBJ_S2PCTL) $(OBJ_GENERATED) | $(BINDIR) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PCTL_CORE) $(OBJ_S2PCTL) $(LIB_SHARED) $(OBJ_GENERATED) -lprotobuf $(BINDIR)/$(S2PDUMP): $(OBJ_S2PDUMP) $(LIB_SHARED) $(LIB_BUS) | $(BINDIR) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PDUMP) $(LIB_SHARED) $(LIB_BUS) -$(BINDIR)/$(S2PEXEC): $(OBJ_S2PEXEC) $(LIB_SHARED_PROTOBUF) $(LIB_BUS) | $(BINDIR) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PEXEC) $(LIB_SHARED_PROTOBUF) $(LIB_BUS) -lprotobuf +$(BINDIR)/$(S2PEXEC): $(OBJ_S2PEXEC) $(LIB_SHARED) $(LIB_BUS) $(OBJ_GENERATED) | $(BINDIR) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PEXEC) $(LIB_SHARED) $(LIB_BUS) $(OBJ_GENERATED) -lprotobuf $(BINDIR)/$(S2P_TEST): $(LIB_SHARED_PROTOBUF) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) $(OBJ_S2PSERVICE_CORE) $(OBJ_S2PCTL_CORE) $(OBJ_S2P_TEST) $(OBJ_S2PCTL_TEST) | $(BINDIR) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PSERVICE_CORE) $(OBJ_S2PCTL_CORE) $(OBJ_S2P_TEST) $(LIB_SHARED_PROTOBUF) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) -lpthread -lpcap -lprotobuf -lgmock -lgtest -$(BINDIR)/$(IN_PROCESS_TEST): $(LIB_SHARED_PROTOBUF) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) $(OBJ_S2P_CORE) $(OBJ_IN_PROCESS_TEST) | $(BINDIR) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PSERVICE_CORE) $(OBJ_IN_PROCESS_TEST) $(LIB_SHARED_PROTOBUF) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) -lpthread -lpcap -lprotobuf +$(BINDIR)/$(IN_PROCESS_TEST): $(LIB_SHARED_S2P) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) $(OBJ_S2P_CORE) $(OBJ_IN_PROCESS_TEST) | $(BINDIR) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_S2PSERVICE_CORE) $(OBJ_IN_PROCESS_TEST) $(LIB_SHARED_S2P) $(LIB_BUS) $(LIB_CONTROLLER) $(LIB_DEVICE) -lpthread -lpcap -lprotobuf # Phony rules for building individual utilities .PHONY: s2p $(S2PSERVICE) $(S2PCTL) $(S2PDUMP) $(S2PEXEC) $(S2P_TEST) $(IN_PROCESS_TEST) diff --git a/cpp/devices/host_services.h b/cpp/devices/host_services.h index c3e0c901..4ea3ceed 100644 --- a/cpp/devices/host_services.h +++ b/cpp/devices/host_services.h @@ -12,8 +12,7 @@ #include "shared_protobuf/command_context.h" #include "shared_protobuf/command_dispatcher.h" -// TODO Move shared service code to new "executor" library -#include "s2pservice/s2pservice_image.h" +#include "shared_s2p/s2pservice_image.h" #include "mode_page_device.h" #include #include diff --git a/cpp/s2pservice/s2pservice_core.h b/cpp/s2pservice/s2pservice_core.h index d69c4ebb..fecf1b4c 100644 --- a/cpp/s2pservice/s2pservice_core.h +++ b/cpp/s2pservice/s2pservice_core.h @@ -12,10 +12,10 @@ #include "controllers/controller_factory.h" #include "shared_protobuf/command_context.h" #include "shared_protobuf/command_dispatcher.h" +#include "shared_s2p/s2pservice_image.h" +#include "shared_s2p/s2pservice_response.h" +#include "shared_s2p/s2pservice_executor.h" #include "s2pservice_thread.h" -#include "s2pservice_image.h" -#include "s2pservice_response.h" -#include "s2pservice_executor.h" #include "generated/command_interface.pb.h" #include #include diff --git a/cpp/shared_protobuf/command_dispatcher.cpp b/cpp/shared_protobuf/command_dispatcher.cpp index d77f275e..3cbca88d 100644 --- a/cpp/shared_protobuf/command_dispatcher.cpp +++ b/cpp/shared_protobuf/command_dispatcher.cpp @@ -10,7 +10,7 @@ #include "command_dispatcher.h" #include "shared/s2p_util.h" #include "shared/shared_exceptions.h" -#include "protobuf_util.h" +#include "shared_protobuf/protobuf_util.h" #include using namespace std; diff --git a/cpp/shared_protobuf/command_dispatcher.h b/cpp/shared_protobuf/command_dispatcher.h index 08fd0c1f..8a8aa4f3 100644 --- a/cpp/shared_protobuf/command_dispatcher.h +++ b/cpp/shared_protobuf/command_dispatcher.h @@ -9,10 +9,9 @@ #pragma once #include "shared_protobuf/command_context.h" -// TODO Move shared code -#include "s2pservice/s2pservice_executor.h" -#include "s2pservice/s2pservice_image.h" -#include "s2pservice/s2pservice_response.h" +#include "shared_s2p/s2pservice_executor.h" +#include "shared_s2p/s2pservice_image.h" +#include "shared_s2p/s2pservice_response.h" #include "generated/command_interface.pb.h" using namespace std; diff --git a/cpp/s2pservice/s2pservice_executor.cpp b/cpp/shared_s2p/s2pservice_executor.cpp similarity index 100% rename from cpp/s2pservice/s2pservice_executor.cpp rename to cpp/shared_s2p/s2pservice_executor.cpp diff --git a/cpp/s2pservice/s2pservice_executor.h b/cpp/shared_s2p/s2pservice_executor.h similarity index 100% rename from cpp/s2pservice/s2pservice_executor.h rename to cpp/shared_s2p/s2pservice_executor.h diff --git a/cpp/s2pservice/s2pservice_image.cpp b/cpp/shared_s2p/s2pservice_image.cpp similarity index 100% rename from cpp/s2pservice/s2pservice_image.cpp rename to cpp/shared_s2p/s2pservice_image.cpp diff --git a/cpp/s2pservice/s2pservice_image.h b/cpp/shared_s2p/s2pservice_image.h similarity index 100% rename from cpp/s2pservice/s2pservice_image.h rename to cpp/shared_s2p/s2pservice_image.h diff --git a/cpp/s2pservice/s2pservice_response.cpp b/cpp/shared_s2p/s2pservice_response.cpp similarity index 99% rename from cpp/s2pservice/s2pservice_response.cpp rename to cpp/shared_s2p/s2pservice_response.cpp index d7c2a712..a683246d 100644 --- a/cpp/s2pservice/s2pservice_response.cpp +++ b/cpp/shared_s2p/s2pservice_response.cpp @@ -12,7 +12,7 @@ #include "shared/s2p_util.h" #include "shared/s2p_version.h" #include "devices/disk.h" -#include "s2pservice_response.h" +#include "shared_s2p/s2pservice_response.h" #include #include diff --git a/cpp/s2pservice/s2pservice_response.h b/cpp/shared_s2p/s2pservice_response.h similarity index 100% rename from cpp/s2pservice/s2pservice_response.h rename to cpp/shared_s2p/s2pservice_response.h