Skip to content

Commit

Permalink
Http Client, added URI class, various memory leak fixes. (#15)
Browse files Browse the repository at this point in the history
Http Bindings, various bug fixes.
  • Loading branch information
JonathanHenson authored Mar 30, 2019
1 parent e0de5f7 commit 57d5691
Show file tree
Hide file tree
Showing 20 changed files with 92,087 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/resources/* text=auto eol=lf

17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ file(GLOB AWS_CRT_MQTT_HEADERS
"include/aws/crt/mqtt/*.h"
)

file(GLOB AWS_CRT_HTTP_HEADERS
"include/aws/crt/http/*.h"
)

file(GLOB AWS_CRT_EXTERNAL_HEADERS
"include/aws/crt/external/*.h"
)
Expand All @@ -120,6 +124,8 @@ file(GLOB AWS_CRT_CPP_HEADERS
${AWS_CRT_CRYPTO_HEADERS}
${AWS_CRT_IO_HEADERS}
${AWS_CRT_MQTT_HEADERS}
${AWS_CRT_HTTP_HEADERS}
${AWS_CRT_EXTERNAL_HEADERS}
)

file(GLOB AWS_CRT_SRC
Expand All @@ -138,6 +144,10 @@ file (GLOB AWS_CRT_MQTT_SRC
"source/mqtt/*.cpp"
)

file (GLOB AWS_CRT_HTTP_SRC
"source/http/*.cpp"
)

file(GLOB AWS_CRT_EXTERNAL_CRC
"source/external/*.cpp"
)
Expand All @@ -147,6 +157,7 @@ file(GLOB AWS_CRT_CPP_SRC
${AWS_CRT_CRYPTO_SRC}
${AWS_CRT_IO_SRC}
${AWS_CRT_MQTT_SRC}
${AWS_CRT_HTTP_SRC}
${AWS_CRT_EXTERNAL_CRC}
)

Expand All @@ -156,12 +167,14 @@ if (WIN32)
source_group("Header Files\\aws\\crt\\crypto" FILES ${AWS_CRT_CRYPTO_HEADERS})
source_group("Header Files\\aws\\crt\\io" FILES ${AWS_CRT_IO_HEADERS})
source_group("Header Files\\aws\\crt\\mqtt" FILES ${AWS_CRT_MQTT_HEADERS})
source_group("Header Files\\aws\\crt\\http" FILES ${AWS_CRT_HTTP_HEADERS})
source_group("Header Files\\aws\\crt\\external" FILES ${AWS_CRT_EXTERNAL_HEADERS})

source_group("Source Files" FILES ${AWS_CRT_SRC})
source_group("Source Files\\crypto" FILES ${AWS_CRT_CRYPTO_SRC})
source_group("Source Files\\io" FILES ${AWS_CRT_IO_SRC})
source_group("Source Files\\mqtt" FILES ${AWS_CRT_MQTT_SRC})
source_group("Source Files\\http" FILES ${AWS_CRT_HTTP_SRC})
source_group("Source Files\\external" FILES ${AWS_CRT_EXTERNAL_SRC})
endif ()
endif()
Expand Down Expand Up @@ -193,14 +206,16 @@ target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

find_package(aws-c-http REQUIRED)
find_package(aws-c-mqtt REQUIRED)
find_package(aws-c-cal REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} AWS::aws-c-cal AWS::aws-c-mqtt)
target_link_libraries(${CMAKE_PROJECT_NAME} AWS::aws-c-cal AWS::aws-c-http AWS::aws-c-mqtt)

install(FILES ${AWS_CRT_HEADERS} DESTINATION "include/aws/crt" COMPONENT Development)
install(FILES ${AWS_CRT_CRYPTO_HEADERS} DESTINATION "include/aws/crt/crypto" COMPONENT Development)
install(FILES ${AWS_CRT_IO_HEADERS} DESTINATION "include/aws/crt/io" COMPONENT Development)
install(FILES ${AWS_CRT_MQTT_HEADERS} DESTINATION "include/aws/crt/mqtt" COMPONENT Development)
install(FILES ${AWS_CRT_HTTP_HEADERS} DESTINATION "include/aws/crt/http" COMPONENT Development)
install(FILES ${AWS_CRT_EXTERNAL_HEADERS} DESTINATION "include/aws/crt/external" COMPONENT Development)

install(
Expand Down
7 changes: 6 additions & 1 deletion aws-common-runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ if (UNIX AND NOT APPLE)
endif()

set(AWS_C_IO_URL "https://github.com/awslabs/aws-c-io.git")
set(AWS_C_IO_SHA "v0.2.4")
set(AWS_C_IO_SHA "v0.2.5")
include(BuildAwsCIO)

set(AWS_C_HTTP_URL "https://github.com/awslabs/aws-c-http.git")
set(AWS_C_HTTP_SHA "v0.1.0")
include(BuildAwsCHttp)

set(AWS_C_MQTT_URL "https://github.com/awslabs/aws-c-mqtt.git")
set(AWS_C_MQTT_SHA "v0.3.2")
include(BuildAwsCMqtt)
Expand All @@ -39,6 +43,7 @@ set(AWS_C_CAL_SHA "v0.1.4")
include(BuildAwsCCal)

add_dependencies(AwsCMqtt AwsCIO)
add_dependencies(AwsCHttp AwsCIO)
add_dependencies(AwsCCal AwsCCommon)

if (UNIX AND NOT APPLE)
Expand Down
56 changes: 56 additions & 0 deletions aws-common-runtime/cmake/BuildAwsCHttp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
if("${TARGET_ARCH}" STREQUAL ANDROID)
ExternalProject_Add(AwsCHttp
PREFIX ${AWS_DEPS_BUILD_DIR}
GIT_REPOSITORY ${AWS_C_HTTP_URL}
GIT_TAG ${AWS_C_HTTP_SHA}
BUILD_IN_SOURCE 0
UPDATE_COMMAND ""
CMAKE_ARGS
-DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR}
-DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}
-DANDROID_ABI=${ANDROID_ABI}
-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME}
-DANDROID_STANDALONE_TOOLCHAIN=${ANDROID_STANDALONE_TOOLCHAIN}
-DANDROID_STL=${ANDROID_STL}
-DENABLE_HW_OPTIMIZATION=OFF
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
)
elseif(MSVC)
ExternalProject_Add(AwsCHttp
PREFIX ${AWS_DEPS_BUILD_DIR}
GIT_REPOSITORY ${AWS_C_HTTP_URL}
GIT_TAG ${AWS_C_HTTP_SHA}
BUILD_IN_SOURCE 0
UPDATE_COMMAND ""
CMAKE_ARGS
-DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR}
-DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
)
else()
ExternalProject_Add(AwsCHttp
PREFIX ${AWS_DEPS_BUILD_DIR}
GIT_REPOSITORY ${AWS_C_HTTP_URL}
GIT_TAG ${AWS_C_HTTP_SHA}
BUILD_IN_SOURCE 0
UPDATE_COMMAND ""
CMAKE_ARGS
-DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR}
-DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
)
endif()
1 change: 1 addition & 0 deletions cmake/aws-crt-cpp-config.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include(CMakeFindDependencyMacro)

find_dependency(aws-c-http)
find_dependency(aws-c-mqtt)
find_dependency(aws-c-cal)

Expand Down
2 changes: 1 addition & 1 deletion codebuild/common-posix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ cd build

cmake -DBUILD_DEPS=ON $@ ../
make
make test
ctest -V

cd ..
19 changes: 19 additions & 0 deletions include/aws/crt/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <sstream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

struct aws_allocator;
Expand Down Expand Up @@ -68,8 +69,26 @@ namespace Aws
AWS_CRT_CPP_API ByteBuf ByteBufNewCopy(Allocator *alloc, const uint8_t *array, size_t len);
AWS_CRT_CPP_API void ByteBufDelete(ByteBuf &);

AWS_CRT_CPP_API ByteCursor ByteCursorFromCString(const char *str) noexcept;
AWS_CRT_CPP_API ByteCursor ByteCursorFromByteBuf(const ByteBuf &) noexcept;
AWS_CRT_CPP_API ByteCursor ByteCursorFromArray(const uint8_t *array, size_t len) noexcept;

AWS_CRT_CPP_API Vector<uint8_t> Base64Decode(const String &decode);
AWS_CRT_CPP_API String Base64Encode(const Vector<uint8_t> &encode);

template <typename T> void Delete(T *t, Allocator *allocator)
{
t->~T();
aws_mem_release(allocator, t);
}

template <typename T, typename... Args> T *New(Allocator *allocator, Args &&... args)
{
T *t = reinterpret_cast<T *>(aws_mem_acquire(allocator, sizeof(T)));
if (!t)
return nullptr;
return new (t) T(std::forward<Args>(args)...);
}

} // namespace Crt
} // namespace Aws
Loading

0 comments on commit 57d5691

Please sign in to comment.