Skip to content

Commit

Permalink
Initial attempt at a Rust AMQP stack, merged against feature/rust_amq…
Browse files Browse the repository at this point in the history
…p for now. (#5942)

* Enabled building AMQP *without* uAMQP

* Start integrating Rust AMQP Value to C++ AMQP Value

* AMQP Value tests now pass

* Moved AmqpValueType ostream inserter to its original location

* Added Rust AMQP Message implementation

* Added start of message source tests

* Enabled building AMQP *without* uAMQP

* Start integrating Rust AMQP Value to C++ AMQP Value

* Moved AmqpValueType ostream inserter to its original location

* Message target support

* Message source and target support
  • Loading branch information
LarryOsterman committed Sep 18, 2024
1 parent fdfc6e0 commit 3fa6db9
Show file tree
Hide file tree
Showing 102 changed files with 14,984 additions and 1,070 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bld*/
[Oo]bj/
[Ll]og/
[Oo]ut/
**/target/
[Tt]emp
#these are for build from source temp directories
[Ss]dk/**/[Ss]dk/
Expand Down Expand Up @@ -352,7 +353,7 @@ build/
[Dd]ocs/

# vscode
.vscode/*
**/.vscode/*
!.vscode/cspell.json
.factorypath

Expand All @@ -365,3 +366,6 @@ CMakeUserPresets.json
**/vendor/**/*.sln
**/vendor/**/*.csproj

# Generated Rust source file
**/rust_amqp_wrapper.h
**/Cargo.lock
6 changes: 5 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"version": "0.2",
"language": "en",
"languageId": "cpp",
"languageId": "c,cpp,rust",
"dictionaries": [
"powershell",
"cpp",
"rust",
"c",
"markdown"
],
"languageSettings": [
Expand Down Expand Up @@ -41,6 +43,8 @@
"eng/docs/api/assets/**/*",
"eng/CredScanSuppression.json",
"sdk/core/azure-core-amqp/vendor/**/*",
"sdk/core/azure-core-amqp/rust_amqp/azure_core_amqp/**/*",
"*.toml",
"sdk/storage/*/NOTICE.txt",
"sdk/tables/*/NOTICE.txt"
],
Expand Down
61 changes: 54 additions & 7 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,15 @@
"BUILD_TRANSPORT_CURL": true
}
},
{
"name": "rust-amqp",
"displayName": "Use Rust AMQP implementation",
"description": "Use Rust AMQP implementation (Hidden)",
"hidden": true,
"cacheVariables": {
"USE_RUST_AMQP": true
}
},
{
"name": "enable-address-sanitizer",
"displayName": "Enable Address Sanitizer",
Expand Down Expand Up @@ -352,7 +361,6 @@
"x86-static",
"release-build"
]

},
{
"name": "x64-debug-tests",
Expand Down Expand Up @@ -471,6 +479,20 @@
"curl-transport"
]
},
{
"name": "x64-static-debug-perftests-rust",
"displayName": "x64 Debug, Rust AMQP, static With Perf Tests and samples, libcurl+winhttp",
"inherits": [
"x64-static",
"debug-build",
"enable-tests",
"enable-samples",
"enable-perf",
"rust-amqp",
"winhttp-transport",
"curl-transport"
]
},
{
"name": "x64-static-release-perftests-asan",
"displayName": "x64 Release static With Perf Tests and samples, plus ASAN",
Expand Down Expand Up @@ -675,26 +697,43 @@
{
"name": "linux-gcc11-debug",
"displayName": "Linux GCC 11 Debug",
"inherits": [ "linux-basic-gcc11", "debug-build" ]
"inherits": [
"linux-basic-gcc11",
"debug-build"
]
},
{
"name": "linux-gcc11-debug-tests",
"inherits": [ "linux-basic-gcc11", "debug-build", "enable-tests" ],
"inherits": [
"linux-basic-gcc11",
"debug-build",
"enable-tests"
],
"displayName": "Linux GCC 11 Debug+Tests"
},
{
"name": "linux-clang-11-debug",
"displayName": "Linux clang 11 Debug",
"inherits": [ "linux-basic-clang-11", "debug-build" ]
"inherits": [
"linux-basic-clang-11",
"debug-build"
]
},
{
"name": "linux-clang-11-debug-tests",
"displayName": "Linux clang 11 Debug+tests",
"inherits": [ "linux-basic-clang-11", "debug-build", "enable-tests" ]
"inherits": [
"linux-basic-clang-11",
"debug-build",
"enable-tests"
]
},
{
"name": "linux-clang-13-debug",
"inherits": [ "linux-basic-clang-13", "debug-build" ],
"inherits": [
"linux-basic-clang-13",
"debug-build"
],
"displayName": "Linux clang 13 Debug"
},
{
Expand Down Expand Up @@ -742,6 +781,14 @@
],
"displayName": "Linux c++ Debug+Tests, samples"
},
{
"name": "linux-g++-rust-debug-tests-samples",
"inherits": [
"linux-g++-debug-tests-samples",
"rust-amqp"
],
"displayName": "Linux c++ Debug+Tests, samples, Rust AMQP"
},
{
"name": "linux-g++-11-debug",
"displayName": "Linux g++-11 Debug",
Expand Down Expand Up @@ -778,4 +825,4 @@
}
}
]
}
}
77 changes: 77 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[workspace]
resolver = "2"
members = [
"sdk/core/azure-core-amqp/rust_amqp/azure_core_amqp",
"sdk/core/azure-core-amqp/rust_amqp/rust_wrapper",
]

