From 75c569b09773c0d7644d54fd77350e6ff1073475 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 9 Mar 2012 21:42:22 +0400 Subject: [PATCH] Add some experimental message definitions to the main library. --- library/CMakeLists.txt | 26 ++++++++++++++ library/proto/.gitignore | 2 ++ library/proto/CoreProtocol.proto | 59 ++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 library/proto/.gitignore create mode 100644 library/proto/CoreProtocol.proto diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index ca4c9d47f..e310268a7 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -141,6 +141,26 @@ ELSE() LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_WINDOWS}) ENDIF() +# Protobuf + +FILE(GLOB PROJECT_PROTOS ${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto) + +STRING(REPLACE ".proto" ".pb.cc" PROJECT_PROTO_SRCS ${PROJECT_PROTOS}) +STRING(REPLACE ".proto" ".pb.h" PROJECT_PROTO_HDRS ${PROJECT_PROTOS}) + +LIST(APPEND PROJECT_HDRS ${PROJECT_PROTO_HDRS}) +LIST(APPEND PROJECT_SRCS ${PROJECT_PROTO_SRCS}) + +ADD_CUSTOM_COMMAND( + OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS} + COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ + --cpp_out=dllexport_decl=DFHACK_EXPORT:${CMAKE_CURRENT_SOURCE_DIR}/proto/ + ${PROJECT_PROTOS} + DEPENDS protoc-bin ${PROJECT_PROTOS} +) + +# + SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE ) LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS}) @@ -193,6 +213,12 @@ else() ENDIF() endif() +IF(WIN32) + SET_TARGET_PROPERTIES(dfhack PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" ) +ELSE() + SET_TARGET_PROPERTIES(dfhack PROPERTIES COMPILE_FLAGS "-include Export.h" ) +ENDIF() + #effectively disables debug builds... SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" ) diff --git a/library/proto/.gitignore b/library/proto/.gitignore new file mode 100644 index 000000000..a1fb10cce --- /dev/null +++ b/library/proto/.gitignore @@ -0,0 +1,2 @@ +*.pb.cc +*.pb.h diff --git a/library/proto/CoreProtocol.proto b/library/proto/CoreProtocol.proto new file mode 100644 index 000000000..33ec0f4a0 --- /dev/null +++ b/library/proto/CoreProtocol.proto @@ -0,0 +1,59 @@ +package dfproto; + +option optimize_for = LITE_RUNTIME; + +message CoreTextFragment { + required string text = 1; + + enum Color { + COLOR_BLACK = 0; + COLOR_BLUE = 1; + COLOR_GREEN = 2; + COLOR_CYAN = 3; + COLOR_RED = 4; + COLOR_MAGENTA = 5; + COLOR_BROWN = 6; + COLOR_GREY = 7; + COLOR_DARKGREY = 8; + COLOR_LIGHTBLUE = 9; + COLOR_LIGHTGREEN = 10; + COLOR_LIGHTCYAN = 11; + COLOR_LIGHTRED = 12; + COLOR_LIGHTMAGENTA = 13; + COLOR_YELLOW = 14; + COLOR_WHITE = 15; + }; + optional Color color = 2; +} + +message CoreTextNotification { + repeated CoreTextFragment fragments = 1; +} + +message CoreErrorNotification { + enum ErrorCode { + CR_WOULD_BREAK = -2; + CR_NOT_IMPLEMENTED = -1; + CR_FAILURE = 0; + CR_OK = 1; + CR_WRONG_USAGE = 2; + }; + + required ErrorCode code = 1; +} + +message CoreBindRequest { + required string method = 1; + optional string plugin = 2; + optional int32 min_version = 3; +} + +message CoreBindReply { + required int32 assigned_id = 1; + required int32 version = 2; +} + +message CoreRunStringRequest { + required string command = 1; + repeated string arguments = 2; +}