From 43e0ff30ba1a74799d3f6eac6b4cd577ea0397d8 Mon Sep 17 00:00:00 2001 From: Artem Chernyshev Date: Tue, 2 Jul 2019 15:43:16 +0300 Subject: [PATCH] [#164132100] Brought back DEB changes that were lost in force push - run dir fixes. - change CEF cache folder. --- .travis.yml | 2 +- CMakeLists.txt | 15 +-- Core/include/Filesystem.h | 14 +++ Core/src/EngineSystem.cpp | 1 + PlugIns/CEF/src/CEFPlugin.cpp | 9 ++ README.md | 2 +- cmake/Dependencies.cmake | 113 -------------------- cmake/Functions.cmake | 2 +- resources/editor/gsage.desktop.in | 4 +- resources/scripts/editor/projectManager.lua | 8 +- resources/scripts/entrypoints/editor.lua | 21 ++-- tools/postinst | 35 ++++++ tools/prerm | 5 + 13 files changed, 91 insertions(+), 140 deletions(-) delete mode 100644 cmake/Dependencies.cmake create mode 100755 tools/postinst create mode 100755 tools/prerm diff --git a/.travis.yml b/.travis.yml index 119c5f5..91db5d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ matrix: - libglew-dev - compiler: clang os: osx - osx_image: xcode9.1 + osx_image: xcode9.4 env: - OGRE_ENABLED=0 - GSAGE_VERSION_BUILD=${TRAVIS_BUILD_NUMBER} diff --git a/CMakeLists.txt b/CMakeLists.txt index 13688d6..c6d45df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,13 +8,8 @@ configure() include(${CMAKE_SOURCE_DIR}/conanbuildinfo.cmake OPTIONAL) -if(CONAN_PACKAGE_NAME) - set(CMAKE_INSTALL_PATH "./") - include(cmake/ConanDependencies.cmake) -else(CONAN_PACKAGE_NAME) - set(CMAKE_INSTALL_PATH "/usr/local") - include(cmake/Dependencies.cmake) -endif(CONAN_PACKAGE_NAME) +set(CMAKE_INSTALL_PATH "./") +include(cmake/ConanDependencies.cmake) process_templates() @@ -64,9 +59,15 @@ elseif(UNIX) set(CPACK_DEBIAN_PACKAGE_NAME "gsage") set(CPACK_DEBIAN_PACKAGE_VERSION "${GSAGE_VERSION_MAJOR}.${GSAGE_VERSION_MINOR}.${GSAGE_VERSION_PATCH}") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Artem Chernyshev") + # additional dependencies for cef + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libcups2, libgconf-2-4, libgtk2.0-dev, libgdk-pixbuf2.0-dev, freeglut3-dev") + + # other deps will be generated automatically set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Open source game engine") + set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${gsage_SOURCE_DIR}/tools/postinst;${gsage_SOURCE_DIR}/tools/prerm") + set(CPACK_GENERATOR "DEB") endif(APPLE) diff --git a/Core/include/Filesystem.h b/Core/include/Filesystem.h index 7fd8f7f..55e2186 100644 --- a/Core/include/Filesystem.h +++ b/Core/include/Filesystem.h @@ -196,6 +196,20 @@ namespace Gsage { return Poco::Path(path).getBaseName(); } + /** + * Same as Poco::Path::cacheHome + */ + inline std::string getCacheHome() const { + return expand(Poco::Path::cacheHome()); + } + + /** + * Same as Poco::Path::expand + */ + inline std::string expand(const std::string& path) const { + return Poco::Path::expand(path); + } + /** * Flush all copy complete events */ diff --git a/Core/src/EngineSystem.cpp b/Core/src/EngineSystem.cpp index e170212..5970860 100644 --- a/Core/src/EngineSystem.cpp +++ b/Core/src/EngineSystem.cpp @@ -119,6 +119,7 @@ namespace Gsage } mEngine->fireEvent(SystemChangeEvent(SystemChangeEvent::SYSTEM_STARTED, getName(), this)); + LOG(INFO) << "System " << getName() << " was started"; return true; } diff --git a/PlugIns/CEF/src/CEFPlugin.cpp b/PlugIns/CEF/src/CEFPlugin.cpp index 72004d8..975ea39 100644 --- a/PlugIns/CEF/src/CEFPlugin.cpp +++ b/PlugIns/CEF/src/CEFPlugin.cpp @@ -917,6 +917,14 @@ namespace Gsage { std::stringstream ss; ss << dirname(path) << "/" << "cef.helper"; CefString(&settings.browser_subprocess_path).FromASCII(ss.str().c_str()); + + if(!getcwd(path, sizeof(path)-1)) { + LOG(ERROR) << "Failed to get current working directory"; + return false; + } + ss = std::stringstream(); + ss << path << "/locales"; + CefString(&settings.locales_dir_path) = ss.str().c_str(); #elif GSAGE_PLATFORM == GSAGE_WIN32 char filename[] = "cef.helper.exe"; char fullFilename[MAX_PATH]; @@ -924,6 +932,7 @@ namespace Gsage { CefString(&settings.browser_subprocess_path).FromASCII(fullFilename); #endif + CefString(&settings.cache_path) = (mFacade->filesystem()->getCacheHome() + "/gsage").c_str(); if(!mFacade->filesystem()->exists(CefString(&settings.browser_subprocess_path).ToString())) { LOG(ERROR) << "Failed to locate cef.helper executable " << CefString(&settings.browser_subprocess_path).ToString(); diff --git a/README.md b/README.md index b894f40..a29e116 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ You can read more documentation on [http://engine.readthedocs.io/](http://engine This engine supports three OS at the moment: * Windows, Visual Studio 2017 and later. -* OSX, ci is using Xcode 9.1. +* OSX, ci is using Xcode 9.4. * Linux, ci is using Ubuntu 16.04 with GCC 5.4. There are plans to support iOS and Android. diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake deleted file mode 100644 index e50dd3f..0000000 --- a/cmake/Dependencies.cmake +++ /dev/null @@ -1,113 +0,0 @@ -set(OGRE_CMAKE_MODULE_PATH_ADDED FALSE) - -if(WIN32 AND DEFINED ENV{OGRE_HOME}) - set(CMAKE_MODULE_PATH "$ENV{OGRE_HOME}/CMake/;${CMAKE_MODULE_PATH}") - set(OGRE_SAMPLES_INCLUDEPATH - $ENV{OGRE_HOME}/Samples/include - ) - set(OGRE_CMAKE_MODULE_PATH_ADDED TRUE) -endif(WIN32 AND DEFINED ENV{OGRE_HOME}) - -if(DEFINED ENV{OGRE_DEPENDENCIES_DIR}) - set(ENV{ZZIP_HOME}, $ENV{OGRE_DEPENDENCIES_DIR}) -endif() - -if(UNIX) - if(EXISTS "/usr/local/lib/OGRE/cmake") - - set(CMAKE_MODULE_PATH "/usr/local/lib/OGRE/cmake/;${CMAKE_MODULE_PATH}") - set(OGRE_SAMPLES_INCLUDEPATH "/usr/local/share/OGRE/samples/Common/include/") # We could just *assume* that developers uses this basepath : /usr/local - set(OGRE_CMAKE_MODULE_PATH_ADDED TRUE) - - elseif(EXISTS "/usr/lib/OGRE/cmake") - - set(CMAKE_MODULE_PATH "/usr/lib/OGRE/cmake/;${CMAKE_MODULE_PATH}") - set(OGRE_SAMPLES_INCLUDEPATH "/usr/share/OGRE/samples/Common/include/") # Otherwise, this one - set(OGRE_CMAKE_MODULE_PATH_ADDED TRUE) - - elseif(DEFINED ENV{OGRE_HOME}) - set(CMAKE_MODULE_PATH "$ENV{OGRE_HOME}/CMake/;${CMAKE_MODULE_PATH}") - set(OGRE_SAMPLES_INCLUDEPATH - $ENV{OGRE_HOME}/Samples/include - ) - set(OGRE_CMAKE_MODULE_PATH_ADDED TRUE) - else() - set(OGRE_FOUND FALSE) - endif(EXISTS "/usr/local/lib/OGRE/cmake") -endif(UNIX) - -if (CMAKE_BUILD_TYPE STREQUAL "") - # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up - # differentiation between debug and release builds. - set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) -endif () - -set(CMAKE_DEBUG_POSTFIX "_d") - -set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dist") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") - -if(OGRE_CMAKE_MODULE_PATH_ADDED) - find_package(OGRE) -endif(OGRE_CMAKE_MODULE_PATH_ADDED) - -if(APPLE) - find_library(COREFOUNDATION_LIBRARY CoreFoundation ) - find_library(COCOA_LIBRARY Cocoa) - find_library(CARBON NAMES Carbon) - find_library(IOKIT NAMES IOKit) - find_library(OpenGL_LIBRARY OpenGL) - - if(OGRE_CMAKE_MODULE_PATH_ADDED) - include(FindOGRE) - endif(OGRE_CMAKE_MODULE_PATH_ADDED) -endif(APPLE) - -if(OGRE_FOUND) - ogre_find_component(Terrain OgreTerrain.h) - ogre_find_plugin(Plugin_ParticleUniverse ParticleUniverseSystemManager.h) -endif(OGRE_FOUND) - -find_package(LuaJIT REQUIRED) -find_package(Msgpack REQUIRED) - -find_package(Qt5 COMPONENTS Quick Core QUIET) - -find_package(LibRocket QUIET) -find_package(OIS QUIET) -find_package(PythonLibs QUIET) -find_package(PYBIND11 QUIET) -set(WITH_RECAST False) - -if(OGRE_FOUND) - # Find Boost - if (NOT OGRE_BUILD_PLATFORM_IPHONE) - if (WIN32 OR APPLE) - set(Boost_USE_STATIC_LIBS TRUE) - else () - # Statically linking boost to a dynamic Ogre build doesn't work on Linux 64bit - set(Boost_USE_STATIC_LIBS ${OGRE_STATIC}) - endif () - if (MINGW) - # this is probably a bug in CMake: the boost find module tries to look for - # boost libraries with name libboost_*, but CMake already prefixes library - # search names with "lib". This is the workaround. - set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "") - endif () - set(Boost_ADDITIONAL_VERSIONS "1.54" ) - # Components that need linking (NB does not include header-only components like bind) - set(OGRE_BOOST_COMPONENTS system filesystem thread date_time) - find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET) - - if (NOT Boost_FOUND) - # Try again with the other type of libs - set(Boost_USE_STATIC_LIBS NOT ${Boost_USE_STATIC_LIBS}) - find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET) - endif(NOT Boost_FOUND) - - # Set up referencing of Boost - include_directories(${Boost_INCLUDE_DIR}) - add_definitions(-DBOOST_ALL_NO_LIB) - set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES}) - endif() -set(OGRE_INCLUDE_DIRS $ENV{OGRE_HOME}/include/OGRE "${OGRE_INCLUDE_DIRS}") diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index b9af871..f4f3af1 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -81,7 +81,7 @@ macro(configure) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") if(NOT APPLE) - set(INSTALL_BINARY_DIR "local/bin/") + set(INSTALL_BINARY_DIR "local/bin/gsage") set(INSTALL_LIB_DIR "local/lib/") set(INSTALL_PLUGINS_DIR "local/lib/gsage") set(INSTALL_RESOURCE_DIR "share/gsage/") diff --git a/resources/editor/gsage.desktop.in b/resources/editor/gsage.desktop.in index a247e88..0fa1e7a 100644 --- a/resources/editor/gsage.desktop.in +++ b/resources/editor/gsage.desktop.in @@ -2,8 +2,8 @@ Version=${GSAGE_VERSION_MAJOR}.${GSAGE_VERSION_MINOR}.${GSAGE_VERSION_PATCH} Name=GSAGE Editor Comment=Open source game engine -Exec=env GSAGE_RUN_DIRECTORY=/usr/share/gsage/ env GSAGE_PLUGINS_DIRECTORIES=/usr/local/lib/gsage/ /usr/local/bin/gsage -Icon=/usr/share/gsage/resources/editor/editor.ico +Exec=env GSAGE_RUN_DIRECTORY=/usr/share/gsage/ env GSAGE_PLUGINS_DIRECTORIES=/usr/local/lib/gsage/ /usr/local/bin/gsage/gsage +Icon=/usr/share/gsage/resources/editor/gsage.ico Terminal=false Type=Application Categories=Development diff --git a/resources/scripts/editor/projectManager.lua b/resources/scripts/editor/projectManager.lua index 6507f05..4cce77a 100644 --- a/resources/scripts/editor/projectManager.lua +++ b/resources/scripts/editor/projectManager.lua @@ -191,7 +191,7 @@ local ProjectManager = class(function(self) end self.awaitedSystems[event.systemID] = true local ready = true - for _, started in pairs(self.awaitedSystems) do + for id, started in pairs(self.awaitedSystems) do if started ~= true then ready = false break @@ -263,7 +263,6 @@ function ProjectManager:create(settings, onProgress, onComplete) message(tostring(err), "#FF0000", true) end end - onComplete(success) end @@ -308,7 +307,7 @@ function ProjectManager:create(settings, onProgress, onComplete) end message(msg, color) - if percent == 100 then + if percent >= 100 then finalize(true) end end @@ -337,7 +336,7 @@ function ProjectManager:create(settings, onProgress, onComplete) message(msg, color) percent = percent + step / filecount - if percent == 100 then + if percent >= 100 then finalize(true) end end @@ -416,7 +415,6 @@ function ProjectManager:open(projectPath) log.error("Failed to open project " .. err) return false end - log.info("Read project file") self.openProjectFile = projectFile local sourcesDir = fs.path.join(self.openProjectFile.projectRoot, "sources") diff --git a/resources/scripts/entrypoints/editor.lua b/resources/scripts/entrypoints/editor.lua index cf395db..68ed2e1 100644 --- a/resources/scripts/entrypoints/editor.lua +++ b/resources/scripts/entrypoints/editor.lua @@ -99,8 +99,10 @@ local mode = "world" local function saveSettings() log.info("Saving imgui dock state") dockstates[mode] = dockspace:getState() - projectManager.openProjectFile:setWorkspace(dockstates) - projectManager.openProjectFile:write() + if projectManager.openProjectFile then + projectManager.openProjectFile:setWorkspace(dockstates) + projectManager.openProjectFile:write() + end editor:putToGlobalState("bindings", bindings:getConfig()) editor:saveGlobalState() end @@ -378,14 +380,13 @@ if imguiInterface:available() then projectManager:onProjectOpen(function(projectFile) hideWizard() - if globalEditorState and globalEditorState.dockState then - log.info("Restoring imgui dock state") - dockstates = projectFile:getWorkspace() or globalEditorState.dockState or { - world = {}, - character = {} - } - dockspace:setState(dockstates[mode] or {}) - end + local dockstates = (projectFile:getWorkspace() or (globalEditorState or {}).dockState) or { + world = {}, + character = {}, + } + + log.info("Restoring imgui dock state") + dockspace:setState(dockstates[mode]) views.assets:configure() event:bind(core, EngineEvent.STOPPING, saveSettings) end) diff --git a/tools/postinst b/tools/postinst new file mode 100755 index 0000000..bc7090c --- /dev/null +++ b/tools/postinst @@ -0,0 +1,35 @@ +#!/bin/sh + +#DEBHELPER# + +set -e + +echo " +* TRACE: + ENABLED = false +* DEBUG: + ENABLED = false +* GLOBAL: + FORMAT = "%datetime [%level] [%fbase:%line] %msg" + ENABLED = true + TO_FILE = true +" > /usr/share/gsage/log.cfg + +chmod 755 /usr/share/gsage/log.cfg + +# update editor configuration +python -c " +import sys, json; + +config_path = '/usr/share/gsage/resources/editorConfig.json' + +config = None + +with open(config_path, 'r') as f: + config = json.load(f) + config['logConfig'] = '/usr/share/gsage/log.cfg' + +with open(config_path, 'w') as f: + json.dump(config, f) + +" diff --git a/tools/prerm b/tools/prerm new file mode 100755 index 0000000..d19758a --- /dev/null +++ b/tools/prerm @@ -0,0 +1,5 @@ +#!/bin/sh + +#DEBHELPER# + +rm /usr/share/gsage/log.cfg