Show OpenMW version and Lua API revision in documentation.

macos_ci_fix
Petr Mikheev 1 year ago
parent 2cd17830d3
commit f260fa006e

1
.gitignore vendored

@ -68,6 +68,7 @@ apps/wizard/ui_intropage.h
apps/wizard/ui_languageselectionpage.h
apps/wizard/ui_methodselectionpage.h
components/ui_contentselector.h
components/version/version.cpp
docs/mainpage.hpp
docs/Doxyfile
docs/DoxyfilePages

@ -72,6 +72,7 @@
Bug #7553: Faction reaction loading is incorrect
Feature #3537: Shader-based water ripples
Feature #5492: Let rain and snow collide with statics
Feature #6149: Dehardcode Lua API_REVISION
Feature #6447: Add LOD support to Object Paging
Feature #6491: Add support for Qt6
Feature #6556: Lua API for sounds

@ -71,6 +71,7 @@ message(STATUS "Configuring OpenMW...")
set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 49)
set(OPENMW_VERSION_RELEASE 0)
set(OPENMW_LUA_API_REVISION 45)
set(OPENMW_VERSION_COMMITHASH "")
set(OPENMW_VERSION_TAGHASH "")
@ -1041,7 +1042,6 @@ elseif(NOT APPLE)
# Install global configuration files
INSTALL(FILES "${INSTALL_SOURCE}/defaults.bin" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw")
INSTALL(FILES "${INSTALL_SOURCE}/openmw.cfg.install" DESTINATION "${SYSCONFDIR}" RENAME "openmw.cfg" COMPONENT "openmw")
INSTALL(FILES "${INSTALL_SOURCE}/resources/version" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw")
INSTALL(FILES "${INSTALL_SOURCE}/gamecontrollerdb.txt" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw")
IF(BUILD_OPENCS)

@ -146,8 +146,7 @@ namespace
config.filterOutNonExistingPaths(dataDirs);
const auto resDir = variables["resources"].as<Files::MaybeQuotedPath>();
const auto v = Version::getOpenmwVersion(resDir);
Log(Debug::Info) << v.describe();
Log(Debug::Info) << Version::getOpenmwVersionDescription();
dataDirs.insert(dataDirs.begin(), resDir / "vfs");
const auto fileCollections = Files::Collections(dataDirs);
const auto archives = variables["fallback-archive"].as<StringsVector>();

@ -174,14 +174,13 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()
void Launcher::MainDialog::setVersionLabel()
{
// Add version information to bottom of the window
Version::Version v = Version::getOpenmwVersion(mGameSettings.value("resources").toUtf8().constData());
QString revision(QString::fromUtf8(v.mCommitHash.c_str()));
QString tag(QString::fromUtf8(v.mTagHash.c_str()));
QString revision(QString::fromUtf8(Version::getCommitHash().data(), Version::getCommitHash().size()));
QString tag(QString::fromUtf8(Version::getTagHash().data(), Version::getTagHash().size()));
versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
if (!v.mVersion.empty() && (revision.isEmpty() || revision == tag))
versionLabel->setText(tr("OpenMW %1 release").arg(QString::fromUtf8(v.mVersion.c_str())));
if (!Version::getVersion().empty() && (revision.isEmpty() || revision == tag))
versionLabel->setText(
tr("OpenMW %1 release").arg(QString::fromUtf8(Version::getVersion().data(), Version::getVersion().size())));
else
versionLabel->setText(tr("OpenMW development (%1)").arg(revision.left(10)));

@ -165,8 +165,7 @@ namespace NavMeshTool
config.filterOutNonExistingPaths(dataDirs);
const auto resDir = variables["resources"].as<Files::MaybeQuotedPath>();
Version::Version v = Version::getOpenmwVersion(resDir);
Log(Debug::Info) << v.describe();
Log(Debug::Info) << Version::getOpenmwVersionDescription();
dataDirs.insert(dataDirs.begin(), resDir / "vfs");
const auto fileCollections = Files::Collections(dataDirs);
const auto archives = variables["fallback-archive"].as<StringsVector>();

@ -225,10 +225,6 @@ if(APPLE AND BUILD_OPENCS)
MACOSX_PACKAGE_LOCATION Resources/resources)
set_source_files_properties(${OPENCS_OPENMW_CFG} PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
add_custom_command(TARGET openmw-cs
POST_BUILD
COMMAND cp "${OpenMW_BINARY_DIR}/resources/version" "${OPENCS_BUNDLE_RESOURCES_DIR}/resources")
endif()
target_link_libraries(openmw-cs-lib

@ -774,7 +774,7 @@ void CSVDoc::View::tutorial()
void CSVDoc::View::infoAbout()
{
// Get current OpenMW version
QString versionInfo = (Version::getOpenmwVersionDescription(mDocument->getResourceDir()) +
QString versionInfo = (Version::getOpenmwVersionDescription() +
#if defined(__x86_64__) || defined(_M_X64)
" (64-bit)")
.c_str();

@ -210,10 +210,6 @@ if(APPLE)
configure_file("${OpenMW_BINARY_DIR}/openmw.cfg" ${BUNDLE_RESOURCES_DIR} COPYONLY)
configure_file("${OpenMW_BINARY_DIR}/gamecontrollerdb.txt" ${BUNDLE_RESOURCES_DIR} COPYONLY)
add_custom_command(TARGET openmw
POST_BUILD
COMMAND cp "${OpenMW_BINARY_DIR}/resources/version" "${BUNDLE_RESOURCES_DIR}/resources")
find_library(COCOA_FRAMEWORK Cocoa)
find_library(IOKIT_FRAMEWORK IOKit)
target_link_libraries(openmw ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK})

@ -723,7 +723,7 @@ void OMW::Engine::prepareEngine()
mWindowManager = std::make_unique<MWGui::WindowManager>(mWindow, mViewer, guiRoot, mResourceSystem.get(),
mWorkQueue.get(), mCfgMgr.getLogPath(), mScriptConsoleMode, mTranslationDataStorage, mEncoding,
Version::getOpenmwVersionDescription(mResDir), shadersSupported, mCfgMgr);
Version::getOpenmwVersionDescription(), shadersSupported, mCfgMgr);
mEnvironment.setWindowManager(*mWindowManager);
mInputManager = std::make_unique<MWInput::InputManager>(mWindow, mViewer, mScreenCaptureHandler,

@ -58,27 +58,14 @@ bool parseOptions(int argc, char** argv, OMW::Engine& engine, Files::Configurati
if (variables.count("version"))
{
cfgMgr.readConfiguration(variables, desc, true);
Version::Version v
= Version::getOpenmwVersion(variables["resources"]
.as<Files::MaybeQuotedPath>()
.u8string()); // This call to u8string is redundant, but required to build
// on MSVC 14.26 due to implementation bugs.
getRawStdout() << v.describe() << std::endl;
getRawStdout() << Version::getOpenmwVersionDescription() << std::endl;
return false;
}
cfgMgr.readConfiguration(variables, desc);
setupLogging(cfgMgr.getLogPath(), "OpenMW");
Version::Version v
= Version::getOpenmwVersion(variables["resources"]
.as<Files::MaybeQuotedPath>()
.u8string()); // This call to u8string is redundant, but required to build on
// MSVC 14.26 due to implementation bugs.
Log(Debug::Info) << v.describe();
Log(Debug::Info) << Version::getOpenmwVersionDescription();
Settings::Manager::load(cfgMgr);

@ -15,6 +15,7 @@
#include <components/lua/luastate.hpp>
#include <components/lua/utilpackage.hpp>
#include <components/misc/strings/lower.hpp>
#include <components/version/version.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/statemanager.hpp"
@ -128,7 +129,7 @@ namespace MWLua
{
auto* lua = context.mLua;
sol::table api(lua->sol(), sol::create);
api["API_REVISION"] = 44;
api["API_REVISION"] = Version::getLuaApiRevision(); // specified in CMakeLists.txt
api["quit"] = [lua]() {
Log(Debug::Warning) << "Quit requested by a Lua script.\n" << lua->debugTraceback();
MWBase::Environment::get().getStateManager()->requestQuit();

@ -28,4 +28,4 @@ endif ()
include(${MACROSFILE})
configure_resource_file(${VERSION_IN_FILE} ${VERSION_FILE_PATH_BASE} ${VERSION_FILE_PATH_RELATIVE})
configure_file(${VERSION_IN_FILE} ${VERSION_FILE})

@ -62,6 +62,13 @@ macro (add_component_dir dir)
list (APPEND cppfiles "${f}")
endforeach (f)
if (u MATCHES ".*[ch]pp")
list (APPEND files "${dir}/${u}")
list (APPEND COMPONENT_FILES "${dir}/${u}")
endif()
if (u MATCHES ".*cpp")
list (APPEND cppfiles "${dir}/${u}")
endif()
endforeach (u)
if (OPENMW_UNITY_BUILD)

@ -6,21 +6,22 @@ if(APPLE)
endif(APPLE)
# Version file
set (VERSION_IN_FILE "${OpenMW_SOURCE_DIR}/files/version.in")
set (VERSION_FILE_PATH_BASE "${OpenMW_BINARY_DIR}")
set (VERSION_FILE_PATH_RELATIVE resources/version)
set (VERSION_IN_FILE "${OpenMW_SOURCE_DIR}/components/version/version.cpp.in")
set (VERSION_FILE "${OpenMW_SOURCE_DIR}/components/version/version.cpp")
if (GIT_CHECKOUT)
get_generator_is_multi_config(multi_config)
add_custom_target (git-version
add_custom_command (
OUTPUT ${VERSION_FILE}
DEPENDS ${VERSION_IN_FILE}
COMMAND ${CMAKE_COMMAND}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
-DVERSION_IN_FILE=${VERSION_IN_FILE}
-DVERSION_FILE_PATH_BASE=${VERSION_FILE_PATH_BASE}
-DVERSION_FILE_PATH_RELATIVE=${VERSION_FILE_PATH_RELATIVE}
-DVERSION_FILE=${VERSION_FILE}
-DOPENMW_VERSION_MAJOR=${OPENMW_VERSION_MAJOR}
-DOPENMW_VERSION_MINOR=${OPENMW_VERSION_MINOR}
-DOPENMW_VERSION_RELEASE=${OPENMW_VERSION_RELEASE}
-DOPENMW_LUA_API_REVISION=${OPENMW_LUA_API_REVISION}
-DOPENMW_VERSION=${OPENMW_VERSION}
-DMACROSFILE=${CMAKE_SOURCE_DIR}/cmake/OpenMWMacros.cmake
"-DCMAKE_CONFIGURATION_TYPES=${CMAKE_CONFIGURATION_TYPES}"
@ -28,7 +29,7 @@ if (GIT_CHECKOUT)
-P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/GitVersion.cmake
VERBATIM)
else (GIT_CHECKOUT)
configure_resource_file(${VERSION_IN_FILE} ${VERSION_FILE_PATH_BASE} ${VERSION_FILE_PATH_RELATIVE})
configure_file(${VERSION_IN_FILE} ${VERSION_FILE})
endif (GIT_CHECKOUT)
# source files
@ -311,6 +312,7 @@ add_component_dir (sdlutil
add_component_dir (version
version
version.cpp
)
add_component_dir (fallback
@ -551,10 +553,6 @@ if (USE_QT)
endif()
endif()
if (GIT_CHECKOUT)
add_dependencies (components git-version)
endif (GIT_CHECKOUT)
if (OSG_STATIC AND CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(X11 REQUIRED COMPONENTS Xinerama Xrandr)
target_link_libraries(components ${CMAKE_DL_LIBS} X11::X11 X11::Xinerama X11::Xrandr)

@ -1,38 +0,0 @@
#include "version.hpp"
#include <filesystem>
#include <fstream>
namespace Version
{
Version getOpenmwVersion(const std::filesystem::path& resourcePath)
{
std::ifstream stream(resourcePath / "version");
Version v;
std::getline(stream, v.mVersion);
std::getline(stream, v.mCommitHash);
std::getline(stream, v.mTagHash);
return v;
}
std::string Version::describe() const
{
std::string str = "OpenMW version " + mVersion;
std::string rev = mCommitHash;
if (!rev.empty())
{
rev = rev.substr(0, 10);
str += "\nRevision: " + rev;
}
return str;
}
std::string getOpenmwVersionDescription(const std::filesystem::path& resourcePath)
{
Version v = getOpenmwVersion(resourcePath);
return v.describe();
}
}

@ -0,0 +1,36 @@
#include "version.hpp"
namespace Version
{
std::string_view getVersion()
{
return "@OPENMW_VERSION@";
}
std::string_view getCommitHash()
{
return "@OPENMW_VERSION_COMMITHASH@";
}
std::string_view getTagHash()
{
return "@OPENMW_VERSION_TAGHASH@";
}
int getLuaApiRevision()
{
return @OPENMW_LUA_API_REVISION@;
}
std::string getOpenmwVersionDescription()
{
std::string str = "OpenMW version ";
str += getVersion();
if (!getCommitHash().empty())
{
str += "\nRevision: ";
str += getCommitHash().substr(0, 10);
}
return str;
}
}

@ -1,27 +1,18 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#include <filesystem>
#include <string>
#include <string_view>
namespace Version
{
std::string_view getVersion();
std::string_view getCommitHash();
std::string_view getTagHash();
int getLuaApiRevision();
struct Version
{
std::string mVersion;
std::string mCommitHash;
std::string mTagHash;
std::string describe() const;
};
/// Read OpenMW version from the version file located in resourcePath.
Version getOpenmwVersion(const std::filesystem::path& resourcePath);
/// Helper function to getOpenmwVersion and describe() it
std::string getOpenmwVersionDescription(const std::filesystem::path& resourcePath);
// Prepares string that contains version and commit hash.
std::string getOpenmwVersionDescription();
}
#endif // VERSION_HPP

@ -66,6 +66,7 @@ copyright = u'2023, OpenMW Team'
# The full version, including alpha/beta/rc tags.
release = version = "UNRELEASED"
luaApiRevision = "UNKNOWN"
try:
cmake_raw = open(project_root+'/CMakeLists.txt', 'r').read()
@ -76,11 +77,18 @@ try:
release = version = '.'.join((majorVersionMatch.group(1),
minorVersionMatch.group(1),
releaseVersionMatch.group(1)))
luaApiRevisionMatch = re.search('set\(OPENMW_LUA_API_REVISION (\d+)\)', cmake_raw)
if luaApiRevisionMatch:
luaApiRevision = luaApiRevisionMatch.group(1)
except Exception as ex:
print("WARNING: Version will be set to '{0}' because: '{1}'.".format(release, str(ex)))
import traceback; traceback.print_exc()
rst_prolog = f"""
.. |luaApiRevision| replace:: {luaApiRevision}
"""
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = cpp

@ -1,6 +1,8 @@
Built-in AI packages
====================
.. include:: version.rst
Starting an AI package
----------------------

@ -2,6 +2,8 @@
Lua API reference
#################
.. include:: version.rst
.. toctree::
:hidden:

@ -1,6 +1,8 @@
Engine handlers reference
=========================
.. include:: version.rst
Engine handler is a function defined by a script, that can be called by the engine.

@ -1,6 +1,8 @@
Built-in events
===============
.. include:: version.rst
Actor events
------------

@ -2,8 +2,10 @@
OpenMW Lua scripting
####################
.. warning::
OpenMW Lua scripting is in early stage of development. Also note that OpenMW Lua is not compatible with MWSE.
.. note::
OpenMW Lua is not compatible with MWSE.
.. include:: version.rst
.. toctree::
:caption: Table of Contents

@ -1,6 +1,8 @@
Interface Activation
====================
.. include:: version.rst
.. raw:: html
:file: generated_html/scripts_omw_activationhandlers.html

@ -1,6 +1,8 @@
Interface AI
============
.. include:: version.rst
.. raw:: html
:file: generated_html/scripts_omw_ai.html

@ -1,6 +1,8 @@
Interface Camera
================
.. include:: version.rst
.. raw:: html
:file: generated_html/scripts_omw_camera_camera.html

@ -1,6 +1,8 @@
Interface Controls
==================
.. include:: version.rst
.. raw:: html
:file: generated_html/scripts_omw_playercontrols.html

@ -1,6 +1,8 @@
Interface MWUI
==============
.. include:: version.rst
.. raw:: html
:file: generated_html/scripts_omw_mwui_init.html

@ -1,6 +1,8 @@
Interface Settings
==================
.. include:: version.rst
.. raw:: html
:file: generated_html/scripts_omw_settings_player.html

@ -1,6 +1,8 @@
Interface UI
============
.. include:: version.rst
.. raw:: html
:file: generated_html/scripts_omw_ui.html

@ -1,6 +1,8 @@
Iterable types
==============
.. include:: version.rst
List Iterable
-------------

@ -1,5 +1,7 @@
Package openmw.ambient
======================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_ambient.html

@ -1,5 +1,7 @@
Package openmw.async
====================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_async.html

@ -1,5 +1,7 @@
Package openmw_aux.calendar
===========================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_aux_calendar.html

@ -1,5 +1,7 @@
Package openmw_aux.time
=======================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_aux_time.html

@ -1,5 +1,7 @@
Package openmw_aux.ui
=======================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_aux_ui.html

@ -1,5 +1,7 @@
Package openmw_aux.util
=======================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_aux_util.html

@ -1,5 +1,7 @@
Package openmw.camera
=====================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_camera.html

@ -1,5 +1,7 @@
Package openmw.core
===================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_core.html

@ -1,5 +1,7 @@
Package openmw.debug
====================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_debug.html

@ -1,6 +1,8 @@
Package openmw.input
====================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_input.html

@ -1,5 +1,7 @@
Package openmw.nearby
=====================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_nearby.html

@ -1,5 +1,7 @@
Package openmw.postprocessing
=============================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_postprocessing.html

@ -1,5 +1,7 @@
Package openmw.self
===================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_self.html

@ -1,5 +1,7 @@
Package openmw.storage
======================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_storage.html

@ -1,5 +1,7 @@
Package openmw.types
====================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_types.html

@ -1,5 +1,7 @@
Package openmw.ui
=================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_ui.html

@ -1,5 +1,7 @@
Package openmw.util
===================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_util.html

@ -1,5 +1,7 @@
Package openmw.world
====================
.. include:: version.rst
.. raw:: html
:file: generated_html/openmw_world.html

@ -1,6 +1,8 @@
Overview of Lua scripting
#########################
.. include:: version.rst
Language and sandboxing
=======================

@ -1,6 +1,8 @@
Built-in Setting Renderers
==========================
.. include:: version.rst
textLine
--------

@ -1,6 +1,8 @@
User interface reference
========================
.. include:: version.rst
Layouts
-------

@ -0,0 +1,2 @@
| `OpenMW version:` |version|
| `core.API_REVISION:` |luaApiRevision| `* <openmw_core.html##(core).API_REVISION>`_

@ -7,7 +7,7 @@
---
-- The revision of OpenMW Lua API. It is an integer that is incremented every time the API is changed.
-- The revision of OpenMW Lua API. It is an integer that is incremented every time the API is changed. See the actual value at the top of the page.
-- @field [parent=#core] #number API_REVISION
---

@ -1,3 +0,0 @@
@OPENMW_VERSION@
@OPENMW_VERSION_COMMITHASH@
@OPENMW_VERSION_TAGHASH@
Loading…
Cancel
Save