[mapguide-commits] r9696 - in sandbox/jng/ogc_viewer_representation: Web/src Web/src/DevHttpServer cmake/modules
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jul 29 08:38:46 PDT 2020
Author: jng
Date: 2020-07-29 08:38:45 -0700 (Wed, 29 Jul 2020)
New Revision: 9696
Added:
sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/CMakeLists.txt
sandbox/jng/ogc_viewer_representation/cmake/modules/FindCppHttpLib.cmake
Modified:
sandbox/jng/ogc_viewer_representation/Web/src/CMakeLists.txt
sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/main.cpp
sandbox/jng/ogc_viewer_representation/cmake/modules/FindMapGuideThirdparty.cmake
Log:
Initial Linux build support
Modified: sandbox/jng/ogc_viewer_representation/Web/src/CMakeLists.txt
===================================================================
--- sandbox/jng/ogc_viewer_representation/Web/src/CMakeLists.txt 2020-07-29 14:51:55 UTC (rev 9695)
+++ sandbox/jng/ogc_viewer_representation/Web/src/CMakeLists.txt 2020-07-29 15:38:45 UTC (rev 9696)
@@ -2,6 +2,7 @@
add_subdirectory(WebApp)
add_subdirectory(WebSupport)
add_subdirectory(HttpHandler)
+add_subdirectory(DevHttpServer)
#add_subdirectory(CgiAgent)
add_subdirectory(PhpApi)
if (WITH_JAVA)
Added: sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/CMakeLists.txt
===================================================================
--- sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/CMakeLists.txt (rev 0)
+++ sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/CMakeLists.txt 2020-07-29 15:38:45 UTC (rev 9696)
@@ -0,0 +1,28 @@
+project(devhttpserver)
+include_directories(
+ ${MG_COMMON_DIR} #For ProductVersion.h
+ ${MG_COMMON_DIR}/Foundation
+ ${MG_COMMON_DIR}/Geometry
+ ${MG_COMMON_DIR}/PlatformBase
+ ${MG_COMMON_DIR}/MapGuideCommon
+ ${MG_COMMON_DIR}/MdfModel
+ ${TCLAP_INCLUDE_DIR}
+ ${CPP_HTTPLIB_INCLUDE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../HttpHandler
+ ${CMAKE_CURRENT_SOURCE_DIR}/../WebSupport
+ ${CMAKE_CURRENT_SOURCE_DIR}/../MapAgentCommon
+)
+set(DevHttpServer_SRCS
+ main.cpp
+ ../MapAgentCommon/MapAgentCommon.cpp
+ ../MapAgentCommon/MapAgentGetParser.cpp
+ ../MapAgentCommon/MapAgentStrings.cpp
+)
+add_executable(MgDevHttpServer ${DevHttpServer_SRCS})
+target_link_libraries(MgDevHttpServer
+ MgFoundation${MG_VERSION_SUFFIX}
+ MgPlatformBase${MG_VERSION_SUFFIX}
+ MgMdfModel${MG_VERSION_SUFFIX}
+ MgMdfParser${MG_VERSION_SUFFIX}
+ MgHttpHandler${MG_VERSION_SUFFIX}
+ MgWebSupport${MG_VERSION_SUFFIX})
\ No newline at end of file
Modified: sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/main.cpp
===================================================================
--- sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/main.cpp 2020-07-29 14:51:55 UTC (rev 9695)
+++ sandbox/jng/ogc_viewer_representation/Web/src/DevHttpServer/main.cpp 2020-07-29 15:38:45 UTC (rev 9696)
@@ -478,6 +478,7 @@
#endif
#endif
+ STRING wcPath = L"webconfig.ini";
try
{
TCLAP::CmdLine cmd("MgDevHttpServer - Development HTTP Server for MapGuide", ' ', version);
@@ -484,9 +485,11 @@
TCLAP::ValueArg<std::string> argMentorPath("m", "mentor-dictionary-path", "The path to the CS-MAP dictionary data files. Not required if this path is set in webconfig.ini", false, "", "path");
TCLAP::ValueArg<int> argPort("p", "port", "The port this server will listen on", false, 8000, "integer");
+ TCLAP::ValueArg<std::string> argWebConfigPath("w", "webconfig-path", "The path to webconfig.ini", false, "webconfig.ini", "path");
cmd.add(argMentorPath);
cmd.add(argPort);
+ cmd.add(argWebConfigPath);
cmd.parse(argc, argv);
@@ -493,10 +496,14 @@
auto mentorPath = argMentorPath.getValue();
if (!mentorPath.empty())
{
+ printf("Setting MENTOR_DICTIONARY_PATH to (%s) in the event this value is not set in webconfig.ini\n", mentorPath.c_str());
+ #ifdef _WIN32
std::string envExpr = "MENTOR_DICTIONARY_PATH=";
envExpr += mentorPath;
- printf("Setting MENTOR_DICTIONARY_PATH to (%s) in the event this value is not set in webconfig.ini\n", mentorPath.c_str());
putenv(envExpr.c_str());
+ #else
+ setenv("MENTOR_DICTIONARY_PATH", mentorPath.c_str(), 1);
+ #endif
}
if (argPort.isSet())
@@ -503,6 +510,11 @@
{
port = argPort.getValue();
}
+
+ if (argWebConfigPath.isSet())
+ {
+ wcPath = MgUtil::MultiByteToWideChar(argWebConfigPath.getValue());
+ }
}
catch (TCLAP::ArgException& e)
{
@@ -514,7 +526,7 @@
{
MG_TRY()
- MgInitializeWebTier(L"webconfig.ini");
+ MgInitializeWebTier(wcPath);
bInit = true;
MG_CATCH(L"main")
@@ -526,26 +538,30 @@
}
}
- g_server.reset(new httplib::Server());
+ if (bInit)
+ {
+ g_server.reset(new httplib::Server());
- g_server->set_mount_point("/mapguide", "./wwwroot");
+ g_server->set_mount_point("/mapguide", "./wwwroot");
- g_server->Post("/mapguide/mapagent/mapagent.fcgi", MapAgentHandlerWithContentReader);
- g_server->Post("/mapguide/mapagent/mapagent.fcgi", MapAgentHandlerWithoutContentReader);
- g_server->Get("/mapguide/mapagent/mapagent.fcgi", MapAgentHandlerWithoutContentReader);
+ g_server->Post("/mapguide/mapagent/mapagent.fcgi", MapAgentHandlerWithContentReader);
+ g_server->Post("/mapguide/mapagent/mapagent.fcgi", MapAgentHandlerWithoutContentReader);
+ g_server->Get("/mapguide/mapagent/mapagent.fcgi", MapAgentHandlerWithoutContentReader);
- printf("Listening on port %d\n", port);
+ printf("Listening on port %d\n", port);
+
#ifdef _WIN32
- if (!SetConsoleCtrlHandler(ConsoleControlHandler, TRUE))
- {
- fprintf(stderr, "WARNING: Could not set console handler\n");
- }
+ if (!SetConsoleCtrlHandler(ConsoleControlHandler, TRUE))
+ {
+ fprintf(stderr, "WARNING: Could not set console handler\n");
+ }
#else
- signal(SIGINT, LinuxControlHandler);
+ signal(SIGINT, LinuxControlHandler);
#endif
- g_server->listen("localhost", port);
+ g_server->listen("localhost", port);
+ }
{
MG_TRY()
Added: sandbox/jng/ogc_viewer_representation/cmake/modules/FindCppHttpLib.cmake
===================================================================
--- sandbox/jng/ogc_viewer_representation/cmake/modules/FindCppHttpLib.cmake (rev 0)
+++ sandbox/jng/ogc_viewer_representation/cmake/modules/FindCppHttpLib.cmake 2020-07-29 15:38:45 UTC (rev 9696)
@@ -0,0 +1,23 @@
+# - Find CppHttpLib
+# Find the headers for the cpp-httplib library
+# This module defines
+# CPP_HTTPLIB_INCLUDE_DIR, where to find headers
+
+find_path(CPP_HTTPLIB_INCLUDE_DIR
+ NAMES "httplib.h"
+ PATHS
+ /usr/include
+ ${MG_OEM_ROOT_DIR}/cpp-httplib)
+
+include(FindPackageHandleStandardArgs)
+
+# handle the QUIETLY and REQUIRED arguments and set CppHttpLib_FOUND to TRUE if
+# all listed variables are TRUE
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(CppHttpLib DEFAULT_MSG CPP_HTTPLIB_INCLUDE_DIR)
+
+if (CppHttpLib_FOUND)
+ message(STATUS "Found cpp-httplib: ${CPP_HTTPLIB_INCLUDE_DIR}")
+endif (CppHttpLib_FOUND)
+
+mark_as_advanced(CPP_HTTPLIB_INCLUDE_DIR)
+
Modified: sandbox/jng/ogc_viewer_representation/cmake/modules/FindMapGuideThirdparty.cmake
===================================================================
--- sandbox/jng/ogc_viewer_representation/cmake/modules/FindMapGuideThirdparty.cmake 2020-07-29 14:51:55 UTC (rev 9695)
+++ sandbox/jng/ogc_viewer_representation/cmake/modules/FindMapGuideThirdparty.cmake 2020-07-29 15:38:45 UTC (rev 9696)
@@ -187,6 +187,7 @@
find_package(FDO REQUIRED)
find_package(TCLAP REQUIRED)
+find_package(CppHttpLib REQUIRED)
find_package(LinuxApt REQUIRED)
find_package(DbXmlInternal REQUIRED)
find_package(Ant REQUIRED)
\ No newline at end of file
More information about the mapguide-commits
mailing list