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

@@ -12,6 +12,8 @@ set(CMAKE_AUTORCC ON)
# setup project # setup project
project(enzo) project(enzo)
set(ENZO_DEV_LIB_DIR "${CMAKE_SOURCE_DIR}/build/src/OpDefs/")
set(ENGINE_SOURCES set(ENGINE_SOURCES
src/Engine/Operator/Attribute.cpp src/Engine/Operator/Attribute.cpp
src/Engine/Operator/Geometry.cpp src/Engine/Operator/Geometry.cpp
@@ -91,16 +93,28 @@ qt_add_executable(${AppExec}
${ENGINE_SOURCES} ${ENGINE_SOURCES}
) )
target_compile_definitions(${AppExec} PRIVATE ENZO_DEV_LIB_DIR="${ENZO_DEV_LIB_DIR}")
# --- packaging --- # --- packaging ---
if(UNIX) set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/CPackProjectConfig.cmake)
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt")
endif(UNIX)
set(ENZO_BIN_DIR ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_PROJECT_NAME}/bin) set(CPACK_GENERATOR "RPM;TGZ")
set(ENZO_BIN_DIR ${CMAKE_PROJECT_NAME}/bin)
set(ENZO_LIB_DIR ${CMAKE_PROJECT_NAME}/lib)
install(
TARGETS ${AppExec}
RUNTIME DESTINATION ${ENZO_BIN_DIR}
LIBRARY DESTINATION ${ENZO_LIB_DIR}
ARCHIVE DESTINATION ${ENZO_LIB_DIR}
)
install(TARGETS ${AppExec} RUNTIME DESTINATION ${ENZO_BIN_DIR})
include(CPack) include(CPack)
# set(CPACK_RPM_PACKAGE_REQUIRES "openssl >= 1.1.1, zlib >= 1.2.11")
# --- end packaging # --- end packaging

View File

@@ -0,0 +1,12 @@
if (CPACK_GENERATOR MATCHES "RPM")
# rpm specific config
if(UNIX)
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt")
endif(UNIX)
elseif(CPACK_GENERATOR MATCHES "TGZ")
# tgz specific config
endif()

View File

@@ -2,8 +2,13 @@
#include "Engine/Operator/OpInfo.h" #include "Engine/Operator/OpInfo.h"
#include "Engine/Types.h" #include "Engine/Types.h"
#include <boost/dll/import.hpp> #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 <iostream>
#include <stdexcept>
void enzo::op::OperatorTable::addOperator(enzo::op::OpInfo info) void enzo::op::OperatorTable::addOperator(enzo::op::OpInfo info)
{ {
@@ -48,13 +53,59 @@ std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::getData()
return opInfoStore_; 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() void enzo::op::OperatorTable::initPlugins()
{ {
static bool pluginsLoaded=false; static bool pluginsLoaded=false;
if(pluginsLoaded) return; 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)>( auto initPlugin = boost::dll::import_symbol<void(enzo::op::addOperatorPtr)>(
"build/src/OpDefs/libenzoOps1.so", "newSopOperator" findPlugin("enzoOps1"), "newSopOperator"
); );
initPlugin(enzo::op::OperatorTable::addOperator); initPlugin(enzo::op::OperatorTable::addOperator);

View File

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

View File

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