[workspace.package]
authors = ["Microsoft"]
edition = "2021"
license = "MIT"
repository = "https://github.com/azure/azure-sdk-for-rust"
rust-version = "1.76"


[workspace.dependencies.azure_core_amqp]
path = "sdk/core/azure-core-amqp/rust_amqp/azure_core_amqp"


[workspace.dependencies]
azure_core = { version = "0.18" }
azure_identity = "0.18"
async-lock = "3.0"
async-process = "2.0"
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
base64 = "0.22"
bytes = "1.0"
cbindgen = "0.26.0"
clap = { version = "4.4.16", features = ["derive"] }
dyn-clone = "1.0"
fe2o3-amqp = { version = "0.12", features = ["native-tls", "tracing", "uuid"] }
fe2o3-amqp-ext = { version = "0.12", features = [] }
fe2o3-amqp-management = { version = "0.12" }
fe2o3-amqp-cbs = { version = "0.12" }
fe2o3-amqp-types = { version = "0.12" }
futures = "0.3"
getrandom = { version = "0.2", features = ["js"] }
hmac = { version = "0.12" }
http-types = { version = "2.12", default-features = false }
oauth2 = { version = "4.0.0", default-features = false }
once_cell = "1.18"
openssl = { version = "0.10.46" }
paste = "1.0"
pin-project = "1.0"
quick-xml = { version = "0.31", features = ["serialize", "serde-types"] }
rand = "0.8"
reqwest = { version = "0.12", features = [
"json",
"stream",
], default-features = false }
rustc_version = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_amqp = { version = "0.12.2", features = ["uuid"] }
serde_bytes = { version = "0.11" }
serde_json = "1.0"
serde_test = "1"
serial_test = "3.0"
sha2 = { version = "0.10" }
thiserror = "1.0"
time = { version = "0.3.10", features = [
"serde-well-known",
"macros",
"wasm-bindgen",
] }
tokio = { version = "1.0", default-features = false, features = [
"rt-multi-thread",
"macros",
"time",
] }
tracing = "0.1.40"
tracing-subscriber = "0.3"
tz-rs = { version = "0.6" }
url = "2.2"
uuid = { version = "1.0", features = ["v4"] }

[workspace.lints]
78 changes: 78 additions & 0 deletions cmake-modules/acquire_rust.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# CMake function to download the "rustup-init" script and run it to install Rust

