diff --git a/.github/actions/CMake/action.yml b/.github/actions/CMake/action.yml deleted file mode 100644 index 2a293ff..0000000 --- a/.github/actions/CMake/action.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Run CMake -description: "Runs CMake" -inputs: - args: - description: "Other arguments" - required: false - default: "" - cmake-version: - description: "The CMake version to run" - required: true - library-type: - description: "Library Type" - required: true - - -runs: - using: composite - steps: - - name: CMake ${{ inputs.cmake-version }} - uses: jwlawson/actions-setup-cmake@v1.13 - with: - cmake-version: "${{ inputs.cmake-version }}" - - - name: Install Conan - uses: turtlebrowser/get-conan@main - - - name: Configure Conan - run: conan profile detect - shell: bash - - - name: Install Conan Packages - run: conan install . --output-folder=${{github.workspace}}/build --build=missing - shell: bash - - - name: Configure CMake - working-directory: ${{github.workspace}}/build - run: cmake .. -DLIBRARY_TYPE=${{ inputs.library-type }} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS:BOOL=true -DBUILD_EXAMPLES:BOOL=true -DCMAKE_TOOLCHAIN_FILE:STRING="conan_toolchain.cmake" ${{ inputs.args }} - shell: bash - - - name: Build - working-directory: ${{github.workspace}}/build - run: cmake --build . --config ${{ env.BUILD_TYPE }} - shell: bash - - - name: Test - working-directory: ${{github.workspace}}/build - run: ctest -C ${{env.BUILD_TYPE}} - shell: bash diff --git a/.github/actions/cmake-build/action.yml b/.github/actions/cmake-build/action.yml new file mode 100644 index 0000000..e1ded1c --- /dev/null +++ b/.github/actions/cmake-build/action.yml @@ -0,0 +1,35 @@ +name: Run CMake +description: "Runs CMake" +inputs: + args: + description: "Other arguments" + required: false + default: -DBUILD_TESTS:BOOL=true -DBUILD_EXAMPLES:BOOL=true + build-type: + description: "Build type" + required: false + default: Release + toolchain: + description: "Toolchain file" + required: false + default: conan_toolchain.cmake + library-type: + description: "Library type" + required: false + default: Static + build-dir: + description: "Build directory" + required: true + +runs: + using: composite + steps: + - name: Configure CMake + working-directory: ${{ inputs.build-dir }} + run: cmake .. -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} -DLIBRARY_TYPE=${{ inputs.library-type }} -DCMAKE_TOOLCHAIN_FILE:STRING="${{ inputs.toolchain }}" ${{ inputs.args }} + shell: pwsh + + - name: Build + working-directory: ${{ inputs.build-dir }} + run: cmake --build . --config ${{ inputs.build-type }} + shell: pwsh diff --git a/.github/actions/conan-install/action.yml b/.github/actions/conan-install/action.yml new file mode 100644 index 0000000..c8b2cf0 --- /dev/null +++ b/.github/actions/conan-install/action.yml @@ -0,0 +1,20 @@ +name: Run CMake +description: "Runs CMake" +inputs: + install-dir: + description: "Installation directory" + required: true + +runs: + using: composite + steps: + - name: Install Conan + uses: turtlebrowser/get-conan@main + + - name: Configure Conan + run: conan profile detect + shell: pwsh + + - name: Install Conan Packages in ${{ inputs.install-dir }} + run: conan install . --output-folder=${{ inputs.install-dir }} --build=missing + shell: pwsh diff --git a/.github/workflows/BasicTest.yml b/.github/workflows/BasicTest.yml deleted file mode 100644 index d3dd3ad..0000000 --- a/.github/workflows/BasicTest.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: BasicTest - -on: - push: - branches: ["dev"] - pull_request: - branches: ["dev"] - -env: - BUILD_TYPE: Release - BUILD_DIR: ${{github.workspace}}/build - -jobs: - test: - strategy: - fail-fast: false - matrix: - libraryType: [Static] - os: [ubuntu-22.04, macos-12, windows-2022] - - runs-on: ${{matrix.os}} - - steps: - - uses: actions/checkout@v3 - - - name: Install Conan - uses: turtlebrowser/get-conan@main - - - name: Configure Conan - run: conan profile detect - - - name: Install Conan Packages - run: conan install . --output-folder=${{ env.BUILD_DIR }} --build=missing - - - name: Configure CMake - working-directory: ${{ env.BUILD_DIR }} - run: cmake .. -DLIBRARY_TYPE=${{ matrix.libraryType }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DBUILD_TESTS:BOOL=true -DBUILD_EXAMPLES:BOOL=true -DCMAKE_TOOLCHAIN_FILE:STRING="conan_toolchain.cmake" - - - name: Build - working-directory: ${{ env.BUILD_DIR }} - run: cmake --build . --config ${{ env.BUILD_TYPE }} - - - name: Test - working-directory: ${{ env.BUILD_DIR }} - run: ctest -C ${{env.BUILD_TYPE}} diff --git a/.github/workflows/DevCI.yml b/.github/workflows/DevCI.yml new file mode 100644 index 0000000..6e57f91 --- /dev/null +++ b/.github/workflows/DevCI.yml @@ -0,0 +1,47 @@ +name: DevCI + +on: + push: + branches: ["dev"] + paths-ignore: + - "Docs/**" + - ".readthedocs.yaml" + - "Readme.md" + pull_request: + branches: ["dev"] + paths-ignore: + - "Docs/**" + - ".readthedocs.yaml" + - "Readme.md" +env: + BUILD_TYPE: Release + BUILD_DIR: ${{github.workspace}}/build + +jobs: + test: + strategy: + fail-fast: false + matrix: + libraryType: [HeaderOnly, Static, Shared] + os: [ubuntu-22.04, macos-12, windows-2022] + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Install Conan Packages + uses: ./.github/actions/conan-install + with: + install-dir: ${{ env.BUILD_DIR }} + + - name: CMake Build + uses: ./.github/actions/cmake-build + with: + build-dir: ${{ env.BUILD_DIR }} + build-type: ${{ env.BUILD_TYPE }} + library-type: ${{ matrix.libraryType }} + + - name: Test + working-directory: ${{ env.BUILD_DIR }} + run: ctest -C ${{env.BUILD_TYPE}} diff --git a/.github/workflows/MainCI.yml b/.github/workflows/MainCI.yml new file mode 100644 index 0000000..c2737d3 --- /dev/null +++ b/.github/workflows/MainCI.yml @@ -0,0 +1,150 @@ +name: MainCI + +on: + push: + branches: ["main"] + paths-ignore: + - "Docs/**" + - ".readthedocs.yaml" + - "Readme.md" + pull_request: + branches: ["main"] + paths-ignore: + - "Docs/**" + - ".readthedocs.yaml" + - "Readme.md" + +env: + BUILD_TYPE: Release + BUILD_DIR: ${{github.workspace}}/build + +jobs: + test-gcc: + strategy: + matrix: + libraryType: [HeaderOnly, Static, Shared] + version: [7, 10, 12] + os: [ubuntu-22.04] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + + - name: Install GCC + uses: egor-tensin/setup-gcc@v1.3 + with: + version: ${{ matrix.version }} + + - name: Install Conan Packages + uses: ./.github/actions/conan-install + with: + install-dir: ${{ env.BUILD_DIR }} + + - name: CMake Build + uses: ./.github/actions/cmake-build + with: + build-dir: ${{ env.BUILD_DIR }} + build-type: ${{ env.BUILD_TYPE }} + + - name: Test + working-directory: ${{ env.BUILD_DIR }} + run: ctest -C ${{env.BUILD_TYPE}} + + test-mingw: + strategy: + matrix: + libraryType: [HeaderOnly, Static] + version: [7, 10, 12] + os: [windows-2022] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + + - name: Install MinGW + uses: egor-tensin/setup-mingw@v2.2.0 + with: + version: ${{ matrix.version }} + + - name: Install Conan Packages + uses: ./.github/actions/conan-install + with: + install-dir: ${{ env.BUILD_DIR }} + + - name: CMake Build + uses: ./.github/actions/cmake-build + with: + build-dir: ${{ env.BUILD_DIR }} + build-type: ${{ env.BUILD_TYPE }} + + - name: Test + working-directory: ${{ env.BUILD_DIR }} + run: ctest -C ${{env.BUILD_TYPE}} + + test-clang: + strategy: + matrix: + libraryType: [HeaderOnly, Static] + version: [6, 10, 15] + os: [windows-2022, ubuntu-22.04] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + + - name: Install Clang + uses: egor-tensin/setup-clang@v1.4 + with: + version: ${{ matrix.version }} + + - name: Install Conan Packages + uses: ./.github/actions/conan-install + with: + install-dir: ${{ env.BUILD_DIR }} + + - name: CMake Build + uses: ./.github/actions/cmake-build + with: + build-dir: ${{ env.BUILD_DIR }} + build-type: ${{ env.BUILD_TYPE }} + + - name: Test + working-directory: ${{ env.BUILD_DIR }} + run: ctest -C ${{env.BUILD_TYPE}} + + test-msvc: + strategy: + fail-fast: false + matrix: + libraryType: [HeaderOnly, Static] + version: [14, 15, 17] + os: [windows-2022] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + + - name: Install MSVC + uses: TheMrMilchmann/setup-msvc-dev@v2.0.0 + with: + toolset: ${{ matrix.version }} + arch: x64 + + - name: Install Conan Packages + uses: ./.github/actions/conan-install + with: + install-dir: ${{ env.BUILD_DIR }} + + - name: CMake Build + uses: ./.github/actions/cmake-build + with: + build-dir: ${{ env.BUILD_DIR }} + build-type: ${{ env.BUILD_TYPE }} + + - name: Test + working-directory: ${{ env.BUILD_DIR }} + run: ctest -C ${{env.BUILD_TYPE}} diff --git a/Include/SevenBit/DI/Details/Impl/ServicesMap.hpp b/Include/SevenBit/DI/Details/Impl/ServicesMap.hpp index 4c6971d..20eda12 100644 --- a/Include/SevenBit/DI/Details/Impl/ServicesMap.hpp +++ b/Include/SevenBit/DI/Details/Impl/ServicesMap.hpp @@ -27,11 +27,6 @@ namespace sb::di::details return it != _serviceListMap.end() ? &it->second : nullptr; } - INLINE const ServiceList *ServicesMap::getList(TypeId serviceTypeId) const - { - auto it = _serviceListMap.find(serviceTypeId); - return it != _serviceListMap.end() ? &it->second : nullptr; - } INLINE void ServicesMap::clear() { if (_strongDestructionOrder) diff --git a/Include/SevenBit/DI/Details/ServiceDescriptorList.hpp b/Include/SevenBit/DI/Details/ServiceDescriptorList.hpp index cb22ebc..e4d0bd8 100644 --- a/Include/SevenBit/DI/Details/ServiceDescriptorList.hpp +++ b/Include/SevenBit/DI/Details/ServiceDescriptorList.hpp @@ -19,10 +19,11 @@ namespace sb::di::details public: ServiceDescriptorList() = default; - ServiceDescriptorList(ServiceDescriptorList &&) = default; ServiceDescriptorList(const ServiceDescriptorList &) = delete; - ServiceDescriptorList &operator=(const ServiceDescriptorList &) = delete; + ServiceDescriptorList(ServiceDescriptorList &&) = default; + ServiceDescriptorList &operator=(ServiceDescriptorList &&) = default; + ServiceDescriptorList &operator=(const ServiceDescriptorList &) = delete; auto begin() const { return _serviceDescriptors.begin(); } auto end() const { return _serviceDescriptors.end(); } diff --git a/Include/SevenBit/DI/Details/ServiceList.hpp b/Include/SevenBit/DI/Details/ServiceList.hpp index 9afbbb1..57a804e 100644 --- a/Include/SevenBit/DI/Details/ServiceList.hpp +++ b/Include/SevenBit/DI/Details/ServiceList.hpp @@ -20,9 +20,12 @@ namespace sb::di::details public: ServiceList() = default; + // fix compilation errors should not be used!! + ServiceList(const ServiceList &) {}; ServiceList(ServiceList &&) = default; - ServiceList(const ServiceList &) = delete; - ServiceList &operator=(const ServiceList &) = delete; + + // fix compilation errors should not be used!! + ServiceList &operator=(const ServiceList &) { return *this; }; ServiceList &operator=(ServiceList &&) = default; auto begin() const { return _services.begin(); } diff --git a/Include/SevenBit/DI/Details/ServicesMap.hpp b/Include/SevenBit/DI/Details/ServicesMap.hpp index 240678c..c59147a 100644 --- a/Include/SevenBit/DI/Details/ServicesMap.hpp +++ b/Include/SevenBit/DI/Details/ServicesMap.hpp @@ -30,8 +30,6 @@ namespace sb::di::details ServiceList *getList(TypeId serviceTypeId); - const ServiceList *getList(TypeId serviceTypeId) const; - void clear(); ~ServicesMap(); diff --git a/Include/SevenBit/DI/Export.hpp b/Include/SevenBit/DI/Export.hpp index c81d3db..520f6bf 100644 --- a/Include/SevenBit/DI/Export.hpp +++ b/Include/SevenBit/DI/Export.hpp @@ -7,9 +7,11 @@ #if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) // Microsoft -#if defined(SevenBitInjector_EXPORTS) +#ifdef SevenBitInjector_EXPORTS +/* We are building this library */ #define EXPORT __declspec(dllexport) #else +/* We are using this library */ #define EXPORT __declspec(dllimport) #endif diff --git a/README.md b/README.md index f37f470..00d5d6e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -[![CI](https://github.com/7bitcoder/7bitinjector/actions/workflows/BasicTest.yml/badge.svg?branch=dev)](https://github.com/7bitcoder/7bitinjector/actions/workflows/BasicTest.ym) +[![DevCI](https://github.com/7bitcoder/7bitinjector/actions/workflows/DevCI.yml/badge.svg?branch=dev)](https://github.com/7bitcoder/7bitinjector/actions/workflows/DevCI.ym) + +[![MainCI](https://github.com/7bitcoder/7bitinjector/actions/workflows/MainCI.yml/badge.svg?branch=main)](https://github.com/7bitcoder/7bitinjector/actions/workflows/MainCI.ym)
logo diff --git a/Source/Source.cpp b/Source/Source.cpp index 39ac278..fe1f078 100644 --- a/Source/Source.cpp +++ b/Source/Source.cpp @@ -2,6 +2,8 @@ #include "ConfigCheck.hpp" #include "SevenBit/DI/Details/Impl/CircularDependencyGuard.hpp" +#include "SevenBit/DI/Details/Impl/DefaultServiceProvider.hpp" +#include "SevenBit/DI/Details/Impl/DefaultServiceProviderRoot.hpp" #include "SevenBit/DI/Details/Impl/Exceptions.hpp" #include "SevenBit/DI/Details/Impl/ScopedGuard.hpp" #include "SevenBit/DI/Details/Impl/ServiceCollection.hpp" @@ -10,6 +12,4 @@ #include "SevenBit/DI/Details/Impl/ServiceDescriptorsMap.hpp" #include "SevenBit/DI/Details/Impl/ServiceLifeTime.hpp" #include "SevenBit/DI/Details/Impl/ServiceList.hpp" -#include "SevenBit/DI/Details/Impl/DefaultServiceProvider.hpp" -#include "SevenBit/DI/Details/Impl/DefaultServiceProviderRoot.hpp" #include "SevenBit/DI/Details/Impl/ServicesMap.hpp" \ No newline at end of file