From 8ab33355ed164bbaaafb94318eb8452e87a7959b Mon Sep 17 00:00:00 2001
From: Laurent Thomas <lts@open-cells.com>
Date: Mon, 6 Dec 2021 17:02:45 +0100
Subject: [PATCH] Clean up build_oai and CMakeLists.txt

- Remove useless RU and PHYSIM variables
- provide function to trigger ASN.1 file generation
---
 cmake_targets/CMakeLists.txt                | 186 ++++++--------------
 cmake_targets/build_oai                     |  37 +---
 openair1/PHY/TOOLS/time_meas.c              |  11 +-
 openair1/PHY/TOOLS/time_meas.h              |   8 +-
 openair1/SCHED_NR_UE/phy_procedures_nr_ue.c |  49 +-----
 5 files changed, 76 insertions(+), 215 deletions(-)

diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 6e960cce232..329ed7bb3da 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -69,8 +69,6 @@ elseif (${RF_BOARD} STREQUAL "OAI_AW2SORI")
 
 endif (${RF_BOARD} STREQUAL "OAI_USRP")
 
-message("RU=${RU}")
-
 pkg_search_module(OPENPGM openpgm-5.1 openpgm-5.2)
 if(NOT ${OPENPGM_FOUND})
   message("PACKAGE openpgm-5.1 is required by binaries such as oaisim: will fail later if this target is built")
@@ -270,6 +268,22 @@ function(make_version VERSION_VALUE)
   endforeach()
   set(${VERSION_VALUE} "${RESULT}" PARENT_SCOPE)
 endfunction()
+
+macro(compile_asn1 asn1Source asn1cCmd ResultFlag)
+   # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
+   execute_process(COMMAND ${asn1cCmd}  ${asn1Source} RESULT_VARIABLE ret)
+
+   if (NOT ${ret} STREQUAL 0)
+      message(FATAL_ERROR "${ret}: error")
+   endif (NOT ${ret} STREQUAL 0)
+
+   add_custom_target (
+     ${ResultFlag} ALL
+     ${asn1cCmd} ${asn1Source}
+     DEPENDS ${asn1Source}
+   )
+endmacro(compile_asn1)
+
 ####################################################
 # compilation flags
 #############################################
@@ -434,23 +448,11 @@ set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-15.6.
 add_definitions(-DLTE_RRC_VERSION=${LTE_RRC_VERSION})
 set (RRC_FULL_DIR ${asn1_generated_dir}/RRC_${RRC_ASN1_VERSION})
 
-# Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
-if (${RU} STREQUAL 0)
-  execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "LTE_" " " "${RRC_FULL_DIR}" "${RRC_GRAMMAR}"
-                  RESULT_VARIABLE ret)
-endif (${RU} STREQUAL 0)
-
-if (NOT ${ret} STREQUAL 0)
-  message(FATAL_ERROR "${ret}: error")
-endif (NOT ${ret} STREQUAL 0)
-file(GLOB rrc_source ${RRC_FULL_DIR}/*.c)
-add_custom_target (
-  rrc_flag ALL
-  ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "LTE_" " " "${RRC_FULL_DIR}" "${RRC_GRAMMAR}"
-  DEPENDS ${RRC_GRAMMAR}
-  )
+set(rrc_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "LTE_" " " "${RRC_FULL_DIR}")
+
+compile_asn1("${RRC_GRAMMAR}" "${rrc_cmd}" rrc_flag)
 
-set_source_files_properties(${rrc_source} PROPERTIES COMPILE_FLAGS -w) # suppress warnings from generated code
+file(GLOB rrc_source ${RRC_FULL_DIR}/*.c)
 add_library(RRC_LIB ${rrc_source}
     ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg.c
     ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c)
@@ -467,21 +469,12 @@ add_definitions(-DNR_RRC_VERSION=${NR_RRC_VERSION})
 set (NR_RRC_FULL_DIR ${asn1_generated_dir}/RRC_${NR_RRC_ASN1_VERSION})
 
 # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
-  execute_process(
-    COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NR_" "-findirect-choice" "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}"
-    RESULT_VARIABLE ret)
-if (NOT ${ret} STREQUAL 0)
-  message(FATAL_ERROR "${ret}: error")
-endif ()
-file(GLOB nr_rrc_source ${NR_RRC_FULL_DIR}/*.c)
-file(GLOB nr_rrc_h ${NR_RRC_FULL_DIR}/*.h)
+set(nr_rrc_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NR_" "-findirect-choice" "${NR_RRC_FULL_DIR}")
 
-add_custom_target (
-  nr_rrc_flag ALL
-  ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "NR_" "-findirect-choice" "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}"
-  DEPENDS ${NR_RRC_GRAMMAR}
-  )
+compile_asn1("${NR_RRC_GRAMMAR}" "${nr_rrc_cmd}"  nr_rrc_flag)
 
+file(GLOB nr_rrc_source ${NR_RRC_FULL_DIR}/*.c)
+file(GLOB nr_rrc_h ${NR_RRC_FULL_DIR}/*.h)
 add_library(NR_RRC_LIB ${nr_rrc_h} ${nr_rrc_source}
     ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c
     )
@@ -503,22 +496,11 @@ set(S1AP_ASN_DIR ${S1AP_DIR}/MESSAGES/ASN1/${S1AP_RELEASE})
 set(S1AP_C_DIR ${asn1_generated_dir}/S1AP_${S1AP_RELEASE})
 
 # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
-if (${RU} STREQUAL 0)
-  execute_process(
-    COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "S1AP_" -fno-include-deps "${S1AP_C_DIR}" "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}"
-    RESULT_VARIABLE ret)
-  if (NOT ${ret} STREQUAL 0)
-    message(FATAL_ERROR "${ret}: error")
-  endif (NOT ${ret} STREQUAL 0)
-  file(GLOB S1AP_source ${S1AP_C_DIR}/*.c)
-endif (${RU} STREQUAL 0)
+set(s1ap_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "S1AP_" -fno-include-deps "${S1AP_C_DIR}")
 
-  add_custom_target (
-    s1ap_flag ALL
-    ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "S1AP_" -fno-include-deps "${S1AP_C_DIR}" "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}"
-    DEPENDS  "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}"
-  )
+compile_asn1("${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" "${s1ap_cmd}"  s1ap_flag)
 
+file(GLOB S1AP_source ${S1AP_C_DIR}/*.c)
 add_library(S1AP_LIB
   ${S1AP_source}
   ${S1AP_DIR}/s1ap_common.c
@@ -560,20 +542,11 @@ set(NGAP_ASN_DIR ${NGAP_DIR}/MESSAGES/ASN1/ASN1_files)
 set(NGAP_C_DIR ${asn1_generated_dir}/NGAP_${NGAP_RELEASE})
 
 # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
-execute_process(
-  COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NGAP_" "-fno-include-deps -findirect-choice" "${NGAP_C_DIR}" "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}"
-  RESULT_VARIABLE ret)
-if (NOT ${ret} STREQUAL 0)
-  message(FATAL_ERROR "${ret}: error")
-endif (NOT ${ret} STREQUAL 0)
-file(GLOB NGAP_source ${NGAP_C_DIR}/*.c)
+set (ngap_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NGAP_" "-fno-include-deps -findirect-choice" "${NGAP_C_DIR}")
 
-add_custom_target (
-  ngap_flag ALL
-  ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "NGAP_" "-fno-include-deps -findirect-choice" "${NGAP_C_DIR}" "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}"
-  DEPENDS  "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}"
-)
+compile_asn1("${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" "${ngap_cmd}"  ngap_flag)
 
+file(GLOB NGAP_source ${NGAP_C_DIR}/*.c)
 add_library(NGAP_LIB
   ${NGAP_source}
 #  ${NGAP_DIR}/ngap_common.c
@@ -627,23 +600,10 @@ set(M2AP_ASN_DIR ${M2AP_DIR}/MESSAGES/ASN1/${M2AP_RELEASE})
 set(M2AP_C_DIR ${asn1_generated_dir}/M2AP_${M2AP_RELEASE})
 
 # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
-if (${RU} STREQUAL 0)
-  execute_process(
-    COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "M2AP_" "-fno-include-deps -DEMIT_ASN_DEBUG=1" "${M2AP_C_DIR}" "${M2AP_ASN_DIR}/${M2AP_ASN_FILES}"
-    RESULT_VARIABLE ret)
-  if (NOT ${ret} STREQUAL 0)
-    message(FATAL_ERROR "${ret}: error")
-  endif (NOT ${ret} STREQUAL 0)
-endif (${RU} STREQUAL 0)
+set(m2ap_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "M2AP_" "-fno-include-deps -DEMIT_ASN_DEBUG=1" "${M2AP_C_DIR}")
 
+compile_asn1("${M2AP_ASN_DIR}/${M2AP_ASN_FILES}" "${m2ap_cmd}"  m2_flag)
 file(GLOB M2AP_source ${M2AP_C_DIR}/*.c)
-
-add_custom_target (
-  m2_flag ALL
-  COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "M2AP_" "-fno-include-deps -DEMIT_ASN_DEBUG=1" "${M2AP_C_DIR}" "${M2AP_ASN_DIR}/${M2AP_ASN_FILES}"
-  DEPENDS ${M2AP_ASN_DIR}/${M2AP_ASN_FILES}
-  )
-
 add_library(M2AP_LIB
   ${M2AP_source}
   ${M2AP_DIR}/m2ap_common.c
@@ -700,22 +660,11 @@ set(M3AP_ASN_DIR ${M3AP_DIR}/MESSAGES/ASN1/${M3AP_RELEASE})
 set(M3AP_C_DIR ${asn1_generated_dir}/M3AP_${M3AP_RELEASE})
 
 # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
-if (${RU} STREQUAL 0)
-  execute_process(
-    COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "M3AP_" -fno-include-deps "${M3AP_C_DIR}" "${M3AP_ASN_DIR}/${M3AP_ASN_FILES}"
-    RESULT_VARIABLE ret)
-  if (NOT ${ret} STREQUAL 0)
-    message(FATAL_ERROR "${ret}: error")
-  endif (NOT ${ret} STREQUAL 0)
-endif (${RU} STREQUAL 0)
+set(m3_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "M3AP_" -fno-include-deps "${M3AP_C_DIR}")
 
-file(GLOB M3AP_source ${M3AP_C_DIR}/*.c)
+compile_asn1("${M3AP_ASN_DIR}/${M3AP_ASN_FILES}" "${m3_cmd}"  m3_flag)
 
-add_custom_target (
-  m3_flag ALL
-  COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh  "M3AP_" -fno-include-deps "${M3AP_C_DIR}" "${M3AP_ASN_DIR}/${M3AP_ASN_FILES}"
-  DEPENDS ${M3AP_ASN_DIR}/${M3AP_ASN_FILES}
-  )
+file(GLOB M3AP_source ${M3AP_C_DIR}/*.c)
 
 add_library(M3AP_LIB
   ${M3AP_source}
@@ -757,22 +706,11 @@ add_definitions(-DX2AP_VERSION=${X2AP_VERSION})
 set(X2AP_ASN_DIR ${X2AP_DIR}/MESSAGES/ASN1/${X2AP_RELEASE})
 set(X2AP_C_DIR ${asn1_generated_dir}/X2AP_${X2AP_RELEASE})
 # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
-if (${RU} STREQUAL 0)
-  execute_process(
-    COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "X2AP_" -fno-include-deps "${X2AP_C_DIR}" "${X2AP_ASN_DIR}/${X2AP_ASN_FILES}"
-    RESULT_VARIABLE ret)
-  if (NOT ${ret} STREQUAL 0)
-    message(FATAL_ERROR "${ret}: error")
-  endif (NOT ${ret} STREQUAL 0)
-endif (${RU} STREQUAL 0)
+set(x2_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "X2AP_" -fno-include-deps "${X2AP_C_DIR}")
 
-file(GLOB X2AP_source ${X2AP_C_DIR}/*.c)
+compile_asn1("${X2AP_ASN_DIR}/${X2AP_ASN_FILES}" "${x2_cmd}"  x2_flag)
 
-add_custom_target (
-  x2_flag ALL
-  COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "X2AP_" -fno-include-deps "${X2AP_C_DIR}" "${X2AP_ASN_DIR}/${X2AP_ASN_FILES}"
-  DEPENDS ${X2AP_ASN_DIR}/${X2AP_ASN_FILES}
-  )
+file(GLOB X2AP_source ${X2AP_C_DIR}/*.c)
 
 add_library(X2AP_LIB
   ${X2AP_source}
@@ -817,36 +755,23 @@ set(F1AP_ASN_FILES
   ${F1AP_ASN_DIR}/F1AP-Containers.asn
   )
 
-if (${RU} STREQUAL 0)
-  set(F1AP_ASN_GENERATED_C_DIR ${asn1_generated_dir}/F1AP_${ASN1RELDIR})
-  message("calling ASN1C_PREFIX=F1AP_ asn1c -gen-PER -no-gen-OER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps -D ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES}")
-  execute_process(
-    COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "F1AP_" "-findirect-choice -fno-include-deps" ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES}
-    RESULT_VARIABLE ret
-    )
-  
-  if (NOT ${ret} STREQUAL 0)
-    message(FATAL_ERROR "asn1c: error")
-  endif (NOT ${ret} STREQUAL 0)
-  
-  add_custom_target (
-    f1_flag ALL
-    COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "F1AP_" "-findirect-choice -fno-include-deps" ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES}
-    DEPENDS ${F1AP_ASN_FILES}
-    )
-  file(GLOB F1AP_ASN_GENERATED_C_FILES ${F1AP_ASN_GENERATED_C_DIR}/*.c)
-  add_library(F1AP_LIB
-    ${F1AP_ASN_GENERATED_C_FILES}
-    )
-  add_dependencies (F1AP_LIB  f1_flag)
-  
-  include_directories ("${F1AP_ASN_GENERATED_C_DIR}")
-  include_directories ("${F1AP_DIR}")
-  
-  file(GLOB F1AP_C_FILES ${F1AP_DIR}/*.c)
-  add_library(F1AP ${F1AP_C_FILES} )
-  
-endif (${RU} STREQUAL 0)
+set(F1AP_ASN_GENERATED_C_DIR ${asn1_generated_dir}/F1AP_${ASN1RELDIR})
+
+set(f1_cmd ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "F1AP_" "-findirect-choice -fno-include-deps" "${F1AP_ASN_GENERATED_C_DIR}")
+
+compile_asn1("${F1AP_ASN_FILES}" "${f1_cmd}" f1_flag)
+
+file(GLOB F1AP_ASN_GENERATED_C_FILES ${F1AP_ASN_GENERATED_C_DIR}/*.c)
+add_library(F1AP_LIB
+  ${F1AP_ASN_GENERATED_C_FILES}
+  )
+add_dependencies (F1AP_LIB  f1_flag)
+
+include_directories ("${F1AP_ASN_GENERATED_C_DIR}")
+include_directories ("${F1AP_DIR}")
+
+file(GLOB F1AP_C_FILES ${F1AP_DIR}/*.c)
+add_library(F1AP ${F1AP_C_FILES} )
 
 # Hardware dependant options
 ###################################
@@ -1036,7 +961,6 @@ add_boolean_option(DRIVER2013              True "only relevant for EXMIMO")
 add_boolean_option(EXMIMO_IOT              True "????")
 add_boolean_option(LOCALIZATION            False "???")
 add_integer_option(MAX_NUM_CCs             1     "????")
-add_boolean_option(PHYSIM                  False  "for L1 simulators (dlsim, ulsim, ...)")
 add_boolean_option(SMBV                    False "Rohde&Schwarz SMBV100A vector signal generator")
 add_boolean_option(DEBUG_PHY               False "Enable PHY layer debugging options")
 add_boolean_option(DEBUG_PHY_PROC          False "Enable debugging of PHY layer procedures")
diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai
index 5c833c502a9..b427b161e58 100755
--- a/cmake_targets/build_oai
+++ b/cmake_targets/build_oai
@@ -27,9 +27,8 @@
 set -e
 
 # Include helper functions
-ORIGIN_PATH=$PWD
-THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
-source $THIS_SCRIPT_PATH/tools/build_helper
+THIS_SCRIPT_PATH=$(dirname $(readlink -f "$0"))
+source "$THIS_SCRIPT_PATH"/tools/build_helper
 
 # Set environment variables (OPENAIR_HOME, ...)
 set_openair_env
@@ -38,7 +37,6 @@ set_openair_env
 gen_nvram_path=$OPENAIR_DIR/targets/bin
 conf_nvram_path=$OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf
 
-MSC_GEN=0
 XFORMS="True"
 SKIP_SHARED_LIB_FLAG="False"
 UE_EXPANSION="False"
@@ -106,7 +104,7 @@ Options
 --nrUE
   Makes the NR UE softmodem
 --RU
-  Makes the OAI RRU (without full stack)
+  Makes the OAI RRU
 --UE
    Makes the UE specific parts (ue_ip, usim, nvram) from the given configuration file
 --UE-conf-nvram [configuration file]
@@ -208,28 +206,24 @@ function main() {
        -g | --run-with-gdb)
             case "$2" in
                 "Release")
-                    GDB=0
                     CMAKE_BUILD_TYPE="Release"
                     echo_info "Will Compile without gdb symbols and with compiler optimization"
                     CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Release"
                     shift
                     ;;
                 "RelWithDebInfo")
-                    GDB=0
                     CMAKE_BUILD_TYPE="RelWithDebInfo"
                     echo_info "Will Compile with gdb symbols"
                     CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=1"
                     shift
                     ;;
                 "MinSizeRel")
-                    GDB=0
                     CMAKE_BUILD_TYPE="MinSizeRel"
                     echo_info "Will Compile for minimal exec size"
                     CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=MinSizeRel"
                     shift
                     ;;
                 "Debug" | *)
-                    GDB=1
                     CMAKE_BUILD_TYPE="Debug"
                     echo_info "Will Compile with gdb symbols and disable compiler optimization"
                     CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Debug"
@@ -244,37 +238,30 @@ function main() {
             shift;;
        --eNB)
             eNB=1
-            RU=0
             echo_info "Will compile eNB"
             shift;;
        --eNBocp)
             eNBocp=1
-            RU=0
             echo_info "Will compile OCP eNB"
             shift;;
       --gNB)
             gNB=1
-            RU=0
-            NR="True"
             echo_info "Will compile gNB"
             shift;;
        --RU)
-	          RU=1
+            RU=1
             echo_info "Will compile RRU"
 	    shift;;
        -a | --agent)
             echo_info "FlexRAN support is always compiled into the eNB"
             shift;;
        --UE)
-            RU=0
             UE=1
             echo_info "Will compile UE"
             shift;;
        --nrUE)
-            RU=0
             nrUE=1
             rfsimNas=1
-            NR="True"
             echo_info "Will compile NR UE"
             shift;;
        --mu)
@@ -282,10 +269,10 @@ function main() {
             echo_info "Will compile with UE_EXPANSION"
             shift;;
        --UE-conf-nvram)
-            conf_nvram_path=$(readlink -f $2)
+            conf_nvram_path=$(readlink -f "$2")
             shift 2;;
        --UE-gen-nvram)
-            gen_nvram_path=$(readlink -f $2)
+            gen_nvram_path=$(readlink -f "$2")
             shift 2;;
        -w | --hardware)
             # Use OAI_USRP as the key word USRP is used inside UHD driver           
@@ -309,7 +296,6 @@ function main() {
             shift 2;;
        -P | --phy_simulators)
             SIMUS_PHY=1
-	          RU=0
             echo_info "Will compile dlsim, ulsim, ..."
             shift;;
        -S | --core_simulators)
@@ -344,11 +330,11 @@ function main() {
             echo_info "Will compile hw latency test program"
             shift;;
        --verbose-ci)
-	        VERBOSE_CI=1
+            VERBOSE_CI=1
             echo_info "Will compile with verbose instructions in CI Docker env"
             shift;;
        --verbose-compile)
-	        VERBOSE_COMPILE=1
+            VERBOSE_COMPILE=1
             echo_info "Will compile with verbose instructions"
             shift;;
        --cflags_processor)
@@ -478,7 +464,7 @@ function main() {
   ########################################################
   # to be discussed
   
-  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$gNB" = "1" -o "$RU" = "1" ] ; then
+  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$gNB" = "1" ] ; then
       if [ "$HW" = "None" -a  "$TP" = "None" ] ; then
 	      echo_info "No local radio head and no transport protocol selected"
       fi
@@ -629,7 +615,6 @@ function main() {
     echo "set ( UE_TIMING_TRACE $UE_TIMING_TRACE )"                       >> $cmake_file
     echo "set ( USRP_REC_PLAY $USRP_REC_PLAY )"                           >> $cmake_file
     echo "set ( SKIP_SHARED_LIB_FLAG $SKIP_SHARED_LIB_FLAG )"             >> $cmake_file
-    echo "set ( RU $RU )"                                                 >> $cmake_file
     echo "set ( ITTI_SIM $ITTI_SIM )"                                     >> $cmake_file
     echo "set ( SANITIZE_ADDRESS $SANITIZE_ADDRESS )"                     >> $cmake_file
     echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)'         >> $cmake_file
@@ -677,14 +662,10 @@ function main() {
         $build_dir $config_libconfig_shlib \
         lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
 
-      if [ "$RU" = "0" ] ; then
-
         compilations \
           $build_dir coding \
           libcoding.so $dbin/libcoding.so
 
-
-      fi
     fi
   fi
 
diff --git a/openair1/PHY/TOOLS/time_meas.c b/openair1/PHY/TOOLS/time_meas.c
index 996f7fb2777..1b62687f7ef 100644
--- a/openair1/PHY/TOOLS/time_meas.c
+++ b/openair1/PHY/TOOLS/time_meas.c
@@ -25,20 +25,17 @@
 #include <unistd.h>
 #include <string.h>
 #include "assertions.h"
-#ifndef PHYSIM
-  #include <pthread.h>
-  #include "common/config/config_userapi.h"
-#endif
+#include <pthread.h>
+#include "common/config/config_userapi.h"
+#include <common/utils/threadPool/thread-pool.h>
 // global var for openair performance profiler
 int opp_enabled = 0;
 double cpu_freq_GHz  __attribute__ ((aligned(32)));
 
 double cpu_freq_GHz  __attribute__ ((aligned(32)))=0.0;
-#ifndef PHYSIM
 static uint32_t    max_cpumeasur;
 static time_stats_t  **measur_table;
 notifiedFIFO_t measur_fifo;
-#endif
 double get_cpu_freq_GHz(void)
 {
   if (cpu_freq_GHz <1 ) {
@@ -187,7 +184,6 @@ double get_time_meas_us(time_stats_t *ts)
   return 0;
 }
 
-#ifndef PHYSIM
 /* function for the asynchronous measurment module: cpu stat are sent to a dedicated thread
  * which is in charge of computing the cpu time spent in a given function/algorithm...
  */
@@ -294,4 +290,3 @@ void end_meas(void) {
     msg->msgid = TIMESTAT_MSGID_END ;
     pushNotifiedFIFO(&measur_fifo, nfe);
 }
-#endif
diff --git a/openair1/PHY/TOOLS/time_meas.h b/openair1/PHY/TOOLS/time_meas.h
index 1ef2935917d..bb2bb3d2764 100644
--- a/openair1/PHY/TOOLS/time_meas.h
+++ b/openair1/PHY/TOOLS/time_meas.h
@@ -31,9 +31,7 @@
 #include <pthread.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
-#ifndef PHYSIM
-  #include "common/utils/threadPool/thread-pool.h"
-#endif
+#include "common/utils/threadPool/thread-pool.h"
 // global var to enable openair performance profiler
 extern int opp_enabled;
 extern double cpu_freq_GHz  __attribute__ ((aligned(32)));;
@@ -72,10 +70,8 @@ typedef struct {
   char *meas_name;           /*!< \brief name to use when printing the measure (not used for PHY simulators)*/
   int meas_index;            /*!< \brief index of this measure in the measure array (not used for PHY simulators)*/
   int meas_enabled;         /*!< \brief per measure enablement flag. send_meas tests this flag, unused today in start_meas and stop_meas*/
-#ifndef PHYSIM
   notifiedFIFO_elt_t *tpoolmsg; /*!< \brief message pushed to the cpu measurment queue to report a measure START or STOP */
   time_stats_msg_t *tstatptr;   /*!< \brief pointer to the time_stats_msg_t data in the tpoolmsg, stored here for perf considerations*/
-#endif
 } time_stats_t;
 #define MEASURE_ENABLED(X)       (X->meas_enabled)
 
@@ -165,7 +161,6 @@ static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts) {
   }
 }
 
