Skip to content

Commit

Permalink
Merge pull request #665 from apache/feature/509-update-cxx-support-to…
Browse files Browse the repository at this point in the history
…-cxx14

Feature/509 update cxx support to cxx14
  • Loading branch information
pnoltes committed Oct 9, 2023
2 parents f8e95a5 + ad8004f commit 3974d91
Show file tree
Hide file tree
Showing 33 changed files with 60 additions and 745 deletions.
2 changes: 1 addition & 1 deletion .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# https://cwiki.apache.org/confluence/display/INFRA/git+-+.asf.yaml+features
---
github:
description: "Apache Celix is a framework for C, C++14 and C++17 to develop dynamic modular software applications using component and in-process service-oriented programming."
description: "Apache Celix is a framework for C and C++14 to develop dynamic modular software applications using component and in-process service-oriented programming."
homepage: https://celix.apache.org/
labels:
- apache
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ jobs:
-o celix:enable_testing=True
-o celix:build_all=True
-o celix:enable_code_coverage=True
-o celix:enable_testing_for_cxx14=True
-o celix:enable_testing_dependency_manager_for_cxx11=True
-o celix:enable_testing_on_ci=True
-o celix:enable_ccache=True
run: |
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/coverity-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
BUILD_OPTIONS: |
-DBUILD_EXPERIMENTAL=ON
-DENABLE_TESTING=ON
-DENABLE_TESTING_DEPENDENCY_MANAGER_FOR_CXX11=ON
-DENABLE_TESTING_FOR_CXX14=ON
-DRSA_JSON_RPC=ON
-DRSA_SHM=ON
-DRSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ jobs:
-o celix:enable_testing=True
-o celix:enable_address_sanitizer=True
-o celix:build_all=True
-o celix:enable_testing_for_cxx14=True
-o celix:enable_testing_dependency_manager_for_cxx11=True
-o celix:enable_cmake_warning_tests=True
-o celix:enable_testing_on_ci=True
-o celix:framework_curlinit=False
Expand Down Expand Up @@ -99,8 +97,6 @@ jobs:
env:
BUILD_OPTIONS: |
-DENABLE_TESTING=ON
-DENABLE_TESTING_DEPENDENCY_MANAGER_FOR_CXX11=ON
-DENABLE_TESTING_FOR_CXX14=ON
-DENABLE_ADDRESS_SANITIZER=ON
-DENABLE_TESTING_ON_CI=ON
-DCMAKE_BUILD_TYPE=Release
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ jobs:
-o celix:enable_testing=True
-o celix:enable_address_sanitizer=True
-o celix:build_all=True
-o celix:enable_testing_for_cxx14=True
-o celix:enable_testing_dependency_manager_for_cxx11=True
-o celix:enable_cmake_warning_tests=True
-o celix:enable_testing_on_ci=True
-o celix:framework_curlinit=False
Expand Down Expand Up @@ -145,8 +143,6 @@ jobs:
BUILD_OPTIONS: |
-DBUILD_EXPERIMENTAL=ON
-DENABLE_TESTING=ON
-DENABLE_TESTING_DEPENDENCY_MANAGER_FOR_CXX11=ON
-DENABLE_TESTING_FOR_CXX14=ON
-DRSA_JSON_RPC=ON
-DRSA_SHM=ON
-DRSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ limitations under the License.
- Shell v2 api is removed and no longer supported.
- Logging v2 api is removed and no longer supported.
- Bonjour Shell bundle is removed and no longer supported.
- pubsub_serializer.h is removed and no longer supported. Use pubsub_message_serialization_service.h instead.
- pubsub_serializer.h is removed and no longer supported. Use pubsub_message_serialization_service.h instead.
- C++11 support for dm is removed. C++14 is now the minimum required version.
- C++17 string_view support is removed from the utils and framework lib.

# Noteworthy Changes for 2.4.0 (2023-09-27)

Expand Down
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ set(CMAKE_CXX_FLAGS "-fno-rtti ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wextra -Weffc++ -Wformat -Wno-error=deprecated-declarations ${CMAKE_CXX_FLAGS}")

if (NOT DEFINED CMAKE_CXX_STANDARD)
#Celix header only C++ supported is based on C++14 and C++17.
#Celix header only C++ supported is based on C++14. However, test code can be and is written in C++17.
#Default using C++14 to ensure the code compiles for C++14.

#There are 2 exceptions: The libraries Promises and PushStream are C++17 only.

