Skip to content

Commit

Permalink
WIP: Add preliminary SE sdk download helpers (Segs#906)
Browse files Browse the repository at this point in the history
* MSVC2017/2019 SE Sdk download helpers
* Update ACE to 6.5.7 + a test of including the editor_engine reference in
the build.
* editor executable driver.
  • Loading branch information
nemerle authored Feb 23, 2020
1 parent 86f354e commit 6f551e6
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ doxygen/
out/
3rd_party/include
3rd_party/lib
3rd_party/prebuilt
3rd_party/bin
3rd_party/gmock
3rd_party/naked_ace/
Temp/

#IDE generated project files
*.user
Expand Down
4 changes: 2 additions & 2 deletions 3rd_party/jcon-cpp/src/jcon/json_rpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "jcon_assert.h"
#include "string_util.h"

//#include <QSignalSpy>
#include <QtCore/QElapsedTimer>
#include <QCoreApplication>
#include <QUuid>

Expand Down Expand Up @@ -72,7 +72,7 @@ JsonRpcClient::waitForSyncCallbacks(const JsonRpcRequest* request)
std::make_shared<JsonRpcError>(code, message, data);
});

QTime timer;
QElapsedTimer timer;
timer.start();
while (m_outstanding_requests.contains(request->id()) &&
timer.elapsed() < m_call_timeout_ms)
Expand Down
3 changes: 2 additions & 1 deletion 3rd_party/jcon-cpp/src/jcon/json_rpc_websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QSignalSpy>
#include <QTime>
#include <QElapsedTimer>
#include <QWebSocket>

namespace jcon {
Expand Down Expand Up @@ -62,7 +63,7 @@ void JsonRpcWebSocket::connectToUrl(const QUrl& url)

bool JsonRpcWebSocket::waitForConnected(int msecs)
{
QTime timer(0, 0, 0, msecs);
QElapsedTimer timer;
QSignalSpy spy(m_socket, &QWebSocket::connected);
timer.start();
while (spy.isEmpty() && timer.elapsed() < msecs) {
Expand Down
Binary file modified 3rd_party/naked_ace.tgz
Binary file not shown.
1 change: 1 addition & 0 deletions 3rd_party/prebuilt/.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0.0
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/out)
set(CMAKE_INCLUDE_PATH ${MAIN_INCLUDE_PATH})
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeScripts;${CMAKE_MODULE_PATH})
set(CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/3rd_party/prebuilt")
set(UNICODE TRUE)
set(INSTALLED_TARGETS)
option(ENABLE_SCRIPTING_ENGINE "Build experimental scripting engine ?" ON)
Expand All @@ -88,6 +89,7 @@ option(BUILD_CLIENT_PATCH "Build client patch for AMD graphics cards ?" OFF)
########################################################################################
find_package(Threads REQUIRED)

include(SDKHelper)
include(3rdparty_support)
set(ThirdParty_Install_Dir ${CMAKE_BINARY_DIR}/3rd_party/built) # ERICEDIT: Changed to CMAKE_BINARY_DIR so that this variable always points to the top level of the build directory.
add_subdirectory(3rd_party)
Expand Down
49 changes: 49 additions & 0 deletions CMakeScripts/SDKHelper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# the following code is based on BSF's HelperMethods.cmake

set(SE_BINARY_DEP_WEBSITE "https://segs.dev/sdk")

function(update_binary_deps DEP_PREFIX DEP_NAME DEP_FOLDER DEP_VERSION)
if(NOT WIN32)
return()
endif()
set(DEP_TYPE VS2017)
# Clean and create a temporary folder
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_SOURCE_DIR}/Temp)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/Temp)

set(BINARY_DEPENDENCIES_URL ${SE_BINARY_DEP_WEBSITE}/${DEP_PREFIX}_${DEP_TYPE}_${DEP_VERSION}.7z)
file(DOWNLOAD ${BINARY_DEPENDENCIES_URL} ${PROJECT_SOURCE_DIR}/Temp/Dependencies.7z
SHOW_PROGRESS
STATUS DOWNLOAD_STATUS)

list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
if(NOT STATUS_CODE EQUAL 0)
message(FATAL_ERROR "Binary dependencies failed to download from URL: ${BINARY_DEPENDENCIES_URL}")
endif()

message(STATUS "Extracting files. Please wait...")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/Temp/unpack)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/Temp/Dependencies.7z
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Temp/unpack
)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${DEP_FOLDER})
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${DEP_FOLDER})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/Temp/unpack ${DEP_FOLDER})
# execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_SOURCE_DIR}/Temp)

endfunction()

