Skip to content

Commit a83dba3

Browse files
committed
Enable Rust based AMQP by default (#6362)
* AMQP tests now pass; Integrate TestAmqpBroker with CI pipeline * Updated changelogs to reflect API changes made during AMQP updates * Replace uAMQP with Rust AMQP as the default AMQP transport; Updated build configurationj to reflect that * Test fixes * PR feedback; test fixes
1 parent 471080d commit a83dba3

36 files changed

+990
-523
lines changed

CMakeLists.txt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
cmake_minimum_required (VERSION 3.13)
77
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules")
88

9+
# Enable Rust based APIs in C++ SDK.
10+
set(DISABLE_RUST_IN_BUILD OFF CACHE BOOL "Disable Rust based APIs in package")
11+
set(DISABLE_AMQP OFF CACHE BOOL "Disable AMQP based functionality")
12+
set(DISABLE_AZURE_CORE_OPENTELEMETRY OFF CACHE BOOL "Disable OpenTelemetry based functionality")
13+
14+
message(STATUS "Disabling Rust temporarily")
15+
set(DISABLE_RUST_IN_BUILD ON)
16+
917
# Variable to indicate whether the entire SDK is being built, as opposed to an individual library.
1018
set(AZ_ALL_LIBRARIES ON)
1119

@@ -40,6 +48,15 @@ if ((${VCPKG_TARGET_TRIPLET} MATCHES ".*-uwp"))
4048
message(STATUS "Building for Windows Store, CMAKE_SYSTEM_NAME=" ${CMAKE_SYSTEM_NAME})
4149
endif()
4250

51+
if (BUILD_WINDOWS_UWP)
52+
if (DISABLE_RUST_IN_BUILD)
53+
message(STATUS "uAMQP is incompatible with UWP builds.")
54+
set(DISABLE_AMQP ON)
55+
endif()
56+
message(STATUS "opentelemetry-cpp package is incompatible with UWP builds.")
57+
set(DISABLE_AZURE_CORE_OPENTELEMETRY ON)
58+
endif()
59+
4360
# For MSVC, ensure that the compiler is operating in strict compliance mode.
4461
if (MSVC)
4562
# See also: https://learn.microsoft.com/cpp/build/reference/permissive-standards-conformance
@@ -161,8 +178,8 @@ add_subdirectory(sdk/core)
161178
add_subdirectory(sdk/appconfiguration)
162179
add_subdirectory(sdk/attestation)
163180
# AMQP doesn't work for UWP yet, and eventhubs depends on AMQP, so we cannot include eventhubs on UWP.
164-
if (NOT BUILD_WINDOWS_UWP)
165-
add_subdirectory(sdk/eventhubs)
181+
if (NOT DISABLE_AMQP)
182+
add_subdirectory(sdk/eventhubs)
166183
endif()
167184
add_subdirectory(sdk/identity)
168185
add_subdirectory(sdk/keyvault)

CMakePresets.json

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@
313313
}
314314
},
315315
{
316-
"name": "rust-amqp",
317-
"displayName": "Use Rust AMQP implementation",
318-
"description": "Use Rust AMQP implementation (Hidden)",
316+
"name": "no-rust-amqp",
317+
"displayName": "Disable use of the Rust AMQP implementation",
318+
"description": "Disable use of the Rust AMQP implementation (Hidden)",
319319
"hidden": true,
320320
"cacheVariables": {
321-
"USE_RUST_AMQP": true
321+
"DISABLE_RUST_IN_BUILD": true
322322
}
323323
},
324324
{
@@ -480,30 +480,30 @@
480480
]
481481
},
482482
{
483-
"name": "x64-static-debug-perftests-rust",
484-
"displayName": "x64 Debug, Rust AMQP, static With Perf Tests and samples, libcurl+winhttp",
483+
"name": "x64-static-debug-perftests-no-rust",
484+
"displayName": "x64 Debug, No Rust, static With Perf Tests and samples, libcurl+winhttp",
485485
"inherits": [
486486
"x64-static",
487487
"debug-build",
488488
"enable-tests",
489489
"enable-samples",
490490
"enable-perf",
491-
"rust-amqp",
491+
"no-rust-amqp",
492492
"winhttp-transport",
493493
"curl-transport"
494494
]
495495
},
496496
{
497-
"name": "x64-static-debug-asan-perftests-rust",
498-
"displayName": "x64 Debug, ASAN Rust AMQP, static With Perf Tests and samples, libcurl+winhttp",
497+
"name": "x64-static-debug-asan-perftests-no-rust",
498+
"displayName": "x64 Debug, ASAN No Rust, static With Perf Tests and samples, libcurl+winhttp",
499499
"inherits": [
500500
"x64-static",
501501
"enable-address-sanitizer",
502502
"debug-build",
503503
"enable-tests",
504504
"enable-samples",
505505
"enable-perf",
506-
"rust-amqp",
506+
"no-rust-amqp",
507507
"winhttp-transport",
508508
"curl-transport"
509509
],
@@ -527,7 +527,7 @@
527527
}
528528
},
529529
{
530-
"name": "x86-msvc-static-debug-perftests",
530+
"name": "x86-msvc-static-dbg-all",
531531
"displayName": "x86 MSVC Debug static With Perf Tests and samples",
532532
"inherits": [
533533
"x86-msvc-static",
@@ -540,7 +540,7 @@
540540
]
541541
},
542542
{
543-
"name": "x64-msvc-static-debug-perftests",
543+
"name": "x64-msvc-static-debug-all",
544544
"displayName": "x64 MSVC Debug static With Perf Tests and samples",
545545
"inherits": [
546546
"x64-msvc-static",
@@ -659,6 +659,24 @@
659659
"rhs": "Linux"
660660
}
661661
},
662+
{
663+
"name": "linux-basic-clang-18",
664+
"displayName": "Linux clang-18",
665+
"description": "Using compilers: C = /usr/bin/clang-18, CXX = /usr/bin/clang++-18",
666+
"binaryDir": "${sourceDir}/out/build/${presetName}",
667+
"generator": "Ninja",
668+
"hidden": true,
669+
"cacheVariables": {
670+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
671+
"CMAKE_C_COMPILER": "/usr/bin/clang-18",
672+
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-18"
673+
},
674+
"condition": {
675+
"type": "equals",
676+
"lhs": "${hostSystemName}",
677+
"rhs": "Linux"
678+
}
679+
},
662680
{
663681
"name": "linux-basic-g++",
664682
"displayName": "Linux G++",
@@ -763,6 +781,23 @@
763781
],
764782
"displayName": "Linux clang 13 Debug+Tests"
765783
},
784+
{
785+
"name": "linux-clang-18-debug",
786+
"inherits": [
787+
"linux-basic-clang-18",
788+
"debug-build"
789+
],
790+
"displayName": "Linux clang 18 Debug"
791+
},
792+
{
793+
"name": "linux-clang-18-debug-tests",
794+
"inherits": [
795+
"linux-basic-clang-18",
796+
"debug-build",
797+
"enable-tests"
798+
],
799+
"displayName": "Linux clang 18 Debug+Tests"
800+
},
766801
{
767802
"name": "linux-g++-debug",
768803
"displayName": "Linux c++ Debug",
@@ -800,12 +835,12 @@
800835
"displayName": "Linux c++ Debug+Tests, samples"
801836
},
802837
{
803-
"name": "linux-g++-rust-debug-tests-samples",
838+
"name": "linux-g++-no-rust-debug-tests-samples",
804839
"inherits": [
805840
"linux-g++-debug-tests-samples",
806-
"rust-amqp"
841+
"no-rust-amqp"
807842
],
808-
"displayName": "Linux c++ Debug+Tests, samples, Rust AMQP"
843+
"displayName": "Linux c++ Debug+Tests, samples, No Rust"
809844
},
810845
{
811846
"name": "linux-g++-11-debug",

cmake-modules/AddGoogleTest.cmake

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ else()
3333
)
3434
FetchContent_GetProperties(googletest)
3535
if(NOT googletest_POPULATED)
36-
FetchContent_Populate(googletest)
37-
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE BOOL "")
38-
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
39-
unset(CMAKE_SUPPRESS_DEVELOPER_WARNINGS)
36+
FetchContent_MakeAvailable(googletest)
4037
endif()
4138
endif()
4239

