Compare commits

..
9 Commits
Author SHA1 Message Date
Al ea3d31fe71 Merge pull request #11 from Holt59/use-manager-extensions
Use list of supported extensions from installation manager.
2020-06-11 11:04:21 -07:00
Mikaël Capelle 289663f1cd Use list of supported extensions from installation manager. 2020-06-11 19:45:24 +02:00
Al 7fc63ddfd7 Merge pull request #10 from Holt59/new-filetree
Update for the new file tree implementation
2020-05-20 13:04:22 +02:00
Mikaël Capelle b3f9d0c575 Fix issue with .fomod file not being accepted by the installer. 2020-05-08 22:03:53 +02:00
Mikaël Capelle 2c7e8a417a Switch to the new file tree implementation and clean code. 2020-05-01 18:16:05 +02:00
Silarn aae2c898f0 Appveyor CMAKE fix 2020-05-01 04:58:55 -05:00
isanae 9bb9c301c4 Merge pull request #9 from isanae/new-cmakefiles
New cmakefiles
2020-04-26 02:54:11 -04:00
isanae 558a806ea8 now using new cmakefiles 2020-04-24 23:26:29 -04:00
Chris Bessent 1e1f77ce55 Merge pull request #8 from ModOrganizer2/2_2_2
Pull in 2.2.2.1 changes
2020-01-13 23:03:48 -07:00
4 changed files with 59 additions and 118 deletions
+10 -12
View File
@@ -1,14 +1,12 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.16)
ADD_COMPILE_OPTIONS($<$<CXX_COMPILER_ID:MSVC>:/MP> $<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELEASE>:/O2>> $<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELWITHDEBINFO>:/O2>>)
project(installer_bundle)
set(project_type plugin)
set(enable_warnings OFF)
SET(PROJ_NAME installer_bundle)
PROJECT(${PROJ_NAME})
SET(DEPENDENCIES_DIR CACHE PATH "")
# hint to find qt in dependencies path
LIST(APPEND CMAKE_PREFIX_PATH ${QT_ROOT}/lib/cmake)
ADD_SUBDIRECTORY(src)
if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/project.cmake)
else()
include(../cmake_common/project.cmake)
endif()
add_subdirectory(src)
+6 -63
View File
@@ -1,63 +1,6 @@
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)
CMAKE_POLICY(SET CMP0020 NEW)
CMAKE_POLICY(SET CMP0043 NEW)
FILE(GLOB ${PROJ_NAME}_SRCS *.cpp)
FILE(GLOB ${PROJ_NAME}_HDRS *.h)
FILE(GLOB ${PROJ_NAME}_FORMS *.ui)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON)
FIND_PACKAGE(Qt5Widgets REQUIRED)
QT5_WRAP_UI(${PROJ_NAME}_UIHDRS ${${PROJ_NAME}_FORMS})
FIND_PACKAGE(Qt5LinguistTools)
QT5_CREATE_TRANSLATION(${PROJ_NAME}_translations_qm ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/${PROJ_NAME}_en.ts)
SET(Boost_USE_STATIC_LIBS ON)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE(Boost)
IF (Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ENDIF (Boost_FOUND)
SET(default_project_path "${DEPENDENCIES_DIR}/modorganizer_super")
GET_FILENAME_COMPONENT(${default_project_path} ${default_project_path} REALPATH)
SET(project_path "${default_project_path}" CACHE PATH "path to the other mo projects")
SET(lib_path "${project_path}/../../install/libs")
INCLUDE_DIRECTORIES(${project_path}/uibase/src)
LINK_DIRECTORIES(${lib_path})
ADD_LIBRARY(${PROJ_NAME} SHARED ${${PROJ_NAME}_HDRS} ${${PROJ_NAME}_SRCS} ${${PROJ_NAME}_UIHDRS} ${${PROJ_NAME}_translations_qm})
TARGET_LINK_LIBRARIES(${PROJ_NAME}
Qt5::Widgets
${Boost_LIBRARIES}
uibase)
IF(MSVC)
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
ELSE(MSVC)
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS "-std=c++11")
ENDIF(MSVC)
IF (NOT "${OPTIMIZE_COMPILE_FLAGS}" STREQUAL "")
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS_RELWITHDEBINFO ${OPTIMIZE_COMPILE_FLAGS})
ENDIF()
IF (NOT "${OPTIMIZE_LINK_FLAGS}" STREQUAL "")
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS_RELWITHDEBINFO ${OPTIMIZE_LINK_FLAGS})
ENDIF()
###############
## Installation
INSTALL(TARGETS ${PROJ_NAME}
RUNTIME DESTINATION bin/plugins)
INSTALL(FILES $<TARGET_PDB_FILE:${PROJ_NAME}>
DESTINATION pdb)
cmake_minimum_required(VERSION 3.16)
if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/src.cmake)
else()
include(../../cmake_common/src.cmake)
endif()
+30 -34
View File
@@ -75,54 +75,50 @@ bool InstallerBundle::isManualInstaller() const
return false;
}
bool InstallerBundle::findObject(DirectoryTree const *tree) const
std::shared_ptr<const FileTreeEntry> InstallerBundle::findObject(std::shared_ptr<const IFileTree> tree) const
{
for (;;) {
DirectoryTree::const_leaf_iterator fileIter = tree->leafsBegin();
// Check if we have an archive:
auto managerExtensions = manager()->getSupportedExtensions();
//Really truly we should use the supported extensions from the installation
//manager here
if (tree->numNodes() == 0 && tree->numLeafs() == 1 &&
(fileIter->getName().endsWith(".7z") ||
fileIter->getName().endsWith(".zip") ||
fileIter->getName().endsWith(".rar"))) {
// nested archive
m_found_dir = tree;
m_found_leaf = fileIter;
return true;
}
for (; fileIter != tree->leafsEnd(); ++fileIter) {
if (fileIter->getName().endsWith(".fomod")) {
m_found_dir = tree;
m_found_leaf = fileIter;
return true;
// Look for a file with a valid extension:
int nDirs = 0;
for (auto entry : *tree) {
if (entry->isFile()) {
if (managerExtensions.contains(entry->suffix(), FileNameComparator::CaseSensitivity)) {
return entry;
}
}
//Arguably this should also check the name of the directory we're looking at
//is the same as the module name
if (tree->numNodes() != 1) {
return false;
else {
nDirs++;
}
tree = *(tree->nodesBegin());
}
// Arguably this should also check the name of the directory we're looking at
// is the same as the module name:
if (nDirs != 1) {
return nullptr;
}
// Retrieve the first folder which is the first item:
return findObject(tree->at(0)->astree());
}
bool InstallerBundle::isArchiveSupported(const DirectoryTree &tree) const
bool InstallerBundle::isArchiveSupported(std::shared_ptr<const IFileTree> tree) const
{
return findObject(&tree);
return findObject(tree) != nullptr;
}
IPluginInstaller::EInstallResult InstallerBundle::install(GuessedValue<QString> &modName,
DirectoryTree &tree,
QString&, int &modId)
IPluginInstaller::EInstallResult InstallerBundle::install(
GuessedValue<QString>& modName, std::shared_ptr<IFileTree>& tree, QString&, int &modId)
{
if (! findObject(&tree)) {
// Find a valid "object":
auto entry = findObject(tree);
if (entry == nullptr) {
return IPluginInstaller::RESULT_NOTATTEMPTED;
}
FileNameString name = m_found_dir->getFullPath(&(*m_found_leaf));
QString tempFile = manager()->extractFile(name.toQString());
// Extract it:
QString tempFile = manager()->extractFile(entry);
IPluginInstaller::EInstallResult res = manager()->installArchive(modName, tempFile, modId);
if (res == IPluginInstaller::RESULT_SUCCESS) {
res = IPluginInstaller::RESULT_SUCCESSCANCEL;
+13 -9
View File
@@ -44,20 +44,24 @@ public:
virtual bool isActive() const;
virtual QList<MOBase::PluginSetting> settings() const;
virtual unsigned int priority() const;
virtual unsigned int priority() const override;
virtual bool isManualInstaller() const;
virtual bool isArchiveSupported(const MOBase::DirectoryTree &tree) const;
virtual bool isArchiveSupported(std::shared_ptr<const MOBase::IFileTree> tree) const override;
virtual EInstallResult install(MOBase::GuessedValue<QString> &modName,
MOBase::DirectoryTree &tree,
QString &version, int &modID);
std::shared_ptr<MOBase::IFileTree> &tree,
QString &version, int &modID) override;
private:
//Stash the results of findObject.
//FIXME return a tuple?
mutable MOBase::DirectoryTree const *m_found_dir;
mutable MOBase::DirectoryTree::const_leaf_iterator m_found_leaf;
bool findObject(MOBase::DirectoryTree const *tree) const;
/**
* @brief Find the first entry that can be extracted from this archive.
*
* @param tree The tree to look the entry in.
*
* @return the entry, if one was found, or a null pointer.
*/
std::shared_ptr<const MOBase::FileTreeEntry> findObject(std::shared_ptr<const MOBase::IFileTree> tree) const;
};