# cspell: words rustup rustc

# This function will download the "rustup-init" script from the Rust website and run it to install Rust.
function(install_rustup)
if(WIN32)
set(_USER_HOME $ENV{USERPROFILE})
set(_CARGO_NAME "cargo.exe")
set(_RUSTC_NAME "rustc.exe")
else()
set(_USER_HOME $ENV{HOME})
set(_CARGO_NAME "cargo")
set(_RUSTC_NAME "rustc")
endif()

if (EXISTS "${_USER_HOME}/.cargo/bin/${_CARGO_NAME}")
set(RUST_EXISTS TRUE)
else()
set(RUST_EXISTS FALSE)
endif()

if (NOT ${RUST_EXISTS})
message(STATUS "Rust is not installed. Downloading and installing Rust using rustup...")
set(RUSTUP_URL "https://sh.rustup.rs")
set(RUSTUP_INIT_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/rustup-init.sh")

if(WIN32)
set(RUSTUP_URL "https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe")
# On Windows, the "rustup-init" script is a .exe file
set(RUSTUP_INIT_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/rustup-init.exe")
endif()

message(STATUS "Downloading and installing Rust using rustup to ${RUSTUP_INIT_SCRIPT}")
message(STATUS "Download URL: ${RUSTUP_URL}")
# Download the "rustup-init" script
if(WIN32)
file(DOWNLOAD "${RUSTUP_URL}" "${RUSTUP_INIT_SCRIPT}"
EXPECTED_HASH SHA256=92535fbde0c7ce45dce7d58f853d89ab1f873d29f78e6d80382f76ca2d1984cf
SHOW_PROGRESS)
else()
file(DOWNLOAD "${RUSTUP_URL}" "${RUSTUP_INIT_SCRIPT}"
EXPECTED_HASH SHA256=32a680a84cf76014915b3f8aa44e3e40731f3af92cd45eb0fcc6264fd257c428
SHOW_PROGRESS)
endif()
# Make the script executable
file(COPY "${RUSTUP_INIT_SCRIPT}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")

if(WIN32)
# Run the rustup-init script on Windows
message(STATUS "Running rustup-init.exe")
execute_process(COMMAND "${CMAKE_CURRENT_BINARY_DIR}/rustup-init.exe" -y RESULTS_VARIABLE _RESULTS OUTPUT_VARIABLE _OUTPUT ERROR_VARIABLE _ERROR)
message(STATUS "Running rustup-init.exe completed: ${_RESULTS}")
if (NOT ${_RESULTS} EQUAL 0)
message(FATAL "rustup-init failed: ${_OUTPUT}")
message(FATAL "Error: ${_ERROR}")
endif()
message(STATUS "Output: ${_OUTPUT}")
message(STATUS "Error: ${_ERROR}")

set(ENV{PATH} "$ENV{_USER_HOME}/.cargo/bin:$ENV{PATH}")
set(Rust_COMPILER ${_USER_HOME}/.cargo/bin/${_RUSTC_NAME})
else()
# Run the rustup-init script on Linux
message(STATUS "Running rustup-init.sh")
execute_process(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/rustup-init.sh")
execute_process(COMMAND "${CMAKE_CURRENT_BINARY_DIR}/rustup-init.sh" -y)

set(ENV{PATH} "${_USER_HOME}/.cargo/bin:$ENV{PATH}")
set(Rust_COMPILER ${_USER_HOME}/.cargo/bin/${RUSTC_NAME} PARENT_SCOPE)
endif()
else()
message(STATUS "Rust is already installed, skipping.")
set(Rust_COMPILER ${_USER_HOME}/.cargo/bin/${_RUSTC_NAME} PARENT_SCOPE)
message(STATUS "Setting Rust Compiler to: ${Rust_COMPILER}")
set(ENV{PATH} "${_USER_HOME}/.cargo/bin;$ENV{PATH}")
endif()
endfunction()
Loading

0 comments on commit 3fa6db9

Please sign in to comment.