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 3da54965d02a6bf0e4806bf2d4acebb3310d60f7
Author: Chun-Hung Hsiao <[email protected]>
AuthorDate: Thu Mar 28 21:26:04 2019 -0700

    Bundled CSI spec 1.1.0.
    
    Since the CSI v1 spec proto file depends on certain proto files in the
    Protobuf library, we have to ensure the Protobuf library's include path
    is in the proto paths of the `protoc` command when compiling the CSI
    spec proto file. Specifically in Autotools, this path is passed through
    the `PROTOBUF_PROTOCFLAGS` variable when building with an unbundled
    protobuf library.
    
    Review: https://reviews.apache.org/r/70360
---
 3rdparty/CMakeLists.txt       |  24 ++++++++++++++++++++++--
 3rdparty/Makefile.am          |  19 ++++++++++++++++---
 3rdparty/cmake/Versions.cmake |   2 ++
 3rdparty/csi-1.1.0.tar.gz     | Bin 0 -> 173338 bytes
 3rdparty/versions.am          |   1 +
 configure.ac                  |   8 +++++++-
 src/CMakeLists.txt            |   1 +
 src/Makefile.am               |  23 ++++++++++++++++++++---
 src/cmake/MesosProtobuf.cmake |   6 ++++++
 9 files changed, 75 insertions(+), 9 deletions(-)

diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index 7f70407..53396fb 100644
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -27,6 +27,7 @@ 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_V0_URL          ${FETCH_URL}/csi-${CSI_V0_VERSION}.tar.gz)
+set(CSI_V1_URL          ${FETCH_URL}/csi-${CSI_V1_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)
@@ -299,12 +300,21 @@ 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.
+EXTERNAL(csi_v1 ${CSI_V1_VERSION} ${CMAKE_CURRENT_BINARY_DIR})
+add_library(csi_v1 INTERFACE)
+add_dependencies(csi_v1 ${CSI_V1_TARGET})
+target_include_directories(csi_v1 INTERFACE ${CSI_V1_ROOT})
+
+# NOTE: To support multiple CSI versions, we move the CSI proto files to
+# version-qualified paths so `protoc` can find them.
 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)
 
