Skip to content

Commit

Permalink
Merge pull request #589 from apache/feature/579-automatic-dependency-…
Browse files Browse the repository at this point in the history
…deduction

Feature/579 automatic dependency deduction
  • Loading branch information
PengZheng authored Jul 31, 2023
2 parents f40d68d + c789b89 commit d40cada
Show file tree
Hide file tree
Showing 135 changed files with 1,456 additions and 919 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/conan_create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Conan Create

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:

ubuntu-build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
compiler: [ [gcc,g++], [clang,clang++] ]
type: [ Debug ]
timeout-minutes: 120
steps:
- name: Checkout source code
uses: actions/checkout@v3.3.0
- name: Install build dependencies
run: |
sudo pip install -U conan==1.59.0
sudo apt-get install -yq --no-install-recommends ninja-build
- name: Setup Conan Profile
env:
CC: ${{ matrix.compiler[0] }}
CXX: ${{ matrix.compiler[1] }}
run: |
# build profile
conan profile new release --detect
conan profile update settings.build_type=Release release
#Note no backwards compatiblity for gcc5 needed, setting libcxx to c++11.
conan profile update settings.compiler.libcxx=libstdc++11 release
conan profile show release
# host profile
conan profile new default --detect
conan profile update settings.build_type=${{ matrix.type }} default
#Note no backwards compatiblity for gcc5 needed, setting libcxx to c++11.
conan profile update settings.compiler.libcxx=libstdc++11 default
conan profile show default
- name: Create Celix
env:
CC: ${{ matrix.compiler[0] }}
CXX: ${{ matrix.compiler[1] }}
CONAN_CMAKE_GENERATOR: Ninja
run: |
conan inspect . -a options | awk 'BEGIN { FS="[\t:]+" } /build/ && !/build_all/ { print $1}' | while read option; do conan create . -b missing -o celix:${option}=True -pr:b release -pr:h default -tf examples/conan_test_package -tbf test-build -o celix:celix_cxx17=True -o celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s --require-override=zlib/1.2.13 || exit 1; done
mac-build:
runs-on: macOS-11
timeout-minutes: 120
steps:
- name: Checkout source code
uses: actions/checkout@v3.3.0
- name: Install build dependencies
run: |
brew install python ninja
pip3 install -U conan==1.59.0
- name: Setup Conan Profile
run: |
conan profile new default --detect
conan profile update settings.build_type=Release default
- name: Create Celix
env:
CC: ${{ matrix.compiler[0] }}
CXX: ${{ matrix.compiler[1] }}
CONAN_CMAKE_GENERATOR: Ninja
run: |
conan inspect . -a options | awk 'BEGIN { FS="[\t:]+" } /build/ && !/build_all/ { print $1}' | while read option; do conan create . -b missing -o celix:${option}=True -pr:b default -pr:h default -tf examples/conan_test_package -tbf test-build -o celix:celix_cxx17=True -o celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s --require-override=zlib/1.2.13 || exit 1; done
5 changes: 1 addition & 4 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ jobs:
source activate_run.sh
ctest --output-on-failure
source deactivate_run.sh
- name: Test Installed Celix
run: |
conan create -pr:b default -pr:h default -tf examples/conan_test_package -tbf test-build -o celix:celix_cxx17=True -o celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s .
build-brew:
runs-on: macOS-latest
runs-on: macOS-11
timeout-minutes: 120
steps:
- name: Checkout source code
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ jobs:
steps:
- name: Checkout source code
uses: actions/checkout@v3.3.0
- name: Install conan
- name: Install build dependencies
run: |
sudo pip install -U conan==1.59.0
sudo apt-get install -yq --no-install-recommends ninja-build
- name: Setup Conan Profile
env:
CC: ${{ matrix.compiler[0] }}
Expand Down Expand Up @@ -51,7 +52,6 @@ jobs:
-o celix:enable_testing_dependency_manager_for_cxx11=True
run: |
#force require libcurl 7.64.1, due to a sha256 verify issue in libcurl/7.87.0
sudo apt-get install -yq --no-install-recommends ninja-build
conan install . celix/ci -pr:b release -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing -b cpputest --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s
- name: Build
env:
Expand All @@ -67,13 +67,6 @@ jobs:
source activate_run.sh
ctest --output-on-failure
source deactivate_run.sh
- name: Test Installed Celix
env:
CC: ${{ matrix.compiler[0] }}
CXX: ${{ matrix.compiler[1] }}
CONAN_CMAKE_GENERATOR: Ninja
run: |
conan create -pr:b release -pr:h default -tf examples/conan_test_package -tbf test-build -o celix:celix_cxx17=True -o celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s .
build-apt:
runs-on: ubuntu-22.04
Expand Down
32 changes: 7 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,9 @@ include(cmake/cmake_celix/UseCelix.cmake)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

