[Dist/Ubuntu] Disable GRPC in xenial. Update GRPC for bionic
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 12 Jul 2019 01:45:57 +0000 (10:45 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 12 Jul 2019 02:19:26 +0000 (11:19 +0900)
GRPC in xenial is too old. Disable it.

Change-Id: Ie9659d76797f468168a18538c052b6751a74d53c
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
debian/control
debian/rules
tensorflow/contrib/cmake/external/grpc.cmake

index 9570502445f625440f2e9b026fe6c32b1cbe2b34..be11f8c79ab82170cb5c25f77b99fcdaeccea8ab 100644 (file)
@@ -2,7 +2,8 @@ Source: tensorflow
 Section: devel
 Priority: optional
 Maintainer: Sangjung Woo <sangjung.woo@samsung.com>
-Build-Depends: debhelper (>=9), sed, zlib1g-dev, cmake (>=3.9), python, git, python-numpy, swig, python-dev, libc6-dev, unzip, libicu-dev, pkg-config, libssl-dev, libprotobuf-dev, protobuf-compiler, protobuf-c-compiler, libprotobuf-c-dev, libgrpc-dev, libc-ares-dev
+Build-Depends: debhelper (>=9), sed, zlib1g-dev, cmake (>=3.9), python, git, python-numpy, swig, python-dev, libc6-dev, unzip, libicu-dev, pkg-config, libssl-dev, libprotobuf-dev, protobuf-compiler, protobuf-c-compiler, libprotobuf-c-dev, libc-ares-dev,
+ libgrpc-dev [bionic], libgrpc++-dev [bionic]
 Standards-Version: 3.9.6
 Homepage: https://github.sec.samsung.net/RS7-STAR/Tensorflow
 
index 1d93f8314bfbdb3228eacc6bb72aa97fcb8ae888..3afc1f9864dbb041537dd1a9ad2e54a6b15dac7f 100755 (executable)
@@ -1,5 +1,9 @@
 #!/usr/bin/make -f
 
+VENDOR ?= $(shell dpkg-vendor --query Vendor | tr [A-Z] [a-z])
+UBUNTU := $(shell cat /etc/os-release | grep "UBUNTU_CODENAME=" | sed "s|UBUNTU_CODENAME=||")
+
+
 ARCH := $(shell arch)
 
 CXXFLAGS = -Wno-sign-compare -Wno-unused-but-set-variable -Wno-format-security -Wno-format -fPIC
@@ -97,7 +101,17 @@ build:
 
        sed -i "s|ExternalProject_Add(\\(.*\\)$$|ExternalProject_add(\\1\\n\\tDOWNLOAD_COMMAND echo\\n\\tUPDATE_DISCONNECTED 1\\n|" tensorflow/contrib/cmake/external/*.cmake
 
-       cd ${topdir}/build && cmake ../tensorflow/contrib/cmake -DCMAKE_INSTALL_PREFIX=/usr -DLIB_INSTALL_DIR=/usr/lib -DINCLUDE_INSTALL_DIR=/usr/include -Dtensorflow_ENABLE_SSL_SUPPORT=OFF -Dsystemlib_ZLIB=ON -Dsystemlib_GRPC=ON -Dsystemlib_PROTOBUF=ON
+       # GRPC > 1.12 supported from bionic. Disable it in xenial or lower.
+       # Controlled by tensorflow_ENABLE_GRPC_SUPPORT=ON/OFF
+       ifeq (${VENDOR},ubuntu)
+               ifeq (${UBUNTU},bionic)
+                       cd ${topdir}/build && cmake ../tensorflow/contrib/cmake -DCMAKE_INSTALL_PREFIX=/usr -DLIB_INSTALL_DIR=/usr/lib -DINCLUDE_INSTALL_DIR=/usr/include -Dtensorflow_ENABLE_SSL_SUPPORT=OFF -Dsystemlib_ZLIB=ON -Dsystemlib_GRPC=ON -Dsystemlib_PROTOBUF=ON
+               else
+                       cd ${topdir}/build && cmake ../tensorflow/contrib/cmake -DCMAKE_INSTALL_PREFIX=/usr -DLIB_INSTALL_DIR=/usr/lib -DINCLUDE_INSTALL_DIR=/usr/include -Dtensorflow_ENABLE_SSL_SUPPORT=OFF -Dsystemlib_ZLIB=ON -Dsystemlib_GRPC=ON -Dsystemlib_PROTOBUF=ON -Dtensorflow_ENABLE_GRPC_SUPPORT=OFF
+               endif
+       else
+               $(error This supports Ubuntu xenial/bionic only: ${VENDOR}/${UBUNTU})
+       endif
 
        printf 'PWD=`pwd`\n' > temp.sh
        printf 'for F in *.cmake ; do\n' >> temp.sh
@@ -153,6 +167,29 @@ install: build
 
        install -d ${buildroot}
        install -d ${buildroot}${_libdir}
+       mkdir -p ${buildroot}${_libdir}/python2.7
+       cp -R -p ${topdir}/build/tf_python* ${buildroot}${_libdir}/python2.7
+       touch ${buildroot}${_libdir}/python2.7/tf_python/__init__.py
+       install -p -m 0755 ${topdir}/build/*.so ${buildroot}${_libdir}
+
+       find tensorflow -name "*.h" -exec dirname {} \; | uniq | xargs -I {} mkdir ${buildroot}${_includedir}/${name}/{} -p
+       find tensorflow -name "*.h" -exec cp {} ${buildroot}${_includedir}/${name}/{} -aPv \;
+
+       find third_party/eigen3/ -type f ! -name '*.cc' ! -name '*.cpp' ! -name '*.c' -exec dirname {} \; | uniq | xargs -I {} mkdir ${buildroot}${_includedir}/${name}/{} -p
+       find third_party/eigen3/ -type f ! -name '*.cc' ! -name '*.cpp' ! -name '*.c' -exec cp {} ${buildroot}${_includedir}/${name}/{} -aPv \;
+
+       cd ${topdir}/build && find tensorflow -name "*.h" -exec dirname {} \; | uniq | xargs -I {} bash -c 'if [ ! -d ${buildroot}${_includedir}/${name}/{} ] ; then mkdir ${buildroot}${_includedir}/${name}/{} -p ; fi'
+       cd ${topdir}/build && find tensorflow -name "*.h" -exec cp {} ${buildroot}${_includedir}/${name}/{} -aPv \;
+
+       cd ${topdir}/build/ && cp -R -p eigen/src/eigen/Eigen ${buildroot}${_includedir}/${name}/
+       cd ${topdir}/build/ && cp -R -p eigen/src/eigen ${buildroot}${_includedir}/${name}/
+
+       cd ${topdir}/build/eigen/src/eigen && find . -type f ! -name '*.cc' ! -name '*.cpp' ! -name '*.c' -exec dirname {} \; | uniq | xargs -I {} bash -c 'if [ ! -d ${buildroot}${_includedir}/${name}/third_party/eigen3/{} ] ; then mkdir ${buildroot}${_includedir}/${name}/third_party/eigen3/{} -p ; fi'
+       cd ${topdir}/build/eigen/src/eigen && find . -type f ! -name  '*.cc' ! -name '*.cpp' ! -name '*.c' -exec cp {} ${buildroot}${_includedir}/${name}/third_party/eigen3/{} -aPv \;
+
+       cd ${topdir}/build && cp -p nsync/install/include/*.h ${buildroot}${_includedir}/${name}/
+
+
        install -d ${buildroot}${_libdir}/pkgconfig
        install -d ${buildroot}${_includedir}/tensorflow/lite
        install -d ${buildroot}${_includedir}/tensorflow/lite/kernels
@@ -181,33 +218,7 @@ install: build
        install -m 0644 ${packagingdir}/${SOURCE4001} ${buildroot}${_libdir}/pkgconfig/tensorflow.pc
        install -m 0644 ${packagingdir}/${SOURCE4002} ${buildroot}${_libdir}/pkgconfig/tensorflow-lite.pc
        sed -i -e "s:@libdir@:${_libdir}:g" -e "s:@includedir@:${_includedir}:g" ${buildroot}${_libdir}/pkgconfig/tensorflow-lite.pc
-       sed -i -e "s:@libdir@:${_libdir}:g" -e "s:@includedir@:${_includedir}:g" ${buildroot}${_libdir}/pkgconfig/tensorflow.pc
-
-       mkdir -p ${buildroot}${_libdir}/python2.7
-       cp -R -p ${topdir}/build/tf_python* ${buildroot}${_libdir}/python2.7
-       touch ${buildroot}${_libdir}/python2.7/tf_python/__init__.py
-       install -p -m 0755 ${topdir}/build/*.so ${buildroot}${_libdir}
-       find tensorflow -name "*.h" -exec dirname {} \; | uniq | xargs -I {} mkdir ${buildroot}${_includedir}/${name}/{} -p
-       find tensorflow -name "*.h" -exec cp {} ${buildroot}${_includedir}/${name}/{} -aPv \;
-       find third_party/eigen3/ -type f ! -name '*.cc' ! -name '*.cpp' ! -name '*.c' -exec dirname {} \; | uniq | xargs -I {} mkdir ${buildroot}${_includedir}/${name}/{} -p
-       find third_party/eigen3/ -type f ! -name '*.cc' ! -name '*.cpp' ! -name '*.c' -exec cp {} ${buildroot}${_includedir}/${name}/{} -aPv \;
-
-       cd ${topdir}/build && find tensorflow -name "*.h" -exec dirname {} \; | uniq | xargs -I {} bash -c 'if [ ! -d ${buildroot}${_includedir}/${name}/{} ] ; then mkdir ${buildroot}${_includedir}/${name}/{} -p ; fi'
-       cd ${topdir}/build && find tensorflow -name "*.h" -exec cp {} ${buildroot}${_includedir}/${name}/{} -aPv \;
-
-       cd ${topdir}/build/protobuf/src/protobuf/src/ && find google -name "*.h" -exec dirname {} \; | uniq | xargs -I {} mkdir ${buildroot}${_includedir}/${name}/{} -p
-       cd ${topdir}/build/protobuf/src/protobuf/src/ && find google -name "*.h" -exec cp {} ${buildroot}${_includedir}/${name}/{} -aPv \;
-
-       cd ${topdir}/build/ && cp -R -p eigen/src/eigen/Eigen ${buildroot}${_includedir}/${name}/
-       cd ${topdir}/build/ && cp -R -p eigen/src/eigen ${buildroot}${_includedir}/${name}/
-
-       cd ${topdir}/build/protobuf/src/protobuf/src/ && find google -name "*.h" -exec dirname {} \; | uniq | xargs -I {} mkdir ${buildroot}${_includedir}/${name}/{} -p
-       cd ${topdir}/build/protobuf/src/protobuf/src/ && find google -name "*.h" -exec cp {} ${buildroot}${_includedir}/${name}/{} -aPv \;
-
-       cd ${topdir}/build/eigen/src/eigen && find . -type f ! -name '*.cc' ! -name '*.cpp' ! -name '*.c' -exec dirname {} \; | uniq | xargs -I {} bash -c 'if [ ! -d ${buildroot}${_includedir}/${name}/third_party/eigen3/{} ] ; then mkdir ${buildroot}${_includedir}/${name}/third_party/eigen3/{} -p ; fi'
-       cd ${topdir}/build/eigen/src/eigen && find . -type f ! -name  '*.cc' ! -name '*.cpp' ! -name '*.c' -exec cp {} ${buildroot}${_includedir}/${name}/third_party/eigen3/{} -aPv \;
-
-       cd ${topdir}/build && cp -p nsync/install/include/*.h ${buildroot}${_includedir}/${name}/
+       sed -i -e "s:@libdir@:${_libdir}:g" -e "s:@includedir@:${_includedir}/tensorflow:g" ${buildroot}${_libdir}/pkgconfig/tensorflow.pc
 
 
 binary: build install
index a14053b6ee98e63de197bc8804ae273d464527a6..9c6c422349b2690ee24ad001a4753aef0e0dd558 100644 (file)
@@ -21,7 +21,13 @@ if (systemlib_GRPC)
   set(grpc_STATIC_LIBRARIES libgrpc.a libgrpc++.a libaddress_sorting.a libgpr.a)
   message("GRPC_LIBRARIES : [${GRPC_LIBRARIES}]")
 
-  pkg_search_module(GPR REQUIRED gpr)
+  # Some distros do not provide gpr.pc with grpc
+  pkg_search_module(GPR QUIET gpr)
+  if (GPR_FOUND)
+  else (GPR_FOUND)
+    set(GPR_LIBRARIES gpr)
+  endif (GPR_FOUND)
+
   pkg_search_module(GRPCPP REQUIRED grpc++)
   set(GRPC_LIBRARIES ${GRPC_LIBRARIES} ${GPR_LIBRARIES} ${GRPCPP_LIBRARIES})