Update to the latest Rust libloadorder

Libloadorder is being rewritten in Rust and the rewrite will be released as v10.

There is some API breakage involved, and the Rust rewrite exposes cache management to the client, so the LOOT API will need to reload state as appropriate to avoid performance issues.
This commit is contained in:
Oliver Hamlet
2017-10-08 15:27:35 +01:00
parent 02a2b8bd4c
commit 6338367743
3 changed files with 26 additions and 23 deletions
+12 -7
View File
@@ -100,14 +100,19 @@ set(LIBGIT2_LIBRARIES "${BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_
ExternalProject_Add(libloadorder
PREFIX "external"
DEPENDS libespm
URL "https://github.com/WrinklyNinja/libloadorder/archive/9.5.5.tar.gz"
CMAKE_ARGS -DBOOST_ROOT=${BOOST_ROOT} -DBOOST_LIBRARYDIR=${BOOST_LIBRARYDIR} -DMSVC_STATIC_RUNTIME=${MSVC_STATIC_RUNTIME} -DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --target loadorder --config $(CONFIGURATION)
URL "https://github.com/WrinklyNinja/libloadorder/archive/rust-rewrite.tar.gz"
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND cargo build --release --all --all-features --target ${RUST_TARGET}
INSTALL_COMMAND "")
ExternalProject_Get_Property(libloadorder SOURCE_DIR BINARY_DIR)
set(LIBLOADORDER_INCLUDE_DIRS "${SOURCE_DIR}/include")
set(LIBLOADORDER_LIBRARIES "${BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}loadorder${CMAKE_STATIC_LIBRARY_SUFFIX}")
ExternalProject_Get_Property(libloadorder SOURCE_DIR)
set(LIBLOADORDER_INCLUDE_DIRS "${SOURCE_DIR}/ffi/include")
set(LIBLOADORDER_LIBRARIES "${SOURCE_DIR}/target/${RUST_TARGET}/release/${CMAKE_STATIC_LIBRARY_PREFIX}loadorder_ffi${CMAKE_STATIC_LIBRARY_SUFFIX}")
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
set (LIBLOADORDER_LIBRARIES ${LIBLOADORDER_LIBRARIES} Userenv)
ELSE ()
set (LIBLOADORDER_LIBRARIES ${LIBLOADORDER_LIBRARIES} dl)
ENDIF ()
ExternalProject_Add(pseudosem
PREFIX "external"
+13 -15
View File
@@ -40,8 +40,8 @@ LoadOrderHandler::~LoadOrderHandler() {
lo_destroy_handle(gh_);
}
void LoadOrderHandler::Init(const GameType& gameType,
const boost::filesystem::path& gamePath,
void LoadOrderHandler::Init(const GameType& gameType,
const boost::filesystem::path& gamePath,
const boost::filesystem::path& gameLocalAppData) {
if (gamePath.empty()) {
throw std::invalid_argument("Game path is not initialised.");
@@ -52,7 +52,7 @@ void LoadOrderHandler::Init(const GameType& gameType,
if (!tempPathString.empty())
gameLocalDataPath = tempPathString.c_str();
// If the handle has already been initialised, close it and open another.
// If the handle has already been initialised, close it and open another.
if (gh_ != nullptr) {
lo_destroy_handle(gh_);
gh_ = nullptr;
@@ -74,7 +74,7 @@ void LoadOrderHandler::Init(const GameType& gameType,
else
ret = LIBLO_ERROR_INVALID_ARGS;
if (ret != LIBLO_OK && ret != LIBLO_WARN_BAD_FILENAME && ret != LIBLO_WARN_INVALID_LIST && ret != LIBLO_WARN_LO_MISMATCH) {
if (ret != LIBLO_OK && ret != LIBLO_WARN_LO_MISMATCH) {
const char * e = nullptr;
string err;
lo_get_error_message(&e);
@@ -83,7 +83,7 @@ void LoadOrderHandler::Init(const GameType& gameType,
} else {
err = (format("libloadorder failed to create a game handle. Details: %1%") % e).str();
}
lo_cleanup();
throw std::system_error(ret, libloadorder_category(), err);
}
}
@@ -93,7 +93,7 @@ bool LoadOrderHandler::IsPluginActive(const std::string& pluginName) const {
bool result = false;
unsigned int ret = lo_get_plugin_active(gh_, pluginName.c_str(), &result);
if (ret != LIBLO_OK && ret != LIBLO_WARN_BAD_FILENAME) {
if (ret != LIBLO_OK) {
const char * e = nullptr;
string err;
lo_get_error_message(&e);
@@ -102,7 +102,7 @@ bool LoadOrderHandler::IsPluginActive(const std::string& pluginName) const {
} else {
err = (format("libloadorder failed to check if a plugin is active. Details: %1%") % e).str();
}
lo_cleanup();
throw std::system_error(ret, libloadorder_category(), err);
}
@@ -116,7 +116,7 @@ std::vector<std::string> LoadOrderHandler::GetLoadOrder() const {
size_t pluginArrSize;
unsigned int ret = lo_get_load_order(gh_, &pluginArr, &pluginArrSize);
if (ret != LIBLO_OK && ret != LIBLO_WARN_BAD_FILENAME && ret != LIBLO_WARN_INVALID_LIST && ret != LIBLO_WARN_LO_MISMATCH) {
if (ret != LIBLO_OK && ret != LIBLO_WARN_LO_MISMATCH) {
const char * e = nullptr;
string err;
lo_get_error_message(&e);
@@ -125,14 +125,13 @@ std::vector<std::string> LoadOrderHandler::GetLoadOrder() const {
} else {
err = (format("libloadorder failed to get the load order. Details: %1%") % e).str();
}
lo_cleanup();
throw std::system_error(ret, libloadorder_category(), err);
}
std::vector<string> loadOrder;
for (size_t i = 0; i < pluginArrSize; ++i) {
loadOrder.push_back(string(pluginArr[i]));
}
std::vector<string> loadOrder(pluginArr, pluginArr + pluginArrSize);
lo_free_string_array(pluginArr, pluginArrSize);
return loadOrder;
}
@@ -154,7 +153,7 @@ void LoadOrderHandler::SetLoadOrder(const std::vector<std::string>& loadOrder) c
delete[] pluginArr[i];
delete[] pluginArr;
if (ret != LIBLO_OK && ret != LIBLO_WARN_BAD_FILENAME && ret != LIBLO_WARN_INVALID_LIST && ret != LIBLO_WARN_LO_MISMATCH) {
if (ret != LIBLO_OK && ret != LIBLO_WARN_LO_MISMATCH) {
const char * e = nullptr;
string err;
lo_get_error_message(&e);
@@ -163,7 +162,6 @@ void LoadOrderHandler::SetLoadOrder(const std::vector<std::string>& loadOrder) c
} else {
err = (format("libloadorder failed to set the load order. Details: %1%") % e).str();
}
lo_cleanup();
throw std::system_error(ret, libloadorder_category(), err);
}
+1 -1
View File
@@ -30,7 +30,7 @@
#include <unordered_set>
#include <boost/filesystem.hpp>
#include <libloadorder/libloadorder.h>
#include <libloadorder.hpp>
#include "loot/enum/game_type.h"