diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zencloud/xmake.lua | 52 | ||||
| -rw-r--r-- | src/zencloud/zencloudmain.cpp | 117 |
2 files changed, 169 insertions, 0 deletions
diff --git a/src/zencloud/xmake.lua b/src/zencloud/xmake.lua new file mode 100644 index 000000000..d7f51093c --- /dev/null +++ b/src/zencloud/xmake.lua @@ -0,0 +1,52 @@ +-- Copyright Epic Games, Inc. All Rights Reserved. + +target("zencloud") + set_kind("binary") + add_headerfiles("**.h") + add_files("**.cpp") + add_files("zencloudmain.cpp", {unity_ignored = true }) + add_deps("zencore", "zenhttp", "zenstore", "zenutil") + add_includedirs(".") + set_symbols("debug") + + if is_mode("release") then + set_optimize("fastest") + end + + if is_plat("windows") then + add_ldflags("/subsystem:console,5.02") + add_ldflags("/LTCG") + add_links("crypt32", "wldap32", "Ws2_32") + add_links("wininet", "ncrypt", "secur32", "shlwapi", "userenv", "version", "winhttp") -- AWS SDK needs these + end + + if is_plat("macosx") then + add_ldflags("-framework CoreFoundation") + add_ldflags("-framework Security") + add_ldflags("-framework SystemConfiguration") + add_syslinks("bsm") + end + + add_packages("vcpkg::cpr", "vcpkg::cxxopts", "vcpkg::mimalloc", "vcpkg::fmt") + + -- AWS bits + + add_packages( + "vcpkg::aws-sdk-cpp[s3-crt]", + "vcpkg::aws-crt-cpp", + "vcpkg::aws-c-auth", + "vcpkg::aws-c-cal", + "vcpkg::aws-checksums", + "vcpkg::aws-c-common", + "vcpkg::aws-c-compression", + "vcpkg::aws-c-event-stream", + "vcpkg::aws-c-http", + "vcpkg::aws-c-io", + "vcpkg::aws-c-mqtt", + "vcpkg::aws-c-s3", + "vcpkg::aws-c-sdkutils" + ) + + if is_plat("windows") then + add_links("wininet", "ncrypt", "secur32", "shlwapi", "userenv", "version", "winhttp") -- AWS SDK needs these + end diff --git a/src/zencloud/zencloudmain.cpp b/src/zencloud/zencloudmain.cpp new file mode 100644 index 000000000..4fd771e68 --- /dev/null +++ b/src/zencloud/zencloudmain.cpp @@ -0,0 +1,117 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include <zencore/filesystem.h> +#include <zencore/logging.h> + +#if ZEN_WITH_TESTS +# define ZEN_TEST_WITH_RUNNER 1 +# include <zencore/testing.h> +#endif + +#if ZEN_USE_MIMALLOC +# include <mimalloc-new-delete.h> +#endif + +ZEN_THIRD_PARTY_INCLUDES_START +#include <spdlog/sinks/ansicolor_sink.h> +#include <spdlog/spdlog.h> +ZEN_THIRD_PARTY_INCLUDES_END + +ZEN_THIRD_PARTY_INCLUDES_START +#include <aws/core/Aws.h> +#include <aws/core/utils/UUID.h> +#include <aws/core/utils/logging/CRTLogSystem.h> +#include <aws/core/utils/memory/stl/AWSStringStream.h> +#include <aws/s3-crt/S3CrtClient.h> +#include <aws/s3-crt/model/BucketLocationConstraint.h> +#include <aws/s3-crt/model/CreateBucketRequest.h> +#include <aws/s3-crt/model/DeleteBucketRequest.h> +#include <aws/s3-crt/model/DeleteObjectRequest.h> +#include <aws/s3-crt/model/GetObjectRequest.h> +#include <aws/s3-crt/model/PutObjectRequest.h> +ZEN_THIRD_PARTY_INCLUDES_END + +////////////////////////////////////////////////////////////////////////// +// TODO: should make this Unicode-aware so we can pass anything in on the +// command line. + +int +main(int argc, char** argv) +{ + using namespace zen; + using namespace std::literals; + + ZEN_UNUSED(argc, argv); + +#if ZEN_USE_MIMALLOC + mi_version(); +#endif + + zen::logging::InitializeLogging(); + + // Set output mode to handle virtual terminal sequences + zen::logging::EnableVTMode(); + std::set_terminate([]() { ZEN_CRITICAL("Program exited abnormally via std::terminate()"); }); + + LoggerRef DefaultLogger = zen::logging::Default(); + auto& Sinks = DefaultLogger.SpdLogger->sinks(); + + Sinks.clear(); + auto ConsoleSink = std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>(); + Sinks.push_back(ConsoleSink); + + zen::MaximizeOpenFileCount(); + + // AWS SDK setup + + Aws::SDKOptions options; + options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug; + Aws::InitAPI(options); + { + // TODO: Add a large file to your executable folder, and update file_name to the name of that file. + // File "ny.json" (1940 census data; https://www.archives.gov/developer/1940-census#accessportiondataset) + // is an example data file large enough to demonstrate multipart upload. + // Download "ny.json" from https://nara-1940-census.s3.us-east-2.amazonaws.com/metadata/json/ny.json + Aws::String file_name = "ny.json"; + + // TODO: Set to your account AWS Region. + Aws::String region = Aws::Region::US_EAST_1; + + // The object_key is the unique identifier for the object in the bucket. + Aws::String object_key = "my-object"; + + // Create a globally unique name for the new bucket. + // Format: "my-bucket-" + lowercase UUID. + Aws::String uuid = Aws::Utils::UUID::RandomUUID(); + Aws::String bucket_name = "my-bucket-" + Aws::Utils::StringUtils::ToLower(uuid.c_str()); + + const double throughput_target_gbps = 5; + const uint64_t part_size = 8 * 1024 * 1024; // 8 MB. + + Aws::S3Crt::ClientConfiguration config; + config.region = region; + config.throughputTargetGbps = throughput_target_gbps; + config.partSize = part_size; + + Aws::S3Crt::S3CrtClient s3_crt_client(config); + + // Use BucketLocationConstraintMapper to get the BucketLocationConstraint enum from the region string. + // https://sdk.amazonaws.com/cpp/api/0.14.3/namespace_aws_1_1_s3_1_1_model_1_1_bucket_location_constraint_mapper.html#a50d4503d3f481022f969eff1085cfbb0 + Aws::S3Crt::Model::BucketLocationConstraint locConstraint = + Aws::S3Crt::Model::BucketLocationConstraintMapper::GetBucketLocationConstraintForName(region); + + // ListBuckets(s3_crt_client, bucket_name); + + // CreateBucket(s3_crt_client, bucket_name, locConstraint); + + // PutObject(s3_crt_client, bucket_name, object_key, file_name); + + // GetObject(s3_crt_client, bucket_name, object_key); + + // DeleteObject(s3_crt_client, bucket_name, object_key); + + // DeleteBucket(s3_crt_client, bucket_name); + } + Aws::ShutdownAPI(options); + return 0; +} |