+set(CSI_V1_CONFIG_CMD
+  ${CMAKE_COMMAND} -E make_directory ${CSI_V1_ROOT}/csi/v1 &&
+  ${CMAKE_COMMAND} -E rename ${CSI_V1_ROOT}/csi.proto 
${CSI_V1_ROOT}/csi/v1/csi.proto)
+
 ExternalProject_Add(
   ${CSI_V0_TARGET}
   PREFIX            ${CSI_V0_CMAKE_ROOT}
@@ -315,6 +325,16 @@ ExternalProject_Add(
   URL               ${CSI_V0_URL}
   URL_HASH          ${CSI_V0_HASH})
 
+ExternalProject_Add(
+  ${CSI_V1_TARGET}
+  PREFIX            ${CSI_V1_CMAKE_ROOT}
+  BUILD_BYPRODUCTS  ${CSI_V1_ROOT}/csi/v1/csi.proto
+  CONFIGURE_COMMAND ${CSI_V1_CONFIG_CMD}
+  BUILD_COMMAND     ${CMAKE_NOOP}
+  INSTALL_COMMAND   ${CMAKE_NOOP}
+  URL               ${CSI_V1_URL}
+  URL_HASH          ${CSI_V1_HASH})
+
 
 # ELFIO: library for reading and generating ELF files.
 # http://elfio.sourceforge.net
diff --git a/3rdparty/Makefile.am b/3rdparty/Makefile.am
index adbbaf5..99815da 100644
--- a/3rdparty/Makefile.am
+++ b/3rdparty/Makefile.am
@@ -51,6 +51,7 @@ include versions.am
 BOOST = boost-$(BOOST_VERSION)
 CONCURRENTQUEUE = concurrentqueue-$(CONCURRENTQUEUE_VERSION)
 CSI_V0 = csi-$(CSI_V0_VERSION)
+CSI_V1 = csi-$(CSI_V1_VERSION)
 ELFIO = elfio-$(ELFIO_VERSION)
 GLOG = glog-$(GLOG_VERSION)
 GMOCK = $(GOOGLETEST)/googlemock
@@ -78,6 +79,7 @@ EXTRA_DIST =                  \
   $(BOOST).tar.gz              \
   $(CONCURRENTQUEUE).tar.gz    \
   $(CSI_V0).tar.gz             \
+  $(CSI_V1).tar.gz             \
   $(ELFIO).tar.gz              \
   $(GLOG).tar.gz               \
   $(GOOGLETEST).tar.gz         \
@@ -140,6 +142,7 @@ CLEAN_EXTRACTED =           \
   $(BOOST)                     \
   $(CONCURRENTQUEUE)           \
   $(CSI_V0)                    \
+  $(CSI_V1)                    \
   $(ELFIO)                     \
   $(GLOG)                      \
   $(GOOGLETEST)                        \
@@ -175,7 +178,7 @@ CLEAN_EXTRACTED =           \
 #
 # 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_V0)-stamp $(CSI_V1)-stamp
 $(CSI_STAMPS): csi-%-stamp: csi-%.tar.gz
        $(MKDIR_P) csi-$*
        gzip -d -c $^ | (cd csi-$* && tar xf -)
@@ -540,20 +543,30 @@ $(GRPC)-build-stamp:
        touch $@
 endif
 
-# NOTE: To support multiple CSI versions, we move the CSI proto file to a
-# version-qualified path so `protoc` can find it.
+# NOTE: To support multiple CSI versions, we move the CSI proto files to
+# version-qualified paths so `protoc` can find them.
 $(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 $@
 
+$(CSI_V1)-build-stamp: $(CSI_V1)-stamp
+       $(MKDIR_P) $(CSI_V1)/csi/v1
+       mv $(CSI_V1)/spec-$(CSI_V1_VERSION)/csi.proto $(CSI_V1)/csi/v1
+       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
 
+csi_v1dir = $(includedir)/csi/v1
+nodist_csi_v1_HEADERS = $(CSI_V1)/csi/v1/csi.proto
+$(nodist_csi_v1_HEADERS): $(CSI_V1)-build-stamp
+
 ALL_LOCAL += $(CSI_V0)-build-stamp
+ALL_LOCAL += $(CSI_V1)-build-stamp
 
 # Convenience library for gmock/gtest.
 check_LTLIBRARIES = libgmock.la
diff --git a/3rdparty/cmake/Versions.cmake b/3rdparty/cmake/Versions.cmake
index a67cb16..b42d52c 100644
--- a/3rdparty/cmake/Versions.cmake
+++ b/3rdparty/cmake/Versions.cmake
@@ -4,6 +4,8 @@ set(CONCURRENTQUEUE_VERSION "7b69a8f")
 set(CONCURRENTQUEUE_HASH    
"SHA256=B2741A1FB2172C2A829503A85D5EE7548BE7ED04236A3FD1EFD2B6088E065CB7")
 set(CSI_V0_VERSION          "0.2.0")
 set(CSI_V0_HASH             
"SHA256=B013F844C1E309B03FE6BCE9F186FEFA8910FCFAE7F8E6F7E4ACBEC166692F92")
+set(CSI_V1_VERSION          "1.1.0")
+set(CSI_V1_HASH             
"SHA256=DF6DF163A1DC1130144D95BEE7725C7FA59F1A8676EAC188B209FCC28DA8379F")
 set(CURL_VERSION            "7.61.0")
 set(CURL_HASH               
"SHA256=64141F0DB4945268A21B490D58806B97C615D3D0C75BF8C335BBE0EFD13B45B5")
 set(ELFIO_VERSION           "3.2")
diff --git a/3rdparty/csi-1.1.0.tar.gz b/3rdparty/csi-1.1.0.tar.gz
new file mode 100644
index 0000000..2cacd32
Binary files /dev/null and b/3rdparty/csi-1.1.0.tar.gz differ
diff --git a/3rdparty/versions.am b/3rdparty/versions.am
index b16132c..54daf00 100644
--- a/3rdparty/versions.am
+++ b/3rdparty/versions.am
@@ -22,6 +22,7 @@
 BOOST_VERSION = 1.65.0
 CONCURRENTQUEUE_VERSION = 7b69a8f
 CSI_V0_VERSION = 0.2.0
+CSI_V1_VERSION = 1.1.0
 ELFIO_VERSION = 3.2
 GLOG_VERSION = 0.3.3
 GOOGLETEST_VERSION = 1.8.0
diff --git a/configure.ac b/configure.ac
index 5302e66..a367c28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1805,6 +1805,12 @@ if test "x$without_bundled_protobuf" = "xyes" || \
                     [AC_MSG_ERROR([cannot find PROTOBUF_JAR=$PROTOBUF_JAR])])
     fi
 
+    AC_CHECK_FILE([$PROTOBUFPREFIX/include/google/protobuf/wrappers.proto],
+                  [],
+                  [AC_MSG_ERROR([cannot find protobuf proto files])])
+
+    PROTOBUF_PROTOCFLAGS="-I${PROTOBUFPREFIX}/include"
+
     AC_CHECK_TOOL([PROTOCOMPILER_TEST], [protoc], [], [$PROTOBUFPREFIX/bin])
 
     if test -z "`echo $PROTOCOMPILER_TEST`"; then
@@ -1816,7 +1822,6 @@ if test "x$without_bundled_protobuf" = "xyes" || \
     if test "x$enable_python" = "xyes"; then
       AC_PYTHON_MODULE([google.protobuf], [yes])
     fi
-
   else
     AC_MSG_ERROR([cannot find protobuf
 -------------------------------------------------------------------
@@ -1840,6 +1845,7 @@ AM_CONDITIONAL([WITH_BUNDLED_PROTOBUF],
 AC_SUBST([PROTOBUF_CPPFLAGS])
 AC_SUBST([PROTOBUF_JAR])
 AC_SUBST([PROTOBUF_LINKERFLAGS])
+AC_SUBST([PROTOBUF_PROTOCFLAGS])
 AC_SUBST([PROTOCOMPILER])
 
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index af3715a..5ffeccd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -27,6 +27,7 @@ set(JAVA_PROTOBUF_SRC "")
 # NOTE: The following `PROTOC_GENERATE` calls will list append to
 # `PUBLIC_PROTOBUF_SRC`. The GRPC option is a noop if gRPC is disabled.
 PROTOC_GENERATE(GRPC LIB csi_v0 TARGET csi/v0/csi)
+PROTOC_GENERATE(GRPC LIB csi_v1 TARGET csi/v1/csi)
 
 # NOTE: The following `PROTOC_GENERATE` calls will list append to
 # `PUBLIC_PROTOBUF_SRC`.
diff --git a/src/Makefile.am b/src/Makefile.am
index a800444..6782e4b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,6 +27,7 @@ include ../3rdparty/versions.am
 BOOST = 3rdparty/boost-$(BOOST_VERSION)
 CONCURRENTQUEUE = 3rdparty/concurrentqueue-$(CONCURRENTQUEUE_VERSION)
 CSI_V0 = 3rdparty/csi-$(CSI_V0_VERSION)
+CSI_V1 = 3rdparty/csi-$(CSI_V1_VERSION)
 ELFIO = 3rdparty/elfio-$(ELFIO_VERSION)
 GLOG = 3rdparty/glog-$(GLOG_VERSION)
 GMOCK = $(GOOGLETEST)/googlemock
@@ -139,6 +140,9 @@ MESOS_CPPFLAGS += -I../include
 # Protobuf headers that depend on mesos.pb.h need this.
 MESOS_CPPFLAGS += -I../include/mesos
 
+# Set up include paths for the protocol buffer compiler.
+PROTOCFLAGS = -I$(top_srcdir)/include -I$(srcdir) -I../$(CSI_V0) -I../$(CSI_V1)
+
 # Header only dependencies will be ignored for --disable-bundled.
 #
 # For non-convenience libraries we need to link them in to make the shared
@@ -247,10 +251,12 @@ if WITH_BUNDLED_PROTOBUF
 MESOS_CPPFLAGS += -I../$(PROTOBUF)/src
 LIB_PROTOBUF = ../$(PROTOBUF)/src/libprotobuf.la
 PROTOC = ../$(PROTOBUF)/src/protoc
+PROTOCFLAGS += -I../$(PROTOBUF)/src
 else
 LIB_PROTOBUF = -lprotobuf
 LDADD += -lprotobuf
 PROTOC = @PROTOCOMPILER@
+PROTOCFLAGS += @PROTOBUF_PROTOCFLAGS@
 endif
 
 if WITH_BUNDLED_RAPIDJSON
@@ -270,9 +276,6 @@ LIB_ZOOKEEPER = -lzookeeper_mt
 LDADD += -lzookeeper_mt
 endif
 
-# Set up include paths for the protocol buffer compiler.
-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
 # but we can use as building blocks to vary compile flags as necessary
@@ -422,6 +425,10 @@ CXX_CSI_PROTOS =                                           
        \
   ../include/csi/v0/csi.grpc.pb.h                                      \
   ../include/csi/v0/csi.pb.cc                                          \
   ../include/csi/v0/csi.pb.h                                           \
+  ../include/csi/v1/csi.grpc.pb.cc                                     \
+  ../include/csi/v1/csi.grpc.pb.h                                      \
+  ../include/csi/v1/csi.pb.cc                                          \
+  ../include/csi/v1/csi.pb.h                                           \
   ../include/mesos/csi/types.pb.cc                                     \
   ../include/mesos/csi/types.pb.h                                      \
   csi/state.pb.cc                                                      \
@@ -497,6 +504,10 @@ CLEANFILES +=                                              
                \
        $(PROTOC) $(PROTOCFLAGS) --cpp_out=../include --grpc_out=../include     
\
                --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN) $^
 
+../include/%.grpc.pb.cc ../include/%.grpc.pb.h ../include/%.pb.cc 
../include/%.pb.h: ../$(CSI_V1)/%.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)
        $(MKDIR_P) $(@D)
@@ -711,6 +722,12 @@ nodist_csi_v0_HEADERS =                                    
                \
   ../include/csi/v0/csi.grpc.pb.h                                      \
   ../include/csi/v0/csi.pb.h
 
+csi_v1dir = $(includedir)/csi/v1
+
+nodist_csi_v1_HEADERS =                                                        
\
+  ../include/csi/v1/csi.grpc.pb.h                                      \
+  ../include/csi/v1/csi.pb.h
+
 dockerdir = $(pkgincludedir)/docker
 
 docker_HEADERS =                                                       \
diff --git a/src/cmake/MesosProtobuf.cmake b/src/cmake/MesosProtobuf.cmake
index 9f7d79a..7011270 100644
--- a/src/cmake/MesosProtobuf.cmake
+++ b/src/cmake/MesosProtobuf.cmake
@@ -101,9 +101,15 @@ function(PROTOC_GENERATE)
     set(JAVA_OUT ${MESOS_BIN_SRC_DIR}/java/generated)
   endif()
 
+  get_target_property(
+    PROTOBUF_INCLUDE_DIR
+    protobuf
+    INTERFACE_INCLUDE_DIRECTORIES)
+
   set(PROTOC_OPTIONS
     -I${MESOS_PUBLIC_INCLUDE_DIR}
     -I${MESOS_SRC_DIR}
+    -I${PROTOBUF_INCLUDE_DIR}
     --cpp_out=${CPP_OUT})
 
   foreach (LIB_PROTO_PATH IN LISTS LIB_PROTO_PATHS)

Reply via email to