mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 12:51:15 +02:00
Use binary resources on OSX
This commit is contained in:
parent
aa19794a94
commit
fa51c15849
4 changed files with 45 additions and 58 deletions
|
@ -133,13 +133,7 @@ if (APPLE)
|
|||
# set where in the bundle to put the resources file
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/icon/${INTERFACE_ICON_FILENAME} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
|
||||
set(DISCOVERED_RESOURCES "")
|
||||
|
||||
# use the add_resources_to_os_x_bundle macro to recurse into resources
|
||||
add_resources_to_os_x_bundle("${CMAKE_CURRENT_SOURCE_DIR}/resources")
|
||||
|
||||
# append the discovered resources to our list of interface sources
|
||||
list(APPEND INTERFACE_SRCS ${DISCOVERED_RESOURCES})
|
||||
list(APPEND INTERFACE_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/icon/${INTERFACE_ICON_FILENAME})
|
||||
endif()
|
||||
|
||||
|
@ -316,18 +310,27 @@ if (APPLE)
|
|||
set(SCRIPTS_INSTALL_DIR "${INTERFACE_INSTALL_APP_PATH}/Contents/Resources")
|
||||
set(RESOURCES_DEV_DIR "$<TARGET_FILE_DIR:${TARGET_NAME}>/../Resources")
|
||||
|
||||
# copy script files beside the executable
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
# copy script files beside the executable
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory
|
||||
"${CMAKE_SOURCE_DIR}/scripts"
|
||||
"${RESOURCES_DEV_DIR}/scripts"
|
||||
)
|
||||
|
||||
# copy JSDoc files beside the executable
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
"${CMAKE_SOURCE_DIR}/scripts"
|
||||
"${RESOURCES_DEV_DIR}/scripts"
|
||||
# copy JSDoc files beside the executable
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory
|
||||
"${CMAKE_SOURCE_DIR}/tools/jsdoc/out"
|
||||
"${RESOURCES_DEV_DIR}/jsdoc"
|
||||
"${CMAKE_SOURCE_DIR}/tools/jsdoc/out"
|
||||
"${RESOURCES_DEV_DIR}/jsdoc"
|
||||
# copy the resources files beside the executable
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
|
||||
"${RESOURCES_RCC}"
|
||||
"${RESOURCES_DEV_DIR}"
|
||||
# FIXME, the edit script code loads HTML from the scripts folder
|
||||
# which in turn relies on CSS that refers to the fonts. In theory
|
||||
# we should be able to modify the CSS to reference the QRC path to
|
||||
# the ttf files, but doing so generates a CORS policy violation,
|
||||
# so we have to retain a copy of the fonts outside of the resources binary
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory
|
||||
"${PROJECT_SOURCE_DIR}/resources/fonts"
|
||||
"${RESOURCES_DEV_DIR}/fonts"
|
||||
)
|
||||
|
||||
# call the fixup_interface macro to add required bundling commands for installation
|
||||
|
@ -356,13 +359,10 @@ else()
|
|||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/resources/serverless/tutorial.json"
|
||||
"${RESOURCES_DEV_DIR}/serverless/tutorial.json"
|
||||
)
|
||||
|
||||
# copy JSDoc files beside the executable
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
# copy JSDoc files beside the executable
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory
|
||||
"${CMAKE_SOURCE_DIR}/tools/jsdoc/out"
|
||||
"${INTERFACE_EXEC_DIR}/jsdoc"
|
||||
"${CMAKE_SOURCE_DIR}/tools/jsdoc/out"
|
||||
"${INTERFACE_EXEC_DIR}/jsdoc"
|
||||
)
|
||||
|
||||
# link target to external libraries
|
||||
|
|
|
@ -802,15 +802,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
|||
qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir);
|
||||
}
|
||||
|
||||
// FIXME fix the OSX installer to install the resources.rcc binary instead of resource files and remove
|
||||
// this conditional exclusion
|
||||
#if !defined(Q_OS_OSX)
|
||||
{
|
||||
#if defined(Q_OS_ANDROID)
|
||||
const QString resourcesBinaryFile = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/resources.rcc";
|
||||
#else
|
||||
const QString resourcesBinaryFile = QCoreApplication::applicationDirPath() + "/resources.rcc";
|
||||
#endif
|
||||
const QString resourcesBinaryFile = PathUtils::getRccPath();
|
||||
if (!QFile::exists(resourcesBinaryFile)) {
|
||||
throw std::runtime_error("Unable to find primary resources");
|
||||
}
|
||||
|
@ -818,7 +811,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
|||
throw std::runtime_error("Unable to load primary resources");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Tell the plugin manager about our statically linked plugins
|
||||
auto pluginManager = PluginManager::getInstance();
|
||||
|
|
|
@ -32,15 +32,13 @@
|
|||
#include "shared/GlobalAppProperties.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
|
||||
// Format: AppName-PID-Timestamp
|
||||
// Example: ...
|
||||
QString TEMP_DIR_FORMAT { "%1-%2-%3" };
|
||||
|
||||
#if !defined(Q_OS_ANDROID) && defined(DEV_BUILD)
|
||||
static bool USE_SOURCE_TREE_RESOURCES() {
|
||||
#if defined(Q_OS_OSX)
|
||||
return true;
|
||||
#else
|
||||
static bool result = false;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&] {
|
||||
|
@ -48,10 +46,28 @@ static bool USE_SOURCE_TREE_RESOURCES() {
|
|||
result = QProcessEnvironment::systemEnvironment().contains(USE_SOURCE_TREE_RESOURCES_FLAG);
|
||||
});
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
const QString& PathUtils::getRccPath() {
|
||||
static QString rccLocation;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&] {
|
||||
static const QString rccName{ "/resources.rcc" };
|
||||
#if defined(Q_OS_OSX)
|
||||
char buffer[8192];
|
||||
uint32_t bufferSize = sizeof(buffer);
|
||||
_NSGetExecutablePath(buffer, &bufferSize);
|
||||
rccLocation = QDir::cleanPath(QFileInfo(buffer).dir().absoluteFilePath("../Resources")) + rccName;
|
||||
#elif defined(Q_OS_ANDROID)
|
||||
rccLocation = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + rccName;
|
||||
#else
|
||||
rccLocation = QCoreApplication::applicationDirPath() + rccName;
|
||||
#endif
|
||||
});
|
||||
return rccLocation;
|
||||
}
|
||||
|
||||
#ifdef DEV_BUILD
|
||||
const QString& PathUtils::projectRootPath() {
|
||||
static QString sourceFolder;
|
||||
|
@ -65,23 +81,9 @@ const QString& PathUtils::projectRootPath() {
|
|||
#endif
|
||||
|
||||
const QString& PathUtils::resourcesPath() {
|
||||
static QString staticResourcePath;
|
||||
static QString staticResourcePath{ ":/" };
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&]{
|
||||
|
||||
#if defined(Q_OS_OSX)
|
||||
// FIXME fix the OSX installer to install the resources.rcc instead of the
|
||||
// individual resource files
|
||||
// FIXME the first call to fetch the resources location seems to return
|
||||
// nothing for QCoreApplication::applicationDirPath()
|
||||
char buffer[8192];
|
||||
uint32_t bufferSize = sizeof(buffer);
|
||||
_NSGetExecutablePath(buffer, &bufferSize);
|
||||
staticResourcePath = QDir::cleanPath(QFileInfo(buffer).dir().absoluteFilePath("../Resources")) + "/";
|
||||
#else
|
||||
staticResourcePath = ":/";
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_ANDROID) && defined(DEV_BUILD)
|
||||
if (USE_SOURCE_TREE_RESOURCES()) {
|
||||
// For dev builds, optionally load content from the Git source tree
|
||||
|
@ -90,21 +92,13 @@ const QString& PathUtils::resourcesPath() {
|
|||
#endif
|
||||
qDebug() << "Resource path resolved to " << staticResourcePath;
|
||||
});
|
||||
|
||||
return staticResourcePath;
|
||||
}
|
||||
|
||||
const QString& PathUtils::resourcesUrl() {
|
||||
static QString staticResourcePath;
|
||||
static QString staticResourcePath{ "qrc:///" };
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&]{
|
||||
|
||||
#if defined(Q_OS_OSX)
|
||||
staticResourcePath = QUrl::fromLocalFile(resourcesPath()).toString();
|
||||
#else
|
||||
staticResourcePath = "qrc:///";
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_ANDROID) && defined(DEV_BUILD)
|
||||
if (USE_SOURCE_TREE_RESOURCES()) {
|
||||
// For dev builds, optionally load content from the Git source tree
|
||||
|
|
|
@ -37,6 +37,7 @@ class PathUtils : public QObject, public Dependency {
|
|||
Q_PROPERTY(QString resources READ resourcesPath CONSTANT)
|
||||
Q_PROPERTY(QUrl defaultScripts READ defaultScriptsLocation CONSTANT)
|
||||
public:
|
||||
static const QString& getRccPath();
|
||||
static const QString& resourcesUrl();
|
||||
static QUrl resourcesUrl(const QString& relative);
|
||||
static const QString& resourcesPath();
|
||||
|
|
Loading…
Reference in a new issue