From d151ce6feb8fe73da39f3c8cf2870a9bbd45c0c4 Mon Sep 17 00:00:00 2001
From: frtabu <francois.taburet@nokia-bell-labs.com>
Date: Mon, 5 Nov 2018 17:28:00 +0100
Subject: [PATCH] Add a parameter to load_configmodule API to allow an exec to
 specify that it may be run with only  command line options

---
 cmake_targets/build_oai                  | 6 +++---
 common/config/config_load_configmodule.c | 8 ++++----
 common/config/config_load_configmodule.h | 5 +++--
 openair1/SIMULATION/LTE_PHY/dlsim.c      | 2 +-
 openair1/SIMULATION/LTE_PHY/ulsim.c      | 2 +-
 targets/RT/USER/lte-softmodem.c          | 2 +-
 targets/RT/USER/lte-uesoftmodem.c        | 4 ++--
 7 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai
index 51d6ac6d016..c6f8199af25 100755
--- a/cmake_targets/build_oai
+++ b/cmake_targets/build_oai
@@ -651,9 +651,9 @@ function main() {
     compilations \
           lte-simulators coding \
           libcoding.so $dbin/libcoding.so
-    compilations \
-	  lte-simulators $config_libconfig_shlib \
-	  lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
+#    compilations \
+#	  lte-simulators $config_libconfig_shlib \
+#	  lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
   fi
 
   # Core simulators
diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c
index cfb6e38440f..15211aec8a0 100644
--- a/common/config/config_load_configmodule.c
+++ b/common/config/config_load_configmodule.c
@@ -169,7 +169,7 @@ int config_cmdlineonly_get(paramdef_t *cfgoptions,int numoptions, char *prefix )
   return numdefvals;
 }
 
-configmodule_interface_t *load_configmodule(int argc, char **argv)
+configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags)
 {
 char *cfgparam=NULL;
 char *modeparams=NULL;
@@ -208,10 +208,10 @@ int OoptIdx=-1;
 /* oad_configmodule function */
   if (cfgparam == NULL) {
     tmpflags = tmpflags | CONFIG_NOOOPT;
-    if (strstr(argv[0],"uesoftmodem") == NULL || strstr(argv[0],"lsim") == NULL) {
-       cfgparam = CONFIG_LIBCONFIGFILE ":" DEFAULT_CFGFILENAME;
+    if ( initflags &  CONFIG_ENABLECMDLINEONLY) {
+       cfgparam = CONFIG_CMDLINEONLY ":dbgl0" ;
     } else {
-      cfgparam = CONFIG_CMDLINEONLY ":dbgl0" ;         
+      cfgparam = CONFIG_CMDLINEONLY ":dbgl0" ;cfgparam = CONFIG_LIBCONFIGFILE ":" DEFAULT_CFGFILENAME;         
     }
   }
  
diff --git a/common/config/config_load_configmodule.h b/common/config/config_load_configmodule.h
index 1f4ebde92d2..d98e8250956 100644
--- a/common/config/config_load_configmodule.h
+++ b/common/config/config_load_configmodule.h
@@ -106,8 +106,9 @@ extern configmodule_interface_t *cfgptr;
 #define printf_params(...) if ( (cfgptr->rtflags & (CONFIG_PRINTPARAMS)) != 0 )  { printf ( __VA_ARGS__ ); }
 #define printf_ptrs(...)   if ( (cfgptr->rtflags & (CONFIG_DEBUGPTR)) != 0 )     { printf ( __VA_ARGS__ ); }     
 #define printf_cmdl(...)   if ( (cfgptr->rtflags & (CONFIG_DEBUGCMDLINE)) != 0 ) { printf ( __VA_ARGS__ ); }
- 
-extern configmodule_interface_t *load_configmodule(int argc, char **argv);
+
+#define CONFIG_ENABLECMDLINEONLY  (1<<1)
+extern configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags);
 extern void end_configmodule(void);
 
 #endif  /* INCLUDE_CONFIG_LOADCONFIGMODULE_H */
diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c
index 0f4655eb2c7..246bdd70078 100644
--- a/openair1/SIMULATION/LTE_PHY/dlsim.c
+++ b/openair1/SIMULATION/LTE_PHY/dlsim.c
@@ -988,7 +988,7 @@ int main(int argc, char **argv)
   if (transmission_mode>1) pa=dBm3;
   printf("dlsim: tmode %d, pa %d\n",transmission_mode,pa);
 
-  AssertFatal(load_configmodule(argc,argv) != NULL,
+  AssertFatal(load_configmodule(argc,argv, CONFIG_ENABLECMDLINEONLY) != NULL,
 	      "cannot load configuration module, exiting\n");
   logInit();
   set_glog_onlinelog(true);
diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c
index c015063b605..53a2c22f15d 100644
--- a/openair1/SIMULATION/LTE_PHY/ulsim.c
+++ b/openair1/SIMULATION/LTE_PHY/ulsim.c
@@ -429,7 +429,7 @@ int main(int argc, char **argv) {
   cpu_freq_GHz = (double)get_cpu_freq_GHz();
   cpuf = cpu_freq_GHz;
   printf("Detected cpu_freq %f GHz\n",cpu_freq_GHz);
-  AssertFatal(load_configmodule(argc,argv) != NULL,
+  AssertFatal(load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) != NULL,
               "cannot load configuration module, exiting\n");
   logInit();
   // enable these lines if you need debug info
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 00ae350ea27..4cf257f3535 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -695,7 +695,7 @@ int main( int argc, char **argv )
 #if defined (XFORMS)
   int ret;
 #endif
-  if ( load_configmodule(argc,argv) == NULL) {
+  if ( load_configmodule(argc,argv,0) == NULL) {
     exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
   } 
       
diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c
index 2306dbc7252..593b64ea400 100644
--- a/targets/RT/USER/lte-uesoftmodem.c
+++ b/targets/RT/USER/lte-uesoftmodem.c
@@ -761,7 +761,7 @@ int main( int argc, char **argv )
 #endif
 
   start_background_system();
-  if ( load_configmodule(argc,argv) == NULL) {
+  if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) {
     exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
   } 
       
@@ -887,7 +887,7 @@ int main( int argc, char **argv )
 
 
   if (simL1flag==1) {
-    AssertFatal(NULL!=load_configmodule(argc,argv),
+    AssertFatal(NULL!=load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY),
                 "[SOFTMODEM] Error, configuration module init failed\n");
 
     RCConfig_sim();
-- 
GitLab