cmake-modules/AzureVcpkg.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ macro(az_vcpkg_integrate)
3333
FetchContent_GetProperties(vcpkg)
3434
# make sure to pull vcpkg only once.
3535
if(NOT vcpkg_POPULATED)
36-
FetchContent_Populate(vcpkg)
36+
FetchContent_MakeAvailable(vcpkg)
3737
endif()
3838
# use the vcpkg source path
3939
set(CMAKE_TOOLCHAIN_FILE "${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")

eng/pipelines/templates/jobs/ci.tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ jobs:
241241
displayName: Test
242242
243243
- ${{ parameters.PostTestSteps }}
244-
244+
245245

246246
- pwsh: |
247247
$ErrorActionPreference = 'SilentlyContinue'

eng/pipelines/templates/stages/platform-matrix.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
"UWP_release": {
128128
"CMAKE_SYSTEM_NAME": "WindowsStore",
129129
"CMAKE_SYSTEM_VERSION": "10.0",
130-
"CmakeArgs": " -DBUILD_TRANSPORT_WINHTTP=ON -DDISABLE_AZURE_CORE_OPENTELEMETRY=ON ",
130+
"CmakeArgs": " -DBUILD_TRANSPORT_WINHTTP=ON ",
131131
"BuildArgs": "--parallel 8 --config Release"
132132
}
133133
},

sdk/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
1010

1111
add_subdirectory(azure-core)
1212

