diff --git a/CMakeLists.txt b/CMakeLists.txt index 173bca57c..114802c37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ option(BUILD_TRANSPORT_CURL "Build an HTTP transport implementation with CURL" O option(BUILD_TRANSPORT_WINHTTP "Build an HTTP transport implementation with WIN HTTP" OFF) option(BUILD_TRANSPORT_CUSTOM "Implementation for AzureSdkGetCustomHttpTransport function must be linked to the final application" OFF) option(BUILD_TESTING "Build test cases" OFF) +option(BUILD_RTTI "Build libraries with run-time type information." ON) option(BUILD_CODE_COVERAGE "Build gcov targets for HTML and XML reports. Requires debug build and BUILD_TESTING" OFF) option(BUILD_DOCUMENTATION "Create HTML based API documentation (requires Doxygen)" OFF) option(RUN_LONG_UNIT_TESTS "Tests that takes more than 5 minutes to complete. No effect if BUILD_TESTING is OFF" OFF) diff --git a/cmake-modules/AzureConfigRTTI.cmake b/cmake-modules/AzureConfigRTTI.cmake new file mode 100644 index 000000000..3641f3bc5 --- /dev/null +++ b/cmake-modules/AzureConfigRTTI.cmake @@ -0,0 +1,36 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +# The option is added again just like from the main CMakeList +# to enable discovering the option directly from each project. +option(BUILD_RTTI "Build libraries with run-time type information." ON) + +macro(az_rtti_setup targetName packagePart rttiHeaderPath) + if (BUILD_RTTI) + target_compile_definitions(${targetName} PUBLIC AZ_RTTI) + + # Patch azure_rtti for installation with RTTI enabled. + set(AZ_${packagePart}_RTTI "*/ + 1 /*") + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/inc/${rttiHeaderPath}" + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${rttiHeaderPath}" + @ONLY + ) + unset(AZ_${packagePart}_RTTI) + + get_filename_component(rttiHeaderDir ${rttiHeaderPath} DIRECTORY) + install( + FILES "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${rttiHeaderPath}" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${rttiHeaderDir}" + ) + unset(rttiHeaderDir) + + else() + message(STATUS "Building library ${targetName} without RTTI") + if(MSVC) + target_compile_options(${targetName} PUBLIC /GR-) + else() + target_compile_options(${targetName} PUBLIC -fno-rtti) + endif() + endif() +endmacro() diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 90a29af12..2794568b4 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -51,6 +51,15 @@ jobs: CC: '/usr/bin/gcc-9' CXX: '/usr/bin/g++-9' BuildArgs: '-j 10' + Linux_x64_gcc9_no_rtti: + Pool: azsdk-pool-mms-ubuntu-1804-general + OSVmImage: MMSUbuntu18.04 + VcpkgInstall: 'curl[ssl] libxml2 openssl' + VCPKG_DEFAULT_TRIPLET: 'x64-linux' + CC: '/usr/bin/gcc-9' + CXX: '/usr/bin/g++-9' + BuildArgs: '-j 10' + CmakeArgs: ' -DBUILD_RTTI=OFF' Linux_x64: Pool: azsdk-pool-mms-ubuntu-1804-general OSVmImage: MMSUbuntu18.04 @@ -74,6 +83,15 @@ jobs: CMAKE_GENERATOR: 'Visual Studio 16 2019' CMAKE_GENERATOR_PLATFORM: x64 BuildArgs: '--parallel 8' + Win_x64_no_rtti: + Pool: azsdk-pool-mms-win-2019-general + OSVmImage: MMS2019 + VcpkgInstall: 'curl[winssl] libxml2' + VCPKG_DEFAULT_TRIPLET: 'x64-windows-static' + CMAKE_GENERATOR: 'Visual Studio 16 2019' + CMAKE_GENERATOR_PLATFORM: x64 + BuildArgs: '--parallel 8' + CmakeArgs: ' -DBUILD_RTTI=OFF' Ubuntu_20_x64_clang: Pool: azsdk-pool-mms-ubuntu-2004-general OSVmImage: MMSUbuntu20.04 diff --git a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml index 338bbf0f4..a9a97a243 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml @@ -57,6 +57,13 @@ jobs: CmakeArgs: ' -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Release' AZURE_CORE_ENABLE_JSON_TESTS: 1 BuildArgs: '-j 4' + Ubuntu20_x64_no_rtti: + Pool: azsdk-pool-mms-ubuntu-1804-general + OSVmImage: MMSUbuntu18.04 + VcpkgInstall: 'curl[ssl] libxml2 openssl' + VCPKG_DEFAULT_TRIPLET: 'x64-linux' + CmakeArgs: ' -DBUILD_RTTI=OFF -DCMAKE_BUILD_TYPE=Release' + BuildArgs: '-j 4' # Not asking for any transport adapter will default to OS -> windows:winHttp or !windows:libcurl Win_x86_with_unit_test_winHttp: Pool: azsdk-pool-mms-win-2019-general @@ -68,6 +75,15 @@ jobs: CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON ' BuildArgs: '-v --parallel 8' AZURE_CORE_ENABLE_JSON_TESTS: 1 + Win_x86_no_rtti_whit_unit_test: + Pool: azsdk-pool-mms-win-2019-general + OSVmImage: MMS2019 + VcpkgInstall: 'libxml2' + VCPKG_DEFAULT_TRIPLET: 'x86-windows-static' + CMAKE_GENERATOR: 'Visual Studio 16 2019' + CMAKE_GENERATOR_PLATFORM: Win32 + CmakeArgs: ' -DBUILD_RTTI=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON' + BuildArgs: '-v --parallel 8' Win_x64_with_unit_test_winHttp: Pool: azsdk-pool-mms-win-2019-general OSVmImage: MMS2019 diff --git a/sdk/core/azure-core/CMakeLists.txt b/sdk/core/azure-core/CMakeLists.txt index 039dc071f..bb6598ab4 100644 --- a/sdk/core/azure-core/CMakeLists.txt +++ b/sdk/core/azure-core/CMakeLists.txt @@ -17,6 +17,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -71,6 +72,7 @@ set( inc/azure/core/internal/strings.hpp inc/azure/core/io/body_stream.hpp inc/azure/core/azure_assert.hpp + inc/azure/core/rtti.hpp inc/azure/core/base64.hpp inc/azure/core/case_insensitive_containers.hpp inc/azure/core/context.hpp @@ -163,6 +165,12 @@ az_vcpkg_export( "azure/core/dll_import_export.hpp" ) +az_rtti_setup( + azure-core + CORE + "azure/core/rtti.hpp" +) + if(BUILD_TESTING) # define a symbol that enables some test hooks in code add_compile_definitions(TESTING_BUILD) diff --git a/sdk/core/azure-core/inc/azure/core/context.hpp b/sdk/core/azure-core/inc/azure/core/context.hpp index 5b8db54f9..bc1ceb0f2 100644 --- a/sdk/core/azure-core/inc/azure/core/context.hpp +++ b/sdk/core/azure-core/inc/azure/core/context.hpp @@ -11,6 +11,7 @@ #include "azure/core/azure_assert.hpp" #include "azure/core/datetime.hpp" #include "azure/core/dll_import_export.hpp" +#include "azure/core/rtti.hpp" #include #include @@ -79,8 +80,9 @@ namespace Azure { namespace Core { std::atomic Deadline; Context::Key Key; std::shared_ptr Value; +#if defined(AZ_CORE_RTTI) const std::type_info& ValueType; - +#endif static constexpr DateTime::rep ToDateTimeRepresentation(DateTime const& dateTime) { return dateTime.time_since_epoch().count(); @@ -92,16 +94,22 @@ namespace Azure { namespace Core { } explicit ContextSharedState() - : Deadline(ToDateTimeRepresentation((DateTime::max)())), Value(nullptr), + : Deadline(ToDateTimeRepresentation((DateTime::max)())), Value(nullptr) +#if defined(AZ_CORE_RTTI) + , ValueType(typeid(std::nullptr_t)) +#endif { } explicit ContextSharedState( const std::shared_ptr& parent, DateTime const& deadline) - : Parent(parent), Deadline(ToDateTimeRepresentation(deadline)), Value(nullptr), + : Parent(parent), Deadline(ToDateTimeRepresentation(deadline)), Value(nullptr) +#if defined(AZ_CORE_RTTI) + , ValueType(typeid(std::nullptr_t)) +#endif { } @@ -112,7 +120,11 @@ namespace Azure { namespace Core { Context::Key const& key, T value) // NOTE, should this be T&& : Parent(parent), Deadline(ToDateTimeRepresentation(deadline)), Key(key), - Value(std::make_shared(std::move(value))), ValueType(typeid(T)) + Value(std::make_shared(std::move(value))) +#if defined(AZ_CORE_RTTI) + , + ValueType(typeid(T)) +#endif { } }; @@ -197,8 +209,10 @@ namespace Azure { namespace Core { { if (ptr->Key == key) { +#if defined(AZ_CORE_RTTI) AZURE_ASSERT_MSG( typeid(T) == ptr->ValueType, "Type mismatch for Context::TryGetValue()."); +#endif outputValue = *reinterpret_cast(ptr->Value.get()); return true; diff --git a/sdk/core/azure-core/inc/azure/core/rtti.hpp b/sdk/core/azure-core/inc/azure/core/rtti.hpp new file mode 100644 index 000000000..c3e1b1aba --- /dev/null +++ b/sdk/core/azure-core/inc/azure/core/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details When RTTI is enabled, defines a macro `AZ_CORE_RTTI`. When + * the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_CORE_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_CORE_RTTI@*/) +#define AZ_CORE_RTTI +#endif diff --git a/sdk/core/azure-core/test/ut/http_test.cpp b/sdk/core/azure-core/test/ut/http_test.cpp index de5e87eca..9a90c23d4 100644 --- a/sdk/core/azure-core/test/ut/http_test.cpp +++ b/sdk/core/azure-core/test/ut/http_test.cpp @@ -6,6 +6,7 @@ #include "http_test.hpp" #include #include +#include #include #include @@ -155,9 +156,11 @@ namespace Azure { namespace Core { namespace Test { Url url("http://test.com"); Http::Request req(httpMethod, url); +#if defined(AZ_CORE_RTTI) Azure::Core::IO::_internal::NullBodyStream* d = dynamic_cast(req.GetBodyStream()); EXPECT_TRUE(d); +#endif req.StartTry(); @@ -172,8 +175,10 @@ namespace Azure { namespace Core { namespace Test { EXPECT_FALSE(headers.count("name")); +#if defined(AZ_CORE_RTTI) d = dynamic_cast(req.GetBodyStream()); EXPECT_TRUE(d); +#endif } { @@ -192,14 +197,18 @@ namespace Azure { namespace Core { namespace Test { Http::Request req(httpMethod, url, &stream); +#if defined(AZ_CORE_RTTI) Azure::Core::IO::MemoryBodyStream* d = dynamic_cast(req.GetBodyStream()); EXPECT_TRUE(d); +#endif req.StartTry(); +#if defined(AZ_CORE_RTTI) d = dynamic_cast(req.GetBodyStream()); EXPECT_TRUE(d); +#endif // Verify that StartTry rewound the stream back. auto getStream = req.GetBodyStream(); diff --git a/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp b/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp index 1041a4e65..0da2ce131 100644 --- a/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp +++ b/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include +#include #if defined(AZ_PLATFORM_POSIX) #include @@ -472,6 +473,7 @@ namespace Azure { namespace Core { namespace Test { } } +#if defined(AZ_CORE_RTTI) TEST_P(TransportAdapter, dynamicCast) { Azure::Core::Url host("http://unresolvedHost.org/get"); @@ -490,6 +492,7 @@ namespace Azure { namespace Core { namespace Test { EXPECT_THROW((void)dynamic_cast(err), std::bad_cast); } } +#endif TEST_P(TransportAdapter, SizePutFromFile) { diff --git a/sdk/identity/azure-identity/CMakeLists.txt b/sdk/identity/azure-identity/CMakeLists.txt index 5a099b0eb..f84c70a0e 100644 --- a/sdk/identity/azure-identity/CMakeLists.txt +++ b/sdk/identity/azure-identity/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -76,6 +77,12 @@ az_vcpkg_export( "azure/identity/dll_import_export.hpp" ) +az_rtti_setup( + azure-identity + IDENTITY + "azure/identity/rtti.hpp" +) + if(BUILD_TESTING) # tests if (NOT AZ_ALL_LIBRARIES) diff --git a/sdk/identity/azure-identity/inc/azure/identity/rtti.hpp b/sdk/identity/azure-identity/inc/azure/identity/rtti.hpp new file mode 100644 index 000000000..89bbb93ce --- /dev/null +++ b/sdk/identity/azure-identity/inc/azure/identity/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details When RTTI is enabled, defines a macro `AZ_IDENTITY_RTTI`. When + * the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_IDENTITY_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_IDENTITY_RTTI@*/) +#define AZ_IDENTITY_RTTI +#endif diff --git a/sdk/keyvault/azure-security-keyvault-certificates/CMakeLists.txt b/sdk/keyvault/azure-security-keyvault-certificates/CMakeLists.txt index d78d51a01..911b68291 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/CMakeLists.txt +++ b/sdk/keyvault/azure-security-keyvault-certificates/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -94,3 +95,9 @@ az_vcpkg_export( SECURITY_KEYVAULT_CERTIFICATES "azure/keyvault/certificates/dll_import_export.hpp" ) + +az_rtti_setup( + azure-security-keyvault-certificates + SECURITY_KEYVAULT_CERTIFICATES + "azure/keyvault/certificates/rtti.hpp" +) diff --git a/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/rtti.hpp b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/rtti.hpp new file mode 100644 index 000000000..66201c3e3 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-certificates/inc/azure/keyvault/certificates/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details Checks whenever RTTI is enabled and exports the symbol + * `AZ_SECURITY_KEYVAULT_CERTIFICATES_RTTI`. When the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_SECURITY_KEYVAULT_CERTIFICATES_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_SECURITY_KEYVAULT_CERTIFICATES_RTTI@*/) +#define AZ_SECURITY_KEYVAULT_CERTIFICATES_RTTI +#endif diff --git a/sdk/keyvault/azure-security-keyvault-keys/CMakeLists.txt b/sdk/keyvault/azure-security-keyvault-keys/CMakeLists.txt index ccfac1c9c..7c37657af 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/CMakeLists.txt +++ b/sdk/keyvault/azure-security-keyvault-keys/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -134,3 +135,9 @@ az_vcpkg_export( SECURITY_KEYVAULT_KEYS "azure/keyvault/keys/dll_import_export.hpp" ) + +az_rtti_setup( + azure-security-keyvault-keys + SECURITY_KEYVAULT_KEYS + "azure/keyvault/keys/rtti.hpp" +) diff --git a/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/rtti.hpp b/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/rtti.hpp new file mode 100644 index 000000000..a03ca767a --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details Checks whenever RTTI is enabled and exports the symbol + * `AZ_SECURITY_KEYVAULT_KEYS_RTTI`. When the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_SECURITY_KEYVAULT_KEYS_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_SECURITY_KEYVAULT_KEYS_RTTI@*/) +#define AZ_SECURITY_KEYVAULT_KEYS_RTTI +#endif diff --git a/sdk/keyvault/azure-security-keyvault-secrets/CMakeLists.txt b/sdk/keyvault/azure-security-keyvault-secrets/CMakeLists.txt index 607d7e12b..595b89f15 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/CMakeLists.txt +++ b/sdk/keyvault/azure-security-keyvault-secrets/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -100,6 +101,12 @@ endif() az_vcpkg_export( azure-security-keyvault-secrets - SECURITY_KEYVAULT_KEYS + SECURITY_KEYVAULT_SECRETS "azure/keyvault/secrets/dll_import_export.hpp" ) + +az_rtti_setup( + azure-security-keyvault-secrets + SECURITY_KEYVAULT_SECRETS + "azure/keyvault/secrets/rtti.hpp" +) diff --git a/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/rtti.hpp b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/rtti.hpp new file mode 100644 index 000000000..27b24df76 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-secrets/inc/azure/keyvault/secrets/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details Checks whenever RTTI is enabled and exports the symbol + * `AZ_SECURITY_KEYVAULT_SECRETS_RTTI`. When the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_SECURITY_KEYVAULT_SECRETS_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_SECURITY_KEYVAULT_SECRETS_RTTI@*/) +#define AZ_SECURITY_KEYVAULT_SECRETS_RTTI +#endif diff --git a/sdk/storage/azure-storage-blobs/CMakeLists.txt b/sdk/storage/azure-storage-blobs/CMakeLists.txt index a313f467a..dc3a80669 100644 --- a/sdk/storage/azure-storage-blobs/CMakeLists.txt +++ b/sdk/storage/azure-storage-blobs/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -81,6 +82,12 @@ az_vcpkg_export( "azure/storage/blobs/dll_import_export.hpp" ) +az_rtti_setup( + azure-storage-blobs + STORAGE_BLOBS + "azure/storage/blobs/rtti.hpp" +) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF create_code_coverage(storage azure-storage-blobs azure-storage-test) diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/rtti.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/rtti.hpp new file mode 100644 index 000000000..bb830c48c --- /dev/null +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details When RTTI is enabled, defines a macro `AZ_STORAGE_BLOBS_RTTI`. + * When the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_STORAGE_BLOBS_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_STORAGE_BLOBS_RTTI@*/) +#define AZ_STORAGE_BLOBS_RTTI +#endif diff --git a/sdk/storage/azure-storage-common/CMakeLists.txt b/sdk/storage/azure-storage-common/CMakeLists.txt index 6ec570bf1..ca8db2061 100644 --- a/sdk/storage/azure-storage-common/CMakeLists.txt +++ b/sdk/storage/azure-storage-common/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -99,6 +100,12 @@ az_vcpkg_export( "azure/storage/common/dll_import_export.hpp" ) +az_rtti_setup( + azure-storage-common + STORAGE_COMMON + "azure/storage/common/rtti.hpp" +) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF # excluding json from coverage report create_code_coverage(storage azure-storage-common azure-storage-test "inc/azure/storage/common/json*") diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/rtti.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/rtti.hpp new file mode 100644 index 000000000..18bb913c2 --- /dev/null +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details When RTTI is enabled, defines a macro `AZ_STORAGE_COMMON_RTTI`. + * When the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_STORAGE_COMMON_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_STORAGE_COMMON_RTTI@*/) +#define AZ_STORAGE_COMMON_RTTI +#endif diff --git a/sdk/storage/azure-storage-files-datalake/CMakeLists.txt b/sdk/storage/azure-storage-files-datalake/CMakeLists.txt index 1192082f3..da5af33cb 100644 --- a/sdk/storage/azure-storage-files-datalake/CMakeLists.txt +++ b/sdk/storage/azure-storage-files-datalake/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -82,6 +83,12 @@ az_vcpkg_export( "azure/storage/files/datalake/dll_import_export.hpp" ) +az_rtti_setup( + azure-storage-files-datalake + STORAGE_FILES_DATALAKE + "azure/storage/files/datalake/rtti.hpp" +) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF create_code_coverage(storage azure-storage-files-datalake azure-storage-test) diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rtti.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rtti.hpp new file mode 100644 index 000000000..b54ba3f2e --- /dev/null +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details Checks whenever RTTI is enabled and exports the symbol + * `AZ_STORAGE_FILES_DATALAKE_RTTI`. When the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_STORAGE_FILES_DATALAKE_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_STORAGE_FILES_DATALAKE_RTTI@*/) +#define AZ_STORAGE_FILES_DATALAKE_RTTI +#endif diff --git a/sdk/storage/azure-storage-files-shares/CMakeLists.txt b/sdk/storage/azure-storage-files-shares/CMakeLists.txt index 466f5ea61..338733546 100644 --- a/sdk/storage/azure-storage-files-shares/CMakeLists.txt +++ b/sdk/storage/azure-storage-files-shares/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -80,6 +81,12 @@ az_vcpkg_export( "azure/storage/files/shares/dll_import_export.hpp" ) +az_rtti_setup( + azure-storage-files-shares + STORAGE_FILES_SHARES + "azure/storage/files/shares/rtti.hpp" +) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF create_code_coverage(storage azure-storage-files-shares azure-storage-test) diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rtti.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rtti.hpp new file mode 100644 index 000000000..a9483dac3 --- /dev/null +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details Checks whenever RTTI is enabled and exports the symbol + * `AZ_STORAGE_FILES_SHARES_RTTI`. When the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_STORAGE_FILES_SHARES_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_STORAGE_FILES_SHARES_RTTI@*/) +#define AZ_STORAGE_FILES_SHARES_RTTI +#endif diff --git a/sdk/storage/azure-storage-queues/CMakeLists.txt b/sdk/storage/azure-storage-queues/CMakeLists.txt index 5e38a5e4c..4144ba4c0 100644 --- a/sdk/storage/azure-storage-queues/CMakeLists.txt +++ b/sdk/storage/azure-storage-queues/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -71,6 +72,12 @@ az_vcpkg_export( STORAGE_QUEUES "azure/storage/queues/dll_import_export.hpp" ) + +az_rtti_setup( + azure-storage-queues + STORAGE_QUEUES + "azure/storage/queues/rtti.hpp" +) # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF create_code_coverage(storage azure-storage-queues azure-storage-test) diff --git a/sdk/storage/azure-storage-queues/inc/azure/storage/queues/rtti.hpp b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/rtti.hpp new file mode 100644 index 000000000..cea2954fc --- /dev/null +++ b/sdk/storage/azure-storage-queues/inc/azure/storage/queues/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details When RTTI is enabled, defines a macro `AZ_STORAGE_QUEUES_RTTI`. + * When the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_STORAGE_QUEUES_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_STORAGE_QUEUES_RTTI@*/) +#define AZ_STORAGE_QUEUES_RTTI +#endif diff --git a/sdk/template/azure-template/CMakeLists.txt b/sdk/template/azure-template/CMakeLists.txt index 805064087..13e7f5311 100644 --- a/sdk/template/azure-template/CMakeLists.txt +++ b/sdk/template/azure-template/CMakeLists.txt @@ -16,6 +16,7 @@ include(AzureCodeCoverage) include(AzureTransportAdapters) include(AzureDoxygen) include(AzureGlobalCompileOptions) +include(AzureConfigRTTI) az_vcpkg_integrate() @@ -68,6 +69,12 @@ az_vcpkg_export( "azure/template/dll_import_export.hpp" ) +az_rtti_setup( + azure-template + TEMPLATE + "azure/template/rtti.hpp" +) + if(BUILD_TESTING) # tests add_subdirectory(test) diff --git a/sdk/template/azure-template/inc/azure/template/rtti.hpp b/sdk/template/azure-template/inc/azure/template/rtti.hpp new file mode 100644 index 000000000..f70768f1a --- /dev/null +++ b/sdk/template/azure-template/inc/azure/template/rtti.hpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Run-time type info enable or disable. + * + * @details When RTTI is enabled, defines a macro `AZ_TEMPLATE_RTTI`. When + * the macro is not defined, RTTI is disabled. + * + * @details Each library has this header file. These headers are being configured by + * `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending + * on the build flags. + */ + +#pragma once + +/** + * @def AZ_TEMPLATE_RTTI + * @brief A macro indicating whether the code is built with RTTI or not. + * + * @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after + * the build is completed, that information is not preserved for the code that consumes Azure SDK + * headers, unless the code that consumes the SDK is the part of the same build process. To address + * this issue, CMake install would patch the header it places in the installation directory, so that + * condition: + * `#if defined(AZ_RTTI) || (0)` + * becomes, effectively, + * `#if defined(AZ_RTTI) || (0 + 1)` + * when the library was built with RTTI support, and will make no changes to the + * condition when it was not. + */ + +#if defined(AZ_RTTI) || (0 /*@AZ_TEMPLATE_RTTI@*/) +#define AZ_TEMPLATE_RTTI +#endif