mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-12 00:59:16 +05:00
Merge branch 'set_version' into 'master'
Set Netgen version in Archive and generated Meshes See merge request jschoeberl/netgen!329
This commit is contained in:
commit
9d71c172f3
@ -11,6 +11,7 @@ add_library(ngcore SHARED
|
||||
table.cpp
|
||||
taskmanager.cpp
|
||||
utils.cpp
|
||||
version.cpp
|
||||
)
|
||||
|
||||
# Pybind11 2.3 Issue https://github.com/pybind/pybind11/issues/1604
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#include "archive.hpp"
|
||||
#include <netgen_version.hpp>
|
||||
#include "version.hpp"
|
||||
|
||||
#ifndef WIN32
|
||||
#include <cxxabi.h>
|
||||
@ -8,18 +8,6 @@
|
||||
|
||||
namespace ngcore
|
||||
{
|
||||
// clang-tidy should ignore this static object
|
||||
static std::map<std::string, VersionInfo> library_versions; // NOLINT
|
||||
std::map<std::string, VersionInfo>& Archive :: GetLibraryVersions()
|
||||
{
|
||||
return library_versions;
|
||||
}
|
||||
const VersionInfo& GetLibraryVersion(const std::string& library)
|
||||
{ return library_versions[library]; }
|
||||
|
||||
void SetLibraryVersion(const std::string& library, const VersionInfo& version)
|
||||
{ library_versions[library] = version; }
|
||||
|
||||
// clang-tidy should ignore this static object
|
||||
static std::unique_ptr<std::map<std::string, detail::ClassArchiveInfo>> type_register; // NOLINT
|
||||
const detail::ClassArchiveInfo& Archive :: GetArchiveRegister(const std::string& classname)
|
||||
@ -45,10 +33,4 @@ namespace ngcore
|
||||
std::make_unique<std::map<std::string, detail::ClassArchiveInfo>>();
|
||||
return type_register->count(classname) != 0;
|
||||
}
|
||||
|
||||
|
||||
static bool dummy = [](){
|
||||
SetLibraryVersion("netgen", NETGEN_VERSION);
|
||||
return true;
|
||||
}();
|
||||
} // namespace ngcore
|
||||
|
@ -30,9 +30,6 @@ namespace pybind11
|
||||
|
||||
namespace ngcore
|
||||
{
|
||||
// Libraries using this archive can store their version here to implement backwards compatibility
|
||||
NGCORE_API const VersionInfo& GetLibraryVersion(const std::string& library);
|
||||
NGCORE_API void SetLibraryVersion(const std::string& library, const VersionInfo& version);
|
||||
|
||||
class NGCORE_API Archive;
|
||||
|
||||
@ -570,9 +567,6 @@ namespace ngcore
|
||||
|
||||
virtual void FlushBuffer() {}
|
||||
|
||||
protected:
|
||||
static std::map<std::string, VersionInfo>& GetLibraryVersions();
|
||||
|
||||
private:
|
||||
template<typename T, typename ... Bases>
|
||||
friend class RegisterClassForArchive;
|
||||
|
@ -230,7 +230,6 @@ namespace ngcore
|
||||
using ARCHIVE::stream;
|
||||
using ARCHIVE::version_map;
|
||||
using ARCHIVE::logger;
|
||||
using ARCHIVE::GetLibraryVersions;
|
||||
public:
|
||||
PyArchive(const pybind11::object& alst = pybind11::none()) :
|
||||
ARCHIVE(std::make_shared<std::stringstream>()),
|
||||
@ -275,10 +274,11 @@ namespace ngcore
|
||||
|
||||
pybind11::list WriteOut()
|
||||
{
|
||||
auto version_runtime = GetLibraryVersions();
|
||||
FlushBuffer();
|
||||
lst.append(pybind11::bytes(std::static_pointer_cast<std::stringstream>(stream)->str()));
|
||||
stream = std::make_shared<std::stringstream>();
|
||||
*this & GetLibraryVersions();
|
||||
*this & version_runtime;
|
||||
FlushBuffer();
|
||||
lst.append(pybind11::bytes(std::static_pointer_cast<std::stringstream>(stream)->str()));
|
||||
stream = std::make_shared<std::stringstream>();
|
||||
|
29
libsrc/core/version.cpp
Normal file
29
libsrc/core/version.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include <map>
|
||||
|
||||
#include <netgen_version.hpp>
|
||||
#include "exception.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
namespace ngcore
|
||||
{
|
||||
// clang-tidy should ignore this static object
|
||||
static std::map<std::string, VersionInfo> library_versions; // NOLINT
|
||||
|
||||
const VersionInfo& GetLibraryVersion(const std::string& library)
|
||||
{ return library_versions[library]; }
|
||||
|
||||
const std::map<std::string, VersionInfo>& GetLibraryVersions()
|
||||
{ return library_versions; }
|
||||
|
||||
void SetLibraryVersion(const std::string& library, const VersionInfo& version)
|
||||
{
|
||||
if(library_versions.count(library) && (library_versions[library] != version))
|
||||
throw Exception("Failed to set library version for " + library + " to " + version.to_string() + ": version already set to " + library_versions[library].to_string());
|
||||
library_versions[library] = version;
|
||||
}
|
||||
|
||||
static bool dummy = [](){
|
||||
SetLibraryVersion("netgen", NETGEN_VERSION);
|
||||
return true;
|
||||
}();
|
||||
} // namespace ngcore
|
@ -80,6 +80,10 @@ namespace ngcore
|
||||
return mayor_ == other.mayor_ && minor_ == other.minor_ && release == other.release
|
||||
&& patch == other.patch;
|
||||
}
|
||||
bool operator !=(const VersionInfo& other) const
|
||||
{
|
||||
return !(*this==other);
|
||||
}
|
||||
bool operator >(const VersionInfo& other) const { return other < (*this); }
|
||||
bool operator <=(const VersionInfo& other) const { return !((*this) > other); }
|
||||
bool operator >=(const VersionInfo& other) const { return !((*this) < other); }
|
||||
@ -89,6 +93,10 @@ namespace ngcore
|
||||
{
|
||||
return ost << version.to_string();
|
||||
}
|
||||
|
||||
NGCORE_API const VersionInfo& GetLibraryVersion(const std::string& library);
|
||||
NGCORE_API const std::map<std::string, VersionInfo>& GetLibraryVersions();
|
||||
NGCORE_API void SetLibraryVersion(const std::string& library, const VersionInfo& version);
|
||||
} // namespace ngcore
|
||||
|
||||
#endif // NETGEN_CORE_VERSION_HPP
|
||||
|
@ -435,6 +435,7 @@ namespace netgen
|
||||
int inverttets = 0; // globflags.GetDefineFlag ("inverttets");
|
||||
int invertsurf = 0; // globflags.GetDefineFlag ("invertsurfacemesh");
|
||||
|
||||
outfile << "# Generated by NETGEN " << GetLibraryVersion("netgen") << endl << endl;
|
||||
|
||||
|
||||
outfile << "mesh3d" << "\n";
|
||||
|
Loading…
Reference in New Issue
Block a user