Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add open62541/1.1 #1856

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions recipes/open62541/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.1.2)

project(cmake_wrapper)
message(WARNING "Conan Open62541 Wrapped CMake")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
message(WARNING "Conan Open62541 Wrapped CMake")


include(conanbuildinfo.cmake)
conan_basic_setup(NO_OUTPUT_DIRS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required?

add_subdirectory(source_subfolder)

4 changes: 4 additions & 0 deletions recipes/open62541/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.0.1":
sha256: ae9fac217267bccdf360fe0f1788f4d65875b06028404cf2440600927d2b3ad3
url: "https://github.com/open62541/open62541/archive/v1.0.1.tar.gz"
212 changes: 212 additions & 0 deletions recipes/open62541/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os
import glob
import shutil


class Open62541Conan(ConanFile):
name = "open62541"
url = "https://github.com/conan-io/conan-center-index"
description = "Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0"
topics = ("conan", "opcua", "iec 62541")
homepage = "http://open62541.org"
license = "MPL-2.0"
exports_sources = ["CMakeLists.txt"]
generators = "cmake", "cmake_find_package"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"multithread": ["no", "thread-safe", "internal-threads"],
"tls": ["openssl", "mbedtls", False],
"enable_amalgamation": [True, False],
"enable_historizing": [True, False],
"enable_methodcalls": [True, False],
"enable_nodemanagement": [True, False],
"enable_subscriptions": [True, False],
"enable_subscriptions_events": [True, False],
"enable_discovery": [True, False],
"enable_subscriptions_alarms_conditions": [True, False],
"enable_discovery_multicast": [True, False],
"enable_parsing": [True, False],
"enable_da": [True, False],
"enable_micro_emb_dev_profile": [True, False],
"enable_websocket_server": [True, False],
"enable_query": [True, False],
"enable_immutable_nodes": [True, False],
"enable_experiemental_historizing": [True, False],
"force_cpp": [True, False],
"enable_pubsub": [True, False],
"enable_pubsub_eth_uadp": [True, False],
"enable_pubsub_eth_uadp_xdp": [True, False],
"enable_pubsub_deltaframes": [True, False],
"enable_pubsub_informationmodel": [True, False],
"enable_pubsub_informationmodel_methods": [True, False],
"enable_pubsub_custom_publish_handling": [True, False],
"enable_pubsub_eth_uadp_etf": [True, False],
"enable_json_encoding": [True, False],
"enable_pubsub_mqtt": [True, False],
"enable_statuscode_descriptions": [True, False],
"enable_typedescription": [True, False],
"enable_nodeset_compiler_descriptions": [True, False],
"enable_malloc_singleton": [True, False],
"msvc_force_static_crt": [True, False],
"enable_discovery_semaphore": [True, False],
"debug_dump_pkgs": [True, False],
"enable_hardening": [True, False]
}

default_options = {
"shared": False,
"fPIC": True,
"multithread": "no",
"tls": "mbedtls",
"enable_amalgamation": True,
"enable_historizing": False,
"enable_methodcalls": True,
"enable_nodemanagement": True,
"enable_subscriptions": True,
"enable_subscriptions_events": False,
"enable_discovery": True,
"enable_subscriptions_alarms_conditions": False,
"enable_discovery_multicast": False,
"enable_parsing": True,
"enable_da": True,
"enable_micro_emb_dev_profile": False,
"enable_websocket_server": False,
"enable_query": False,
"enable_immutable_nodes": False,
"enable_experiemental_historizing": False,
"force_cpp": False,
"enable_pubsub": False,
"enable_pubsub_eth_uadp": False,
"enable_pubsub_eth_uadp_xdp": False,
"enable_pubsub_deltaframes": False,
"enable_pubsub_informationmodel": False,
"enable_pubsub_informationmodel_methods": False,
"enable_pubsub_custom_publish_handling": False,
"enable_pubsub_eth_uadp_etf": False,
"enable_json_encoding": False,
"enable_pubsub_mqtt": False,
"enable_statuscode_descriptions": True,
"enable_typedescription": True,
"enable_nodeset_compiler_descriptions": True,
"enable_malloc_singleton": False,
"msvc_force_static_crt": True,
"enable_discovery_semaphore": True,
"debug_dump_pkgs": False,
"enable_hardening": True
}

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def requirements(self):
if self.options.tls == "openssl":
self.requires("openssl/1.1.1g")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.requires("openssl/1.1.1g")
self.requires("openssl/1.1.1h")


