added a build option to remove the generated code's dependency to libcurses
authorBotond Baranyi <botond.baranyi@ericsson.com>
Tue, 14 Jun 2016 14:10:39 +0000 (16:10 +0200)
committerBotond Baranyi <botond.baranyi@ericsson.com>
Tue, 14 Jun 2016 14:10:39 +0000 (16:10 +0200)
Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
Makefile.cfg
compiler2/makefile.c
core/DebuggerUI.cc
core/DebuggerUI.hh
core/Makefile

index f1f38d454ed55588d0771df9897c0d2a8e01cad1..53425f351f20bc5aa3d1167497914415778b9feb 100644 (file)
@@ -58,6 +58,11 @@ DEBUG := no
 # Set it to 'yes' to generate coverage data (requires DEBUG=yes)
 COVERAGE := no
 
+# Set it to 'yes' to enable extra features for the debugger UI in single mode
+# (this requires an extra library when linking the generated code).
+# Set it to 'no' to use a simplified debugger UI.
+ADVANCED_DEBUGGER_UI := yes
+
 # Your platform. Allowed values: SOLARIS, SOLARIS8, LINUX, FREEBSD,
 # WIN32. Decided automagically if not defined (recommended).
 # PLATFORM :=
@@ -215,6 +220,10 @@ ifeq ($(COVERAGE), yes)
   LDFLAGS += -fprofile-arcs -ftest-coverage -lgcov
 endif
 
+ifeq ($(ADVANCED_DEBUGGER_UI), yes)
+  CPPFLAGS += -DADVANCED_DEBUGGER_UI
+endif
+
 # Directory which contains the code for POSIX regular expression handling.
 # It is needed on platforms where the system's libc does not support POSIX
 # regexps. This is the case for Mingw.
index 7d54fb21f9193bc0c340cecd4a41a87f93237971..a72983066d029f0c669661619542641a89081e20 100644 (file)
@@ -2942,9 +2942,12 @@ static void print_makefile(struct makefile_struct *makefile)
       "# Platform specific additional libraries:\n"
       "#\n", fp);
 
-    fputs("SOLARIS_LIBS = -lsocket -lnsl -lxml2 -lcurses", fp);
+    fputs("SOLARIS_LIBS = -lsocket -lnsl -lxml2", fp);
 #ifdef USAGE_STATS
     fputs(" -lresolv", fp);
+#endif
+#ifdef ADVANCED_DEBUGGER_UI
+    fputs(" -lcurses", fp);
 #endif
     if (makefile->solspeclibraries) {
       struct string_list* act_elem = makefile->solspeclibraries;
@@ -2957,9 +2960,12 @@ static void print_makefile(struct makefile_struct *makefile)
     }
     fputs("\n", fp);
 
-    fputs("SOLARIS8_LIBS = -lsocket -lnsl -lxml2 -lcurses", fp);
+    fputs("SOLARIS8_LIBS = -lsocket -lnsl -lxml2", fp);
 #ifdef USAGE_STATS
     fputs(" -lresolv", fp);
+#endif
+#ifdef ADVANCED_DEBUGGER_UI
+    fputs(" -lcurses", fp);
 #endif
     if (makefile->sol8speclibraries) {
       struct string_list* act_elem = makefile->sol8speclibraries;
@@ -2972,9 +2978,12 @@ static void print_makefile(struct makefile_struct *makefile)
     }
     fputs("\n", fp);
 
-    fputs("LINUX_LIBS = -lxml2 -lncurses", fp);
+    fputs("LINUX_LIBS = -lxml2", fp);
 #ifdef USAGE_STATS
     fputs(" -lpthread -lrt", fp);
+#endif
+#ifdef ADVANCED_DEBUGGER_UI
+    fputs(" -lncurses", fp);
 #endif
     if (makefile->linuxspeclibraries) {
       struct string_list* act_elem = makefile->linuxspeclibraries;
@@ -2987,7 +2996,10 @@ static void print_makefile(struct makefile_struct *makefile)
     }
     fputs("\n", fp);
 