#find required packages
find_package(ZLIB REQUIRED) #framework
find_package(libuuid REQUIRED) #framework
find_package(CURL REQUIRED) #framework, etcdlib
find_package(libzip REQUIRED) #framework, etcdlib
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

if (NOT TARGET ZLIB::ZLIB)
#Note more recent zlib will create ZLIB::ZLIB target
message("Note ZLIB::ZLIB target not created by find_package(ZLIB). Creating ZLIB::ZLIB Target.")
add_library(ZLIB::ZLIB SHARED IMPORTED)
set_target_properties(ZLIB::ZLIB PROPERTIES
IMPORTED_LOCATION "${ZLIB_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}"
)
endif ()

if (NOT TARGET CURL::libcurl)
#Note more recent curl will create CURL::libcurl target
message("Note CURL::libcurl target not created by find_package(CURL). Creating CURL::libcurl Target.")
add_library(CURL::libcurl SHARED IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LOCATION "${CURL_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}"
)
endif ()

# see https://public.kitware.com/Bug/view.php?id=15696
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} EQUAL 3.3 AND ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
message( FATAL_ERROR "Building Celix using CMake 3.3 and makefiles is not supported due to a bug in the Makefile Generator (see Bug 15696). Please change the used CMake version - both, CMake 3.2 and CMake 3.4 are working fine. Or use a different generator (e.g. Ninja)." )
Expand All @@ -70,7 +46,7 @@ if (ENABLE_TESTING)
endif ()

# Set C specific flags
set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=c99 -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "-Wall -Werror -Wformat -Wno-error=deprecated-declarations ${CMAKE_C_FLAGS}")

# Set C++ specific flags
Expand Down Expand Up @@ -196,6 +172,12 @@ include(CheckLinkerFlag)
check_linker_flag(CXX LINKER:--wrap,celix_nonexistent_symbol LINKER_WRAP_SUPPORTED)
cmake_pop_check_state()

# avoid unknown export "celix" error when building nothing
add_library(celix INTERFACE)
add_library(Celix::celix ALIAS celix)
install(TARGETS celix EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix)

#Add generate_export_header to cmake
include(GenerateExportHeader)

Expand Down
6 changes: 1 addition & 5 deletions bundles/cxx_remote_services/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
# specific language governing permissions and limitations
# under the License.

celix_subproject(CXX_RSA_INTEGRATION "Option to build the C++17 Remote Service Admin Service integration" ON DEPS SHELL SHELL_TUI PUBSUB PROMISES PUSHSTREAMS PUBSUB_PSA_ZMQ PUBSUB_DISCOVERY_ETCD)
celix_subproject(CXX_RSA_INTEGRATION "Option to build the C++17 Remote Service Admin Service integration" ON)
if (CXX_RSA_INTEGRATION)
find_package(ZeroMQ REQUIRED)
find_package(czmq REQUIRED)
add_celix_bundle(TestExportImportRemoteServiceFactory
SOURCES src/TestExportImportRemoteServiceFactory.cc
)
Expand Down Expand Up @@ -71,7 +69,6 @@ if (CXX_RSA_INTEGRATION)

CalculatorProvider
)
target_link_libraries(RemoteCalculatorProvider PRIVATE ZeroMQ::ZeroMQ czmq::czmq)

