Reorganize directories and switch libaries to using asn1c
[it/test.git] / simulators / e2sim / build_e2sim
index a24ba14..ede61a7 100755 (executable)
 #!/bin/bash
-#
-#
-# Copyright 2019 AT&T Intellectual Property
-# Copyright 2019 Nokia
-#
-# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
-#
-# 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.
-#
-# build utility for E2 Agent
+#/*****************************************************************************
+#                                                                            *
+# Copyright 2019 AT&T Intellectual Property                                  *
+# Copyright 2019 Nokia                                                       *
+#                                                                            *
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0                            *
+#                                                                            *
+# 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.                                             *
+#                                                                            *
+#******************************************************************************/
 
 set -e
 
-E2SIM_DIR=$PWD
-ASN1_C_DIR=$E2SIM_DIR/build/CMakeFiles/ASN1
-
+E2SIM_VERSION='1.3.0'
+export E2SIM_DIR=$PWD
 source $E2SIM_DIR/tools/build_helper.bash
+DOCKER_IMAGE='e2sim'
 
-print_help()
-{
+print_help() {
   echo "
     This program installs E2 Simulator
     You should have ubuntu 14.xx, updated, and the Linux kernel >= 3.14
     The program is run by default with no option
 
-    Options
+    USAGE:
+      ./build_e2sim [OPTIONS]
+
+    OPTIONS:
     --clean
        Erase all files to make a rebuild from start
+    --docker
+       Build docker image
     -h
        Print this help
     "
 }
 
-generate_asn1c_codes()
-{
-  X2AP_RELEASE="R14"
-  X2AP_ASN_FILES="x2ap-14.6.0.asn1"
-  ASN_SOURCE_X2AP=$E2SIM_DIR/src/X2AP/MESSAGES/ASN1/${X2AP_RELEASE}/${X2AP_ASN_FILES}
-
-  ASN_SOURCE_Pendulum=$E2SIM_DIR/src/ONS2019/pendulum.asn1
-
-  done_flag="$ASN1_C_DIR"/done
-
-  #-ot = older than, -nt = newer than
-
-  if [ "$done_flag" -ot $ASN_SOURCE_X2AP ] ; then
-    echo_info "Generate C codes for from source file"
-    #echo_info $ASN_SOURCE
-
-    rm -f "$ASN1_C_DIR"/*.c "$ASN1_C_DIR"/*.h
-    mkdir -p $ASN1_C_DIR
-    asn1c -pdu=all -fcompound-names -gen-PER -no-gen-OER -no-gen-example \
-                -fno-include-deps -D $ASN1_C_DIR $ASN_SOURCE_X2AP  \
-                |& egrep -v "^Copied|^Compiled" | sort -u
-
-    asn1c -pdu=all -fcompound-names -gen-PER -no-gen-OER -no-gen-example \
-                -fno-include-deps -D $ASN1_C_DIR $ASN_SOURCE_Pendulum  \
-                |& egrep -v "^Copied|^Compiled" | sort -u
-
-    echo_success "ASN1 C codes generated at: $ASN1_C_DIR"
-  fi
-  touch $done_flag
-}
-
-install_rmr()
-{
-  echo_info "Will install rmr library"
-  /bin/bash rmr_interface/rmr_install.sh
-}
-
-compile_asn_api_lib()
-{
-  echo_info "Will complie ASN1_API library"
-  # rm -rf build/libASN1_API.a
-  # rm -rf build/asn_x2ap.o
-  # rm -rf build/asn_e2ap.o
-
-  g++ -O3  -std=c++14 -Wall \
-    -I./src/ASN1/ -I./src/ASN1/asn/ -I./src/ASN1/generated/  \
-    -c src/ASN1/lib/asn_e2ap.cpp \
-    -o build/asn_e2ap.o
-    ar -crv build/libASN1_API.a build/asn_e2ap.o
-
-  g++ -O3  -std=c++14 -Wall \
-    -I./src/ASN1/ -I./src/ASN1/asn/ -I./src/ASN1/generated/  \
-    -c src/ASN1/lib/asn_x2ap.cpp \
-    -o build/asn_x2ap.o
-    ar -crv build/libASN1_API.a build/asn_x2ap.o
-}
-
-function main()
-{
-
+function main(){
   case "$1" in
     --clean)
       echo_info "Will clean all previously producted files under build/"
@@ -108,17 +53,13 @@ function main()
       exit
       ;;
 
-    "")
-      ;;
-
-    --rmr)
-      install_rmr
+    --docker)
+      echo "Will build docker image ${DOCKER_IMAGE}:${E2SIM_VERSION}"
+      sudo docker build -f docker/Dockerfile -t $DOCKER_IMAGE:$E2SIM_VERSION .
       exit
       ;;
 
-    --lib)
-      compile_asn_api_lib
-      exit
+    "")
       ;;
 
     -h)
@@ -132,11 +73,6 @@ function main()
 
   BUILD_DIR=$E2SIM_DIR/build
   mkdir -p $BUILD_DIR
-  mkdir -p $BUILD_DIR/log
-
-  # generate_asn1c_codes #X2AP, pendulum
-
-  compile_asn_api_lib
 
   echo_info "Will build e2sim"
   cd $BUILD_DIR
@@ -145,7 +81,6 @@ function main()
   make -j`nproc`
 
   echo_success "e2sim compiled"
-
 }
 
 main "$@"