if self.options.tls == "mbedtls":
self.requires("mbedtls/2.16.3-apache")

if self.options.enable_websocket_server:
raise ConanInvalidConfiguration("libwebsocket is not (yet) available on CCI")
self.requires("libwebsockets/x.y.z")


def source(self):
archive_name = self.name + "-" + self.version
tools.get(**self.conan_data["sources"][self.version])
os.rename(archive_name, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)

self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
self._cmake.definitions["UA_ARCHITECTURE"] = "win32" if self.settings.os == "Windows" else "posix"

if self.options.tls == "openssl":
self._cmake.definitions["UA_ENABLE_ENCRYPTION_OPENSSL"] = True

if self.options.tls == "mbedtls":
self._cmake.definitions["UA_ENABLE_ENCRYPTION_MBEDTLS"] = True

if self.options.multithread == "no":
self._cmake.definitions["UA_MULTITHREADING"] = "0"

if self.options.multithread == "thread-safe":
self._cmake.definitions["UA_MULTITHREADING"] = "100"

if self.options.multithread == "internal-threads":
self._cmake.definitions["UA_MULTITHREADING"] = "200"
syoliver marked this conversation as resolved.
Show resolved Hide resolved

self._cmake.definitions["UA_ENABLE_AMALGAMATION"] = self.options.enable_amalgamation
self._cmake.definitions["UA_ENABLE_HISTORIZING"] = self.options.enable_historizing
self._cmake.definitions["UA_ENABLE_METHODCALLS"] = self.options.enable_methodcalls
self._cmake.definitions["UA_ENABLE_NODEMANAGEMENT"] = self.options.enable_nodemanagement
self._cmake.definitions["UA_ENABLE_SUBSCRIPTIONS"] = self.options.enable_subscriptions
self._cmake.definitions["UA_ENABLE_SUBSCRIPTIONS_EVENTS"] = self.options.enable_subscriptions_events
self._cmake.definitions["UA_ENABLE_DISCOVERY"] = self.options.enable_discovery
self._cmake.definitions["UA_ENABLE_SUBSCRIPTIONS_ALARMS_CONDITIONS"] = self.options.enable_subscriptions_alarms_conditions
self._cmake.definitions["UA_ENABLE_DISCOVERY_MULTICAST"] = self.options.enable_discovery_multicast
self._cmake.definitions["UA_ENABLE_PARSING"] = self.options.enable_parsing
self._cmake.definitions["UA_ENABLE_DA"] = self.options.enable_da
self._cmake.definitions["UA_ENABLE_MICRO_EMB_DEV_PROFILE"] = self.options.enable_micro_emb_dev_profile
self._cmake.definitions["UA_ENABLE_WEBSOCKET_SERVER"] = self.options.enable_websocket_server
self._cmake.definitions["UA_ENABLE_QUERY"] = self.options.enable_query
self._cmake.definitions["UA_ENABLE_IMMUTABLE_NODES"] = self.options.enable_immutable_nodes
self._cmake.definitions["UA_ENABLE_EXPERIMENTAL_HISTORIZING"] = self.options.enable_experiemental_historizing
self._cmake.definitions["UA_FORCE_32BIT"] = not(self.settings.arch == "armv8" or self.settings.arch == "x86_64")
self._cmake.definitions["UA_FORCE_CPP"] = self.options.force_cpp
self._cmake.definitions["UA_ENABLE_PUBSUB"] = self.options.enable_pubsub
self._cmake.definitions["UA_ENABLE_PUBSUB_ETH_UADP"] = self.options.enable_pubsub_eth_uadp
self._cmake.definitions["UA_ENABLE_PUBSUB_ETH_UADP_XDP"] = self.options.enable_pubsub_eth_uadp_xdp
self._cmake.definitions["UA_ENABLE_PUBSUB_DELTAFRAMES"] = self.options.enable_pubsub_deltaframes
self._cmake.definitions["UA_ENABLE_PUBSUB_INFORMATIONMODEL"] = self.options.enable_pubsub_informationmodel
self._cmake.definitions["UA_ENABLE_PUBSUB_INFORMATIONMODEL_METHODS"] = self.options.enable_pubsub_informationmodel_methods
self._cmake.definitions["UA_ENABLE_PUBSUB_CUSTOM_PUBLISH_HANDLING"] = self.options.enable_pubsub_custom_publish_handling
self._cmake.definitions["UA_ENABLE_PUBSUB_ETH_UADP_ETF"] = self.options.enable_pubsub_eth_uadp_etf
self._cmake.definitions["UA_ENABLE_JSON_ENCODING"] = self.options.enable_json_encoding
self._cmake.definitions["UA_ENABLE_PUBSUB_MQTT"] = self.options.enable_pubsub_mqtt
self._cmake.definitions["UA_ENABLE_STATUSCODE_DESCRIPTIONS"] = self.options.enable_statuscode_descriptions
self._cmake.definitions["UA_ENABLE_TYPEDESCRIPTION"] = self.options.enable_typedescription
self._cmake.definitions["UA_ENABLE_NODESET_COMPILER_DESCRIPTIONS"] = self.options.enable_nodeset_compiler_descriptions
self._cmake.definitions["UA_ENABLE_MALLOC_SINGLETON"] = self.options.enable_malloc_singleton
self._cmake.definitions["UA_MSVC_FORCE_STATIC_CRT"] = self.options.msvc_force_static_crt
self._cmake.definitions["UA_ENABLE_DISCOVERY_SEMAPHORE"] = self.options.enable_discovery_semaphore
self._cmake.definitions["UA_DEBUG_DUMP_PKGS"] = self.options.debug_dump_pkgs
self._cmake.definitions["UA_ENABLE_HARDENING"] = self.options.enable_hardening
self._cmake.definitions["OPEN62541_VERSION"] = self.version