add_celix_container(RemoteCalculatorConsumer
GROUP rsa
Expand All @@ -95,5 +92,4 @@ if (CXX_RSA_INTEGRATION)

CalculatorConsumer
)
target_link_libraries(RemoteCalculatorConsumer PRIVATE ZeroMQ::ZeroMQ czmq::czmq)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
add_executable(test_cxx_remote_services_integration
src/RemoteServicesIntegrationTestSuite.cc
)
target_link_libraries(test_cxx_remote_services_integration PRIVATE Celix::framework Celix::dfi Celix::Promises Celix::PushStreams Celix::shell_api ZeroMQ::ZeroMQ czmq::czmq GTest::gtest GTest::gtest_main)
target_link_libraries(test_cxx_remote_services_integration PRIVATE Celix::framework Celix::Promises Celix::PushStreams Celix::shell_api GTest::gtest GTest::gtest_main)
target_include_directories(test_cxx_remote_services_integration PRIVATE ../include) #Add ICalculator

add_celix_bundle_dependencies(test_cxx_remote_services_integration
Expand Down
1 change: 1 addition & 0 deletions bundles/cxx_remote_services/rsa_spi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_library(rsa_spi INTERFACE)
target_include_directories(rsa_spi INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
)
target_link_libraries(rsa_spi INTERFACE Celix::framework Celix::utils)

install(TARGETS rsa_spi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT rsa
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/rsa)
Expand Down
2 changes: 1 addition & 1 deletion bundles/logging/log_admin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ add_celix_bundle(log_admin
src/celix_log_admin_activator.c
FILENAME celix_log_admin
)
target_link_libraries(log_admin PRIVATE Celix::log_helper Celix::shell_api)
target_link_libraries(log_admin PRIVATE Celix::log_service_api Celix::shell_api)
target_include_directories(log_admin PRIVATE src)
celix_deprecated_utils_headers(log_admin)
install_celix_bundle(log_admin EXPORT celix COMPONENT logging)
Expand Down
2 changes: 1 addition & 1 deletion bundles/logging/log_admin/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
add_executable(test_log_admin
src/LogAdminTestSuite.cc
)
target_link_libraries(test_log_admin PRIVATE Celix::log_service_api Celix::shell_api GTest::gtest GTest::gtest_main)
target_link_libraries(test_log_admin PRIVATE Celix::framework Celix::log_service_api Celix::shell_api GTest::gtest GTest::gtest_main)

add_celix_bundle_dependencies(test_log_admin Celix::log_admin)
target_compile_definitions(test_log_admin PRIVATE -DLOG_ADMIN_BUNDLE=\"$<TARGET_PROPERTY:log_admin,BUNDLE_FILE>\")
Expand Down
60 changes: 33 additions & 27 deletions bundles/logging/log_helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,42 @@
# specific language governing permissions and limitations
# under the License.

if (CELIX_INSTALL_DEPRECATED_API)
set(SOURCES src/celix_log_helper.c src/log_helper.c)
else ()
set(SOURCES src/celix_log_helper.c)
endif ()
celix_subproject(LOG_HELPER "Option to enable building the log helper library" ON)
if (LOG_HELPER)
if (CELIX_INSTALL_DEPRECATED_API)
set(SOURCES src/celix_log_helper.c src/log_helper.c)
else ()
set(SOURCES src/celix_log_helper.c)
endif ()

add_library(log_helper STATIC ${SOURCES})
set_target_properties(log_helper PROPERTIES OUTPUT_NAME "celix_log_utils")
target_include_directories(log_helper PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
)
target_link_libraries(log_helper PUBLIC Celix::log_service_api Celix::framework PRIVATE Celix::utils)
add_library(log_helper STATIC ${SOURCES})
set_target_properties(log_helper PROPERTIES OUTPUT_NAME "celix_log_utils")
target_include_directories(log_helper PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
)
target_link_libraries(log_helper PUBLIC Celix::log_service_api Celix::framework PRIVATE Celix::utils)

if (CELIX_INSTALL_DEPRECATED_API)
target_include_directories(log_helper PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include_v1>
)
install(DIRECTORY include_v1/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper)
endif ()
if (CELIX_INSTALL_DEPRECATED_API)
target_include_directories(log_helper PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include_v1>
)
install(DIRECTORY include_v1/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper)
endif ()

install(TARGETS log_helper EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT logging
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper COMPONENT logging)
install(TARGETS log_helper EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT logging
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_helper COMPONENT logging)

celix_target_hide_symbols(log_helper)
celix_deprecated_utils_headers(log_helper)
celix_deprecated_framework_headers(log_helper)
celix_target_hide_symbols(log_helper)
celix_deprecated_utils_headers(log_helper)
celix_deprecated_framework_headers(log_helper)

add_library(Celix::log_helper ALIAS log_helper)
add_library(Celix::log_helper ALIAS log_helper)

if (ENABLE_TESTING)
add_subdirectory(gtest)
endif()
if (ENABLE_TESTING)
if (LINKER_WRAP_SUPPORTED)
add_subdirectory(error_injector)
endif ()
add_subdirectory(gtest)
endif ()
endif ()
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

add_library(log_helper_ei STATIC src/celix_log_helper_ei.cc)

target_include_directories(log_helper_ei PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
target_include_directories(log_helper_ei PUBLIC include)
target_link_libraries(log_helper_ei PUBLIC Celix::error_injector Celix::log_helper)
# It plays nicely with address sanitizer this way.
target_link_options(log_helper_ei INTERFACE LINKER:--wrap,celix_logHelper_create)
Expand Down
34 changes: 19 additions & 15 deletions bundles/logging/log_service_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@
# specific language governing permissions and limitations
# under the License.

add_library(log_service_api INTERFACE)
target_include_directories(log_service_api INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
)
target_link_libraries(log_service_api INTERFACE Celix::utils Celix::framework)
celix_subproject(LOG_SERVICE_API "Option to enable building the log service API" ON)
if (LOG_SERVICE_API)
add_library(log_service_api INTERFACE)
target_include_directories(log_service_api INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
)
target_link_libraries(log_service_api INTERFACE Celix::utils)

if (CELIX_INSTALL_DEPRECATED_API)
target_include_directories(log_service_api INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include_v2>
)
install(DIRECTORY include_v2/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_service)
endif ()
if (CELIX_INSTALL_DEPRECATED_API)
target_link_libraries(log_service_api INTERFACE Celix::framework)
target_include_directories(log_service_api INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include_v2>
)
install(DIRECTORY include_v2/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_service)
endif ()

install(TARGETS log_service_api EXPORT celix
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_service)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_service)
install(TARGETS log_service_api EXPORT celix
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_service)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/log_service)

add_library(Celix::log_service_api ALIAS log_service_api)
add_library(Celix::log_service_api ALIAS log_service_api)
endif ()
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define CELIX_LOG_CONTROL_H

#include <stdbool.h>
#include <stddef.h>
#include "celix_log_level.h"
#include "celix_array_list.h"

Expand Down
2 changes: 1 addition & 1 deletion bundles/logging/log_writers/syslog_writer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ add_celix_bundle(syslog_writer
SOURCES
src/celix_syslog_writer_activator.c
)
target_link_libraries(syslog_writer PRIVATE Celix::log_helper Celix::log_service_api)
target_link_libraries(syslog_writer PRIVATE Celix::log_service_api)
install_celix_bundle(syslog_writer EXPORT celix COMPONENT logging)

#Setup target aliases to match external usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
add_executable(test_syslog_writer
src/SyslogWriterTestSuite.cc
)
target_link_libraries(test_syslog_writer PRIVATE Celix::log_helper GTest::gtest GTest::gtest_main)
target_link_libraries(test_syslog_writer PRIVATE Celix::log_service_api GTest::gtest GTest::gtest_main)
add_celix_bundle_dependencies(test_syslog_writer Celix::log_admin Celix::syslog_writer)
target_compile_definitions(test_syslog_writer PRIVATE -DLOG_ADMIN_BUNDLE=\"$<TARGET_PROPERTY:log_admin,BUNDLE_FILE>\")
target_compile_definitions(test_syslog_writer PRIVATE -DSYSLOG_WRITER_BUNDLE=\"$<TARGET_PROPERTY:syslog_writer,BUNDLE_FILE>\")
Expand Down
2 changes: 1 addition & 1 deletion bundles/pubsub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

celix_subproject(PUBSUB "Option to build the pubsub bundles" ON DEPS CELIX_DFI)
celix_subproject(PUBSUB "Option to build the pubsub bundles" ON)
if (PUBSUB)
add_subdirectory(pubsub_api)
add_subdirectory(pubsub_utils)
Expand Down
Loading

0 comments on commit d40cada

Please sign in to comment.