diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fa1e215b..9d4ae8f21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,3 +49,4 @@ if(BUILD_CURL_TRANSPORT) add_subdirectory(sdk/core/azure-core/test/e2e) # will work only if BUILD_CURL_TRANSPORT=ON endif() add_subdirectory(sdk/storage) +add_subdirectory(sdk/template/azure-template) diff --git a/sdk/core/azure-core/CMakeLists.txt b/sdk/core/azure-core/CMakeLists.txt index a60aab7fc..e9f3f5c75 100644 --- a/sdk/core/azure-core/CMakeLists.txt +++ b/sdk/core/azure-core/CMakeLists.txt @@ -32,7 +32,7 @@ add_library ( src/http/winhttp/win_http_transport.cpp src/logging/logging.cpp src/strings.cpp - ) + src/version.cpp) target_include_directories (${TARGET_NAME} PUBLIC $ $) diff --git a/sdk/core/azure-core/inc/azure/core/version.hpp b/sdk/core/azure-core/inc/azure/core/version.hpp new file mode 100644 index 000000000..a5c6bc3b4 --- /dev/null +++ b/sdk/core/azure-core/inc/azure/core/version.hpp @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +#define AZURE_CORE_VERSION_MAJOR 1 +#define AZURE_CORE_VERSION_MINOR 0 +#define AZURE_CORE_VERSION_PATCH 0 +#define AZURE_CORE_VERSION_PRERELEASE "beta.1" + +namespace Azure { namespace Core { + + class Version { + public: + static constexpr int Major = AZURE_CORE_VERSION_MAJOR; + static constexpr int Minor = AZURE_CORE_VERSION_MINOR; + static constexpr int Patch = AZURE_CORE_VERSION_PATCH; + static std::string const PreRelease; + static std::string const VersionString(); + + private: + // To avoid leaking out the #define values we smuggle out the value + // which will later be used to initialize the PreRelease std::string + static constexpr const char* secret = AZURE_CORE_VERSION_PRERELEASE; + }; + +}} // namespace Azure::Core + +#undef AZURE_CORE_VERSION_MAJOR +#undef AZURE_CORE_VERSION_MINOR +#undef AZURE_CORE_VERSION_PATCH +#undef AZURE_CORE_VERSION_PRERELEASE diff --git a/sdk/core/azure-core/src/version.cpp b/sdk/core/azure-core/src/version.cpp new file mode 100644 index 000000000..16828daaa --- /dev/null +++ b/sdk/core/azure-core/src/version.cpp @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include "azure/core/version.hpp" + +#include +#include + +using namespace Azure::Core; + +const std::string Version::PreRelease = secret; + +std::string const Version::VersionString() +{ + static const std::string versionString = [] { + std::string version; + std::stringstream ss; + std::string dot = "."; + + ss << Version::Major << dot << Version::Minor << dot << Version::Patch; + + if (!Version::PreRelease.empty()) + ss << "-" << Version::PreRelease; + + return ss.str(); + }(); + + return versionString; +} + diff --git a/sdk/core/azure-core/test/ut/CMakeLists.txt b/sdk/core/azure-core/test/ut/CMakeLists.txt index e1f39dfdd..a1b67fe41 100644 --- a/sdk/core/azure-core/test/ut/CMakeLists.txt +++ b/sdk/core/azure-core/test/ut/CMakeLists.txt @@ -30,6 +30,7 @@ add_executable ( telemetry_policy.cpp transport_adapter.cpp transport_adapter.hpp + uuid.cpp ) target_link_libraries(${TARGET_NAME} PRIVATE azure-core) diff --git a/sdk/core/azure-core/test/uuid.cpp b/sdk/core/azure-core/test/ut/uuid.cpp similarity index 66% rename from sdk/core/azure-core/test/uuid.cpp rename to sdk/core/azure-core/test/ut/uuid.cpp index 6d2e8fbe7..c32599020 100644 --- a/sdk/core/azure-core/test/uuid.cpp +++ b/sdk/core/azure-core/test/ut/uuid.cpp @@ -8,8 +8,8 @@ using namespace Azure::Core; -TEST(UUID, Basic) +TEST(Uuid, Basic) { - auto uuid = UUID::CreateUUID(); - EXPECT_TRUE(uuid.GetUUIDString().length() == 36); + auto uuid = Uuid::CreateUuid(); + EXPECT_TRUE(uuid.GetUuidString().length() == 36); } diff --git a/sdk/template/azure-template/CHANGELOG.md b/sdk/template/azure-template/CHANGELOG.md new file mode 100644 index 000000000..cae13767f --- /dev/null +++ b/sdk/template/azure-template/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +* Template package diff --git a/sdk/template/azure-template/CMakeLists.txt b/sdk/template/azure-template/CMakeLists.txt new file mode 100644 index 000000000..ef915e315 --- /dev/null +++ b/sdk/template/azure-template/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +cmake_minimum_required (VERSION 3.12) +set(TARGET_NAME "azure-template") +project(azure-template LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +add_library ( + azure-template + src/version.cpp + src/template_client.cpp + ) + +target_include_directories (azure-template PUBLIC $) + +# make sure that users can consume the project as a library. +add_library (Azure::Template ALIAS azure-template) + +if(BUILD_TESTING) + # tests + add_subdirectory(test) +endif() diff --git a/sdk/template/azure-template/LICENSE b/sdk/template/azure-template/LICENSE new file mode 100644 index 000000000..51b6a76e5 --- /dev/null +++ b/sdk/template/azure-template/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/sdk/template/azure-template/README.md b/sdk/template/azure-template/README.md new file mode 100644 index 000000000..561342807 --- /dev/null +++ b/sdk/template/azure-template/README.md @@ -0,0 +1,70 @@ +# Azure Template Package client library for C++ + +Azure Template Package client library for C++ (`azure-template`) matches necessary patterns that the development team has established to create a unified sdk written in the C++ programming language. These libraries follow the Azure SDK Design Guidelines for C++. + +The library allows client libraries to expose common functionality in a consistent fashion. Once you learn how to use these APIs in one client library, you will know how to use them in other client libraries. + +## Getting started + +For a rich example of a well formatted readme, please check [here.](https://github.com/Azure/azure-sdk/blob/master/docs/policies/README-TEMPLATE.md) In addition, this is an [example readme](https://github.com/Azure/azure-sdk/blob/master/docs/policies/README-EXAMPLE.md) that should be emulated. Note that the top-level sections in this template align with that of the [template.](https://github.com/Azure/azure-sdk/blob/master/docs/policies/README-TEMPLATE.md) + +# Key concepts + +Bullet point list of your library's main concepts. + +# Examples + +Examples of some of the key concepts for your library. + +# Troubleshooting + +Running into issues? This section should contain details as to what to do there. + +# Next steps + +More sample code should go here, along with links out to the appropriate example tests. + +## Contributing +For details on contributing to this repository, see the [contributing guide][azure_sdk_for_cpp_contributing]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a +Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us +the rights to use your contribution. For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide +a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions +provided by the bot. You will only need to do this once across all repos using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or +contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + +### Additional Helpful Links for Contributors +Many people all over the world have helped make this project better. You'll want to check out: + +* [What are some good first issues for new contributors to the repo?](https://github.com/azure/azure-sdk-for-cpp/issues?q=is%3Aopen+is%3Aissue+label%3A%22up+for+grabs%22) +* [How to build and test your change][azure_sdk_for_cpp_contributing_developer_guide] +* [How you can make a change happen!][azure_sdk_for_cpp_contributing_pull_requests] +* Frequently Asked Questions (FAQ) and Conceptual Topics in the detailed [Azure SDK for C++ wiki](https://github.com/azure/azure-sdk-for-cpp/wiki). + + +### Reporting security issues and security bugs + +Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) . You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://www.microsoft.com/msrc/faqs-report-an-issue). + +### License + +Azure SDK for C++ is licensed under the [MIT](LICENSE) license. + + +[azure_sdk_for_cpp_contributing]: https://github.com/Azure/azure-sdk-for-cpp/blob/master/CONTRIBUTING.md +[azure_sdk_for_cpp_contributing_developer_guide]: https://github.com/Azure/azure-sdk-for-cpp/blob/master/CONTRIBUTING.md#developer-guide +[azure_sdk_for_cpp_contributing_pull_requests]: https://github.com/Azure/azure-sdk-for-cpp/blob/master/CONTRIBUTING.md#pull-requests +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_pattern_circuit_breaker]: https://docs.microsoft.com/azure/architecture/patterns/circuit-breaker +[azure_pattern_retry]: https://docs.microsoft.com/azure/architecture/patterns/retry +[azure_portal]: https://portal.azure.com +[azure_sub]: https://azure.microsoft.com/free/ +[c_compiler]: https://visualstudio.microsoft.com/vs/features/cplusplus/ +[cloud_shell]: https://docs.microsoft.com/azure/cloud-shell/overview +[cloud_shell_bash]: https://shell.azure.com/bash \ No newline at end of file diff --git a/sdk/template/azure-template/inc/azure/template/template_client.hpp b/sdk/template/azure-template/inc/azure/template/template_client.hpp new file mode 100644 index 000000000..72dd81160 --- /dev/null +++ b/sdk/template/azure-template/inc/azure/template/template_client.hpp @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +namespace Azure { namespace Template { + + class TemplateClient { + public: + std::string const ClientVersion(); + }; + +}} // namespace Azure::Template diff --git a/sdk/template/azure-template/inc/azure/template/version.hpp b/sdk/template/azure-template/inc/azure/template/version.hpp new file mode 100644 index 000000000..febd1ce61 --- /dev/null +++ b/sdk/template/azure-template/inc/azure/template/version.hpp @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +#define AZURE_TEMPLATE_VERSION_MAJOR 1 +#define AZURE_TEMPLATE_VERSION_MINOR 0 +#define AZURE_TEMPLATE_VERSION_PATCH 0 +#define AZURE_TEMPLATE_VERSION_PRERELEASE "beta.1" + +namespace Azure { namespace Template { + + class Version { + public: + static constexpr int Major = AZURE_TEMPLATE_VERSION_MAJOR; + static constexpr int Minor = AZURE_TEMPLATE_VERSION_MINOR; + static constexpr int Patch = AZURE_TEMPLATE_VERSION_PATCH; + static std::string const PreRelease; + static std::string const VersionString(); + + private: + //To avoid leaking out the #define values we smuggle out the value + // which will later be used to initialize the PreRelease std::string + static constexpr const char* secret = AZURE_TEMPLATE_VERSION_PRERELEASE; + }; + +}} // namespace Azure::Template + +#undef AZURE_TEMPLATE_VERSION_MAJOR +#undef AZURE_TEMPLATE_VERSION_MINOR +#undef AZURE_TEMPLATE_VERSION_PATCH +#undef AZURE_TEMPLATE_VERSION_PRERELEASE diff --git a/sdk/template/azure-template/src/template_client.cpp b/sdk/template/azure-template/src/template_client.cpp new file mode 100644 index 000000000..9a7992bfd --- /dev/null +++ b/sdk/template/azure-template/src/template_client.cpp @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include +#include + +#include + +using namespace Azure::Template; + +std::string const TemplateClient::ClientVersion() +{ + return Version::VersionString(); +} diff --git a/sdk/template/azure-template/src/version.cpp b/sdk/template/azure-template/src/version.cpp new file mode 100644 index 000000000..16ebde750 --- /dev/null +++ b/sdk/template/azure-template/src/version.cpp @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include +#include +#include + +using namespace Azure::Template; + +const std::string Version::PreRelease = secret; + +std::string const Azure::Template::Version::VersionString() +{ + static const std::string versionString = [] { + std::string version; + std::stringstream ss; + std::string dot = "."; + + ss << Version::Major << dot << Version::Minor << dot << Version::Patch; + + if (!Version::PreRelease.empty()) + ss << "-" << Version::PreRelease; + + return ss.str(); + }(); + + return versionString; +} + diff --git a/sdk/template/azure-template/test/CMakeLists.txt b/sdk/template/azure-template/test/CMakeLists.txt new file mode 100644 index 000000000..234df2cc6 --- /dev/null +++ b/sdk/template/azure-template/test/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +cmake_minimum_required (VERSION 3.12) + +project (azure-template-test LANGUAGES CXX) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +add_compile_definitions(AZURE_TEST_DATA_PATH="${CMAKE_BINARY_DIR}") + +add_executable ( + azure-template-test + ut/template_test.cpp + ) + +target_link_libraries(azure-template-test PUBLIC Azure::Template) + +if (MSVC) + target_compile_options(azure-template-test PUBLIC /wd6326 /wd26495 /wd26812) +endif() + +add_gtest(azure-template-test) + diff --git a/sdk/template/azure-template/test/ut/template_test.cpp b/sdk/template/azure-template/test/ut/template_test.cpp new file mode 100644 index 000000000..cd013cc2c --- /dev/null +++ b/sdk/template/azure-template/test/ut/template_test.cpp @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include "gtest/gtest.h" + +#include + +using namespace Azure::Template; + +TEST(Template, Basic) +{ + TemplateClient templateClient; + + EXPECT_FALSE(templateClient.ClientVersion().empty()); +}