build_helper.fb_folly 4.93 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
################################################################################
# Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The OpenAirInterface Software Alliance licenses this file to You under
# the OAI Public License, Version 1.1  (the "License"); you may not use this file
# except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.openairinterface.org/?page_id=698
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------
# For more information about the OpenAirInterface (OAI) Software Alliance:
#      contact@openairinterface.org
################################################################################

# file build_helper.fb_folly
# brief
# author Lionel GAUTHIER
#
#######################################
SCRIPT=$(readlink -f ${BASH_SOURCE})
THIS_SCRIPT_PATH=`dirname $SCRIPT`
source $THIS_SCRIPT_PATH/build_helper

#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_fb_folly_from_source(){
  if [ $1 -eq 0 ]; then
    OPTION=""
    read -p "Do you want to install FaceBook folly (github)? <y/N> " prompt
  else
    prompt='y'
    OPTION="-y"
  fi
  if [ $2 -eq 0 ]; then
    debug=0
  else
    debug=1
  fi


  if [[ $prompt =~ [yY](es)* ]]
  then
    if [[ "$OS_BASEDISTRO" == "fedora" ]]; then 
      $SUDO $INSTALLER install $OPTION \
        gcc-c++ \
        $CMAKE \
        boost-devel \
        libevent-devel \
        double-conversion-devel \
        glog-devel \
        gflags-devel \
        snappy-devel \
        make \
        lz4-devel \
        zlib-devel \
        binutils-devel \
        jemalloc-devel \
        openssl-devel \
        pkg-config
      ret=$?;[[ $ret -ne 0 ]] && return $ret
    elif [[ $OS_DISTRO == "ubuntu" ]]; then
      $SUDO $INSTALLER install $OPTION \
        g++ \
        cmake \
        libboost-all-dev \
        libevent-dev \
        libdouble-conversion-dev \
        libgoogle-glog-dev \
        libgflags-dev \
        libiberty-dev \
        liblz4-dev \
        liblzma-dev \
        libsnappy-dev \
        make \
        zlib1g-dev \
        binutils-dev \
        libjemalloc-dev \
        libssl-dev \
        pkg-config
      ret=$?;[[ $ret -ne 0 ]] && return $ret
    fi

    pushd /tmp

    if [ $debug -eq 1 ]; then
      # For advanced debugging options
      $SUDO $INSTALLER install $OPTION \
        libunwind8-dev \
        libelf-dev \
        libdwarf-dev
      ret=$?;[[ $ret -ne 0 ]] && return $ret
      
      wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz && \
      tar zxf release-1.8.0.tar.gz && \
      rm -f release-1.8.0.tar.gz && \
      cd googletest-release-1.8.0 && \
      $CMAKE . && \
      make && \
      $SUDO make install
      ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
      cd ..
    fi

    
    $SUDO rm -rf /tmp/folly
    git clone https://github.com/facebook/folly.git
    ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
    cd folly
    if [[ "$OS_BASEDISTRO" == "fedora" ]]; then
      git checkout -f v2019.06.17.00
      echo 'diff --git a/build/fbcode_builder/CMake/FindGflags.cmake b/build/fbcode_builder/CMake/FindGflags.cmake' > patch.diff
      echo 'index 246ceac..3b96716 100644' >> patch.diff
      echo '--- a/build/fbcode_builder/CMake/FindGflags.cmake' >> patch.diff
      echo '+++ b/build/fbcode_builder/CMake/FindGflags.cmake' >> patch.diff
      echo '@@ -34,6 +34,9 @@ IF (LIBGFLAGS_INCLUDE_DIR)' >> patch.diff
      echo ' ENDIF ()' >> patch.diff
      echo '' >> patch.diff
      echo ' find_package(gflags CONFIG QUIET)' >> patch.diff
      echo '+get_filename_component (_LIB_PATH "${gflags_CONFIG}/../../../" ABSOLUTE)' >> patch.diff
      echo '+unset(gflags_LIBRARIES)' >> patch.diff
      echo '+find_library(gflags_LIBRARIES gflags PATHS ${_LIB_PATH})' >> patch.diff
      echo ' if (gflags_FOUND)' >> patch.diff
      echo '   if (NOT Gflags_FIND_QUIETLY)' >> patch.diff
      echo '     message(STATUS "Found gflags from package config ${gflags_CONFIG}")' >> patch.diff
      git apply patch.diff
    else
      git checkout -f v2019.11.11.00
    fi 
    mkdir _build && cd _build
    if [[ "$OS_BASEDISTRO" == "fedora" ]]; then
      cmake3  ..
    else
      cmake  ..
    fi
    ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
    make -j $(nproc)
    ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
    $SUDO make install
    ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
    popd
  fi
  echo_success "End of folly installation"
  return 0
}