function(check_and_update_binary_deps DEP_PREFIX DEP_NAME DEP_FOLDER DEP_VERSION)
set(BUILTIN_DEP_VERSION_FILE ${DEP_FOLDER}/.version)
if(NOT EXISTS ${BUILTIN_DEP_VERSION_FILE})
message(STATUS "Binary dependencies for '${DEP_PREFIX}' are missing. Downloading package...")
update_binary_deps(${DEP_PREFIX} ${DEP_NAME} ${DEP_FOLDER} ${DEP_VERSION})
else()
file (STRINGS ${BUILTIN_DEP_VERSION_FILE} CURRENT_DEP_VERSION)
if(${DEP_VERSION} VERSION_GREATER ${CURRENT_DEP_VERSION})
message(STATUS "Your precomiled dependencies package for '${DEP_PREFIX}' is out of date. Downloading latest package...")
update_binary_deps(${DEP_PREFIX} ${DEP_NAME} ${DEP_FOLDER} ${DEP_VERSION})
endif()
endif()
endfunction()
1 change: 1 addition & 0 deletions Projects/CoX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include_directories(Common)

ADD_SUBDIRECTORY(Common)
ADD_SUBDIRECTORY(Utilities)
ADD_SUBDIRECTORY(Editor)
ADD_SUBDIRECTORY(Servers)
ADD_SUBDIRECTORY(Clients)

Expand Down
19 changes: 19 additions & 0 deletions Projects/CoX/Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if(MSVC)
check_and_update_binary_deps(SegsEngine SegsEngine ${PROJECT_SOURCE_DIR}/3rd_party/prebuilt 4.0.0-alpha)
find_package(SegsEngine REQUIRED)

set(SOURCES
main.cpp
os_specific/app.rc
)
add_executable(SegsEditor ${SOURCES})
target_link_libraries(SegsEditor SegsEngine::editor_engine)

# copy engine dlls and plugins to editor executable directory
add_custom_command(
TARGET SegsEditor POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/3rd_party/prebuilt/bin
${CMAKE_BINARY_DIR}/out)

endif()
94 changes: 94 additions & 0 deletions Projects/CoX/Editor/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include <QCoreApplication>
#include <qlogging.h>

#include "core/version.h"
#include "main/main.h"
#include "core/os/os.h"
#include "EASTL/unique_ptr.h"

#include <climits>
#include <clocale>
#include <cstdlib>
#include <QDir>


#ifdef Q_OS_WIN32
#include <windows.h>
static HINSTANCE godot_hinstance = nullptr;
#else
static void *godot_hinstance = nullptr;
#endif

/* NOTE: enable this to set breakpoints on qdebug messages. */
#define WRAP_QT_MESSAGES
#ifdef WRAP_QT_MESSAGES
static void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &lMessage)
{
QString text;
switch (type)
{
case QtDebugMsg:
text = QString("Qt::Debug (%1:%2, %3): %4").arg(context.file).arg(context.line).arg(context.function).arg(lMessage.constData());
break;

case QtWarningMsg:
text = QString("Qt::Warning (%1:%2, %3): %4").arg(context.file).arg(context.line).arg(context.function).arg(lMessage.constData());
break;

case QtCriticalMsg:
text = QString("Qt::Critical (%1:%2, %3): %4").arg(context.file).arg(context.line).arg(context.function).arg(lMessage.constData());
break;

case QtFatalMsg:
text = QString("Qt::Fatal (%1:%2, %3): %4").arg(context.file).arg(context.line).arg(context.function).arg(lMessage.constData());
abort();
}
QByteArray az = text.toUtf8();
printf("%s\n",az.data());
}

#endif

static int mainT(int argc, char *argv[]) {

#ifdef WRAP_QT_MESSAGES
qInstallMessageHandler(myMessageOutput);
#endif
QCoreApplication app(argc,argv);
QCoreApplication::setApplicationName("SegsEditor");
QCoreApplication::setApplicationVersion("0.0.1");
QCoreApplication::setOrganizationName("Segs");

eastl::unique_ptr<OS> os(instantiateOS(godot_hinstance));
setlocale(LC_CTYPE, "");

QString cwd = QDir::currentPath();

Error err = Main::setup();
if (err != OK) {
return 255;
}

if (Main::start())
os->run(); // it is actually the OS that decides how to run
Main::cleanup();

if (!QDir::setCurrent(cwd)) {
ERR_PRINT("Couldn't return to previous working directory.");
}

return os->get_exit_code();
}

int main(int argc, char *argv[]) {
#ifdef CRASH_HANDLER_EXCEPTION
godot_hinstance = GetModuleHandle(nullptr);
__try {
return mainT<OS_Windows>(argc,argv);
} __except (CrashHandlerException(GetExceptionInformation())) {
return 1;
}
#else
return mainT(argc,argv);
#endif
}
1 change: 1 addition & 0 deletions Projects/CoX/Editor/os_specific/app.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IDR_MAIN_ICON ICON "..\\resources\\segs.ico"

0 comments on commit 6f551e6

Please sign in to comment.