Skip to content

Commit

Permalink
azure-sdk-for-cpp/1.11.3:new recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
trns1997 committed Apr 19, 2024
1 parent 9399ff6 commit 34b5aba
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/azure-sdk-for-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.11.3":
url: "https://github.com/Azure/azure-sdk-for-cpp/archive/refs/tags/azure-core_1.11.3.tar.gz"
sha256: "c67e42622bf1ebafee29aa09f333e41adc24712b0c993ada5dd97c9265b444cc"
108 changes: 108 additions & 0 deletions recipes/azure-sdk-for-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.files import get, copy
from conan.tools.scm import Version
import os

required_conan_version = ">=1.53.0"


class AzureSDKForCppConan(ConanFile):
name = "azure-sdk-for-cpp"
description = "Microsoft Azure Storage Client Library for C++"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/Azure/azure-sdk-for-cpp"
topics = ("azure", "cpp", "cross-platform", "microsoft", "cloud")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
_sdks = (
"azure-core",
"azure-template",
"azure-security-keyvault-administration",
"azure-security-keyvault-certificates",
"azure-security-keyvault-secrets",
"azure-security-attestation",
"azure-security-keyvault-keys",
"azure-data-tables",
"azure-identity",
"azure-storage-common",
"azure-storage-queues",
"azure-storage-files-shares",
"azure-storage-blobs",
"azure-storage-files-datalake"
)
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def configure(self):
if self.options.get_safe("shared"):
self.options.rm_safe("fPIC")

def requirements(self):
self.requires("libcurl/8.6.0")
self.requires("libxml2/2.12.6")

def layout(self):
cmake_layout(self, src_folder="src")

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 14)

if self.settings.os != "Linux":
raise ConanInvalidConfiguration(
f"{self.ref} is not supported on {self.settings.os}.")

if self.settings.compiler != "gcc":
raise ConanInvalidConfiguration(
f"{self.ref} is not supported on {self.settings.compiler}.")

if self.settings.compiler == 'gcc' and Version(self.settings.compiler.version) < "6":
raise ConanInvalidConfiguration("Building requires GCC >= 6")

def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["BUILD_TESTING"] = "OFF"
tc.cache_variables["BUILD_SAMPLES"] = "OFF"
tc.cache_variables["BUILD_WINDOWS_UWP"] = "ON"
tc.cache_variables["DISABLE_AZURE_CORE_OPENTELEMETRY"] = "ON"
tc.cache_variables["BUILD_TRANSPORT_CURL"] = "ON"
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, "LICENSE.txt",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder)
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "AzureSDK")

for sdk in self._sdks:
self.cpp_info.components[sdk].set_property("cmake_target_name", f"Azure::{sdk}")
self.cpp_info.components[sdk].libs = [sdk]

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.components[sdk].names["cmake_find_package"] = sdk
self.cpp_info.components[sdk].names["cmake_find_package_multi"] = sdk
self.cpp_info.components[sdk].requires.extend(["libcurl::curl", "libxml2::libxml2"])

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.filenames["cmake_find_package"] = "AzureSDK"
self.cpp_info.filenames["cmake_find_package_multi"] = "AzureSDK"
self.cpp_info.names["cmake_find_package"] = "Azure"
self.cpp_info.names["cmake_find_package_multi"] = "Azure"
self.cpp_info.components["azure-core"].names["cmake_find_package"] = "azure-core"
self.cpp_info.components["azure-core"].names["cmake_find_package_multi"] = "azure-core"
9 changes: 9 additions & 0 deletions recipes/azure-sdk-for-cpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)

find_package(AzureSDK CONFIG REQUIRED)

add_executable(${PROJECT_NAME} test_package.cc)
target_link_libraries(${PROJECT_NAME} PRIVATE azure-sdk-for-cpp::azure-sdk-for-cpp)
25 changes: 25 additions & 0 deletions recipes/azure-sdk-for-cpp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
19 changes: 19 additions & 0 deletions recipes/azure-sdk-for-cpp/all/test_package/test_package.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>

// Include the necessary SDK headers
#include <azure/core.hpp>
#include <azure/storage/blobs.hpp>

// Add appropriate using namespace directives
using namespace Azure::Storage;
using namespace Azure::Storage::Blobs;

int main()
{
BlobAudience audience{"TEST"};

std::vector<uint8_t> data = {1, 2, 3, 4};
Azure::Core::IO::MemoryBodyStream stream(data);

return 0;
}
3 changes: 3 additions & 0 deletions recipes/azure-sdk-for-cpp/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.11.3":
folder: "all"

0 comments on commit 34b5aba

Please sign in to comment.