Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro util #936

Merged
merged 9 commits into from Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitmodules
Expand Up @@ -19,3 +19,15 @@
[submodule "provisioning_client/deps/utpm"]
path = provisioning_client/deps/utpm
url = https://github.com/Azure/azure-utpm-c.git
[submodule "deps/azure-macro-utils-c"]
path = deps/azure-macro-utils-c
url = https://github.com/Azure/azure-macro-utils-c.git
[submodule "deps/umock-c"]
path = deps/umock-c
url = https://github.com/Azure/umock-c.git
[submodule "deps/azure-c-testrunnerswitcher"]
path = deps/azure-c-testrunnerswitcher
url = https://github.com/Azure/azure-c-testrunnerswitcher.git
[submodule "deps/azure-ctest"]
path = deps/azure-ctest
url = https://github.com/Azure/azure-ctest.git
47 changes: 38 additions & 9 deletions CMakeLists.txt
Expand Up @@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 2.8.11)
project(azure_iot_sdks)

include("configs/azure_iot_sdksFunctions.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/configs/azure_iot_sdksFunctions.cmake")

getIoTSDKVersion()
message(STATUS "IoT Client SDK Version = ${IOT_SDK_VERSION}")
Expand Down Expand Up @@ -197,10 +197,6 @@ endif()

include("configs/azure_iot_sdksFunctions.cmake")

if (${run_unittests} OR ${run_e2e_tests} OR ${run_sfc_tests})
include("dependencies-test.cmake")
endif()

# do not add or build any tests of the dependencies
set(original_run_e2e_tests ${run_e2e_tests})
set(original_run_unittests ${run_unittests})
Expand All @@ -210,21 +206,54 @@ set(run_e2e_tests OFF)
set(run_unittests OFF)
set(skip_samples ON)

if (NOT ${use_installed_dependencies})
if (NOT TARGET azure_macro_utils_c AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/deps/azure-macro-utils-c/CMakeLists.txt")
add_subdirectory(deps/azure-macro-utils-c)
endif()
if (NOT TARGET umock_c)
# Get the repo if it's not there
add_subdirectory(deps/umock-c)
endif()

if (${original_run_e2e_tests} OR ${original_run_unittests} OR ${run_sfc_tests})
if (NOT TARGET testrunnerswitcher)
add_subdirectory(deps/azure-c-testrunnerswitcher)
endif()
if (NOT TARGET ctest)
# Get the repo if it's not there
add_subdirectory(deps/azure-ctest)
endif()
enable_testing()
endif()
else()
if (NOT azure_macro_utils_cFOUND)
find_package(azure_macro_utils_c REQUIRED CONFIG)
endif ()
if (NOT umock_cFOUND)
find_package(umock_c REQUIRED CONFIG)
endif ()
endif()

include_directories(${MACRO_UTILS_INC_FOLDER})
include_directories(${UMOCK_C_INC_FOLDER})

include("dependencies.cmake")
if (${original_run_e2e_tests} OR ${original_run_unittests} OR ${run_sfc_tests})
# Used for serializer
add_subdirectory("${SHARED_UTIL_FOLDER}/testtools/sal")
add_subdirectory("${SHARED_UTIL_FOLDER}/testtools/micromock")
endif()

if (${original_run_e2e_tests} OR ${original_run_unittests} OR ${run_sfc_tests})
set(SHARED_UTIL_REAL_TEST_FOLDER ${CMAKE_CURRENT_LIST_DIR}/c-utility/tests/real_test_files CACHE INTERNAL "this is what needs to be included when doing test sources" FORCE)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/c-utility/testtools)
endif()

set_platform_files(${CMAKE_CURRENT_LIST_DIR}/c-utility)
set_platform_files(${SHARED_UTIL_FOLDER})

set(run_e2e_tests ${original_run_e2e_tests})
set(run_unittests ${original_run_unittests})
set(skip_samples ${original_skip_samples})

enable_testing()

# this project uses several other projects that are build not by these CMakeFiles
# this project also targets several OSes

Expand Down
2 changes: 1 addition & 1 deletion c-utility
Submodule c-utility updated 133 files
14 changes: 0 additions & 14 deletions dependencies-test.cmake

This file was deleted.

1 change: 1 addition & 0 deletions deps/azure-c-testrunnerswitcher
1 change: 1 addition & 0 deletions deps/azure-ctest
Submodule azure-ctest added at 5afd05
1 change: 1 addition & 0 deletions deps/azure-macro-utils-c
Submodule azure-macro-utils-c added at fa2030
1 change: 1 addition & 0 deletions deps/umock-c
Submodule umock-c added at 0e3951
4 changes: 3 additions & 1 deletion doc/Docker_SDK_Cross_Compile.md
Expand Up @@ -63,7 +63,9 @@ RUN wget https://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620n/Open
RUN tar -xvf OpenWrt-Toolchain-ramips-for-mipsel_24kec+dsp-gcc-4.8-linaro_uClibc-0.9.33.2.tar.bz2