-#ifndef PHYSIM
 extern notifiedFIFO_t measur_fifo;
 #define CPUMEASUR_SECTION "cpumeasur"
 
@@ -187,5 +182,4 @@ extern notifiedFIFO_t measur_fifo;
   }
   void end_meas(void);
 
-#endif  //ifndef PHYSIM
 #endif
diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
index 940931694c9..aa5c66c8f5c 100644
--- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
+++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
@@ -844,11 +844,7 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_
       } else AssertFatal(1==0,"Not RA_PDSCH, SI_PDSCH or PDSCH\n");
 
       stop_meas(&ue->dlsch_llr_stats_parallelization[proc->thread_id][slot]);
-#if PHYSIM
-      printf("[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",frame_rx,nr_slot_rx,m,ue->dlsch_llr_stats_parallelization[proc->thread_id][slot].p_time/(cpuf*1000.0));
-#else
       LOG_D(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",frame_rx,nr_slot_rx,m,ue->dlsch_llr_stats_parallelization[proc->thread_id][slot].p_time/(cpuf*1000.0));
-#endif
 
       if(first_symbol_flag) {
         proc->first_symbol_available = 1;
@@ -1028,17 +1024,11 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
 
 
       stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]);
-#if PHYSIM
-    printf(" --> Unscrambling for CW0 %5.3f\n",
-           (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0));
-    printf("AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n",
-           frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0));
-#else
+
     LOG_I(PHY, " --> Unscrambling for CW0 %5.3f\n",
           (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0));
     LOG_I(PHY, "AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n",
           frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0));
