[alibabacloud-oss-cpp-sdk-v2] add new port (0.1.0) (#52128)

This commit is contained in:
huiguangjun 2026-06-10 08:04:00 +08:00 committed by GitHub
parent 1d48960945
commit 81fd6444aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 285 additions and 0 deletions

View File

@ -0,0 +1,11 @@
--- a/sdk/src/crypto/OSSEncryptionClient.cpp
+++ b/sdk/src/crypto/OSSEncryptionClient.cpp
@@ -18,8 +18,6 @@
constexpr const char* kCseCekAlgHeader = "x-oss-meta-client-side-encryption-cek-alg";
constexpr const char* kCseWrapAlgHeader = "x-oss-meta-client-side-encryption-wrap-alg";
constexpr const char* kCseMatDescHeader = "x-oss-meta-client-side-encryption-matdesc";
-constexpr const char* kCseDataSizeHeader = "x-oss-meta-client-side-encryption-data-size";
-constexpr const char* kCsePartSizeHeader = "x-oss-meta-client-side-encryption-part-size";
constexpr const char* kCseUnencryptedContentLengthHeader =
"x-oss-meta-client-side-encryption-unencrypted-content-length";
constexpr const char* kCseUnencryptedContentMD5Header = "x-oss-meta-client-side-encryption-unencrypted-content-md5";

View File

@ -0,0 +1,43 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO aliyun/alibabacloud-oss-cpp-sdk-v2
REF "${VERSION}"
SHA512 d5bc33e237dcf5a74327e35c4550e83eb7d8cf1ced7dbe82fc72bb46ea201dd7a069145711dfa4f949e21938178f712cac2e147114e7bd0d3fb307a38824d672
HEAD_REF main
PATCHES
fix-unused-variables.patch
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
curl USE_CURL_TRANSPORT
curl USE_SYSTEM_CURL
winhttp USE_WINHTTP_TRANSPORT
openssl USE_SYSTEM_OPENSSL
encryption ENABLE_ENCRYPTION
rtti ENABLE_RTTI
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE
OPTIONS
-DBUILD_TESTS=OFF
-DBUILD_SAMPLES=OFF
${FEATURE_OPTIONS}
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME alibabacloud_oss_v2 CONFIG_PATH lib/cmake/alibabacloud_oss_v2)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_install_copyright(
FILE_LIST "${SOURCE_PATH}/LICENSE"
COMMENT [[Consult sdk/src/thirdparty/* in the original source tree for authoritative third-party notices.
As of 2026-06-09, vendored code under sdk/src/thirdparty includes:
- tinyxml2
- base64]]
)

View File

@ -0,0 +1,57 @@
{
"name": "alibabacloud-oss-cpp-sdk-v2",
"version": "0.1.0",
"description": "Alibaba Cloud OSS SDK for C++ v2",
"homepage": "https://github.com/aliyun/alibabacloud-oss-cpp-sdk-v2",
"license": "Apache-2.0 AND Zlib AND BSL-1.0",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"curl": {
"description": "Libcurl HTTP transport",
"dependencies": [
{
"name": "curl",
"default-features": false,
"features": [
"ssl"
]
}
]
},
"encryption": {
"description": "Enable client-side encryption",
"dependencies": [
{
"name": "alibabacloud-oss-cpp-sdk-v2",
"default-features": false,
"features": [
"openssl"
],
"platform": "!windows"
}
]
},
"openssl": {
"description": "Use OpenSSL for hash",
"dependencies": [
"openssl"
]
},
"rtti": {
"description": "Build with run-time type information"
},
"winhttp": {
"description": "WinHTTP transport (Windows only)",
"supports": "windows"
}
}
}

View File

@ -0,0 +1,16 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
vcpkg_cmake_configure(
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
)
vcpkg_cmake_install()
if(NOT VCPKG_CROSSCOMPILING)
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/bin/${PORT}/")
vcpkg_execute_required_process(
COMMAND "${CURRENT_PACKAGES_DIR}/bin/${PORT}/main"
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}"
LOGNAME runtime-${TARGET_TRIPLET}
)
endif()

View File

@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.20)
project(vcpkg-ci-alibabacloud-oss-cpp-sdk-v2 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(alibabacloud_oss_v2 CONFIG REQUIRED)
find_package(tinyxml2 CONFIG REQUIRED)
find_path(BOOST_BEAST_INCLUDE_DIR boost/beast/core/detail/base64.hpp REQUIRED)
add_executable(main main.cpp)
target_include_directories(main PRIVATE "${BOOST_BEAST_INCLUDE_DIR}")
target_link_libraries(main PRIVATE alibabacloud_oss_v2::oss tinyxml2::tinyxml2)
install(TARGETS main RUNTIME DESTINATION "bin/vcpkg-ci-alibabacloud-oss-cpp-sdk-v2")
if(NOT WIN32)
find_package(unofficial-aliyun-oss-cpp-sdk CONFIG REQUIRED)
get_property(imported_targets DIRECTORY PROPERTY IMPORTED_TARGETS)
foreach(imported_target IN LISTS imported_targets)
if(imported_target MATCHES "^unofficial::aliyun-oss-cpp-sdk::")
set(legacy_oss_target "${imported_target}")
break()
endif()
endforeach()
if(NOT DEFINED legacy_oss_target)
message(FATAL_ERROR "Could not find the imported target for unofficial-aliyun-oss-cpp-sdk.")
endif()
target_compile_definitions(main PRIVATE HAS_LEGACY_OSS_SDK=1)
target_link_libraries(main PRIVATE "${legacy_oss_target}")
endif()

View File

@ -0,0 +1,78 @@
#include <alibabacloud/oss2/ClientConfiguration.h>
#include <alibabacloud/oss2/OSSClient.h>
#include <alibabacloud/oss2/credentials/CredentialsProvider.h>
#include <boost/beast/core/detail/base64.hpp>
#include <tinyxml2.h>
#include <cstring>
#include <cstdio>
#include <memory>
#include <string>
#if defined(HAS_LEGACY_OSS_SDK)
#include <alibabacloud/oss/OssClient.h>
#include <alibabacloud/oss/client/ClientConfiguration.h>
#endif
int main() {
std::fprintf(stderr, "[diag] parsing tinyxml2 test document\n");
tinyxml2::XMLDocument doc;
if (doc.Parse("<root answer='42' />") != tinyxml2::XML_SUCCESS) {
std::fprintf(stderr, "[diag] tinyxml2 parse failed\n");
return 1;
}
const auto* root = doc.FirstChildElement("root");
if (!root) {
std::fprintf(stderr, "[diag] missing <root> element\n");
return 1;
}
std::fprintf(stderr, "[diag] tinyxml2 root element: %s\n", root->Name());
std::fprintf(stderr, "[diag] running boost::beast base64 encode\n");
char encoded_buffer[16] = {};
const auto encoded_size = boost::beast::detail::base64::encode(encoded_buffer, "oss", 3);
const std::string encoded(encoded_buffer, encoded_size);
std::fprintf(stderr, "[diag] encoded value: %s\n", encoded.c_str());
std::fprintf(stderr, "[diag] constructing OSS SDK v2 client configuration\n");
alibabacloud::oss2::ClientConfiguration v2_config;
v2_config.region = "cn-hangzhou";
v2_config.credentialsProvider = std::make_shared<alibabacloud::oss2::StaticCredentialsProvider>(
"access-key-id", "access-key-secret");
std::fprintf(stderr, "[diag] constructing OSS SDK v2 client\n");
alibabacloud::oss2::OSSClient v2_client(v2_config);
(void)v2_client;
std::fprintf(stderr, "[diag] OSS SDK v2 client constructed successfully\n");
#if defined(HAS_LEGACY_OSS_SDK)
std::fprintf(stderr, "[diag] initializing legacy OSS SDK\n");
AlibabaCloud::OSS::InitializeSdk();
AlibabaCloud::OSS::ClientConfiguration legacy_config;
std::string legacy_md5;
{
std::fprintf(stderr, "[diag] constructing legacy OSS client\n");
AlibabaCloud::OSS::OssClient legacy_client(
"oss-cn-hangzhou.aliyuncs.com",
"access-key-id",
"access-key-secret",
legacy_config);
std::fprintf(stderr, "[diag] computing legacy SDK MD5\n");
legacy_md5 = AlibabaCloud::OSS::ComputeContentMD5("oss", 3);
std::fprintf(stderr, "[diag] legacy OSS client scope ending\n");
}
std::fprintf(stderr, "[diag] legacy SDK MD5 value: %s\n", legacy_md5.c_str());
std::fprintf(stderr, "[diag] legacy SDK MD5 size: %zu\n", legacy_md5.size());
AlibabaCloud::OSS::ShutdownSdk();
std::fprintf(stderr, "[diag] shut down legacy OSS SDK\n");
const bool ok = encoded == "b3Nz" && std::strcmp(root->Name(), "root") == 0 && legacy_md5.size() == 24;
std::fprintf(stderr, "[diag] final result: %s\n", ok ? "PASS" : "FAIL");
return ok ? 0 : 1;
#else
const bool ok = encoded == "b3Nz" && std::strcmp(root->Name(), "root") == 0;
std::fprintf(stderr, "[diag] final result: %s\n", ok ? "PASS" : "FAIL");
return ok ? 0 : 1;
#endif
}

View File

@ -0,0 +1,34 @@
{
"name": "vcpkg-ci-alibabacloud-oss-cpp-sdk-v2",
"version-string": "ci",
"description": "Builds a link-compatibility check for the Alibaba OSS SDK ports and separately installed sandboxed third-party libraries",
"homepage": "https://github.com/microsoft/vcpkg",
"license": "MIT",
"supports": "!emscripten",
"dependencies": [
{
"name": "alibabacloud-oss-cpp-sdk-v2",
"features": [
"winhttp"
],
"platform": "windows"
},
{
"name": "alibabacloud-oss-cpp-sdk-v2",
"features": [
"curl"
],
"platform": "!windows"
},
{
"name": "aliyun-oss-cpp-sdk",
"platform": "linux | osx | android"
},
"boost-beast",
"tinyxml2",
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "b889c42b31a594874213157d6b52347298aa4020",
"version": "0.1.0",
"port-version": 0
}
]
}

View File

@ -88,6 +88,10 @@
"baseline": "1.8.11",
"port-version": 0
},
"alibabacloud-oss-cpp-sdk-v2": {
"baseline": "0.1.0",
"port-version": 0
},
"aliyun-oss-c-sdk": {
"baseline": "3.11.2",
"port-version": 0