self._cmake.configure(source_dir=self._source_subfolder)
return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
for f in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")):
os.remove(f)
for f in glob.glob(os.path.join(self.package_folder, "lib", "*.pdb")):
os.remove(f)
shutil.move(os.path.join(self.package_folder, "share", "open62541", "tools"), os.path.join(self.package_folder, "bin", "tools"))
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))


def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In package, you remove lib/cmake and lib/pkgconfig.
Please check + add the cmake_find_package/cmake_find_package_multi/pkg_config names.

In the future, .pc will files might be created only for those recipes that set pkg_config explicitly. So that one should be set anyhow.

10 changes: 10 additions & 0 deletions recipes/open62541/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8.11)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

find_package(Threads)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
17 changes: 17 additions & 0 deletions recipes/open62541/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
51 changes: 51 additions & 0 deletions recipes/open62541/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
* See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */

#include "open62541.h"

#include <signal.h>
#include <stdlib.h>

/* Build Instructions (Linux)
* - gcc -std=c99 -c open62541.c
* - g++ server.cpp open62541.o -o server */

UA_Boolean running = true;

static void stopHandler(int sign) {
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "received ctrl-c");
running = false;
}

int main() {
signal(SIGINT, stopHandler);
signal(SIGTERM, stopHandler);

UA_Server *server = UA_Server_new();
UA_ServerConfig_setDefault(UA_Server_getConfig(server));

// add a variable node to the adresspace
UA_VariableAttributes attr = UA_VariableAttributes_default;
UA_Int32 myInteger = 42;
UA_Variant_setScalarCopy(&attr.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
attr.description = UA_LOCALIZEDTEXT_ALLOC("en-US","the answer");
attr.displayName = UA_LOCALIZEDTEXT_ALLOC("en-US","the answer");
UA_NodeId myIntegerNodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME_ALLOC(1, "the answer");
UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
parentReferenceNodeId, myIntegerName,
UA_NODEID_NULL, attr, NULL, NULL);

/* allocations on the heap need to be freed */
UA_VariableAttributes_clear(&attr);
UA_NodeId_clear(&myIntegerNodeId);
UA_QualifiedName_clear(&myIntegerName);

// UA_StatusCode retval = UA_Server_run(server, &running);
UA_StatusCode retval = UA_STATUSCODE_GOOD;

UA_Server_delete(server);
return retval == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE;
}
3 changes: 3 additions & 0 deletions recipes/open62541/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.0.1":
folder: all