mirror of
https://github.com/loot/libloot-python.git
synced 2026-07-27 14:14:13 -07:00
+23
-2
@@ -6,6 +6,26 @@ include(ExternalProject)
|
||||
set(EXTERNAL_PROJECTS_PATH "${CMAKE_BINARY_DIR}/external/src")
|
||||
make_directory(${EXTERNAL_PROJECTS_PATH})
|
||||
|
||||
##############################
|
||||
# Get Build Revision
|
||||
##############################
|
||||
|
||||
find_package(Git)
|
||||
|
||||
IF (GIT_FOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_STRING
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
ELSE()
|
||||
SET (GIT_COMMIT_STRING "unknown")
|
||||
ENDIF ()
|
||||
|
||||
message(STATUS "Git revision: ${GIT_COMMIT_STRING}")
|
||||
|
||||
# Write to file.
|
||||
configure_file("${CMAKE_SOURCE_DIR}/src/wrapper_version.cpp.in" "${CMAKE_BINARY_DIR}/generated/wrapper_version.cpp" @ONLY)
|
||||
|
||||
#######################################
|
||||
# pybind11
|
||||
#######################################
|
||||
@@ -37,7 +57,8 @@ ExternalProject_Add(loot-api-c++
|
||||
ExternalProject_Get_Property(loot-api-c++ SOURCE_DIR)
|
||||
set(LOOT_API_EXTRACTED_PATH ${SOURCE_DIR})
|
||||
|
||||
include_directories("${LOOT_API_EXTRACTED_PATH}/include")
|
||||
include_directories("${CMAKE_SOURCE_DIR}/src"
|
||||
"${LOOT_API_EXTRACTED_PATH}/include")
|
||||
link_directories(${LOOT_API_EXTRACTED_PATH})
|
||||
set(LOOT_API_STATIC_LIBRARY "${CMAKE_STATIC_LIBRARY_PREFIX}loot_api${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
set(LOOT_API_SHARED_LIBRARY "${CMAKE_SHARED_LIBRARY_PREFIX}loot_api${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
@@ -57,7 +78,7 @@ ExternalProject_Add(test-masterlist
|
||||
# Python Module
|
||||
#######################################
|
||||
|
||||
pybind11_add_module(loot_api "${CMAKE_SOURCE_DIR}/src/main.cpp")
|
||||
pybind11_add_module(loot_api "${CMAKE_SOURCE_DIR}/src/main.cpp" "${CMAKE_BINARY_DIR}/generated/wrapper_version.cpp")
|
||||
|
||||
add_dependencies(loot_api loot-api-c++ test-masterlist)
|
||||
target_link_libraries(loot_api PRIVATE ${LOOT_API_STATIC_LIBRARY})
|
||||
|
||||
@@ -190,3 +190,28 @@ Classes
|
||||
.. py:staticmethod:: string() -> unicode
|
||||
|
||||
Returns the API version as a string of the form ``major.minor.patch``
|
||||
|
||||
.. py:class:: loot_api.WrapperVersion
|
||||
|
||||
Provides information about the version of the LOOT API Python wrapper that is
|
||||
being run.
|
||||
|
||||
.. py:attribute:: major
|
||||
|
||||
An unsigned integer giving the major version number.
|
||||
|
||||
.. py:attribute:: minor
|
||||
|
||||
An unsigned integer giving the minor version number.
|
||||
|
||||
.. py:attribute:: patch
|
||||
|
||||
An unsigned integer giving the patch version number.
|
||||
|
||||
.. py:attribute:: revision
|
||||
|
||||
A Unicode string containing the SHA-1 of the Git revision that the wrapped C++ API was built from.
|
||||
|
||||
.. py:staticmethod:: string() -> unicode
|
||||
|
||||
Returns the API version as a string of the form ``major.minor.patch``
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "wrapper_version.h"
|
||||
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>);
|
||||
|
||||
PYBIND11_PLUGIN(loot_api) {
|
||||
@@ -40,6 +42,7 @@ PYBIND11_PLUGIN(loot_api) {
|
||||
using loot::PluginCleanliness;
|
||||
using loot::SimpleMessage;
|
||||
using loot::PluginTags;
|
||||
using loot::WrapperVersion;
|
||||
|
||||
using pybind11::arg;
|
||||
using pybind11::enum_;
|
||||
@@ -102,6 +105,13 @@ PYBIND11_PLUGIN(loot_api) {
|
||||
.def_readonly_static("revision", &LootVersion::revision)
|
||||
.def("string", LootVersion::string);
|
||||
|
||||
class_<WrapperVersion>(module, "WrapperVersion")
|
||||
.def_readonly_static("major", &WrapperVersion::major)
|
||||
.def_readonly_static("minor", &WrapperVersion::minor)
|
||||
.def_readonly_static("patch", &WrapperVersion::patch)
|
||||
.def_readonly_static("revision", &WrapperVersion::revision)
|
||||
.def("string", WrapperVersion::string);
|
||||
|
||||
class_<DatabaseInterface, std::shared_ptr<DatabaseInterface>>(module, "DatabaseInterface")
|
||||
.def("load_lists", &DatabaseInterface::LoadLists, arg("masterlist_path"), arg("userlist_path") = emptyString)
|
||||
.def("eval_lists", &DatabaseInterface::EvalLists)
|
||||
|
||||
@@ -5,6 +5,7 @@ import os.path
|
||||
import shutil
|
||||
import unittest
|
||||
from loot_api import Version
|
||||
from loot_api import WrapperVersion
|
||||
from loot_api import GameType
|
||||
from loot_api import LanguageCode
|
||||
from loot_api import Message
|
||||
@@ -36,6 +37,13 @@ class TestLootApi(GameFixture):
|
||||
self.assertEqual(Version.patch, 0)
|
||||
self.assertNotEqual(Version.revision, u'')
|
||||
|
||||
def test_wrapper_version(self):
|
||||
self.assertEqual(WrapperVersion.major, 1)
|
||||
self.assertEqual(WrapperVersion.minor, 0)
|
||||
self.assertEqual(WrapperVersion.patch, 0)
|
||||
self.assertNotEqual(WrapperVersion.revision, u'')
|
||||
self.assertNotEqual(WrapperVersion.revision, Version.revision)
|
||||
|
||||
def test_create_db(self):
|
||||
db = create_database(GameType.tes4, self.game_path, u'')
|
||||
self.assertNotEqual(db, None)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/* LOOT
|
||||
|
||||
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
|
||||
Fallout: New Vegas.
|
||||
|
||||
Copyright (C) 2012-2016 WrinklyNinja
|
||||
|
||||
This file is part of LOOT.
|
||||
|
||||
LOOT is free software: you can redistribute
|
||||
it and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
LOOT is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LOOT. If not, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "wrapper_version.h"
|
||||
|
||||
namespace loot {
|
||||
const unsigned int WrapperVersion::major = 1;
|
||||
const unsigned int WrapperVersion::minor = 0;
|
||||
const unsigned int WrapperVersion::patch = 0;
|
||||
const std::string WrapperVersion::revision = "@GIT_COMMIT_STRING@";
|
||||
|
||||
std::string WrapperVersion::string() {
|
||||
return std::to_string(major) + '.' + std::to_string(minor) + '.' + std::to_string(patch);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/* LOOT
|
||||
|
||||
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
|
||||
Fallout: New Vegas.
|
||||
|
||||
Copyright (C) 2014-2016 WrinklyNinja
|
||||
|
||||
This file is part of LOOT.
|
||||
|
||||
LOOT is free software: you can redistribute
|
||||
it and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
LOOT is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LOOT. If not, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOOT_API_PYTHON_WRAPPER_VERSION
|
||||
#define LOOT_API_PYTHON_WRAPPER_VERSION
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace loot {
|
||||
class WrapperVersion {
|
||||
public:
|
||||
static const unsigned int major;
|
||||
static const unsigned int minor;
|
||||
static const unsigned int patch;
|
||||
static const std::string revision;
|
||||
|
||||
static std::string string();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user