13-
if (NOT BUILD_WINDOWS_UWP)
13+
if (NOT DISABLE_AMQP)
1414
message(STATUS "Including AMQP library")
1515
add_subdirectory(azure-core-amqp)
1616
endif()

sdk/core/azure-core-amqp/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
### Features Added
66

7+
Rust based AMQP library is now available for use in the Azure SDK for C++. This replaces the uAMQP library with a library based on the azure_core_amqp Rust crate.
8+
79
### Breaking Changes
810

11+
Updated `MessageProperties`to remove `Azure::Nullable` from the types which are an `AmqpValue` because the `AmqpValue` already embeds the concept of nullability.
12+
913
### Bugs Fixed
1014

1115
### Other Changes

sdk/core/azure-core-amqp/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ if(NOT AZ_ALL_LIBRARIES)
3333
endif()
3434
endif()
3535

36+
set(USE_RUST_AMQP ON CACHE BOOL "Enable Rust AMQP stack" FORCE)
37+
38+
if (DISABLE_RUST_IN_BUILD)
39+
message(STATUS "Disabling Rust based functionality in build.")
40+
set(USE_RUST_AMQP OFF CACHE BOOL "Enable Rust AMQP stack" FORCE)
41+
endif()
42+
3643

3744
if (USE_RUST_AMQP)
3845
message(STATUS "Using RUST based AMQP stack")
3946
set(VENDOR_UAMQP OFF CACHE BOOL "Use vendored uAMQP" FORCE)
47+
set(USE_UAMQP OFF CACHE BOOL "Enable uAMQP AMQP stack" FORCE)
4048
else()
4149
set(USE_UAMQP ON CACHE BOOL "Enable uAMQP AMQP stack" FORCE)
4250
set(VENDOR_UAMQP ON CACHE BOOL "Use vendored uamqp" FORCE)
@@ -71,13 +79,38 @@ if (USE_RUST_AMQP)
7179
# install_rustup()
7280

7381
include(FetchContent)
82+
83+
# If the cmake build is x86, add the x86 target to the rust build
84+
message("VCPKG_TARGET_TRIPLET: ${VCPKG_TARGET_TRIPLET}")
85+
if (${VCPKG_TARGET_TRIPLET} MATCHES "x86.*")
86+
message("Configure rust for x86 builds.")
87+
88+
if (${VCPKG_TARGET_TRIPLET} MATCHES ".*-windows.*")
89+
message("Configure rust for Windows x86 builds.")
90+
91+
# Run the rustup command to install the toolchain
92+
execute_process(COMMAND rustup toolchain install stable-i686-pc-windows-msvc)
93+
94+
set(Rust_TOOLCHAIN "stable-i686-pc-windows-msvc")
95+
set(Rust_CARGO_TARGET "i686-pc-windows-msvc")
96+
else()
97+
message("Configure rust for Linux x86 builds.")
98+
execute_process(COMMAND rustup toolchain install stable-i686-unknown-linux-gnu)
99+
set(Rust_CARGO_TARGET "i686-unknown-linux-gnu")
100+
endif()
101+
else()
102+
message("Configure rust for 64 builds.")
103+
endif()
104+
105+
74106
FetchContent_Declare(
75107
Corrosion
76108
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
77109
GIT_TAG v0.5 # Optionally specify a commit hash, version tag or branch here
78110
)
79111
FetchContent_MakeAvailable(Corrosion)
80112

113+
81114
# Import targets defined in a package or workspace manifest `Cargo.toml` file
82115
corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/impl/rust_amqp/rust_amqp/rust_wrapper/Cargo.toml)
83116
endif()
@@ -257,6 +290,12 @@ elseif(USE_RUST_AMQP)
257290

258291
if (MSVC)
259292
target_link_libraries(azure-core-amqp PRIVATE Secur32 ncrypt)
293+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
294+
target_link_libraries(azure-core-amqp PRIVATE "-lssl -lcrypto")
295+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
296+
# target_link_libraries()
297+
else()
298+
target_link_libraries(azure-core-amqp PRIVATE "-lssl -lcrypto")
260299
endif()
261300
endif()
262301

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
# cspell: ignore JOBID
4+
5+
. "$PSScriptRoot\..\..\..\eng\common\scripts\common.ps1"
6+
7+
Write-Host "Test Broker output:"
8+
Receive-Job -Id $env:TEST_BROKER_JOBID
9+
10+
# Check if the test broker job is still running
11+
$job = Get-Job -Id $env:TEST_BROKER_JOBID
12+
if ($job.State -ne "Running") {
13+
Write-Host "Test broker terminated unexpectedly."
14+
exit 1
15+
}
16+
17+
# Stop the test broker job started in Test-Setup.ps1
18+
Write-Host "Stopping test broker"
19+
Stop-Job -Id $env:TEST_BROKER_JOBID
20+
Remove-Job -Id $env:TEST_BROKER_JOBID
21+
Write-Host "Test broker stopped."

0 commit comments

Comments
 (0)