From 88f234d9760328709d54c0fa6aa19f023c41fbf6 Mon Sep 17 00:00:00 2001 From: George Arama <50641385+gearama@users.noreply.github.com> Date: Fri, 21 Jan 2022 13:13:15 -0800 Subject: [PATCH] build source identity (#3244) * build source identity * pipeline * PR comments * PR comments * DFETCH cspell * EOL --- .vscode/cspell.json | 1 + CMakeLists.txt | 19 +++----- cmake-modules/FolderList.cmake | 48 ++++++++++--------- sdk/identity/azure-identity/CMakeLists.txt | 20 +++++++- sdk/identity/ci.yml | 7 +++ .../CMakeLists.txt | 19 +++++--- sdk/keyvault/ci.yml | 2 +- 7 files changed, 72 insertions(+), 44 deletions(-) diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 2c61c9b5e..37bab3b81 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -39,6 +39,7 @@ "DCMAKE", "deserializers", "Deserializes", + "DFETCH", "docfx", "DPAPI", "DRUN", diff --git a/CMakeLists.txt b/CMakeLists.txt index cf87aa6d1..e5b200877 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,18 +8,13 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules") set(AZ_ALL_LIBRARIES ON) # Compile Options -option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON) -option(BUILD_TRANSPORT_CURL "Build an HTTP transport implementation with CURL" OFF) -option(BUILD_TRANSPORT_WINHTTP "Build an HTTP transport implementation with WIN HTTP" OFF) -option(BUILD_TRANSPORT_CUSTOM "Implementation for AzureSdkGetCustomHttpTransport function must be linked to the final application" OFF) -option(BUILD_TESTING "Build test cases" OFF) -option(BUILD_SAMPLES "Build sample application for Azure Storage clients" OFF) -option(BUILD_RTTI "Build libraries with run-time type information." ON) -option(BUILD_CODE_COVERAGE "Build gcov targets for HTML and XML reports. Requires debug build and BUILD_TESTING" OFF) -option(BUILD_DOCUMENTATION "Create HTML based API documentation (requires Doxygen)" OFF) -option(RUN_LONG_UNIT_TESTS "Tests that takes more than 5 minutes to complete. No effect if BUILD_TESTING is OFF" OFF) -option(BUILD_PERFORMANCE_TESTS "Build the performance test library" OFF) -option(MSVC_USE_STATIC_CRT "(MSVC only) Set to ON to link SDK with static CRT (/MT or /MTd switch)." OFF) +include(FolderList) +SetGlobalOptions() + +if(FETCH_SOURCE_DEPS) + message(FATAL_ERROR, "FETCH_SOURCE_DEPS flag not for global use, instead use when building individual components") + return() +endif() include(AzureTransportAdapters) include(AzureVcpkg) diff --git a/cmake-modules/FolderList.cmake b/cmake-modules/FolderList.cmake index 2f07caa9f..cb8d7dde1 100644 --- a/cmake-modules/FolderList.cmake +++ b/cmake-modules/FolderList.cmake @@ -2,38 +2,42 @@ macro(GetFolderList project) message ("project found ${project}") if(${project} STREQUAL CERTIFICATES) - DownloadDepVersion(sdk/core azure-core 1.3.1) + DownloadDepVersion(sdk/core azure-core 1.2.0) DownloadDepVersion(sdk/identity azure-identity 1.1.0) + elseif(${project} STREQUAL IDENTITY) + DownloadDepVersion(sdk/core azure-core 1.2.0) endif() list(REMOVE_DUPLICATES BUILD_FOLDERS) endmacro() +macro(SetGlobalOptions) + option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON) + option(BUILD_TRANSPORT_CURL "Build an HTTP transport implementation with CURL" OFF) + option(BUILD_TRANSPORT_WINHTTP "Build an HTTP transport implementation with WIN HTTP" OFF) + option(BUILD_TRANSPORT_CUSTOM "Implementation for AzureSdkGetCustomHttpTransport function must be linked to the final application" OFF) + option(BUILD_TESTING "Build test cases" OFF) + option(BUILD_RTTI "Build libraries with run-time type information." ON) + option(BUILD_CODE_COVERAGE "Build gcov targets for HTML and XML reports. Requires debug build and BUILD_TESTING" OFF) + option(BUILD_DOCUMENTATION "Create HTML based API documentation (requires Doxygen)" OFF) + option(BUILD_SAMPLES "Build sample application for Azure Storage clients" OFF) + option(RUN_LONG_UNIT_TESTS "Tests that takes more than 5 minutes to complete. No effect if BUILD_TESTING is OFF" OFF) + option(BUILD_PERFORMANCE_TESTS "Build the performance test library" OFF) + option(MSVC_USE_STATIC_CRT "(MSVC only) Set to ON to link SDK with static CRT (/MT or /MTd switch)." OFF) + option(FETCH_SOURCE_DEPS "fetch source dependencies for a package, not for global use, instead use when building specific component" OFF) +endmacro() + macro(SetCompileOptions project) message ("setting up compile options for ${project}") - - if(${project} STREQUAL CERTIFICATES) + # Compile Options - option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON) - option(BUILD_TRANSPORT_CURL "Build an HTTP transport implementation with CURL" OFF) - option(BUILD_TRANSPORT_WINHTTP "Build an HTTP transport implementation with WIN HTTP" OFF) - option(BUILD_TRANSPORT_CUSTOM "Implementation for AzureSdkGetCustomHttpTransport function must be linked to the final application" OFF) - option(BUILD_TESTING "Build test cases" OFF) - option(BUILD_RTTI "Build libraries with run-time type information." ON) - option(BUILD_CODE_COVERAGE "Build gcov targets for HTML and XML reports. Requires debug build and BUILD_TESTING" OFF) - option(BUILD_DOCUMENTATION "Create HTML based API documentation (requires Doxygen)" OFF) - option(RUN_LONG_UNIT_TESTS "Tests that takes more than 5 minutes to complete. No effect if BUILD_TESTING is OFF" OFF) - option(BUILD_PERFORMANCE_TESTS "Build the performance test library" OFF) - option(MSVC_USE_STATIC_CRT "(MSVC only) Set to ON to link SDK with static CRT (/MT or /MTd switch)." OFF) - option(BUILD_FROM_SOURCE_EXPORT "if export is built from source" ON) - option(TESTING_BUILD "BUILD test cases" OFF) - endif() + SetGlobalOptions() endmacro() macro(DownloadDepVersion DEP_FOLDER DEP_NAME DEP_VERSION) - file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/${DEP_FOLDER}) - set(DOWNLOAD_FOLDER ${CMAKE_SOURCE_DIR}/downloads) + file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/build/${DEP_FOLDER}) + set(DOWNLOAD_FOLDER ${CMAKE_SOURCE_DIR}/build/downloads) set(DOWNLOAD_FILE ${DEP_NAME}_${DEP_VERSION}.zip) set(DEP_PREFIX azure-sdk-for-cpp) # get the zip @@ -42,14 +46,14 @@ macro(DownloadDepVersion DEP_FOLDER DEP_NAME DEP_VERSION) #extract the zip file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_FOLDER}/${DOWNLOAD_FILE} DESTINATION ${DOWNLOAD_FOLDER}/${DEP_NAME}) #make target folder - file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/${DEP_FOLDER}) + file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/build/${DEP_FOLDER}) # need a nicer way to copy/move folder # i need to archive the folder then extract at new location execute_process(COMMAND tar -cf ${DOWNLOAD_FOLDER}/${DEP_NAME}.tar -C ${DOWNLOAD_FOLDER}/${DEP_NAME}/${DEP_PREFIX}-${DEP_NAME}_${DEP_VERSION}/${DEP_FOLDER} .) - file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_FOLDER}/${DEP_NAME}.tar DESTINATION ${CMAKE_SOURCE_DIR}/${DEP_FOLDER}) + file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_FOLDER}/${DEP_NAME}.tar DESTINATION ${CMAKE_SOURCE_DIR}/build/${DEP_FOLDER}) #cleanup file(REMOVE_RECURSE ${DOWNLOAD_FOLDER}) #add dependency folder to build list - list(APPEND BUILD_FOLDERS ${DEP_FOLDER}) + list(APPEND BUILD_FOLDERS build/${DEP_FOLDER}) endmacro() diff --git a/sdk/identity/azure-identity/CMakeLists.txt b/sdk/identity/azure-identity/CMakeLists.txt index 86172e8f4..e5fe3a159 100644 --- a/sdk/identity/azure-identity/CMakeLists.txt +++ b/sdk/identity/azure-identity/CMakeLists.txt @@ -12,6 +12,14 @@ project(azure-identity LANGUAGES CXX) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +# Compile Options +option(FETCH_SOURCE_DEPS "build source dependencies" OFF) + +if(FETCH_SOURCE_DEPS) + set(AZ_ALL_LIBRARIES ON) + include(FolderList) + SetCompileOptions(IDENTITY) +endif() include(AzureVersion) include(AzureCodeCoverage) @@ -23,7 +31,13 @@ include(AzureBuildTargetForCI) # Add create_map_file function include(CreateMapFile) -if(NOT AZ_ALL_LIBRARIES) +if(FETCH_SOURCE_DEPS) + GetFolderList(IDENTITY) + foreach(oneFolder IN LISTS BUILD_FOLDERS) + message("add folder ${oneFolder}") + add_subdirectory(${oneFolder} EXCLUDE_FROM_ALL) + endforeach() +elseif(NOT AZ_ALL_LIBRARIES) find_package(azure-core-cpp "1.2.0" CONFIG QUIET) if(NOT azure-core-cpp_FOUND) find_package(azure-core-cpp "1.2.0" REQUIRED) @@ -88,7 +102,7 @@ az_rtti_setup( if(BUILD_TESTING) # tests - if (NOT AZ_ALL_LIBRARIES) + if (NOT AZ_ALL_LIBRARIES OR FETCH_SOURCE_DEPS) include(AddGoogleTest) enable_testing () endif() @@ -105,3 +119,5 @@ endif() if (BUILD_PERFORMANCE_TESTS) add_subdirectory(test/perf) endif() + +unset(FETCH_SOURCE_DEPS CACHE) diff --git a/sdk/identity/ci.yml b/sdk/identity/ci.yml index 46a20f26f..e9285dab8 100644 --- a/sdk/identity/ci.yml +++ b/sdk/identity/ci.yml @@ -36,6 +36,10 @@ stages: - Name: azure-identity Path: azure-identity VcpkgPortName: azure-identity-cpp + ArtifactsSource: + - Name: azure-identity + Path: azure-identity + VcpkgPortName: azure-identity-cpp TestEnv: # Tenant ID should use the uniqueID format for playback recordings - Name: AZURE_TENANT_ID @@ -53,3 +57,6 @@ stages: Value: '-DBUILD_TESTING=ON -DBUILD_SAMPLES=ON' - Name: Performance Value: '-DBUILD_TESTING=ON -DBUILD_SAMPLES=ON -DBUILD_PERFORMANCE_TESTS=ON' + CMakeSourceTestOptions: + - Name: Source + Value: '-DFETCH_SOURCE_DEPS=ON' diff --git a/sdk/keyvault/azure-security-keyvault-certificates/CMakeLists.txt b/sdk/keyvault/azure-security-keyvault-certificates/CMakeLists.txt index c232ba1d6..4e0b5ed9c 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/CMakeLists.txt +++ b/sdk/keyvault/azure-security-keyvault-certificates/CMakeLists.txt @@ -11,13 +11,13 @@ project(azure-security-keyvault-certificates LANGUAGES CXX) # Compile Options -option(BUILD_SOURCE_DEPS "build source dependencies" OFF) +option(FETCH_SOURCE_DEPS "build source dependencies" OFF) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -if(BUILD_SOURCE_DEPS) +if(FETCH_SOURCE_DEPS) set(AZ_ALL_LIBRARIES ON) include(FolderList) SetCompileOptions(CERTIFICATES) @@ -33,11 +33,11 @@ include(AzureBuildTargetForCI) # Add create_map_file function include(CreateMapFile) -if(BUILD_SOURCE_DEPS) +if(FETCH_SOURCE_DEPS) GetFolderList(CERTIFICATES) foreach(oneFolder IN LISTS BUILD_FOLDERS) message("add folder ${oneFolder}") - add_subdirectory(${oneFolder}) + add_subdirectory(${oneFolder} EXCLUDE_FROM_ALL) endforeach() elseif(NOT AZ_ALL_LIBRARIES) find_package(azure-core-cpp "1.2.0" CONFIG QUIET) @@ -74,7 +74,7 @@ target_include_directories( PUBLIC $ $ - $ + $ $ ) message($