#To ensure IDE like CLion can provide optimal C++17 support, the CMAKE_CXX_STANDARD variable is only set if
#not already defined.
set(CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -154,19 +157,19 @@ endif ()
set(DEFAULT_VERSION 1.0.0)

if (ENABLE_TESTING)
#Note tests are C++. Default C++14 and some C++17. For C++14 tests no additional option is needed.
#For C++17 tests CELIX_CXX17 must be enabled.
enable_testing()
endif()

option(CELIX_USE_ZIP_INSTEAD_OF_JAR "Default Celix cmake command will use jar to package bundle (if found). This option enforces Celix to use zip instead." OFF)

option(CELIX_CXX14 "Build C++14 libraries and bundles. Note for tests C++ is always used." ON)
option(CELIX_CXX17 "Build C++17 libraries and bundles." ON)
option(CELIX_CXX14 "Build C++14 libraries and bundles." ON)
option(CELIX_CXX17 "Build C++17 libraries, bundles and if testing is enabled C++17 tests" ON)
if (CELIX_CXX17 AND NOT CELIX_CXX14)
set(CELIX_CXX14 ON)
endif ()

option(ENABLE_TESTING_DEPENDENCY_MANAGER_FOR_CXX11 "Test the Dependency Manager for C++11 support" OFF)
option(ENABLE_TESTING_FOR_CXX14 "Test celix utils and framework C++ header for C++14 support" OFF)
option(ENABLE_CMAKE_WARNING_TESTS "Enable cmake warning tests to test warning prints" OFF)
option(ENABLE_TESTING_ON_CI "Whether to enable testing on CI. This influence allowed timing errors during unit tests" OFF)
option(ENABLE_DEPRECATED_WARNINGS "Enable compiler warnings for usage of deprecated functionality" OFF)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.
[![codecov](https://codecov.io/gh/apache/celix/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/celix)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/6685/badge.svg)](https://scan.coverity.com/projects/6685)

Apache Celix is a framework for C, C++14 and C++17 to develop dynamic modular software applications using component
Apache Celix is a framework for C and C++14 to develop dynamic modular software applications using component
and in-process service-oriented programming.
Apache Celix is inspired by the [OSGi specification](https://www.osgi.org/) adapted for C and C++.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ namespace celix::rsa {
result.set(celix::rsa::SERVICE_IMPORTED, true);

if (result.get(celix::rsa::ENDPOINT_ID).empty()) {
result.set(celix::rsa::ENDPOINT_ID, std::string{frameworkUUID} + "-" + serviceProperties.get(celix::SERVICE_ID));
std::string value = std::string{frameworkUUID} + "-" + serviceProperties.get(celix::SERVICE_ID);
result.set(celix::rsa::ENDPOINT_ID, value);
}

return result;
Expand Down
6 changes: 1 addition & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CelixConan(ConanFile):
generators = "CMakeDeps", "VirtualRunEnv"
settings = "os", "arch", "compiler", "build_type"
license = " Apache-2.0"
description = "Apache Celix is an implementation of the OSGi specification adapted to C and C++ (C++17). " \
description = "Apache Celix is an implementation of the OSGi specification adapted to C and C++ (C++14). " \
"It is a framework to develop (dynamic) modular software applications " \
"using component and/or service-oriented programming."

Expand All @@ -47,8 +47,6 @@ class CelixConan(ConanFile):
"enable_address_sanitizer": False,
"enable_undefined_sanitizer": False,
"enable_thread_sanitizer": False,
"enable_testing_dependency_manager_for_cxx11": False,
"enable_testing_for_cxx14": False,
"build_all": False,
"build_http_admin": False,
"build_log_service": False,
Expand Down Expand Up @@ -139,8 +137,6 @@ def package_id(self):
del self.info.options.build_pubsub_examples
del self.info.options.build_cxx_rsa_integration
del self.info.options.build_examples
del self.info.options.enable_testing_dependency_manager_for_cxx11
del self.info.options.enable_testing_for_cxx14
del self.info.options.enable_cmake_warning_tests
del self.info.options.enable_testing_on_ci
del self.info.options.enable_ccache
Expand Down
2 changes: 1 addition & 1 deletion documents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ is that this can be done with a single `add_celix_container` Apache Celix CMake
One of the reasons why C was chosen as implementation language is that C can act as a common denominator for
(service oriented) interoperability between a range of languages.

C++ (C++17) support is build on top of the C API and is realized using a header only implementation.
C++ support is build on top of the C API and is realized using a header only implementation.
This means that all the binary artifact for the Apache Celix framework and util library are pure C and do not depend on
libstdc++.

Expand Down
4 changes: 2 additions & 2 deletions documents/subprojects.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The Apache Celix project is organized into several libraries, bundles, group of
## Core Libraries
The core of Apache Celix is realized in the following libraries:

* [Framework](../libs/framework) - The Apache Celix framework, an implementation of OSGi adapted to C and C++11.
* [Framework](../libs/framework) - The Apache Celix framework, an implementation of OSGi adapted to C and C++14.
* [Utils](../libs/utils/README.md) - The Celix utils library, containing a wide range of general utils and
OSGi supporting types (properties, version, filter, string utils, file utils, etc).

Expand All @@ -52,7 +52,7 @@ the Apache Celix functionality. Most of these bundles are based on the OSGi spec
* [HTTP Admin](../bundles/http_admin/README.md) - An implementation for the OSGi HTTP whiteboard adapted to C and based on civetweb.
* [Log Service](../bundles/logging/README.md) - A Log Service logging abstraction for Apache Celix.
* [Syslog Writer](../bundles/logging/log_writers/syslog_writer) - A syslog writer for use in combination with the Log Service.
* [Shell](../bundles/shell/README.md) - A OSGi C and C++11 shell implementation, which can be extended with shell command services.
* [Shell](../bundles/shell/README.md) - A OSGi C and C++ shell implementation, which can be extended with shell command services.
* [Pubsub](../bundles/pubsub/README.md) - An implementation for a publish-subscribe remote message communication system.
* [Remote Services](../bundles/remote_services) - A C adaption and implementation of the OSGi Remote Service Admin specification.
* [C++ Remote Services](../bundles/cxx_remote_services/README.md) - A C++17 adaption and implementation of the OSGi Remote Service Admin specification. Requires manually or code-generated import/export factories to work.
Expand Down
2 changes: 1 addition & 1 deletion examples/celix-examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (EXAMPLES)
add_subdirectory(services_example_cxx)
add_subdirectory(dependency_manager_example_cxx)
endif ()
if (CELIX_CXX17)
if (CELIX_CXX14)
add_subdirectory(readme_cxx_examples)
endif ()

Expand Down
2 changes: 1 addition & 1 deletion libs/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if (FRAMEWORK)
if (ENABLE_TESTING AND EI_TESTS)
add_subdirectory(error_injector)
endif ()
if (ENABLE_TESTING AND CELIX_CXX17) #framework tests are C++17
if (ENABLE_TESTING)
add_library(framework_cut STATIC ${FRAMEWORK_SRC})

target_include_directories(framework_cut PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion libs/framework/doxygen.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.

# Intro

Apache Celix is a framework for C, C++14 and C++17 to develop dynamic modular software applications using component
Apache Celix is a framework for C and C++14 to develop dynamic modular software applications using component
and in-process service-oriented programming.
Apache Celix is inspired by the [OSGi specification](https://www.osgi.org/) and adapted to C and C++.

Expand Down
77 changes: 0 additions & 77 deletions libs/framework/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# specific language governing permissions and limitations
# under the License.

set(CMAKE_CXX_STANDARD 17)

add_celix_bundle(simple_test_bundle1 NO_ACTIVATOR VERSION 1.0.0)
celix_bundle_name(simple_test_bundle1 "Simple Test Bundle")
celix_bundle_group(simple_test_bundle1 "test/group")
Expand Down Expand Up @@ -170,78 +168,3 @@ if (EI_TESTS)
add_test(NAME test_framework_with_ei COMMAND test_framework_with_ei)
setup_target_for_coverage(test_framework_with_ei SCAN_DIR ..)
endif ()

if (ENABLE_TESTING_DEPENDENCY_MANAGER_FOR_CXX11)
#Setting standard to C++11 and testing C++ dependency manager to ensure that this still support C++11.
#This ensure that the C++11 dependency manager is backwards compatible with Celix 2.2.1
set(CMAKE_CXX_STANDARD 11)
add_executable(test_dep_man_with_cxx11
src/DependencyManagerTestSuite.cc
)
target_link_libraries(test_dep_man_with_cxx11 PRIVATE framework_cut Celix::framework GTest::gtest GTest::gtest_main)
target_compile_definitions(test_dep_man_with_cxx11 PRIVATE
SIMPLE_CXX_DEP_MAN_BUNDLE_LOC="${SIMPLE_CXX_DEP_MAN_BUNDLE_LOC}"
)
celix_deprecated_utils_headers(test_dep_man_with_cxx11)
celix_deprecated_framework_headers(test_dep_man_with_cxx11)
add_test(NAME test_dep_man_with_cxx11 COMMAND test_dep_man_with_cxx11)
setup_target_for_coverage(test_dep_man_with_cxx11 SCAN_DIR ..)

#Also to ensure that CELIX_GEN_CXX_BUNDLE_ACTIVATOR still works for C++11 bundle activators with a
#dependency manager argument, the HelloWorldCxxActivatorWithDepMan will be used to create a C++11 bundle
add_celix_bundle(test_dep_man_bundle_activator_with_cxx11 SOURCES src/HelloWorldCxxActivatorWithDepMan.cc VERSION 1.0.0)
endif ()

if (ENABLE_TESTING_FOR_CXX14)
#Setting standard to C++14 and testing the C++ framework headers to ensure that C++14 is also supported.
set(CMAKE_CXX_STANDARD 14)

add_executable(test_framework_with_cxx14 ${CELIX_FRAMEWORK_TEST_SOURCES})
target_link_libraries(test_framework_with_cxx14 PRIVATE framework_cut Celix::framework GTest::gtest GTest::gtest_main)
celix_deprecated_utils_headers(test_framework_with_cxx14)
celix_deprecated_framework_headers(test_framework_with_cxx14)
add_celix_bundle_dependencies(test_framework_with_cxx14
simple_test_bundle1
simple_test_bundle2 simple_test_bundle3 simple_test_bundle4
simple_test_bundle5 bundle_with_exception unresolvable_bundle simple_cxx_bundle simple_cxx_dep_man_bundle cmp_test_bundle)
target_include_directories(test_framework_with_cxx14 PRIVATE ../src)

#Also to ensure that CELIX_GEN_CXX_BUNDLE_ACTIVATOR still for C++11.
add_celix_bundle(simple_cxx_bundle_with_cxx1 SOURCES src/HelloWorldCxxActivator.cc VERSION 1.0.0)
add_celix_bundle(simple_cxx_dep_man_bundle_with_cxx1 SOURCES src/HelloWorldCxxActivatorWithDepMan.cc VERSION 1.0.0)
add_celix_bundle_dependencies(test_framework_with_cxx14 simple_cxx_bundle_with_cxx1 simple_cxx_dep_man_bundle_with_cxx1)

celix_get_bundle_file(simple_cxx_bundle_with_cxx1 SIMPLE_CXX_BUNDLE_WITH_CXX11_LOC)
celix_get_bundle_file(simple_cxx_dep_man_bundle_with_cxx1 SIMPLE_CXX_DEP_MAN_WITH_CXX11_BUNDLE_LOC)

#embed bundle in the test_framework executable
celix_target_embedded_bundles(test_framework_with_cxx14 simple_test_bundle1 simple_test_bundle2)

#Create bundle set definitions
celix_target_bundle_set_definition(test_framework_with_cxx14 NAME BUNDLE_EMPTY_TEST_SET)
celix_target_bundle_set_definition(test_framework_with_cxx14 NAME BUNDLE_TEST_SET
#Note this test set has two version fo bundle1, this is done for testing purpose.
simple_test_bundle1 simple_test_bundle3 simple_test_bundle1 simple_test_bundle2
)

target_compile_definitions(test_framework_with_cxx14 PRIVATE
SIMPLE_TEST_BUNDLE1_LOCATION="${SIMPLE_TEST_BUNDLE1}"
SIMPLE_TEST_BUNDLE2_LOCATION="${SIMPLE_TEST_BUNDLE2}"
SIMPLE_TEST_BUNDLE3_LOCATION="${SIMPLE_TEST_BUNDLE3}"
SIMPLE_TEST_BUNDLE4_LOCATION="${SIMPLE_TEST_BUNDLE4_FILENAME}"
SIMPLE_TEST_BUNDLE5_LOCATION="${SIMPLE_TEST_BUNDLE5_FILENAME}"
TEST_BUNDLE_WITH_EXCEPTION_LOCATION="${BUNDLE_WITH_EXCEPTION}"
TEST_BUNDLE_UNRESOLVABLE_LOCATION="${UNRESOLVABLE_BUNDLE}"
SIMPLE_CXX_BUNDLE_LOC="${SIMPLE_CXX_BUNDLE_WITH_CXX11_LOC}"
CMP_TEST_BUNDLE_LOC="${CMP_TEST_BUNDLE_LOC}"
SIMPLE_CXX_DEP_MAN_BUNDLE_LOC="${SIMPLE_CXX_DEP_MAN_WITH_CXX11_BUNDLE_LOC}"
CMP_TEST_BUNDLE_LOC="${CMP_TEST_BUNDLE_LOC}"
COND_TEST_BUNDLE_LOC="${COND_TEST_BUNDLE_LOC}"
INSTALL_AND_START_BUNDLES_CONFIG_PROPERTIES_FILE="${CMAKE_CURRENT_BINARY_DIR}/install_and_start_bundles.properties"
)
if (ENABLE_TESTING_ON_CI)
target_compile_definitions(test_framework_with_cxx14 PRIVATE TESTING_ON_CI=1)
endif ()
add_test(NAME test_framework_with_cxx14 COMMAND test_framework_with_cxx14)
setup_target_for_coverage(test_framework_with_cxx14 SCAN_DIR ..)
endif ()
15 changes: 0 additions & 15 deletions libs/framework/gtest/src/CxxBundleContextTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -725,21 +725,6 @@ TEST_F(CxxBundleContextTestSuite, GetBundleInformation) {
EXPECT_TRUE(startCalled);
}

#if __cplusplus >= 201703L //C++17 or higher
class TestInterfaceWithStaticInfo {
public:
static constexpr std::string_view NAME = "TestName";
static constexpr std::string_view VERSION = "1.2.3";
};

TEST_F(CxxBundleContextTestSuite, RegisterServiceWithNameAndVersionInfo) {
auto reg = ctx->registerService<TestInterfaceWithStaticInfo>(std::make_shared<TestInterfaceWithStaticInfo>())
.build();
EXPECT_EQ(reg->getServiceName(), "TestName");
EXPECT_EQ(reg->getServiceVersion(), "1.2.3");
}
#endif

TEST_F(CxxBundleContextTestSuite, listBundles) {
auto list = ctx->listBundleIds();
EXPECT_EQ(0, list.size());
Expand Down
21 changes: 9 additions & 12 deletions libs/framework/gtest/src/DependencyManagerTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1152,19 +1152,18 @@ TEST_F(DependencyManagerTestSuite, testStateToString) {

}

#if __cplusplus >= 201703L //C++17 or higher

class TestInterfaceWithStaticInfo {
class TestInterface {
public:
static constexpr const char * const NAME = "TestName";
static constexpr const char * const VERSION = "1.2.3";
};

TEST_F(DependencyManagerTestSuite, ProvideInterfaceWithStaticInfo) {
class TestComponent : public TestInterfaceWithStaticInfo {};
TEST_F(DependencyManagerTestSuite, ProvideInterfaceInfo) {
class TestComponent : public TestInterface {};
celix::dm::DependencyManager dm{ctx};
auto& cmp = dm.createComponent<TestComponent>();
cmp.createProvidedService<TestInterfaceWithStaticInfo>();
cmp.createProvidedService<TestInterface>(TestInterface::NAME)
.setVersion(TestInterface::VERSION);
cmp.build();
EXPECT_EQ(cmp.getState(), celix::dm::ComponentState::TRACKING_OPTIONAL);

Expand All @@ -1176,11 +1175,11 @@ TEST_F(DependencyManagerTestSuite, ProvideInterfaceWithStaticInfo) {
EXPECT_EQ(it->second, "1.2.3");
}

TEST_F(DependencyManagerTestSuite, CreateInterfaceWithStaticInfo) {
class TestComponent : public TestInterfaceWithStaticInfo {};
TEST_F(DependencyManagerTestSuite, CreateInterfaceInfo) {
class TestComponent : public TestInterface {};
celix::dm::DependencyManager dm{ctx};
auto& cmp = dm.createComponent<TestComponent>();
cmp.addInterface<TestInterfaceWithStaticInfo>();
cmp.addInterfaceWithName<TestInterface>(TestInterface::NAME, TestInterface::VERSION);
cmp.build();
EXPECT_EQ(cmp.getState(), celix::dm::ComponentState::TRACKING_OPTIONAL);

Expand All @@ -1196,7 +1195,7 @@ TEST_F(DependencyManagerTestSuite, TestPrintInfo) {
celix::dm::DependencyManager dm{ctx};
auto& cmp = dm.createComponent<Cmp1>();
cmp.addInterface<TestService>();
cmp.createServiceDependency<TestInterfaceWithStaticInfo>();
cmp.createServiceDependency<TestInterface>(TestInterface::NAME);
cmp.build();

char* buf = nullptr;
Expand Down Expand Up @@ -1255,5 +1254,3 @@ TEST_F(DependencyManagerTestSuite, TestPrintInfo) {
ss << cmp;
EXPECT_TRUE(strstr(ss.str().c_str(), "Cmp1"));
}

#endif
Loading

0 comments on commit 3974d91

Please sign in to comment.