This is an automated email from the ASF dual-hosted git repository. chhsiao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 4fc6ceba906d4e726c6c9d1ebd94ece152f2cf57 Author: Chun-Hung Hsiao <[email protected]> AuthorDate: Mon Apr 1 23:24:05 2019 -0700 Adjusted CSI v0 bundling and proto compilation. This patch makes the following adjustments so we can build CSI v0 and v1 in the future: * Standardize placements for third-party proto files: `csi.proto` from CSI v0 should be in `csi/v0/` of the library root directory and that from v1 should be in `csi/v1/` in the future. Dependent proto files should import `csi/v0/csi.proto` or `csi/v1/csi.proto`. * The generated files for CSI v0 is placed in `build/include/csi/v0`, and those for CSI v1 will be in `build/include/csi/v1` in the future. * Moved `include/csi/spec.hpp` to `include/mesos/csi/v0.hpp`. In the future, CSI v1 proto headers will be in `include/mesos/csi/v1.hpp`. * Install the CSI v0 proto file and its generated headers to `$PREFIX/include/csi/v0` in autotools. CSI v1 files will be installed at `$PREFIX/include/csi/v1` in the future. Review: https://reviews.apache.org/r/70302/ --- 3rdparty/CMakeLists.txt | 29 ++-- 3rdparty/Makefile.am | 37 ++++- 3rdparty/cmake/Versions.cmake | 4 +- 3rdparty/csi-0.2.0.tar.gz | Bin 70677 -> 71292 bytes 3rdparty/versions.am | 2 +- include/{csi/spec.hpp => mesos/csi/v0.hpp} | 10 +- src/CMakeLists.txt | 15 +- src/Makefile.am | 42 +++--- src/cmake/MesosProtobuf.cmake | 154 ++++++++------------- src/csi/client.hpp | 2 +- src/csi/rpc.hpp | 2 +- src/csi/utils.hpp | 3 +- src/examples/test_csi_plugin.cpp | 4 +- src/resource_provider/storage/disk_profile.proto | 2 +- .../storage/disk_profile_utils.hpp | 4 +- src/tests/csi_utils_tests.cpp | 3 +- src/tests/disk_profile_adaptor_tests.cpp | 3 +- src/tests/mock_csi_plugin.hpp | 4 +- 18 files changed, 145 insertions(+), 175 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 1999dd2..7f70407 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -26,7 +26,7 @@ endif () set(BOOST_URL ${FETCH_URL}/boost-${BOOST_VERSION}.tar.gz) set(BZIP2_URL ${FETCH_URL}/bzip2-${BZIP2_VERSION}.tar.gz) set(CONCURRENTQUEUE_URL ${FETCH_URL}/concurrentqueue-${CONCURRENTQUEUE_VERSION}.tar.gz) -set(CSI_URL ${FETCH_URL}/csi-${CSI_VERSION}.tar.gz) +set(CSI_V0_URL ${FETCH_URL}/csi-${CSI_V0_VERSION}.tar.gz) set(ELFIO_URL ${FETCH_URL}/elfio-${ELFIO_VERSION}.tar.gz) set(GLOG_URL ${FETCH_URL}/glog-${GLOG_VERSION}.tar.gz) set(GOOGLETEST_URL ${FETCH_URL}/googletest-release-${GOOGLETEST_VERSION}.tar.gz) @@ -294,21 +294,26 @@ endif () # CSI: Container Storage Interface Specification. # https://github.com/container-storage-interface/spec ##################################################### -EXTERNAL(csi ${CSI_VERSION} ${CMAKE_CURRENT_BINARY_DIR}) -add_library(csi INTERFACE) -add_dependencies(csi ${CSI_TARGET}) -target_include_directories(csi INTERFACE ${CSI_ROOT}) +EXTERNAL(csi_v0 ${CSI_V0_VERSION} ${CMAKE_CURRENT_BINARY_DIR}) +add_library(csi_v0 INTERFACE) +add_dependencies(csi_v0 ${CSI_V0_TARGET}) +target_include_directories(csi_v0 INTERFACE ${CSI_V0_ROOT}) + +# NOTE: To support multiple CSI versions, we move the CSI proto file to a +# version-qualified path so `protoc` can find it. +set(CSI_V0_CONFIG_CMD + ${CMAKE_COMMAND} -E make_directory ${CSI_V0_ROOT}/csi/v0 && + ${CMAKE_COMMAND} -E rename ${CSI_V0_ROOT}/csi.proto ${CSI_V0_ROOT}/csi/v0/csi.proto) -# NOTE: We hard-code `csi.proto` as a byproduct since it exists in the tarball. ExternalProject_Add( - ${CSI_TARGET} - PREFIX ${CSI_CMAKE_ROOT} - BUILD_BYPRODUCTS ${CSI_ROOT}/csi.proto - CONFIGURE_COMMAND ${CMAKE_NOOP} + ${CSI_V0_TARGET} + PREFIX ${CSI_V0_CMAKE_ROOT} + BUILD_BYPRODUCTS ${CSI_V0_ROOT}/csi/v0/csi.proto + CONFIGURE_COMMAND ${CSI_V0_CONFIG_CMD} BUILD_COMMAND ${CMAKE_NOOP} INSTALL_COMMAND ${CMAKE_NOOP} - URL ${CSI_URL} - URL_HASH ${CSI_HASH}) + URL ${CSI_V0_URL} + URL_HASH ${CSI_V0_HASH}) # ELFIO: library for reading and generating ELF files. diff --git a/3rdparty/Makefile.am b/3rdparty/Makefile.am index 98a2623..adbbaf5 100644 --- a/3rdparty/Makefile.am +++ b/3rdparty/Makefile.am @@ -50,7 +50,7 @@ include versions.am BOOST = boost-$(BOOST_VERSION) CONCURRENTQUEUE = concurrentqueue-$(CONCURRENTQUEUE_VERSION) -CSI = csi-$(CSI_VERSION) +CSI_V0 = csi-$(CSI_V0_VERSION) ELFIO = elfio-$(ELFIO_VERSION) GLOG = glog-$(GLOG_VERSION) GMOCK = $(GOOGLETEST)/googlemock @@ -77,7 +77,7 @@ ZOOKEEPER = zookeeper-$(ZOOKEEPER_VERSION) EXTRA_DIST = \ $(BOOST).tar.gz \ $(CONCURRENTQUEUE).tar.gz \ - $(CSI).tar.gz \ + $(CSI_V0).tar.gz \ $(ELFIO).tar.gz \ $(GLOG).tar.gz \ $(GOOGLETEST).tar.gz \ @@ -139,7 +139,7 @@ EXTRA_DIST += \ CLEAN_EXTRACTED = \ $(BOOST) \ $(CONCURRENTQUEUE) \ - $(CSI) \ + $(CSI_V0) \ $(ELFIO) \ $(GLOG) \ $(GOOGLETEST) \ @@ -169,6 +169,20 @@ CLEAN_EXTRACTED = \ test ! -e $(srcdir)/$*.patch || patch -d $* -p1 <$(srcdir)/$*.patch touch $@ +# NOTE: The upstream CSI release tarball is packed with top-level directory +# `spec-<X.Y.Z>`. To avoid conflicts and be consistent with where other packages +# are extracted, we extract the tarball in directory `csi-<X.Y.Z>`. +# +# NOTE: Since GNU make 3.81 does not support shortest-stem pattern matching, we +# explicitly specify a static pattern rule here. +CSI_STAMPS = $(CSI_V0)-stamp +$(CSI_STAMPS): csi-%-stamp: csi-%.tar.gz + $(MKDIR_P) csi-$* + gzip -d -c $^ | (cd csi-$* && tar xf -) + test ! -e $(srcdir)/csi-$*.patch || \ + patch -d csi-$*/spec-$* -p1 <$(srcdir)/csi-$*.patch + touch $@ + # Dependencies for all-local. ALL_LOCAL = # Initialize ALL_LOCAL so we can add to it. @@ -526,9 +540,20 @@ $(GRPC)-build-stamp: touch $@ endif -# NOTE: We extract `csi.proto` even if gRPC is disabled because it is -# imported by other proto files. -ALL_LOCAL += $(CSI)-stamp +# NOTE: To support multiple CSI versions, we move the CSI proto file to a +# version-qualified path so `protoc` can find it. +$(CSI_V0)-build-stamp: $(CSI_V0)-stamp + $(MKDIR_P) $(CSI_V0)/csi/v0 + mv $(CSI_V0)/spec-$(CSI_V0_VERSION)/csi.proto $(CSI_V0)/csi/v0 + touch $@ + +# Mesos depends on CSI. Install the CSI proto file into $PREFIX/include but +# don't add it to the source tarball. +csi_v0dir = $(includedir)/csi/v0 +nodist_csi_v0_HEADERS = $(CSI_V0)/csi/v0/csi.proto +$(nodist_csi_v0_HEADERS): $(CSI_V0)-build-stamp + +ALL_LOCAL += $(CSI_V0)-build-stamp # Convenience library for gmock/gtest. check_LTLIBRARIES = libgmock.la diff --git a/3rdparty/cmake/Versions.cmake b/3rdparty/cmake/Versions.cmake index 972c706..a67cb16 100644 --- a/3rdparty/cmake/Versions.cmake +++ b/3rdparty/cmake/Versions.cmake @@ -2,8 +2,8 @@ set(BOOST_VERSION "1.65.0") set(BOOST_HASH "SHA256=0442df595dc56e7da11665120ce9d92ec40c192eb060488131b346bac0938ba3") set(CONCURRENTQUEUE_VERSION "7b69a8f") set(CONCURRENTQUEUE_HASH "SHA256=B2741A1FB2172C2A829503A85D5EE7548BE7ED04236A3FD1EFD2B6088E065CB7") -set(CSI_VERSION "0.2.0") -set(CSI_HASH "SHA256=CB75FC99B03F3C7C30E407AE86BA63EB069AE4A167A26C94FE97F09CB7FF8771") +set(CSI_V0_VERSION "0.2.0") +set(CSI_V0_HASH "SHA256=B013F844C1E309B03FE6BCE9F186FEFA8910FCFAE7F8E6F7E4ACBEC166692F92") set(CURL_VERSION "7.61.0") set(CURL_HASH "SHA256=64141F0DB4945268A21B490D58806B97C615D3D0C75BF8C335BBE0EFD13B45B5") set(ELFIO_VERSION "3.2") diff --git a/3rdparty/csi-0.2.0.tar.gz b/3rdparty/csi-0.2.0.tar.gz index eea1cbd..9953dbc 100644 Binary files a/3rdparty/csi-0.2.0.tar.gz and b/3rdparty/csi-0.2.0.tar.gz differ diff --git a/3rdparty/versions.am b/3rdparty/versions.am index 2438107..b16132c 100644 --- a/3rdparty/versions.am +++ b/3rdparty/versions.am @@ -21,7 +21,7 @@ BOOST_VERSION = 1.65.0 CONCURRENTQUEUE_VERSION = 7b69a8f -CSI_VERSION = 0.2.0 +CSI_V0_VERSION = 0.2.0 ELFIO_VERSION = 3.2 GLOG_VERSION = 0.3.3 GOOGLETEST_VERSION = 1.8.0 diff --git a/include/csi/spec.hpp b/include/mesos/csi/v0.hpp similarity index 87% rename from include/csi/spec.hpp rename to include/mesos/csi/v0.hpp index 19d9445..58b2c61 100644 --- a/include/csi/spec.hpp +++ b/include/mesos/csi/v0.hpp @@ -14,14 +14,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef __CSI_SPEC_HPP__ -#define __CSI_SPEC_HPP__ +#ifndef __MESOS_CSI_V0_HPP__ +#define __MESOS_CSI_V0_HPP__ // ONLY USEFUL AFTER RUNNING PROTOC. -#include <csi/csi.pb.h> +#include <csi/v0/csi.pb.h> // ONLY USEFUL AFTER RUNNING PROTOC WITH GRPC CPP PLUGIN. -#include <csi/csi.grpc.pb.h> +#include <csi/v0/csi.grpc.pb.h> namespace mesos { namespace csi { @@ -33,4 +33,4 @@ using namespace ::csi::v0; } // namespace csi { } // namespace mesos { -#endif // __CSI_SPEC_HPP__ +#endif // __MESOS_CSI_V0_HPP__ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 20e50a4..2071576 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,20 +18,15 @@ ######################################### include(MesosProtobuf) -set(PUBLIC_PROTO_PATH "") -set(PUBLIC_PROTOBUF_INCLUDE_DIR "") set(PUBLIC_PROTOBUF_SRC "") -set(INTERNAL_PROTO_PATH "") -set(INTERNAL_PROTOBUF_INCLUDE_DIR "") set(INTERNAL_PROTOBUF_SRC "") set(JAVA_PROTOBUF_SRC "") # Build the protobuf structs. # # NOTE: The following `PROTOC_GENERATE` calls will list append to -# `PUBLIC_PROTO_PATH`, `PUBLIC_PROTOBUF_INCLUDE_DIR` and `PUBLIC_PROTOBUF_SRC`. -# The GRPC option is a noop if gRPC is disabled. -PROTOC_GENERATE(GRPC LIB csi TARGET csi) +# `PUBLIC_PROTOBUF_SRC`. The GRPC option is a noop if gRPC is disabled. +PROTOC_GENERATE(GRPC LIB csi_v0 TARGET csi/v0/csi) # NOTE: The following `PROTOC_GENERATE` calls will list append to # `PUBLIC_PROTOBUF_SRC`. @@ -119,11 +114,7 @@ target_link_libraries(mesos-protobufs PUBLIC target_include_directories( mesos-protobufs PUBLIC - ${MESOS_PROTOBUF_HEADER_INCLUDE_DIRS} - ${PUBLIC_PROTOBUF_INCLUDE_DIR} - - PRIVATE - ${INTERNAL_PROTOBUF_INCLUDE_DIR}) + ${MESOS_PROTOBUF_HEADER_INCLUDE_DIRS}) # BUILD JAVA ARTIFACTS. diff --git a/src/Makefile.am b/src/Makefile.am index d03e56f..d132d80 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,7 @@ include ../3rdparty/versions.am # them include $(top_builddir) as appropriate. BOOST = 3rdparty/boost-$(BOOST_VERSION) CONCURRENTQUEUE = 3rdparty/concurrentqueue-$(CONCURRENTQUEUE_VERSION) -CSI = 3rdparty/csi-$(CSI_VERSION) +CSI_V0 = 3rdparty/csi-$(CSI_V0_VERSION) ELFIO = 3rdparty/elfio-$(ELFIO_VERSION) GLOG = 3rdparty/glog-$(GLOG_VERSION) GMOCK = $(GOOGLETEST)/googlemock @@ -271,13 +271,7 @@ LDADD += -lzookeeper_mt endif # Set up include paths for the protocol buffer compiler. -PROTOCFLAGS = -I$(top_srcdir)/include -I$(srcdir) -I../$(CSI) - -# TODO(josephw): This is a temporary include directory which points to the -# generated CSI protocol buffer code. Derivative protocol buffers need -# this include in order to build. When the 3rdparty CSI repo builds its own -# generated code, this can be changed to include that directory instead. -MESOS_CPPFLAGS += -I../include/csi +PROTOCFLAGS = -I$(top_srcdir)/include -I$(srcdir) -I../$(CSI_V0) # README: we build the Mesos library out of a collection of # convenience libraries (that is, libraries that do not get installed @@ -424,10 +418,10 @@ CXX_PROTOS += \ resource_provider/storage/disk_profile.pb.h CXX_CSI_PROTOS = \ - ../include/csi/csi.grpc.pb.cc \ - ../include/csi/csi.grpc.pb.h \ - ../include/csi/csi.pb.cc \ - ../include/csi/csi.pb.h \ + ../include/csi/v0/csi.grpc.pb.cc \ + ../include/csi/v0/csi.grpc.pb.h \ + ../include/csi/v0/csi.pb.cc \ + ../include/csi/v0/csi.pb.h \ ../include/mesos/csi/types.pb.cc \ ../include/mesos/csi/types.pb.h \ csi/state.pb.cc \ @@ -499,14 +493,9 @@ CLEANFILES += \ %.pb.cc %.pb.h: %.proto $(PROTOC) $(PROTOCFLAGS) --cpp_out=. $^ -../include/csi/%.pb.cc ../include/csi/%.pb.h: ../$(CSI)/%.proto - $(MKDIR_P) $(@D) - $(PROTOC) $(PROTOCFLAGS) --cpp_out=../include/csi $^ - -../include/csi/%.grpc.pb.cc ../include/csi/%.grpc.pb.h: ../$(CSI)/%.proto - $(MKDIR_P) $(@D) - $(PROTOC) $(PROTOCFLAGS) --grpc_out=../include/csi $^ \ - --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN) +../include/%.grpc.pb.cc ../include/%.grpc.pb.h ../include/%.pb.cc ../include/%.pb.h: ../$(CSI_V0)/%.proto + $(PROTOC) $(PROTOCFLAGS) --cpp_out=../include --grpc_out=../include \ + --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN) $^ # Targets for generating Java protocol buffer code. java/generated/org/apache/mesos/executor/Protos.java: $(EXECUTOR_PROTO) @@ -709,11 +698,19 @@ csidir = $(pkgincludedir)/csi csi_HEADERS = \ $(top_srcdir)/include/mesos/csi/types.hpp \ - $(top_srcdir)/include/mesos/csi/types.proto + $(top_srcdir)/include/mesos/csi/types.proto \ + $(top_srcdir)/include/mesos/csi/v0.hpp nodist_csi_HEADERS = \ ../include/mesos/csi/types.pb.h +# Install the generated CSI headers into $PREFIX/include. +csi_v0dir = $(includedir)/csi/v0 + +nodist_csi_v0_HEADERS = \ + ../include/csi/v0/csi.grpc.pb.h \ + ../include/csi/v0/csi.pb.h + dockerdir = $(pkgincludedir)/docker docker_HEADERS = \ @@ -1582,8 +1579,7 @@ libcsi_la_SOURCES = \ csi/v0_volume_manager.hpp \ csi/v0_volume_manager_process.hpp \ csi/volume_manager.cpp \ - csi/volume_manager.hpp \ - ../include/csi/spec.hpp + csi/volume_manager.hpp nodist_libcsi_la_SOURCES = $(CXX_CSI_PROTOS) libcsi_la_CPPFLAGS = $(MESOS_CPPFLAGS) diff --git a/src/cmake/MesosProtobuf.cmake b/src/cmake/MesosProtobuf.cmake index 09074d7..9f7d79a 100644 --- a/src/cmake/MesosProtobuf.cmake +++ b/src/cmake/MesosProtobuf.cmake @@ -17,18 +17,14 @@ # PROTOC_GENERATE is a convenience function that will: # (1) Compile .proto files found in the Mesos public-facing `include/` # directory, or with the `INTERNAL` option the Mesos `src/` directory, -# or with the `LIB` option a third-party specification library. +# or with the `LIB` option the external library's include directory. # (2) Place the generated files in the build folder, under the `include/` -# directory, or with the `INTERNAL` option the `src/` directory. The -# `JAVA` option will generate the Java Protobuf files to -# `src/java/generated` (not supported with the `LIB` option). The `GRPC` +# directory, or with the `INTERNAL` option the `src/` directory (cannot +# be used in conjunction with the `LIB` option). The `JAVA` option will +# generate the Java Protobuf files to `src/java/generated`. The `GRPC` # option will generate the `.grpc.pb.h` and `.grpc.pb.cc` files. -# (3) With the `LIB` option, append to list variable `PUBLIC_PROTO_PATH` or -# `INTERNAL_PROTO_PATH` the fully qualified path to the library's include -# directory, and append to list variable `PUBLIC_PROTOBUF_INCLUDE_DIR` or -# `INTERNAL_PROTOBUF_INCLUDE_DIR` the fully qualified path to the -# directory where the generated `.pb.h` files are placed. This export is a -# *side effect* and modifies the variables in the parent scope. +# (3) With the `LIB` option, append to list variable `LIB_PROTO_PATHS` the +# fully qualified path to the external library's include directory. # (4) Append to list variables `PUBLIC_PROTOBUF_SRC`, `INTERNAL_PROTOBUF_SRC`, # and `JAVA_PROTOBUF_SRC` (depending on options passed in) the fully # qualified path to the generated files. This export is a *side effect* @@ -48,25 +44,23 @@ # (2) Append the path `${MESOS_ROOT}/build/include/mesos/mesos.pb.cc` to # the parent scope variable `PUBLIC_PROTOBUF_SRC`. # -# Example 2: Suppose we wish to compile `csi.proto` in the `csi` specification -# library (assuming version 0.1.0) with gRPC enabled, we might pass in the -# following values for the parameters: +# Example 2: Suppose we wish to compile `csi/v0/csi.proto` in the `csi_v0` +# external library with gRPC enabled, we might pass in the following values for +# the parameters: # -# PROTOC_GENERATE(GRPC LIB csi TARGET csi) +# PROTOC_GENERATE(GRPC LIB csi_v0 TARGET csi/v0/csi) # -# Where `csi.proto` would be the relative path to the .proto file in the `csi` -# library's include directory. In this case, this function would: +# Where `csi/v0/csi.proto` would be the relative path to the .proto file in the +# `csi_v0` library's include directory. In this case, this function would: # -# (1) Compile `build/3rdparty/csi-0.1.0/src/csi-0.1.0/csi.proto`, which would -# generate the files `build/include/csi/csi.pb.h`, -# `build/include/csi/csi.pb.cc`, `build/include/csi/csi.grpc.pb.h`, and -# `build/include/csi/csi.grpc.pb.cc`. -# (2) Append the path `${MESOS_ROOT}/build/3rdparty/csi-0.1.0/src/csi-0.1.0/` -# to the parent scope variable `PUBLIC_PROTO_PATH`, and the path -# `${MESOS_ROOT}/build/include/csi/` to the parent scope variable -# `PUBLIC_PROTOBUF_INCLUDE_DIR`. -# (3) Append the paths `${MESOS_ROOT}/build/include/csi/csi.pb.cc` and -# `${MESOS_ROOT}/build/include/csi/csi.grpc.pb.cc` to the parent scope +# (1) Compile `${CSI_V0_ROOT}/csi/v0/csi.proto`, which would generate the +# files `build/include/csi/v0/csi.pb.h`, `build/include/csi/v0/csi.pb.cc`, +# `build/include/csi/v0/csi.grpc.pb.h`, and +# `build/include/csi/v0/csi.grpc.pb.cc`. +# (2) Append the path `${CSI_V0_ROOT}` to the parent scope variable +# `LIB_PROTO_PATHS`. +# (3) Append the paths `${MESOS_ROOT}/build/include/csi/v0/csi.pb.cc` and +# `${MESOS_ROOT}/build/include/csi/v0/csi.grpc.pb.cc` to the parent scope # variable `PUBLIC_PROTOBUF_SRC`. # # NOTE: The `protoc` binary used here is an imported executable target from @@ -79,53 +73,42 @@ function(PROTOC_GENERATE) # Fully qualified paths for the input .proto file and the output directories. if (PROTOC_LIB) + if (PROTOC_INTERNAL) + message(FATAL_ERROR + "Cannot generate internal proto files from an external library") + endif() + get_target_property( - PROTOC_LIB_INCLUDE_DIR + LIB_INCLUDE_DIR ${PROTOC_LIB} INTERFACE_INCLUDE_DIRECTORIES) - set(PROTO ${PROTOC_LIB_INCLUDE_DIR}/${PROTOC_TARGET}.proto) + list(APPEND LIB_PROTO_PATHS ${LIB_INCLUDE_DIR}) + list(REMOVE_DUPLICATES LIB_PROTO_PATHS) + set(LIB_PROTO_PATHS ${LIB_PROTO_PATHS} PARENT_SCOPE) - # TODO(chhsiao): `PUBLIC_PROTOBUF_INCLUDE_DIR` and - # `INTERNAL_PROTOBUF_INCLUDE_DIR` are temporary include directories which - # point to the generated header files. Derivative protocol buffers need the - # headers in order to build. These variables can be removed if all 3rd-party - # specification libraries build their own generated code. - if (PROTOC_INTERNAL) - set(CPP_OUT ${MESOS_BIN_SRC_DIR}/${PROTOC_LIB}) - list(APPEND INTERNAL_PROTO_PATH ${PROTOC_LIB_INCLUDE_DIR}) - list(APPEND INTERNAL_PROTOBUF_INCLUDE_DIR ${CPP_OUT}) - else () - set(CPP_OUT ${MESOS_BIN_INCLUDE_DIR}/${PROTOC_LIB}) - list(APPEND PUBLIC_PROTO_PATH ${PROTOC_LIB_INCLUDE_DIR}) - list(APPEND PUBLIC_PROTOBUF_INCLUDE_DIR ${CPP_OUT}) - endif () + set(PROTO ${LIB_INCLUDE_DIR}/${PROTOC_TARGET}.proto) + set(CPP_OUT ${MESOS_BIN_INCLUDE_DIR}) + elseif (PROTOC_INTERNAL) + set(PROTO ${MESOS_SRC_DIR}/${PROTOC_TARGET}.proto) + set(CPP_OUT ${MESOS_BIN_SRC_DIR}) else () - if (PROTOC_INTERNAL) - set(PROTO ${MESOS_SRC_DIR}/${PROTOC_TARGET}.proto) - set(CPP_OUT ${MESOS_BIN_SRC_DIR}) - else () - set(PROTO ${MESOS_PUBLIC_INCLUDE_DIR}/${PROTOC_TARGET}.proto) - set(CPP_OUT ${MESOS_BIN_INCLUDE_DIR}) - endif() + set(PROTO ${MESOS_PUBLIC_INCLUDE_DIR}/${PROTOC_TARGET}.proto) + set(CPP_OUT ${MESOS_BIN_INCLUDE_DIR}) + endif() - if (PROTOC_JAVA AND HAS_JAVA) - set(JAVA_OUT ${MESOS_BIN_SRC_DIR}/java/generated) - endif() - endif () + if (PROTOC_JAVA AND HAS_JAVA) + set(JAVA_OUT ${MESOS_BIN_SRC_DIR}/java/generated) + endif() set(PROTOC_OPTIONS -I${MESOS_PUBLIC_INCLUDE_DIR} -I${MESOS_SRC_DIR} --cpp_out=${CPP_OUT}) - if (PUBLIC_PROTO_PATH) - list(APPEND PROTOC_OPTIONS -I${PUBLIC_PROTO_PATH}) - endif () - - if (INTERNAL_PROTO_PATH) - list(APPEND PROTOC_OPTIONS -I${INTERNAL_PROTO_PATH}) - endif () + foreach (LIB_PROTO_PATH IN LISTS LIB_PROTO_PATHS) + list(APPEND PROTOC_OPTIONS -I${LIB_PROTO_PATH}) + endforeach (LIB_PROTO_PATH) if (PROTOC_GRPC) list(APPEND PROTOC_OPTIONS @@ -138,7 +121,8 @@ function(PROTOC_GENERATE) --java_out=${JAVA_OUT}) endif () - # Fully qualified paths for the output .pb.h and .pb.cc files. + # Fully qualified paths for the input .proto file and the output .pb.h and + # .pb.cc files. set(CC ${CPP_OUT}/${PROTOC_TARGET}.pb.cc) set(H ${CPP_OUT}/${PROTOC_TARGET}.pb.h) @@ -155,20 +139,9 @@ function(PROTOC_GENERATE) # Export variables holding the target filenames. if (PROTOC_INTERNAL) - set(INTERNAL_PROTO_PATH ${INTERNAL_PROTO_PATH} PARENT_SCOPE) - - set( - INTERNAL_PROTOBUF_INCLUDE_DIR - ${INTERNAL_PROTOBUF_INCLUDE_DIR} - PARENT_SCOPE) - list(APPEND INTERNAL_PROTOBUF_SRC ${CC} ${GRPC_CC}) set(INTERNAL_PROTOBUF_SRC ${INTERNAL_PROTOBUF_SRC} PARENT_SCOPE) else () - set(PUBLIC_PROTO_PATH ${PUBLIC_PROTO_PATH} PARENT_SCOPE) - - set(PUBLIC_PROTOBUF_INCLUDE_DIR ${PUBLIC_PROTOBUF_INCLUDE_DIR} PARENT_SCOPE) - list(APPEND PUBLIC_PROTOBUF_SRC ${CC} ${GRPC_CC}) set(PUBLIC_PROTOBUF_SRC ${PUBLIC_PROTOBUF_SRC} PARENT_SCOPE) endif () @@ -179,35 +152,18 @@ function(PROTOC_GENERATE) endif () # Make the directory that generated files go into. - # TODO(chhsiao): Put the following directory creation targets together with - # `make_bin_include_dir` and `make_bin_src_dir`, and find a better way to - # ensure that the output directories are created. + if (PROTOC_INTERNAL) + set(PROTOC_DEPENDS make_bin_src_dir) + else () + set(PROTOC_DEPENDS make_bin_include_dir) + endif () + if (PROTOC_LIB) - if (PROTOC_INTERNAL) - set(MAKE_CPP_OUT_DIR make_bin_src_${PROTOC_LIB}_dir) - add_custom_target( - ${MAKE_CPP_OUT_DIR} ALL - COMMAND ${CMAKE_COMMAND} -E make_directory ${CPP_OUT} - DEPENDS make_bin_src_dir) - else () - set(MAKE_CPP_OUT_DIR make_bin_include_${PROTOC_LIB}_dir) - add_custom_target( - ${MAKE_CPP_OUT_DIR} ALL - COMMAND ${CMAKE_COMMAND} -E make_directory ${CPP_OUT} - DEPENDS make_bin_include_dir) - endif() + list(APPEND PROTOC_DEPENDS ${PROTOC_LIB}) + endif () - set(PROTOC_DEPENDS ${MAKE_CPP_OUT_DIR} ${PROTOC_LIB}) - else () - if (PROTOC_INTERNAL) - set(PROTOC_DEPENDS make_bin_src_dir) - else () - set(PROTOC_DEPENDS make_bin_include_dir) - endif () - - if (JAVA_OUT) - list(APPEND PROTOC_DEPENDS make_bin_java_dir) - endif () + if (JAVA_OUT) + list(APPEND PROTOC_DEPENDS make_bin_java_dir) endif () # Make sure that the gRPC plugin is built. diff --git a/src/csi/client.hpp b/src/csi/client.hpp index c2583cf..1429526 100644 --- a/src/csi/client.hpp +++ b/src/csi/client.hpp @@ -17,7 +17,7 @@ #ifndef __CSI_CLIENT_HPP__ #define __CSI_CLIENT_HPP__ -#include <csi/spec.hpp> +#include <mesos/csi/v0.hpp> #include <process/grpc.hpp> diff --git a/src/csi/rpc.hpp b/src/csi/rpc.hpp index b2502ce..4d0ce49 100644 --- a/src/csi/rpc.hpp +++ b/src/csi/rpc.hpp @@ -19,7 +19,7 @@ #include <ostream> -#include <csi/spec.hpp> +#include <mesos/csi/v0.hpp> namespace mesos { namespace csi { diff --git a/src/csi/utils.hpp b/src/csi/utils.hpp index f1471c7..30b579e 100644 --- a/src/csi/utils.hpp +++ b/src/csi/utils.hpp @@ -20,8 +20,6 @@ #include <ostream> #include <type_traits> -#include <csi/spec.hpp> - #include <google/protobuf/map.h> #include <google/protobuf/util/json_util.h> @@ -29,6 +27,7 @@ #include <mesos/mesos.hpp> #include <mesos/csi/types.hpp> +#include <mesos/csi/v0.hpp> #include <stout/foreach.hpp> #include <stout/try.hpp> diff --git a/src/examples/test_csi_plugin.cpp b/src/examples/test_csi_plugin.cpp index 73a6c43..5b3ba4b 100644 --- a/src/examples/test_csi_plugin.cpp +++ b/src/examples/test_csi_plugin.cpp @@ -18,8 +18,6 @@ #include <thread> #include <utility> -#include <csi/spec.hpp> - #include <grpcpp/grpcpp.h> #include <grpcpp/generic/async_generic_service.h> @@ -27,6 +25,8 @@ #include <mesos/type_utils.hpp> +#include <mesos/csi/v0.hpp> + #include <stout/bytes.hpp> #include <stout/flags.hpp> #include <stout/foreach.hpp> diff --git a/src/resource_provider/storage/disk_profile.proto b/src/resource_provider/storage/disk_profile.proto index 1c97e9c..69982c8 100644 --- a/src/resource_provider/storage/disk_profile.proto +++ b/src/resource_provider/storage/disk_profile.proto @@ -16,7 +16,7 @@ syntax = "proto3"; -import "csi.proto"; +import "csi/v0/csi.proto"; package mesos.resource_provider; diff --git a/src/resource_provider/storage/disk_profile_utils.hpp b/src/resource_provider/storage/disk_profile_utils.hpp index 8a83a15..09ab20a 100644 --- a/src/resource_provider/storage/disk_profile_utils.hpp +++ b/src/resource_provider/storage/disk_profile_utils.hpp @@ -17,10 +17,10 @@ #ifndef __RESOURCE_PROVIDER_URI_DISK_PROFILE_UTILS_HPP__ #define __RESOURCE_PROVIDER_URI_DISK_PROFILE_UTILS_HPP__ -#include <csi/spec.hpp> - #include <mesos/mesos.hpp> +#include <mesos/csi/v0.hpp> + #include <stout/option.hpp> #include <stout/try.hpp> diff --git a/src/tests/csi_utils_tests.cpp b/src/tests/csi_utils_tests.cpp index a0d0c37..db58b49 100644 --- a/src/tests/csi_utils_tests.cpp +++ b/src/tests/csi_utils_tests.cpp @@ -17,13 +17,12 @@ #include <string> #include <vector> -#include <csi/spec.hpp> - #include <google/protobuf/util/json_util.h> #include <gtest/gtest.h> #include <mesos/csi/types.hpp> +#include <mesos/csi/v0.hpp> #include "csi/utils.hpp" diff --git a/src/tests/disk_profile_adaptor_tests.cpp b/src/tests/disk_profile_adaptor_tests.cpp index 84e5cb0..2809847 100644 --- a/src/tests/disk_profile_adaptor_tests.cpp +++ b/src/tests/disk_profile_adaptor_tests.cpp @@ -19,9 +19,8 @@ #include <tuple> #include <vector> -#include <csi/spec.hpp> - #include <mesos/csi/types.hpp> +#include <mesos/csi/v0.hpp> #include <mesos/module/disk_profile_adaptor.hpp> diff --git a/src/tests/mock_csi_plugin.hpp b/src/tests/mock_csi_plugin.hpp index 6897fbc..2e3cbfd 100644 --- a/src/tests/mock_csi_plugin.hpp +++ b/src/tests/mock_csi_plugin.hpp @@ -20,12 +20,12 @@ #include <memory> #include <string> -#include <csi/spec.hpp> - #include <gmock/gmock.h> #include <grpcpp/grpcpp.h> +#include <mesos/csi/v0.hpp> + #include <process/grpc.hpp> #include <stout/none.hpp>
