diff --git a/README.md b/README.md index c1f6b7b..4426864 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Download](https://api.bintray.com/packages/lukaszlaszko/shadow/di%3Ashadow/images/download.svg) ](https://bintray.com/lukaszlaszko/shadow/di%3Ashadow/_latestVersion) [![Build Status](https://travis-ci.org/lukaszlaszko/di.svg?branch=master)](https://travis-ci.org/lukaszlaszko/di) [![codecov](https://codecov.io/gh/lukaszlaszko/di/branch/master/graph/badge.svg)](https://codecov.io/gh/lukaszlaszko/di) [![CodeFactor](https://www.codefactor.io/repository/github/lukaszlaszko/di/badge)](https://www.codefactor.io/repository/github/lukaszlaszko/di) @@ -16,6 +17,7 @@ * [Annotations](#annotations) * [Usage](#usage) * [Compilation](#compilation) + * [Conan package](#conan-package) ---- @@ -521,3 +523,58 @@ $ sudo apt-get install libstdc++-6-dev ``` after prior registration of `ubuntu-toolchain-r-test` source channel. + +#### Conan package + +[Conan](https://docs.conan.io/en/latest) is an opena source package manager for C/C++. [Bintray shadow](https://bintray.com/lukaszlaszko/shadow) +repository provides latest redistributable package with project artefacts. In order to use it in your cmake based project: + +1. Add following block to root `CMakeLists.txt` of your project: + + ```cmake + if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup() + else() + message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first") + endif() + ``` + +2. Add `conanfile.txt` side by side with your top level `CMakeLists.txt`: + + ```text + [requires] + di/1.0@shadow/stable + + [generators] + cmake + ``` + +4. Add `shadow` to your list of conan remotes: + + ``` + $ conan remote add shadow https://api.bintray.com/conan/lukaszlaszko/shadow + ``` + +3. Install conan dependencies into your cmake build directory: + + ``` + $ conan install . -if + ``` + + if for whatever reason installation of binary package fails, add `--build di` flag to the above. This will perform install the source package and compile all necessary modules. + +4. To link against libraries provided by the package, either add: + + ```cmake + target_link_libraries([..] ${CONAN_LIBS}) + ``` + + for your target. Or specifically: + + ```cmake + target_link_libraries([..] ${CONAN_LIBS_DI}) + ``` + +5. Reload cmake configuration. + diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..b54a39f --- /dev/null +++ b/conanfile.py @@ -0,0 +1,33 @@ +from conans import ConanFile, CMake + + +class DiConan(ConanFile): + name = "di" + version = "1.0" + license = "Apache-2.0" + author = "Lukasz Laszko lukaszlaszko@gmail.com" + url = "https://github.com/lukaszlaszko/di" + description = "Compile and runtime dependency injection for C++ 14" + topics = ("dependency injection", "di", "c++", "cpp", "", "cxx") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False]} + default_options = "shared=False" + generators = "cmake" + exports_sources = ["CMakeLists.txt", "src/*", "external/*", "tests/*"] + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build(target="di") + + def package(self): + self.copy("*.hpp", dst="include", src="src") + self.copy("*.ipp", dst="include", src="src") + self.copy("*.lib", dst="lib", keep_path=False) + self.copy("*.dll", dst="bin", keep_path=False) + self.copy("*.dylib*", dst="lib", keep_path=False) + self.copy("*.so", dst="lib", keep_path=False) + self.copy("*.a", dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["di"] diff --git a/tests/unit/di/definition_builder_tests.cpp b/tests/unit/di/definition_builder_tests.cpp index 37fe167..a311e92 100644 --- a/tests/unit/di/definition_builder_tests.cpp +++ b/tests/unit/di/definition_builder_tests.cpp @@ -1041,11 +1041,15 @@ TEST(definition_builder, define_decorator__lambda__unique_pointer__context) { struct interface { + virtual ~interface() = default; + virtual void method() { }; }; struct component : interface { + virtual ~component() = default; + void method() override { } @@ -1088,11 +1092,15 @@ TEST(definition_builder, define_decorator__lambda__unique_pointer__no_context) { struct interface { + virtual ~interface() = default; + virtual void method() { }; }; struct component : interface { + virtual ~component() = default; + void method() override { } @@ -1221,11 +1229,15 @@ TEST(definition_builder, define_decorator__unique_pointer__static_method__conte { struct interface { + virtual ~interface() = default; + virtual void method() { }; }; struct component : interface { + virtual ~component() = default; + void method() override { } @@ -1272,11 +1284,15 @@ TEST(definition_builder, define_decorator__unique_pointer__static_method__no_co { struct interface { + virtual ~interface() = default; + virtual void method() { }; }; struct component : interface { + virtual ~component() = default; + void method() override { } @@ -1323,11 +1339,15 @@ TEST(definition_builder, define_decorator__unique_pointer__non_static_method__c { struct interface { + virtual ~interface() = default; + virtual void method() { }; }; struct component : interface { + virtual ~component() = default; + void method() override { } @@ -1377,11 +1397,15 @@ TEST(definition_builder, define_decorator__unique_pointer__non_static_method__n { struct interface { + virtual ~interface() = default; + virtual void method() { }; }; struct component : interface { + virtual ~component() = default; + void method() override { } diff --git a/tests/unit/di/instance_activator_tests.cpp b/tests/unit/di/instance_activator_tests.cpp index f17bb52..759b164 100644 --- a/tests/unit/di/instance_activator_tests.cpp +++ b/tests/unit/di/instance_activator_tests.cpp @@ -1904,11 +1904,15 @@ TEST(instance_activator, activate__decorate__unique_ptr) struct interface { + virtual ~interface() = default; + virtual void method() = 0; }; struct component : interface { + virtual ~component() = default; + void method() override { component_count++; @@ -1958,11 +1962,15 @@ TEST(instance_activator, activate__decorate__unique_ptr__multidecoration) struct interface { + virtual ~interface() = default; + virtual void method() = 0; }; struct component : interface { + virtual ~component() = default; + void method() override { component_count++;