changeset 36:b649aebfcc61

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Jan 2021 17:14:18 +0100
parents 8a7a5defd5d0 (current diff) 7ddd840563c9 (diff)
children f55b2afdf53d
files
diffstat 4 files changed, 85 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Jan 04 17:13:47 2021 +0100
+++ b/.hgignore	Mon Jan 04 17:14:18 2021 +0100
@@ -1,3 +1,4 @@
 syntax: glob
 CMakeLists.txt.user*
 *~
+*/ThirdPartyDownloads/*
\ No newline at end of file
--- a/Azure/AzureBlobStoragePlugin.cpp	Mon Jan 04 17:13:47 2021 +0100
+++ b/Azure/AzureBlobStoragePlugin.cpp	Mon Jan 04 17:14:18 2021 +0100
@@ -72,7 +72,7 @@
     try
     {
       concurrency::streams::istream inputStream = concurrency::streams::rawptr_stream<uint8_t>::open_istream(reinterpret_cast<const uint8_t*>(data), size);
-      azure::storage::cloud_block_blob blob = container_.get_block_blob_reference(path_);
+      azure::storage::cloud_block_blob blob = container_.get_block_blob_reference(utility::conversions::to_string_t(path_));
       blob.upload_from_stream(inputStream);
       inputStream.close().wait();
     }
@@ -99,7 +99,7 @@
   {
     try
     {
-      block_ = container_.get_block_blob_reference(path_);
+      block_ = container_.get_block_blob_reference(utility::conversions::to_string_t(path_));
       block_.download_attributes(); // to retrieve the properties
     }
     catch (std::exception& ex)
@@ -220,13 +220,13 @@
   {
     OrthancPlugins::LogInfo("Connecting to Azure storage ...");
 
-    as::cloud_storage_account storageAccount = as::cloud_storage_account::parse(connectionString);
+    as::cloud_storage_account storageAccount = as::cloud_storage_account::parse(utility::conversions::to_string_t(connectionString));
     OrthancPlugins::LogInfo("Storage account created");
 
     as::cloud_blob_client blobClient = storageAccount.create_cloud_blob_client();
     OrthancPlugins::LogInfo("Blob client created");
 
-    as::cloud_blob_container blobContainer = blobClient.get_container_reference(containerName);
+    as::cloud_blob_container blobContainer = blobClient.get_container_reference(utility::conversions::to_string_t(containerName));
     OrthancPlugins::LogInfo("Accessing blob container");
 
     // Return value is true if the container did not exist and was successfully created.
@@ -273,7 +273,7 @@
 
   try
   {
-    as::cloud_block_blob blockBlob = blobContainer_.get_block_blob_reference(path);
+    as::cloud_block_blob blockBlob = blobContainer_.get_block_blob_reference(utility::conversions::to_string_t(path));
 
     blockBlob.delete_blob();
   }
--- a/Azure/CMakeLists.txt	Mon Jan 04 17:13:47 2021 +0100
+++ b/Azure/CMakeLists.txt	Mon Jan 04 17:14:18 2021 +0100
@@ -41,14 +41,32 @@
 find_package(cryptopp CONFIG REQUIRED)
 
 # Azure stuff (from https://github.com/Microsoft/vcpkg/issues/6277)
-find_package(cpprestsdk CONFIG REQUIRED)
-find_path(WASTORAGE_INCLUDE_DIR was/blob.h)
-find_library(WASTORAGE_LIBRARY azurestorage)
-find_package(Boost REQUIRED COMPONENTS log)
-find_library(UUID_LIBRARY uuid)
-find_package(LibXml2 REQUIRED)
+if (NOT WIN32)
+  find_package(cpprestsdk CONFIG REQUIRED)
+  find_path(WASTORAGE_INCLUDE_DIR was/blob.h)
+  find_library(WASTORAGE_LIBRARY azurestorage)
+  find_package(Boost REQUIRED COMPONENTS log)
+  find_library(UUID_LIBRARY uuid)
+  find_package(LibXml2 REQUIRED)
+else()  # inspired from https://github.com/phongcao/azure-storage-cpp-sas-sample/blob/master/CMakeLists.txt
+  find_path(WASTORAGE_INCLUDE_DIR was/blob.h)
+  find_library(CPPREST_LIBRARY
+    NAMES cpprest cpprest_2_10)
+  find_library(WASTORAGE_LIBRARY wastorage)
 
-include_directories(${WASTORAGE_INCLUDE_DIR})
+  set (CMAKE_CXX_STANDARD 11)
+  set (CMAKE_CXX_STANDARD_REQUIRED ON)
+  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa")
+  set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
+  set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
+
+  add_definitions(-D_NO_WASTORAGE_API=1)   # from https://github.com/Azure/azure-storage-cpp/issues/263
+endif()
+
+
+if (NOT WIN32)
+  include_directories(${WASTORAGE_INCLUDE_DIR})
+endif()
 
 set(COMMON_SOURCES
     ${CMAKE_SOURCE_DIR}/../Common/IStoragePlugin.h
@@ -76,25 +94,47 @@
   SOVERSION ${PLUGIN_VERSION}
   )
 
-target_link_libraries(OrthancAzureBlobStorage
-  PRIVATE
-  cryptopp-static
-  ${WASTORAGE_LIBRARY} ${UUID_LIBRARY} ${Boost_LIBRARIES} ${LIBXML2_LIBRARIES} cpprestsdk::cpprest
+if (NOT WIN32)
+
+  target_link_libraries(OrthancAzureBlobStorage
+    PRIVATE
+    cryptopp-static
+    ${WASTORAGE_LIBRARY} 
+    ${UUID_LIBRARY} 
+    ${Boost_LIBRARIES} 
+    ${LIBXML2_LIBRARIES} 
+    cpprestsdk::cpprest
+    )
+else()
+  target_link_libraries(OrthancAzureBlobStorage
+    PRIVATE
+    cryptopp-static
+    ${OPENSSL_LIBRARY}
+    ${WASTORAGE_LIBRARY} 
+    ${CPPREST_LIBRARY} 
+    Winhttp.lib
+    Crypt32.lib
+    xmllite.lib
   )
 
+endif()
 
 
-add_executable(UnitTests
-    ${GOOGLE_TEST_SOURCES}
-    ${COMMON_SOURCES}
+# add_executable(UnitTests
+#     ${GOOGLE_TEST_SOURCES}
+#     ${COMMON_SOURCES}
+
+#     ${CMAKE_SOURCE_DIR}/../UnitTestsSources/EncryptionTests.cpp
+#     ${CMAKE_SOURCE_DIR}/../UnitTestsSources/UnitTestsMain.cpp
+#     )
 
-    ${CMAKE_SOURCE_DIR}/../UnitTestsSources/EncryptionTests.cpp
-    ${CMAKE_SOURCE_DIR}/../UnitTestsSources/UnitTestsMain.cpp
-    )
-
-target_link_libraries(UnitTests
-  PRIVATE
-  cryptopp-static
-  ${GOOGLE_TEST_LIBRARIES}
-  ${WASTORAGE_LIBRARY} ${UUID_LIBRARY} ${Boost_LIBRARIES} ${LIBXML2_LIBRARIES} cpprestsdk::cpprest
-  )
+# target_link_libraries(UnitTests
+#   PRIVATE
+#   cryptopp-static
+#   ${GOOGLE_TEST_LIBRARIES}
+#   ${WASTORAGE_LIBRARY} 
+#   # ${UUID_LIBRARY} 
+#   # ${Boost_LIBRARIES} 
+#   # ${LIBXML2_LIBRARIES} 
+#   cpprestsdk::cpprest
+#   )
--- a/README.md	Mon Jan 04 17:13:47 2021 +0100
+++ b/README.md	Mon Jan 04 17:14:18 2021 +0100
@@ -55,12 +55,27 @@
 
 ### Compile Azure plugin ###
 
+On Linux:
+
 * `./vcpkg install cpprestsdk`
+* `./vcpkg install cryptopp`
 * `hg clone ...`
 * `mkdir -p build/azure`
 * `cd build/azure` 
 * `cmake -DCMAKE_TOOLCHAIN_FILE=[vcpkg root]\scripts\buildsystems\vcpkg.cmake ../../orthanc-object-storage/Azure`
 
+On Windows:
+
+* `.\vcpkg.exe install cpprestsdk:x64-windows-static`
+* `.\vcpkg.exe install azure-storage-cpp:x64-windows-static`
+* `.\vcpkg.exe install cryptopp:x64-windows-static`
+* `hg clone ...`
+* `mkdir -p build/azure`
+* `cd build/azure` 
+* `cmake -DCMAKE_TOOLCHAIN_FILE=[vcpkg root]\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE="Release" ../../orthanc-object-storage/Azure`
+* `cmake --build . --config Release`
+
+
 ### Azure plugin configuration ###
 
 ```