# Download the Azure IoT SDK for C
RUN git clone --recursive https://github.com/azure/azure-iot-sdk-c.git
RUN git clone https://github.com/azure/azure-iot-sdk-c.git
RUN cd azure-iot-sdk-c
RUN git submodule update --init

# Download OpenSSL source and expand it
RUN wget https://www.openssl.org/source/openssl-1.0.2o.tar.gz
Expand Down
8 changes: 6 additions & 2 deletions doc/SDK_cross_compile_example.md
Expand Up @@ -26,12 +26,16 @@ Though it may be possible to use a host machine running a variant of Windows thi
Open a terminal prompt on your host machine in the manner you prefer.

We need to acquire the SDK source code. This is available in the [C SDK GitHub repository](https://github.com/Azure/azure-iot-sdk-c.git). We clone this too our host machine as follows:
```

```Shell
cd ~
mkdir Source
cd Source
git clone --recursive https://github.com/Azure/azure-iot-sdk-c.git
git clone https://github.com/Azure/azure-iot-sdk-c.git
cd azure-iot-sdk-c
git submodule update --init
```

Further information regarding this step and other set up requirements can be found in this [guide](https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/devbox_setup.md). This step is only included in this document to establish the directory structure used for the rest of the example.

You might consider building the SDK for your local platform at this point simply to ensure you have all the required components. At the very least, you must ensure that the SDK's prerequisite libraries are installed on your Raspberry Pi. You can achieve this by running the script _setup.sh_ found in _azure-iot-sdk-c/build\_all/linux_.
Expand Down
39 changes: 26 additions & 13 deletions doc/devbox_setup.md
Expand Up @@ -13,22 +13,26 @@ This document describes how to prepare your development environment to use the *
## Set up a Windows development environment

- Install [Visual Studio 2017][visual-studio]. You can use the **Visual Studio Community** Free download if you meet the licensing requirements. (**Visual Studio 2015** is also supported.)

> Be sure to include Visual C++.

- Install [git]. Confirm git is in your PATH by typing `git version` from a command prompt.

- Install [CMake]. Make sure it is in your PATH by typing `cmake -version` from a command prompt. CMake will be used to create Visual Studio projects to build libraries and samples.

- Locate the tag name for the [latest release][latest-release] of the SDK.

> Our release tag names are date values in `yyyy-mm-dd` format.

- Clone the latest release of SDK to your local machine using the tag name you found:

```Shell
git clone -b <yyyy-mm-dd> --recursive https://github.com/Azure/azure-iot-sdk-c.git
git clone -b <yyyy-mm-dd> https://github.com/Azure/azure-iot-sdk-c.git
cd azure-iot-sdk-c
git submodule update --init
```

> The `--recursive` argument instructs git to clone other GitHub repos this SDK depends on. Dependencies are listed [here](https://github.com/Azure/azure-iot-sdk-c/blob/master/.gitmodules).
> If you are using a release before 2019-04-15 then you will need to use the `--recursive` argument to instructs git to clone other GitHub repos this SDK depends on. Dependencies are listed [here](https://github.com/Azure/azure-iot-sdk-c/blob/master/.gitmodules).

### Build a sample application without building the SDK

Expand All @@ -45,7 +49,7 @@ static const char* connectionString = "[device connection string]";

...and replace `[device connection string]` with a valid device connection string for a device registered with your IoT Hub. For more information, see the [samples section](#samplecode) below.

Build the sample project.
Build the sample project.

### Build the C SDK in Windows

Expand Down Expand Up @@ -103,11 +107,16 @@ For TLS operations, by default the C-SDK uses Schannel on Windows Platforms. Yo
You are responsible for updating your OpenSSL dependencies as security fixes for it become available. Schannel on Windows is a system component automatically serviced by Windows Update. OpenSSL on Linux is updated by Linux packaging mechanisms, such as apt-get on Debian based distributions. Shipping the C-SDK on Windows using OpenSSL means you are responsible for getting updated versions of it to your devices.

[OpenSSL] binaries that the C-SDK depends on are **ssleay32** and **libeay32**. To enable OpenSSL to be used on Windows, you need to
* Obtain OpenSSL binaries. There are many ways to do this, but one of the easier ways is to:
* Open the appropriate developer command prompt you plan on building the C-SDK from.
* Install [vcpkg], a Microsoft tool that helps you manage C and C++ libraries.
* Run `.\vcpkg install openssl` to obtain the required OpenSSL binaries.
* Make note of the directory that OpenSSL has been installed to by vcpkg, e.g. `C:\vcpkgRoot\vcpkg\packages\openssl_x86-windows`.

- Obtain OpenSSL binaries. There are many ways to do this, but one of the easier ways is to:

- Open the appropriate developer command prompt you plan on building the C-SDK from.

- Install [vcpkg], a Microsoft tool that helps you manage C and C++ libraries.

- Run `.\vcpkg install openssl` to obtain the required OpenSSL binaries.

- Make note of the directory that OpenSSL has been installed to by vcpkg, e.g. `C:\vcpkgRoot\vcpkg\packages\openssl_x86-windows`.

* Make the C-SDK link against these OpenSSL binaries instead of the default Schannel.
* Regardless of how you obtained OpenSSL binaries, set environment variables to point at its root directory. *Be careful there are no leading spaces between the `=` and directory name as cmake's errors are not always obvious.*
Expand All @@ -127,7 +136,6 @@ You are responsible for updating your OpenSSL dependencies as security fixes for

Building samples and your application should be the same as using the default Schannel at this point.


<a name="linux"></a>

## Set up a Linux development environment
Expand Down Expand Up @@ -167,10 +175,12 @@ This section describes how to set up a development environment for the C SDK on
- Clone the latest release of SDK to your local machine using the tag name you found:

```Shell
git clone -b <yyyy-mm-dd> --recursive https://github.com/Azure/azure-iot-sdk-c.git
git clone -b <yyyy-mm-dd> https://github.com/Azure/azure-iot-sdk-c.git
cd azure-iot-sdk-c
git submodule update --init
```

> The `--recursive` argument instructs git to clone other GitHub repos this SDK depends on. Dependencies are listed [here](https://github.com/Azure/azure-iot-sdk-c/blob/master/.gitmodules).
> If you are using a release before 2019-04-15 then you will need to use the `--recursive` argument to instructs git to clone other GitHub repos this SDK depends on. Dependencies are listed [here](https://github.com/Azure/azure-iot-sdk-c/blob/master/.gitmodules).

### Build the C SDK in Linux

Expand Down Expand Up @@ -238,9 +248,12 @@ We've tested the device SDK for C on macOS High Sierra, with XCode version 9.2.
- Clone the latest release of SDK to your local machine using the tag name you found:

```Shell
git clone -b <yyyy-mm-dd> --recursive https://github.com/Azure/azure-iot-sdk-c.git
git clone -b <yyyy-mm-dd> https://github.com/Azure/azure-iot-sdk-c.git
cd azure-iot-sdk-c
git submodule update --init
```
> The `--recursive` argument instructs git to clone other GitHub repos this SDK depends on. Dependencies are listed [here](https://github.com/Azure/azure-iot-sdk-c/blob/master/.gitmodules).

> If you are using a release before 2019-04-15 then you will need to use the `--recursive` argument to instructs git to clone other GitHub repos this SDK depends on. Dependencies are listed [here](https://github.com/Azure/azure-iot-sdk-c/blob/master/.gitmodules).

#### Upgrade CURL on Mac OS

Expand Down
4 changes: 2 additions & 2 deletions iothub_client/inc/internal/blob.h
Expand Up @@ -13,7 +13,7 @@
#ifndef BLOB_H
#define BLOB_H

#include "azure_c_shared_utility/macro_utils.h"
#include "azure_macro_utils/macro_utils.h"
#include "azure_c_shared_utility/buffer_.h"
#include "azure_c_shared_utility/strings_types.h"
#include "azure_c_shared_utility/httpapiex.h"
Expand All @@ -28,7 +28,7 @@ extern "C"
#include <stddef.h>
#endif

#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"

/* Allow unit tests to override MAX_BLOCK_COUNT to something much smaller */
#ifndef MAX_BLOCK_COUNT
Expand Down
4 changes: 2 additions & 2 deletions iothub_client/inc/internal/iothub_client_authorization.h
Expand Up @@ -4,8 +4,8 @@
#ifndef IOTHUB_CLIENT_AUTHORIZATION_H
#define IOTHUB_CLIENT_AUTHORIZATION_H

#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/umock_c_prod.h"
#include "azure_macro_utils/macro_utils.h"
#include "umock_c/umock_c_prod.h"
#include "azure_c_shared_utility/xio.h"

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothub_client_diagnostic.h
Expand Up @@ -9,7 +9,7 @@
#ifndef IOTHUB_CLIENT_DIAGNOSTIC_H
#define IOTHUB_CLIENT_DIAGNOSTIC_H

#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"

#include "iothub_message.h"
#include <stdint.h>
Expand Down
4 changes: 2 additions & 2 deletions iothub_client/inc/internal/iothub_client_edge.h
Expand Up @@ -3,8 +3,8 @@

#include <stddef.h>

#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/umock_c_prod.h"
#include "azure_macro_utils/macro_utils.h"
#include "umock_c/umock_c_prod.h"

#include "iothub_client_authorization.h"
#include "iothub_client_core_common.h"
Expand Down
4 changes: 2 additions & 2 deletions iothub_client/inc/internal/iothub_client_hsm_ll.h
Expand Up @@ -8,8 +8,8 @@
#ifndef IOTHUB_CLIENT_PROVISIONING_H
#define IOTHUB_CLIENT_PROVISIONING_H

#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/umock_c_prod.h"
#include "azure_macro_utils/macro_utils.h"
#include "umock_c/umock_c_prod.h"

#ifdef USE_PROV_MODULE
#include "azure_prov_client/internal/iothub_auth_client.h"
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothub_client_ll_uploadtoblob.h
Expand Up @@ -28,7 +28,7 @@
#include "iothub_client_core_ll.h"
#include "internal/iothub_client_authorization.h"

#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"
#ifdef __cplusplus
#include <cstddef>
extern "C"
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothub_client_private.h
Expand Up @@ -9,7 +9,7 @@
#include "azure_c_shared_utility/constbuffer.h"
#include "azure_c_shared_utility/doublylinkedlist.h"
#include "azure_c_shared_utility/tickcounter.h"
#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"

#include "iothub_message.h"
#include "internal/iothub_transport_ll_private.h"
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothub_client_retry_control.h
Expand Up @@ -7,7 +7,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include "azure_c_shared_utility/optionhandler.h"
#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"
#include "iothub_client_core_ll.h"
#include "internal/iothubtransport.h"
#include "azure_c_shared_utility/const_defines.h"
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothubtransport.h
Expand Up @@ -24,7 +24,7 @@ extern "C"
#include <stdbool.h>
#endif

#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"

/** @brief This struct captures IoTHub transport configuration. */
struct IOTHUBTRANSPORT_CONFIG_TAG
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothubtransport_amqp_cbs_auth.h
Expand Up @@ -7,7 +7,7 @@
#include <stdint.h>
#include "internal/iothub_transport_ll_private.h"
#include "azure_uamqp_c/cbs.h"
#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"
#include "azure_c_shared_utility/optionhandler.h"

static const char* AUTHENTICATION_OPTION_SAVED_OPTIONS = "saved_authentication_options";
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothubtransport_amqp_common.h
Expand Up @@ -5,7 +5,7 @@
#define IOTHUBTRANSPORTAMQP_COMMON_H

#include "azure_c_shared_utility/strings.h"
#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"
#include "internal/iothub_transport_ll_private.h"

#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions iothub_client/inc/internal/iothubtransport_amqp_connection.h
Expand Up @@ -4,8 +4,8 @@
#ifndef IOTHUBTRANSPORTAMQP_AMQP_CONNECTION_H
#define IOTHUBTRANSPORTAMQP_AMQP_CONNECTION_H

#include "azure_c_shared_utility/umock_c_prod.h"
#include "azure_c_shared_utility/macro_utils.h"
#include "umock_c/umock_c_prod.h"
#include "azure_macro_utils/macro_utils.h"
#include "azure_c_shared_utility/xio.h"
#include "azure_uamqp_c/session.h"
#include "azure_uamqp_c/cbs.h"
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothubtransport_amqp_device.h
Expand Up @@ -4,7 +4,7 @@
#ifndef IOTHUBTRANSPORTAMQP_AMQP_DEVICE_H
#define IOTHUBTRANSPORTAMQP_AMQP_DEVICE_H

#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"
#include "azure_c_shared_utility/optionhandler.h"
#include "azure_uamqp_c/session.h"
#include "azure_uamqp_c/cbs.h"
Expand Down
Expand Up @@ -4,7 +4,7 @@
#ifndef IOTHUBTRANSPORT_AMQP_MESSENGER
#define IOTHUBTRANSPORT_AMQP_MESSENGER

#include "azure_c_shared_utility/umock_c_prod.h"
#include "umock_c/umock_c_prod.h"
#include "azure_c_shared_utility/optionhandler.h"
#include "azure_c_shared_utility/map.h"
#include "azure_uamqp_c/message.h"
Expand Down