diff options
| author | Mike Stewart | 2012-01-20 11:21:29 -0800 |
|---|---|---|
| committer | Mike Stewart | 2012-01-20 11:21:29 -0800 |
| commit | bf60f5975a2a9592026764924a228a9dcd1b7ec2 (patch) | |
| tree | ae75aa59bc3cfb245c6cce630d3aef36bf17119f /plugins/mapexport | |
| parent | 9b0b0d53f9c9a375109b5a61b629979890537c9c (diff) | |
| download | dfhack-bf60f5975a2a9592026764924a228a9dcd1b7ec2.tar.gz dfhack-bf60f5975a2a9592026764924a228a9dcd1b7ec2.tar.bz2 dfhack-bf60f5975a2a9592026764924a228a9dcd1b7ec2.tar.xz | |
Cleaned up the protobuf and mapexport build scripts a lot, and added two more simple proto files to store map geometry information.
Diffstat (limited to 'plugins/mapexport')
| -rw-r--r-- | plugins/mapexport/.gitignore | 1 | ||||
| -rw-r--r-- | plugins/mapexport/CMakeLists.txt | 29 | ||||
| -rw-r--r-- | plugins/mapexport/mapexport.cpp | 3 | ||||
| -rw-r--r-- | plugins/mapexport/proto/Block.proto | 12 | ||||
| -rw-r--r-- | plugins/mapexport/proto/Map.proto | 12 | ||||
| -rw-r--r-- | plugins/mapexport/proto/Tile.proto | 2 |
6 files changed, 47 insertions, 12 deletions
diff --git a/plugins/mapexport/.gitignore b/plugins/mapexport/.gitignore new file mode 100644 index 00000000..294e8eb6 --- /dev/null +++ b/plugins/mapexport/.gitignore @@ -0,0 +1 @@ +proto/*.pb.* diff --git a/plugins/mapexport/CMakeLists.txt b/plugins/mapexport/CMakeLists.txt index b28c0e42..c866ebc9 100644 --- a/plugins/mapexport/CMakeLists.txt +++ b/plugins/mapexport/CMakeLists.txt @@ -1,12 +1,11 @@ PROJECT(mapexport) -SET(MAPEXPORT_SOURCE_DIR ${dfhack_SOURCE_DIR}/plugins/mapexport) include_directories ( - ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} ${dfhack_SOURCE_DIR}/library/depends/protobuf/ ) -#Generated protobuf files and the headers they will require +#The protobuf sources we generate will require these headers SET(PROJECT_HDRS ${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/stubs/once.h ${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/stubs/common.h @@ -15,23 +14,33 @@ ${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/wire_format_lite_i ${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/generated_message_util.h ${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/repeated_field.h ${dfhack_SOURCE_DIR}/library/depends/protobuf/google/protobuf/extension_set.h -proto/Tile.pb.h ) SET(PROJECT_SRCS mapexport.cpp -proto/Tile.pb.cc ) +SET(PROJECT_PROTOS +${CMAKE_CURRENT_SOURCE_DIR}/proto/Tile.proto +${CMAKE_CURRENT_SOURCE_DIR}/proto/Block.proto +${CMAKE_CURRENT_SOURCE_DIR}/proto/Map.proto +) + +#Create new lists of what sources and headers protoc will output after we invoke it +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}) + SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS}) -FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/proto) - +#Generate sources from our proto files and store them in the source tree ADD_CUSTOM_COMMAND( -OUTPUT proto/Tile.pb.cc proto/Tile.pb.h -COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto --cpp_out=${CMAKE_CURRENT_BINARY_DIR}/proto ${CMAKE_CURRENT_SOURCE_DIR}/proto/Tile.proto -DEPENDS protoc-bin ${CMAKE_CURRENT_SOURCE_DIR}/proto/Tile.proto +OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS} +COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto ${PROJECT_PROTOS} +DEPENDS protoc-bin ${PROJECT_PROTOS} ) DFHACK_PLUGIN(mapexport ${PROJECT_SRCS} ${PROJECT_HDRS} LINK_LIBRARIES protobuf-lite) diff --git a/plugins/mapexport/mapexport.cpp b/plugins/mapexport/mapexport.cpp index b788e33a..db32cada 100644 --- a/plugins/mapexport/mapexport.cpp +++ b/plugins/mapexport/mapexport.cpp @@ -2,7 +2,8 @@ #include <Console.h> #include <Export.h> #include <PluginManager.h> -#include "proto/Tile.pb.h" + +#include "proto/Map.pb.h" using namespace DFHack; DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & parameters); diff --git a/plugins/mapexport/proto/Block.proto b/plugins/mapexport/proto/Block.proto new file mode 100644 index 00000000..7d39fdb3 --- /dev/null +++ b/plugins/mapexport/proto/Block.proto @@ -0,0 +1,12 @@ +package dfproto; +option optimize_for = LITE_RUNTIME; + +import "Tile.proto"; + +message Block +{ + required uint32 x = 1; + required uint32 y = 2; + required uint32 z = 3; + repeated Tile tiles = 4; +} diff --git a/plugins/mapexport/proto/Map.proto b/plugins/mapexport/proto/Map.proto new file mode 100644 index 00000000..59b7ad3b --- /dev/null +++ b/plugins/mapexport/proto/Map.proto @@ -0,0 +1,12 @@ +package dfproto; +option optimize_for = LITE_RUNTIME; + +import "Block.proto"; + +message Map +{ + required uint32 x_size = 1; + required uint32 y_size = 2; + required uint32 z_size = 3; + repeated Block blocks = 4; +} diff --git a/plugins/mapexport/proto/Tile.proto b/plugins/mapexport/proto/Tile.proto index aa708be2..a5039bd2 100644 --- a/plugins/mapexport/proto/Tile.proto +++ b/plugins/mapexport/proto/Tile.proto @@ -7,4 +7,4 @@ message Tile required uint32 y = 2; required uint32 tiletype = 3; optional uint32 material = 4; -}
\ No newline at end of file +} |
