Skip to content

Commit

Permalink
shadow codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Oct 2, 2023
1 parent 17d0d75 commit cd6883b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
21 changes: 6 additions & 15 deletions shadow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
cmake_minimum_required(VERSION 3.1)
# This file is generated

project(IotShadow-cpp LANGUAGES CXX)
if (DEFINED SIMPLE_VERSION)
message("Shadow version is ${SIMPLE_VERSION}")
set(PROJECT_VERSION ${SIMPLE_VERSION})
endif()
cmake_minimum_required(VERSION 3.1)
project(IotShadow-cpp CXX)

set(RUNTIME_DIRECTORY bin)

Expand Down Expand Up @@ -57,7 +54,9 @@ else ()
target_compile_options(IotShadow-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

target_compile_definitions(IotShadow-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)
if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(IotShadow-cpp PRIVATE "-DDEBUG_BUILD")
endif ()

if (BUILD_SHARED_LIBS)
target_compile_definitions(IotShadow-cpp PUBLIC "-DAWS_IOTSHADOW_USE_IMPORT_EXPORT")
Expand Down Expand Up @@ -109,14 +108,6 @@ else()
set(TARGET_DIR "static")
endif()

include(CMakePackageConfigHelpers)
if (DEFINED SIMPLE_VERSION)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/iotshadow-cpp-config-version.cmake"
COMPATIBILITY SameMajorVersion
)
endif()

install(EXPORT "IotShadow-cpp-targets"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/IotShadow-cpp/cmake/${TARGET_DIR}"
NAMESPACE AWS::
Expand Down
2 changes: 2 additions & 0 deletions shadow/cmake/iotshadow-cpp-config.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This file is generated

include(CMakeFindDependencyMacro)

find_dependency(aws-crt-cpp)
Expand Down
2 changes: 2 additions & 0 deletions shadow/include/aws/iotshadow/IotShadowClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <aws/crt/StlAllocator.h>
#include <aws/crt/Types.h>

#include <aws/crt/mqtt/Mqtt5Client.h>
#include <aws/crt/mqtt/MqttClient.h>

namespace Aws
Expand Down Expand Up @@ -103,6 +104,7 @@ namespace Aws
{
public:
IotShadowClient(const std::shared_ptr<Aws::Crt::Mqtt::MqttConnection> &connection);
IotShadowClient(const std::shared_ptr<Aws::Crt::Mqtt5::Mqtt5Client> &mqtt5Client);

operator bool() const noexcept;
int GetLastError() const noexcept;
Expand Down
5 changes: 5 additions & 0 deletions shadow/source/IotShadowClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ namespace Aws
{
}

IotShadowClient::IotShadowClient(const std::shared_ptr<Aws::Crt::Mqtt5::Mqtt5Client> &mqtt5Client)
{
m_connection = Aws::Crt::Mqtt::MqttConnection::NewConnectionFromMqtt5Client(mqtt5Client);
}

IotShadowClient::operator bool() const noexcept { return m_connection && *m_connection; }

int IotShadowClient::GetLastError() const noexcept { return aws_last_error(); }
Expand Down

0 comments on commit cd6883b

Please sign in to comment.