build_test_epc_tools 4.46 KB
Newer Older
1
#!/bin/bash
2 3 4 5 6
#/*
# * 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
7
# * the OAI Public License, Version 1.1  (the "License"); you may not use this file
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# * 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
# */

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
# file build_test_epc_tools
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
################################
# include helper functions
################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
source $THIS_SCRIPT_PATH/build_helper

function help()
{
  echo_error " "
  echo_error "Usage: build_test_epc_tools [OPTION]..."
  echo_error "Build the executables for generating and running a test case for EPC."
  echo_error " "
  echo_error "Options:"
  echo_error "Mandatory arguments to long options are mandatory for short options too."
  echo_error "  -c, --clean                               Clean the build generated files (build from scratch)"
  echo_error "  -d, --debug                               Compile with debug informations."
  echo_error "  -h, --help                                Print this help."
  echo_error "  -v, --verbose                             Build process verbose."
  echo_error " "
}



function main()
{
  local -i clean=0
  local -i verbose=0
  local    cmake_args=" "
  local    make_args="-j $NUM_CPU"
  local    realm=""


  until [ -z "$1" ]
    do
    case "$1" in
      -c | --clean)
        clean=1
        echo "Clean the build generated files (build from scratch)"
        shift;
        ;;
      -d | --debug)
        cmake_args="$cmake_args -DDEBUG=1"
        echo "Compile with debug informations"
        shift;
        ;;
      -h | --help)
        help
        shift;
        exit 0
        ;;
      -v | --verbose)
        echo "Make build process verbose"
        cmake_args="$cmake_args -DCMAKE_VERBOSE_MAKEFILE=ON"
        make_args="VERBOSE=1 $make_args"
        verbose=1
        shift;
        ;;
      *)   
        echo "Unknown option $1"
        help
        exit 1
        ;;
    esac
  done
  



  set_openair_env 
  if [[ $verbose -eq 1 ]]; then
    cecho "OPENAIR_DIR    = $OPENAIR_DIR" $green
  fi
    
  local dbin=$OPENAIR_DIR/targets/bin
  local dlog=$OPENAIR_DIR/cmake_targets/log
  local dconf=$OPENAIR_DIR/targets/bin
  
  mkdir -m 777 -p $dbin $dlog
  
  ##############################################################################
  # Compile userspace executable
  ##############################################################################
  cd $OPENAIR_DIR/cmake_targets/epc_test
  if [ $clean -ne 0 ]; then
    if [[ $verbose -eq 1 ]]; then
      echo "Cleaning TEST_EPC"
    fi
    rm -f $OPENAIR_DIR/targets/bin/test_epc_generate_scenario
117
    rm -f $OPENAIR_DIR/targets/bin/test_epc_play_scenario
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
    rm -Rf build 2>&1
    mkdir -m 777 -p -v build
  fi
  
  ##############################################################################
  # Compile EPC
  ##############################################################################
  cd $OPENAIR_DIR/cmake_targets/epc_test
  if [ ! -d ./build ]; then
    mkdir -m 777 -p -v build
  fi
  cmake_file=./CMakeLists.txt
  cp $OPENAIR_DIR/cmake_targets/epc_test/CMakeLists.template $cmake_file
  echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
  cd ./build
  cmake  $cmake_args ..
  compilations \
      epc_test test_epc_generate_scenario \
      test_epc_generate_scenario $dbin/test_epc_generate_scenario
137

138 139 140
  compilations \
      epc_test test_epc_play_scenario \
      test_epc_play_scenario $dbin/test_epc_play_scenario
141 142 143
      
  $SUDO cp -upv test_epc_generate_scenario /usr/local/bin
  $SUDO cp -upv test_epc_play_scenario     /usr/local/bin
144 145 146 147 148
}


main "$@"