Skip to content

Commit

Permalink
Move code
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Nov 30, 2023
1 parent d166d9d commit de21f7b
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 22 deletions.
29 changes: 18 additions & 11 deletions cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)))
Expand Down Expand Up @@ -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):
Expand All @@ -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 $@ $^

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions cpp/devices/host_services.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span>
#include <vector>
Expand Down
6 changes: 3 additions & 3 deletions cpp/s2pservice/s2pservice_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion cpp/shared_protobuf/command_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <spdlog/spdlog.h>

using namespace std;
Expand Down
7 changes: 3 additions & 4 deletions cpp/shared_protobuf/command_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <spdlog/spdlog.h>
#include <filesystem>

Expand Down
File renamed without changes.

0 comments on commit de21f7b

Please sign in to comment.