-    fputs("FREEBSD_LIBS = -lxml2 -lncurses", fp);
+    fputs("FREEBSD_LIBS = -lxml2", fp);
+#ifdef ADVANCED_DEBUGGER_UI
+    fputs(" -lncurses", fp);
+#endif
     if (makefile->freebsdspeclibraries) {
       struct string_list* act_elem = makefile->freebsdspeclibraries;
       while (act_elem) {
@@ -2999,7 +3011,10 @@ static void print_makefile(struct makefile_struct *makefile)
     }
     fputs("\n", fp);
 
-    fputs("WIN32_LIBS = -lxml2 -lncurses", fp);
+    fputs("WIN32_LIBS = -lxml2", fp);
+#ifdef ADVANCED_DEBUGGER_UI
+    fputs(" -lncurses", fp);
+#endif
     if (makefile->win32speclibraries) {
       struct string_list* act_elem = makefile->win32speclibraries;
       while (act_elem) {
index 08509aa4e6727201a0e1a46f8301fdec131f997b..37b75e7c0bd30e1e8440264c46c25a255ccbf120 100644 (file)
 #include "DebuggerUI.hh"
 #include "DebugCommands.hh"
 #include "Debugger.hh"
-#include "../mctr2/editline/libedit/src/editline/readline.h"
 #include <stdio.h>
 #include <ctype.h>
 
+#ifdef ADVANCED_DEBUGGER_UI
+#include "../mctr2/editline/libedit/src/editline/readline.h"
+// use a different file, than the MCTR CLI, since not all commands are the same
+#define TTCN3_HISTORY_FILENAME ".ttcn3_history_single"
+#endif
+
 #define PROMPT_TEXT "DEBUG> "
 #define BATCH_TEXT "batch"
 #define HELP_TEXT "help"
 
-// use a different file, than the MCTR CLI, since not all commands are the same
-#define TTCN3_HISTORY_FILENAME ".ttcn3_history_single"
-
 const TTCN_Debugger_UI::command_t TTCN_Debugger_UI::debug_command_list[] = {
   { D_SWITCH_TEXT, D_SWITCH, D_SWITCH_TEXT " on|off",
     "Switch the debugger on or off." },
@@ -82,7 +84,9 @@ const TTCN_Debugger_UI::command_t TTCN_Debugger_UI::debug_command_list[] = {
   { NULL, D_ERROR, NULL, NULL }
 };
 
+#ifdef ADVANCED_DEBUGGER_UI
 char* TTCN_Debugger_UI::ttcn3_history_filename = NULL;
+#endif
 
 /** local function for extracting the command name and its arguments from an
   * input line
@@ -114,7 +118,9 @@ void TTCN_Debugger_UI::process_command(const char* p_line_read)
     // empty command
     return;
   }
+#ifdef ADVANCED_DEBUGGER_UI
   add_history(p_line_read + start);
+#endif
   for (const command_t *command = debug_command_list; command->name != NULL;
        ++command) {
     if (!strncmp(p_line_read + start, command->name, end - start)) {
@@ -199,6 +205,7 @@ void TTCN_Debugger_UI::help(const char* p_argument)
 
 void TTCN_Debugger_UI::init()
 {
+#ifdef ADVANCED_DEBUGGER_UI
   // initialize history library
   using_history();
   // calculate history file name
@@ -211,25 +218,38 @@ void TTCN_Debugger_UI::init()
   read_history(ttcn3_history_filename);
   // set our own command completion function
   rl_completion_entry_function = (Function*)complete_command;
+#endif
 }
 
 void TTCN_Debugger_UI::clean_up()
 {
+#ifdef ADVANCED_DEBUGGER_UI
   if (write_history(ttcn3_history_filename)) {
     puts("Could not save debugger command history.");
   }
   Free(ttcn3_history_filename);
+#endif
 }
 
 void TTCN_Debugger_UI::read_loop()
 {
   while (ttcn3_debugger.is_halted()) {
+#ifdef ADVANCED_DEBUGGER_UI
     // print the prompt and read a line using the readline(), which
     // automatically handles command completion and command history
     char* line = readline(PROMPT_TEXT);
     if (line != NULL) {
+#else
+    // simplified debugger UI: use a simple fgets
+    printf(PROMPT_TEXT);
+    char line[1024];
+    char* res = fgets(line, sizeof(line), stdin);
+    if (res != NULL) {
+#endif
       process_command(line);
+#ifdef ADVANCED_DEBUGGER_UI     
       free(line);
+#endif
     }
     else {
       // EOF was received -> exit all
@@ -276,6 +296,7 @@ void TTCN_Debugger_UI::print(const char* p_str)
   puts(p_str);
 }
 
+#ifdef ADVANCED_DEBUGGER_UI
 char* TTCN_Debugger_UI::complete_command(const char* p_prefix, int p_state)
 {
   static int command_index;
@@ -296,4 +317,5 @@ char* TTCN_Debugger_UI::complete_command(const char* p_prefix, int p_state)
   }
   // no match found
   return NULL;
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
index f81513c8f153e81c7b5c097003005f3538130a1e..627d68226ca8cdf271ddbc59a25091b8319ce1db 100644 (file)
@@ -34,9 +34,11 @@ class TTCN_Debugger_UI {
   
   /** list of commands */
   static const command_t debug_command_list[];
-  
+
+#ifdef ADVANCED_DEBUGGER_UI
   /** name of the file, where the command history is stored */
   static char* ttcn3_history_filename;
+#endif
   
   /** processes the command in the specified input line
     * if it's a valid command, then it is added to the command history and 
@@ -44,6 +46,7 @@ class TTCN_Debugger_UI {
     * if it's not valid, an error message is displayed */
   static void process_command(const char* p_line_read);
   
+  /** displays help for the specified command, or lists available commands */
   static void help(const char* p_argument);
   
 public:
@@ -65,8 +68,10 @@ public:
   /** prints the specified text to the standard output */
   static void print(const char* p_str);
   
+#ifdef ADVANCED_DEBUGGER_UI
   /** command completion function for editline */
   static char* complete_command(const char* p_prefix, int p_state);
+#endif
 };
 
 #endif /* DEBUGGER_UI_HH */
index ea118e12aa206413c3f1ef79ae2c5a8c814d055a..138423bf5aba8c94e2c29dc68690e3c07781372c 100644 (file)
@@ -75,12 +75,21 @@ TTCN_COMPILER_FLAGS += -o $(APIDIR)
 # -I. is needed because TitanLoggerApi.hh (generated) does #include <TTCN3.hh>
 CPPFLAGS += -I. -I$(APIDIR)
 
-SOLARIS_LIBS   := -lsocket -lnsl -lxml2 -lcurses
-SOLARIS8_LIBS  := -lsocket -lnsl -lxml2 -lcurses
-LINUX_LIBS     := -lxml2 -lncurses
-FREEBSD_LIBS   := -lxml2 -lncurses
-WIN32_LIBS     := -lxml2 -lncurses
-INTERIX_LIBS   := -lxml2 -lncurses
+SOLARIS_LIBS   := -lsocket -lnsl -lxml2
+SOLARIS8_LIBS  := -lsocket -lnsl -lxml2
+LINUX_LIBS     := -lxml2
+FREEBSD_LIBS   := -lxml2
+WIN32_LIBS     := -lxml2
+INTERIX_LIBS   := -lxml2
+       
+ifeq ($(ADVANCED_DEBUGGER_UI), yes)
+  SOLARIS_LIBS   += -lcurses
+  SOLARIS8_LIBS  += -lcurses
+  LINUX_LIBS     += -lncurses
+  FREEBSD_LIBS   += -lncurses
+  WIN32_LIBS     += -lncurses
+  INTERIX_LIBS   += -lncurses
+endif
 
 ifeq ($(USAGE_STATS), yes)
   SOLARIS_LIBS  += -lresolv
@@ -170,10 +179,12 @@ ifeq ($(USAGE_STATS), yes)
   COMMON_OBJECTS += ../common/usage_stats.o
 endif
 
+ifeq ($(ADVANCED_DEBUGGER_UI), yes)
 EDITLINE_OBJECTS := $(addprefix ../mctr2/editline/build/src/.libs/, chared.o common.o \
 emacs.o fgetln.o help.o history.o map.o prompt.o read.o search.o strlcat.o term.o tty.o \
 vi.o wcsdup.o chartype.o el.o fcns.o filecomplete.o hist.o key.o parse.o readline.o \
 refresh.o sig.o strlcpy.o tokenizer.o unvis.o vis.o)
+endif
 
 LIBRARY_OBJECTS_NOMAIN := $(filter-out Single_main.o Parallel_main.o ProfMerge_main.o, \
   $(OBJECTS)) $(COMMON_OBJECTS) $(EDITLINE_OBJECTS)
This page took 0.0306 seconds and 5 git commands to generate.