-#endif
 
     if(is_cw1_active) {
       // start ldpc decode for CW 1
@@ -1091,19 +1081,12 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
       }
 
 
-    stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]);
-#if PHYSIM
-      printf(" --> Unscrambling for CW1 %5.3f\n",
-             (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0));
-      printf("AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n",
-             frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0));
-#else
+      stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]);
+
       LOG_D(PHY, " --> Unscrambling for CW1 %5.3f\n",
             (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0));
       LOG_D(PHY, "AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n",
             frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0));
-#endif
-
 
       LOG_D(PHY,"AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n",
             frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0));
@@ -1413,11 +1396,8 @@ void *UE_thread_slot1_dl_processing(void *arg) {
 
 
     stop_meas(&ue->ue_front_end_per_slot_stat[proc->thread_id][1]);
-#if PHYSIM
-    printf("[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,nr_slot_rx,ue->ue_front_end_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0));
-#else
+
     LOG_D(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,nr_slot_rx,ue->ue_front_end_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0));
-#endif
 
 
     //wait until pdcch is decoded
@@ -1507,11 +1487,8 @@ void *UE_thread_slot1_dl_processing(void *arg) {
     //printf("Set available LLR slot1 to 1 AbsSubframe %d.%d \n",frame_rx,nr_slot_rx);
 
     stop_meas(&ue->pdsch_procedures_per_slot_stat[proc->thread_id][1]);
-#if PHYSIM
-    printf("[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,nr_slot_rx,ue->pdsch_procedures_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0));
-#else
+
     LOG_D(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,nr_slot_rx,ue->pdsch_procedures_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0));
-#endif
 
     if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) {
       LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
@@ -1881,14 +1858,9 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
 			   dlsch_parallel);
 
   stop_meas(&ue->dlsch_procedures_stat[proc->thread_id]);
-#if PHYSIM
-  printf("[SFN %d] Slot1:       Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0));
-  printf("[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0));
-#else
+
   LOG_D(PHY, "[SFN %d] Slot1:       Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0));
   LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0));
-#endif
-
 
 
   // deactivate dlsch once dlsch proc is done
@@ -1964,9 +1936,7 @@ if (nr_slot_rx==9) {
  }
 
 stop_meas(&ue->generic_stat);
-#if PHYSIM
-printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0));
-#endif
+ LOG_D(PHY,"after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0));
 
 #ifdef EMOS
 phy_procedures_emos_UE_RX(ue,slot,gNB_id);
@@ -1976,11 +1946,8 @@ phy_procedures_emos_UE_RX(ue,slot,gNB_id);
 VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT);
 
 stop_meas(&ue->phy_proc_rx[proc->thread_id]);
-#if PHYSIM
-printf("------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx[proc->thread_id].p_time/(cpuf*1000.0));
-#else
+
 LOG_D(PHY, "------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx[proc->thread_id].p_time/(cpuf*1000.0));
-#endif
 
 //#endif //pdsch
 
-- 
GitLab