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

feat: add bacnet stack #909

Merged
merged 31 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
58f6761
feat: add bacnet stack
gocarlos Feb 18, 2020
8f50357
Update recipes/bacnet-stack/all/test_package/conanfile.py
gocarlos Feb 18, 2020
719870a
Update recipes/bacnet-stack/all/test_package/conanfile.py
gocarlos Feb 18, 2020
39c46e8
Update recipes/bacnet-stack/all/conandata.yml
gocarlos Feb 18, 2020
6efbdd4
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
7bdfb83
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
74cfd1d
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
2c50b76
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
1c6267c
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
b6b5286
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
cbd1745
Update recipes/bacnet-stack/all/test_package/conanfile.py
gocarlos Feb 18, 2020
a69469e
Update recipes/bacnet-stack/all/test_package/conanfile.py
gocarlos Feb 18, 2020
c906941
Update recipes/bacnet-stack/all/test_package/conanfile.py
gocarlos Feb 18, 2020
96de499
Update recipes/bacnet-stack/config.yml
gocarlos Feb 18, 2020
39fa186
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
c0e2a18
Update recipes/bacnet-stack/all/test_package/conanfile.py
gocarlos Feb 18, 2020
4f9c96f
Apply suggestions from code review
gocarlos Feb 18, 2020
134cef9
Update recipes/bacnet-stack/config.yml
gocarlos Feb 18, 2020
311c37c
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
e4cb397
Apply suggestions from code review
gocarlos Feb 18, 2020
e851435
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
8e4aeef
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Feb 18, 2020
908c0d3
Apply suggestions from code review
gocarlos Feb 18, 2020
d6bd90b
Apply suggestions from code review
gocarlos Feb 18, 2020
ca6698a
chore: simplify test file
gocarlos Feb 25, 2020
495dce9
chore: add invalid conf for shared libs
gocarlos Mar 2, 2020
83f96e9
chore: apply test patch
gocarlos Mar 2, 2020
57fcf25
chore: update patch
gocarlos Mar 5, 2020
19a925c
chore: remove patch
gocarlos Mar 7, 2020
1528e51
Update recipes/bacnet-stack/all/conanfile.py
gocarlos Mar 10, 2020
c17bf6c
fix: cmake min required command
gocarlos Mar 10, 2020
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
7 changes: 7 additions & 0 deletions recipes/bacnet-stack/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.11)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/bacnet-stack/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"20200306":
sha256: bf61bc7ffe556b30464ac0734e18d975fe6a8676d9c2fcb7c215981a46381847
url: https://github.com/bacnet-stack/bacnet-stack/archive/4a916468c63de478b84ef4d0c67d541cd84da27e.zip
76 changes: 76 additions & 0 deletions recipes/bacnet-stack/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import os
from conans import CMake, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
gocarlos marked this conversation as resolved.
Show resolved Hide resolved


class BacnetStackConan(ConanFile):
name = "bacnet-stack"
license = "GPL-2.0-or-later"
homepage = "https://github.com/bacnet-stack/bacnet-stack/"
url = "https://github.com/conan-io/conan-center-index"
description = """
BACnet Protocol Stack library provides a BACnet application layer,
network layer and media access (MAC) layer communications services."""
topics = ("bacnet")
exports_sources = ['CMakeLists.txt']
settings = "os", "compiler", "build_type", "arch"
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True
}
generators = "cmake", "cmake_find_package"

gocarlos marked this conversation as resolved.
Show resolved Hide resolved
_cmake = None

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

gocarlos marked this conversation as resolved.
Show resolved Hide resolved
@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("Windows shared builds are not supported right now, see issue https://github.com/bacnet-stack/bacnet-stack/issues/49")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + os.path.basename(self.conan_data["sources"][self.version]["url"]).split(".")[0]
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["BACNET_STACK_BUILD_APPS"] = False
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

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

def package(self):
self.copy("gpl-2.txt", dst='licenses', src=os.path.join(self._source_subfolder, "license"))
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder,
"lib", "bacnet-stack", "cmake"))

def package_info(self):
self.cpp_info.libs = ["bacnet-stack"]
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["pthread"]
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions recipes/bacnet-stack/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project(test_package)
cmake_minimum_required(VERSION 2.8.11)

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

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
18 changes: 18 additions & 0 deletions recipes/bacnet-stack/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from conans import ConanFile, CMake, tools


class TestConan(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")
bin_path = self.run(bin_path, run_environment=True)
24 changes: 24 additions & 0 deletions recipes/bacnet-stack/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "bacnet/basic/object/device.h"
#include "bacnet/basic/service/h_apdu.h"
#include "bacnet/basic/binding/address.h"
#include "bacnet/bacdef.h"
#include "bacnet/basic/services.h"

static void Init_Service_Handlers(void)
{
Device_Init(nullptr);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
apdu_set_unrecognized_service_handler_handler(handler_unrecognized_service);
apdu_set_confirmed_handler(
SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, handler_i_am_add);
}

int main(int argc, char *argv[])
{
address_init();
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
Init_Service_Handlers();

return 0;
}
4 changes: 4 additions & 0 deletions recipes/bacnet-stack/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
versions:
"20200306":
folder: "all"