From 1179703b6d3c7c03d3f168d00dd8bcea7fd5948f Mon Sep 17 00:00:00 2001 From: "Penn, John M 047828115" Date: Thu, 14 Oct 2021 18:17:04 -0500 Subject: [PATCH] Refactor civitweb linkage #1188 --- autoconf/configure.ac | 5 ++- configure | 37 ++++++++++++++++++- include/trick/MyCivetServer.hh | 2 +- .../trick}/WebSocketSession.hh | 4 +- share/trick/makefiles/Makefile.common | 4 +- .../include/VariableServerSession.hh | 2 +- .../web/CivetServer/src/MyCivetServer.cpp | 2 +- 7 files changed, 45 insertions(+), 11 deletions(-) rename {trick_source/web/CivetServer/include => include/trick}/WebSocketSession.hh (93%) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 848cbf8e..516525c1 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -105,9 +105,10 @@ AC_DEFUN([AX_CIVETWEB_HOME],[ AS_IF([test "$CIVETWEB_HOME" = "no"], [CIVETWEB_HOME=""], # else --with-civet was provided with a directory path. - AC_CHECK_FILE([$CIVETWEB_HOME/include/civetweb.h], + AC_CHECK_FILES([$CIVETWEB_HOME/include/civetweb.h $CIVETWEB_HOME/lib/libcivetweb.a], [USE_CIVETWEB="1"], - AC_MSG_ERROR([could not find $CIVETWEB_HOME/include/civetweb.h])))) + AC_MSG_ERROR([Could not find all of the civetweb files.])) + )) ], # --with option not provided. [AC_CHECK_HEADER(civetweb.h, diff --git a/configure b/configure index 32956fa6..f054c1e4 100755 --- a/configure +++ b/configure @@ -10159,10 +10159,43 @@ eval ac_res=\$$as_ac_File printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes" then : - USE_CIVETWEB="1" + +cat >>confdefs.h <<_ACEOF +#define `printf "%s\n" "HAVE_$CIVETWEB_HOME/include/civetweb.h" | $as_tr_cpp` 1 +_ACEOF +USE_CIVETWEB="1" else $as_nop - as_fn_error $? "could not find $CIVETWEB_HOME/include/civetweb.h" "$LINENO" 5 + as_fn_error $? "Could not find all of the civetweb files." "$LINENO" 5 fi +as_ac_File=`printf "%s\n" "ac_cv_file_$CIVETWEB_HOME/lib/libcivetweb.a" | $as_tr_sh` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CIVETWEB_HOME/lib/libcivetweb.a" >&5 +printf %s "checking for $CIVETWEB_HOME/lib/libcivetweb.a... " >&6; } +if eval test \${$as_ac_File+y} +then : + printf %s "(cached) " >&6 +else $as_nop + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "$CIVETWEB_HOME/lib/libcivetweb.a"; then + eval "$as_ac_File=yes" +else + eval "$as_ac_File=no" +fi +fi +eval ac_res=\$$as_ac_File + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_File"\" = x"yes" +then : + +cat >>confdefs.h <<_ACEOF +#define `printf "%s\n" "HAVE_$CIVETWEB_HOME/lib/libcivetweb.a" | $as_tr_cpp` 1 +_ACEOF +USE_CIVETWEB="1" +else $as_nop + as_fn_error $? "Could not find all of the civetweb files." "$LINENO" 5 +fi + fi fi diff --git a/include/trick/MyCivetServer.hh b/include/trick/MyCivetServer.hh index bc8374d5..5e5a2855 100644 --- a/include/trick/MyCivetServer.hh +++ b/include/trick/MyCivetServer.hh @@ -12,8 +12,8 @@ PURPOSE: (Represent the state and initial conditions of an http server.) #include #include #include +#include "trick/WebSocketSession.hh" -class WebSocketSession; typedef WebSocketSession* (*WebSocketSessionMaker)(struct mg_connection *nc); typedef void (*httpMethodHandler)(struct mg_connection *, void* cbdata); diff --git a/trick_source/web/CivetServer/include/WebSocketSession.hh b/include/trick/WebSocketSession.hh similarity index 93% rename from trick_source/web/CivetServer/include/WebSocketSession.hh rename to include/trick/WebSocketSession.hh index 5caaba48..e1b1b15d 100644 --- a/trick_source/web/CivetServer/include/WebSocketSession.hh +++ b/include/trick/WebSocketSession.hh @@ -4,7 +4,6 @@ PURPOSE: (Represent Websocket connection.) #ifndef WEB_SOCKET_SESSION_HH #define WEB_SOCKET_SESSION_HH -#if USE_CIVETWEB #include #ifndef SWIG #include "civet/CivetServer.h" @@ -24,8 +23,7 @@ class WebSocketSession { virtual void sendMessage()=0; virtual int handleMessage(std::string)=0; - struct mg_connection* connection; + struct mg_connection* connection; /* ** */ }; #endif -#endif diff --git a/share/trick/makefiles/Makefile.common b/share/trick/makefiles/Makefile.common index d8dd88e5..c7a32e5a 100644 --- a/share/trick/makefiles/Makefile.common +++ b/share/trick/makefiles/Makefile.common @@ -174,9 +174,11 @@ ifneq ($(GSL_HOME),) endif ifeq (${USE_CIVETWEB},1) - TRICK_LIBS += ${CIVETWEB_HOME}/libcivetweb.a ${TRICK_LIB_DIR}/libtrickCivet.a + TRICK_LIBS += -ltrickCivet + TRICK_EXEC_LINK_LIBS += -L${CIVETWEB_HOME}/lib -lcivetweb -lz TRICK_SWIG_FLAGS += -DUSE_CIVETWEB TRICK_SYSTEM_CXXFLAGS += -DUSE_CIVETWEB + TRICK_SYSTEM_ICG_EXCLUDE += ${CIVETWEB_HOME} endif # We pipe the output of compiler through tee. If the user wanted gcc color, make sure they get it. diff --git a/trick_source/web/CivetServer/include/VariableServerSession.hh b/trick_source/web/CivetServer/include/VariableServerSession.hh index 6c9d55ea..2c7421c8 100644 --- a/trick_source/web/CivetServer/include/VariableServerSession.hh +++ b/trick_source/web/CivetServer/include/VariableServerSession.hh @@ -12,7 +12,7 @@ PURPOSE: (Represent the state of a variable server websocket connection.) #include "civet/CivetServer.h" #endif -#include "WebSocketSession.hh" +#include "trick/WebSocketSession.hh" #include "VariableServerVariable.hh" class VariableServerSession : public WebSocketSession { diff --git a/trick_source/web/CivetServer/src/MyCivetServer.cpp b/trick_source/web/CivetServer/src/MyCivetServer.cpp index b8755dc5..9c27e8aa 100644 --- a/trick_source/web/CivetServer/src/MyCivetServer.cpp +++ b/trick_source/web/CivetServer/src/MyCivetServer.cpp @@ -18,7 +18,7 @@ PURPOSE: (Represent the state and initial conditions for my server) #include "trick/exec_proto.h" #include "simpleJSON.hh" #include "VariableServerSession.hh" -#include "WebSocketSession.hh" +#include "trick/WebSocketSession.hh" #ifndef SWIG #include "civet/CivetServer.h"