mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[Server] Build the server startup once for every server executable (#7863)
This commit is contained in:
parent
9315a4aa6d
commit
a6d5dd5275
3 changed files with 42 additions and 13 deletions
|
|
@ -39,8 +39,10 @@ cockatrice_disable_coverage_for(
|
||||||
src/smtp/qxthmac.cpp src/smtp/qxtmailattachment.cpp src/smtp/qxtmailmessage.cpp src/smtp/qxtsmtp.cpp
|
src/smtp/qxthmac.cpp src/smtp/qxtmailattachment.cpp src/smtp/qxtmailmessage.cpp src/smtp/qxtsmtp.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(servatrice_PLATFORM_SOURCES)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(servatrice_SOURCES ${servatrice_SOURCES} servatrice.rc)
|
set(servatrice_PLATFORM_SOURCES ${servatrice_PLATFORM_SOURCES} servatrice.rc)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
# Under FreeBSD we need libexecinfo to use backtrace_symbols_fd()
|
# Under FreeBSD we need libexecinfo to use backtrace_symbols_fd()
|
||||||
|
|
@ -54,7 +56,7 @@ if(APPLE)
|
||||||
set_source_files_properties(
|
set_source_files_properties(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources
|
${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources
|
||||||
)
|
)
|
||||||
set(servatrice_SOURCES ${servatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
|
set(servatrice_PLATFORM_SOURCES ${servatrice_PLATFORM_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
qt_add_resources(servatrice_RESOURCES_RCC ${servatrice_RESOURCES})
|
qt_add_resources(servatrice_RESOURCES_RCC ${servatrice_RESOURCES})
|
||||||
|
|
@ -106,22 +108,37 @@ set(DESKTOPDIR
|
||||||
CACHE STRING "desktop file destination"
|
CACHE STRING "desktop file destination"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Build servatrice binary and link it
|
# The startup path, shared by the shipped binary and the dev server.
|
||||||
add_executable(servatrice MACOSX_BUNDLE ${servatrice_MOC_SRCS} ${servatrice_RESOURCES_RCC} ${servatrice_SOURCES})
|
set(servatrice_CORE_SOURCES ${servatrice_SOURCES})
|
||||||
|
list(REMOVE_ITEM servatrice_CORE_SOURCES src/main.cpp)
|
||||||
|
list(APPEND servatrice_CORE_SOURCES src/servatrice_globals.cpp)
|
||||||
|
|
||||||
target_precompile_headers(servatrice PRIVATE "${CMAKE_SOURCE_DIR}/cmake/pch/qtcore_pch.h")
|
add_library(servatrice_core OBJECT ${servatrice_MOC_SRCS} ${servatrice_CORE_SOURCES})
|
||||||
|
|
||||||
|
target_precompile_headers(servatrice_core PRIVATE "${CMAKE_SOURCE_DIR}/cmake/pch/qtcore_pch.h")
|
||||||
|
|
||||||
if(CMAKE_HOST_SYSTEM MATCHES "FreeBSD")
|
if(CMAKE_HOST_SYSTEM MATCHES "FreeBSD")
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
servatrice libcockatrice_deck_list libcockatrice_network_server_remote Threads::Threads ${SERVATRICE_QT_MODULES}
|
servatrice_core PUBLIC libcockatrice_deck_list libcockatrice_network_server_remote Threads::Threads
|
||||||
${LIBEXECINFO_LIBRARY}
|
${SERVATRICE_QT_MODULES} ${LIBEXECINFO_LIBRARY}
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
servatrice libcockatrice_deck_list libcockatrice_network_server_remote Threads::Threads ${SERVATRICE_QT_MODULES}
|
servatrice_core PUBLIC libcockatrice_deck_list libcockatrice_network_server_remote Threads::Threads
|
||||||
|
${SERVATRICE_QT_MODULES}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Build servatrice binary and link it
|
||||||
|
add_executable(
|
||||||
|
servatrice MACOSX_BUNDLE ${servatrice_MOC_SRCS} ${servatrice_PLATFORM_SOURCES} ${servatrice_RESOURCES_RCC}
|
||||||
|
src/main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_precompile_headers(servatrice PRIVATE "${CMAKE_SOURCE_DIR}/cmake/pch/qtcore_pch.h")
|
||||||
|
|
||||||
|
target_link_libraries(servatrice PRIVATE servatrice_core)
|
||||||
|
|
||||||
# install rules
|
# install rules
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#include "libcockatrice/rng/rng_abstract.h"
|
#include "libcockatrice/rng/rng_abstract.h"
|
||||||
#include "servatrice.h"
|
#include "servatrice.h"
|
||||||
#include "server_logger.h"
|
#include "server_logger.h"
|
||||||
|
|
@ -51,12 +53,7 @@
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
RNG_Abstract *rng;
|
|
||||||
ServerLogger *logger;
|
|
||||||
QThread *loggerThread;
|
|
||||||
SettingsCache *settingsCache;
|
|
||||||
SignalHandler *signalhandler;
|
SignalHandler *signalhandler;
|
||||||
SmtpClient *smtpClient;
|
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
|
|
||||||
|
|
|
||||||
15
servatrice/src/servatrice_globals.cpp
Normal file
15
servatrice/src/servatrice_globals.cpp
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include "libcockatrice/rng/rng_abstract.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "server_logger.h"
|
||||||
|
#include "settingscache.h"
|
||||||
|
#include "smtpclient.h"
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
// Process-wide services the server sources reach through these pointers. They are defined here, not
|
||||||
|
// in main.cpp, so that every executable sharing servatrice_core sees the same instances.
|
||||||
|
RNG_Abstract *rng = nullptr;
|
||||||
|
ServerLogger *logger = nullptr;
|
||||||
|
QThread *loggerThread = nullptr;
|
||||||
|
SettingsCache *settingsCache = nullptr;
|
||||||
|
SmtpClient *smtpClient = nullptr;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue