feat: working rpm and targz packages with opDefs library

This commit is contained in:
parker
2025-08-12 22:22:46 +01:00
parent b832b37341
commit 3557c4d4e7
6 changed files with 113 additions and 28 deletions

View File

@@ -2,8 +2,13 @@
#include "Engine/Operator/OpInfo.h"
#include "Engine/Types.h"
#include <boost/dll/import.hpp>
#include <boost/dll/runtime_symbol_info.hpp>
#include <boost/filesystem/file_status.hpp>
#include <icecream.hpp>
#include <boost/dll/shared_library.hpp>
#include <iostream>
#include <stdexcept>
void enzo::op::OperatorTable::addOperator(enzo::op::OpInfo info)
{
@@ -48,13 +53,59 @@ std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::getData()
return opInfoStore_;
}
boost::filesystem::path enzo::op::OperatorTable::findPlugin(const std::string& undecoratedLibName)
{
const auto libName = boost::dll::shared_library::decorate(undecoratedLibName);
// check for lib dir
{
const boost::filesystem::path executable = boost::dll::program_location();
const boost::filesystem::path enzoRoot = executable.parent_path().parent_path();
const boost::filesystem::path enzoLib = enzoRoot / "lib";
const boost::filesystem::path candidate = enzoLib / libName;
if(boost::filesystem::exists(candidate))
{
IC(candidate);
return candidate;
}
else std::cout << "Couldn't find lib at: " << candidate.string() << "\n";
}
// check for dev macro
#ifndef ENZO_DEV_LIB_DIR
#define ENZO_DEV_LIB_DIR ""
#endif
if(std::string(ENZO_DEV_LIB_DIR).size())
{
const auto candidate = boost::filesystem::path(ENZO_DEV_LIB_DIR) / libName;
if(boost::filesystem::exists(candidate))
{
IC(candidate);
return candidate;
}
else std::cout << "Couldn't find lib at: " << candidate.string() << "\n";
}
// TODO: add env var finder
// TODO: add same dirfinder
throw std::runtime_error("Couldn't find plugin: " + libName.string());
}
void enzo::op::OperatorTable::initPlugins()
{
static bool pluginsLoaded=false;
if(pluginsLoaded) return;
// auto initPlugin = boost::dll::import_symbol<void(enzo::op::addOperatorPtr)>(
// "build/src/OpDefs/libenzoOps1.so", "newSopOperator"
// );
auto initPlugin = boost::dll::import_symbol<void(enzo::op::addOperatorPtr)>(
"build/src/OpDefs/libenzoOps1.so", "newSopOperator"
findPlugin("enzoOps1"), "newSopOperator"
);
initPlugin(enzo::op::OperatorTable::addOperator);

View File

@@ -5,6 +5,7 @@
#include "Engine/Operator/GeometryOpDef.h"
#include "Engine/Operator/OpInfo.h"
#include "Engine/Parameter/Template.h"
#include <boost/filesystem.hpp>
namespace enzo::op
@@ -17,6 +18,7 @@ public:
static nt::opConstructor getOpConstructor(std::string name);
static const std::optional<op::OpInfo> getOpInfo(std::string name);
static std::vector<OpInfo> getData();
static boost::filesystem::path findPlugin(const std::string& undecoratedLibName);
// TODO: move to better spot (maybe engine class)
static void initPlugins();
private:

View File

@@ -32,6 +32,12 @@ add_library(${libName} SHARED
)
target_link_libraries(${libName} PRIVATE Qt6::Core Qt6::Widgets Qt6::SvgWidgets Qt6::OpenGLWidgets glm::glm Eigen3::Eigen TBB::tbb)
# packaging
install(TARGETS ${libName}
LIBRARY DESTINATION ${ENZO_LIB_DIR}
ARCHIVE DESTINATION ${ENZO_LIB_DIR}
)
MESSAGE("CURRENT SOURCE DIR" ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${libName} PUBLIC

View File

@@ -25,28 +25,28 @@ extern "C"
1,
}
);
addOperator(
enzo::op::OpInfo {
"house",
"House",
&GOP_house::ctor,
GOP_house::parameterList,
0,
0,
1,
}
);
addOperator(
enzo::op::OpInfo {
"testGeoCube",
"Test Cube",
&GopTestGeoCube::ctor,
GopTestGeoCube::parameterList,
0,
0,
1,
}
);
// addOperator(
// enzo::op::OpInfo {
// "house",
// "House",
// &GOP_house::ctor,
// GOP_house::parameterList,
// 0,
// 0,
// 1,
// }
// );
// addOperator(
// enzo::op::OpInfo {
// "testGeoCube",
// "Test Cube",
// &GopTestGeoCube::ctor,
// GopTestGeoCube::parameterList,
// 0,
// 0,
// 1,
// }
// );
addOperator(
enzo::op::OpInfo {
"geometryImport",