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);