diff --git a/.gitignore b/.gitignore index ba7956db..679b9cb6 100644 --- a/.gitignore +++ b/.gitignore @@ -220,4 +220,5 @@ browse.VC.db api_reference/ # install prefix -install-deps/ \ No newline at end of file +install-deps/ +Testing/Temporary/CTestCostData.txt diff --git a/.gitmodules b/.gitmodules index 7bc6be6d..646468ff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "deps/azure-c-shared-utility"] path = deps/c-utility url = https://github.com/Azure/azure-c-shared-utility -[submodule "deps/azure-iot-sdks"] - path = deps/iot-sdk - url = https://github.com/azure/azure-iot-sdks [submodule "deps/parson"] path = deps/parson url = https://github.com/kgabis/parson @@ -25,3 +22,6 @@ [submodule "deps/umqtt"] path = deps/umqtt url = https://github.com/azure/azure-umqtt-c +[submodule "deps/iot-sdk-c"] + path = deps/iot-sdk-c + url = https://github.com/Azure/azure-iot-sdk-c.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b5b6b7dd..394da734 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.8.12) project(azure_iot_gateway_sdk) -set(GATEWAY_VERSION 1.0.0 CACHE INTERNAL "") +set(GATEWAY_VERSION 1.0.1 CACHE INTERNAL "") set(COMPANY_NAME "Microsoft") SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -37,9 +37,13 @@ else() set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) endif() +# tests and samples should use pre-install path to gateway.so +set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${CMAKE_CURRENT_BINARY_DIR}/core/) + #the following variables are project-wide and can be used with cmake-gui -option(skip_unittests "set skip_unittests to ON to skip unittests (default is OFF)[if possible, they are always built]" OFF) -option(run_e2e_tests "set run_e2e_tests to ON to run e2e tests (default is OFF) [if possible, they are always built]" OFF) +option(run_unittests "set run_unittests to ON to run unittests (default is OFF)" OFF) +option(run_e2e_tests "set run_e2e_tests to ON to run e2e tests (default is OFF) " OFF) +option(nuget_e2e_tests "" OFF) option(install_executables "should cmake run cmake's install function (that includes dynamic link libraries) [it does for yocto]" OFF) option(install_modules "should cmake install the default gateway modules" OFF) option(enable_java_binding "set enable_java_binding to ON to enable building of Java binding (default is OFF)" OFF) @@ -51,6 +55,7 @@ option(use_amqp "set use_amqp to ON if amqp is to be used, set to OFF to not use option(use_http "set use_http to ON if http is to be used, set to OFF to not use http" ON) option(use_mqtt "set use_mqtt to ON if mqtt is to be used, set to OFF to not use mqtt" ON) + SET(use_condition ON CACHE BOOL "Build C shared utility with condition code" FORCE) set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -120,11 +125,9 @@ endfunction() function(add_sample_to_solution sampleName) set_target_properties(${sampleName} PROPERTIES FOLDER "Samples") - #if(DEFINED ${dependency_install_prefix}) - set_target_properties(${sampleName} PROPERTIES - BUILD_WITH_INSTALL_RPATH TRUE - ) - #endif() + set_target_properties(${sampleName} PROPERTIES + BUILD_WITH_INSTALL_RPATH TRUE + ) endfunction() @@ -184,6 +187,46 @@ function(install_broker whatIsBuilding whatIsBuildingLocation) endif() endfunction(install_broker) +set(preinstall_gateway_library_dll ${CMAKE_CURRENT_BINARY_DIR}/core/$(Configuration)/gateway.dll) + +function(copy_gateway_dll whatIsBuilding whatIsBuildingLocation) + if(WIN32) + add_custom_command(TARGET ${whatIsBuilding} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${preinstall_gateway_library_dll} + ${whatIsBuildingLocation}) + if(EXISTS "${azure_c_shared_utility_DIR}/../bin/${SHARED_UTIL_LIB}.dll") + add_custom_command(TARGET ${whatIsBuilding} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${azure_c_shared_utility_DIR}/../bin/${SHARED_UTIL_LIB}.dll" + ${whatIsBuildingLocation}) + endif() + + + endif() +endfunction(copy_gateway_dll) + +function(copy_iothub_client_dll whatIsBuilding whatIsBuildingLocation) + if(WIN32) + if(EXISTS "${azure_iot_sdks_DIR}/../bin/iothub_client.dll") + add_custom_command(TARGET ${whatIsBuilding} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${azure_iot_sdks_DIR}/../bin/iothub_client.dll" + ${whatIsBuildingLocation}) + endif() + endif() +endfunction(copy_iothub_client_dll) + +function(copy_iothub_service_dll whatIsBuilding whatIsBuildingLocation) + if(WIN32) + if(EXISTS "${azure_iot_sdks_DIR}/../bin/iothub_service_client.dll") + add_custom_command(TARGET ${whatIsBuilding} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${azure_iot_sdks_DIR}/../bin/iothub_service_client.dll" + ${whatIsBuildingLocation}) + endif() + endif() +endfunction(copy_iothub_service_dll) if(${ARCHITECTURE} STREQUAL "x86_64") set(dotnet_managed_binding_dll ${CMAKE_CURRENT_BINARY_DIR}/../bindings/dotnet/dotnet-binding/Microsoft.Azure.IoT.Gateway/bin/x64/$(Configuration)/Microsoft.Azure.IoT.Gateway.dll CACHE INTERNAL "The location of the Microsoft.Azure.IoT.Gateway.dll (windows)" FORCE) @@ -193,6 +236,7 @@ if(${ARCHITECTURE} STREQUAL "x86_64") set(dotnet_sensor_module_dll ${CMAKE_CURRENT_BINARY_DIR}/../bindings/dotnet/dotnet-binding/SensorModule/bin/x64/$(Configuration)/SensorModule.dll CACHE INTERNAL "The location of the SensorModule.dll (windows)" FORCE) set(dotnet_printer_module_dll ${CMAKE_CURRENT_BINARY_DIR}/../bindings/dotnet/dotnet-binding/PrinterModule/bin/x64/$(Configuration)/PrinterModule.dll CACHE INTERNAL "The location of the PrinterModule.dll (windows)" FORCE) + elseif(${ARCHITECTURE} STREQUAL "x86") set(dotnet_managed_binding_dll ${CMAKE_CURRENT_BINARY_DIR}/../bindings/dotnet/dotnet-binding/Microsoft.Azure.IoT.Gateway/bin/x86/$(Configuration)/Microsoft.Azure.IoT.Gateway.dll CACHE INTERNAL "The location of the Microsoft.Azure.IoT.Gateway.dll (windows)" FORCE) diff --git a/bindings/dotnet/CMakeLists.txt b/bindings/dotnet/CMakeLists.txt index 3411da7c..b3f968be 100644 --- a/bindings/dotnet/CMakeLists.txt +++ b/bindings/dotnet/CMakeLists.txt @@ -34,7 +34,7 @@ target_link_libraries(dotnet_static gateway mscoree) linkSharedUtil(dotnet) linkSharedUtil(dotnet_static) -if(NOT ${skip_unittests}) +if(${run_unittests}) add_subdirectory(tests) endif() diff --git a/bindings/dotnet/devdoc/dotnet_binding_hld.md b/bindings/dotnet/devdoc/dotnet_binding_hld.md index 85f65dd0..317199b6 100644 --- a/bindings/dotnet/devdoc/dotnet_binding_hld.md +++ b/bindings/dotnet/devdoc/dotnet_binding_hld.md @@ -46,12 +46,13 @@ The JSON configuration for .NET Module will be similar to the configuration for } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -1. `loader->name` is the name of the module created (.NET Module) that will be stored by the gateway and used internally; +1. `name` is the name of the module created (.NET Module) that will be stored by the gateway and used internally; 2. `loader` is the configuration specifically for the .NET Loader. - 2.1 `loader->assembly_name`: place where the .NET module is located; - 2.2 `loader->entry_type`: class that implements `IGatewayModule`; + 2.1 `loader->assembly.name`: Name of the managed assembly that contains the module implementation; + + 2.2 `loader->entry.type`: Fully qualified name of the managed class that implements `IGatewayModule`; 3. `args` The value of this property is used to supply configuration information specific to a given .NET module. The value is passed as a byte[] to .NET module and it shall be converted as a UTF-8 String; diff --git a/bindings/dotnet/devdoc/images/flow_chart.png b/bindings/dotnet/devdoc/images/flow_chart.png index 2bd5dd45..22ca1703 100644 Binary files a/bindings/dotnet/devdoc/images/flow_chart.png and b/bindings/dotnet/devdoc/images/flow_chart.png differ diff --git a/bindings/dotnet/devdoc/images/overall-design.png b/bindings/dotnet/devdoc/images/overall-design.png index 2e8207ec..9da23cbf 100644 Binary files a/bindings/dotnet/devdoc/images/overall-design.png and b/bindings/dotnet/devdoc/images/overall-design.png differ diff --git a/bindings/dotnet/devdoc/resources/dotnetbiding-hld.vsdx b/bindings/dotnet/devdoc/resources/dotnetbiding-hld.vsdx index cd9275ae..30ae35f4 100644 Binary files a/bindings/dotnet/devdoc/resources/dotnetbiding-hld.vsdx and b/bindings/dotnet/devdoc/resources/dotnetbiding-hld.vsdx differ diff --git a/bindings/dotnet/tests/dotnet_e2e/CMakeLists.txt b/bindings/dotnet/tests/dotnet_e2e/CMakeLists.txt index 7652fffb..995fe042 100644 --- a/bindings/dotnet/tests/dotnet_e2e/CMakeLists.txt +++ b/bindings/dotnet/tests/dotnet_e2e/CMakeLists.txt @@ -45,6 +45,7 @@ if(TARGET ${theseTestsName}_exe) add_dependencies(${theseTestsName}_exe dotnet) install_broker(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) + copy_gateway_dll(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) install_binaries(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ${dotnet_managed_binding_dll} ) install_binaries(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ${dotnet_e2etest_module_dll} ) install_binaries(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ${dotnet_host_binding_dll} ) diff --git a/bindings/dotnetcore/devdoc/dotnet_core_binding_hld.md b/bindings/dotnetcore/devdoc/dotnet_core_binding_hld.md new file mode 100644 index 00000000..205b083e --- /dev/null +++ b/bindings/dotnetcore/devdoc/dotnet_core_binding_hld.md @@ -0,0 +1,218 @@ +Building Azure IoT Gateway Modules in .NET Core +=============================================== + +Overview +-------- + +This document describes the high level design of the .NET Core binding mechanism used by Azure IoT Gateway SDK. +It describes how the .NET Core CLR is hosted in the gateway process's memory and how the interaction between the +native and .NET Core Managed Modules will work. + +The existing binding implementation in the Gateway SDK for .NET targets the full .NET framework (desktop and server) on Windows only. +The binding discussed in this document relates to the cross platform open source .NET Core product that works on Windows, Linux and macOS. + +Hosting .NET CLR +---------------- + +In order to be able to host the CLR, we are going to use the following exports from .NET Core CLR: +-coreclr_initialize; +-coreclr_create_delegate; +-coreclr_shutdown; + +Some documentation on how to host the .NET CLR can be found on: +- [.NET Core GitHub](https://github.com/dotnet/) - Check sample `corerun` and `coreconsole` for both windows and linux. + +Design +------ +![](images/overall-design.png) + +.NET Core Module Host +--------------------- +The **.NET Core Module Host** is a C module that + +1. Creates a [.NET Core](https://github.com/dotnet/) CLR instance; + +2. Creates delegates for .NET Module Calls (Create, destroy, receive, start); + +3. Brokers calls **from** the managed module to the message broker (dotnetHost_PublishMessage, which invokes `MessageCreate_FromByteArray` and `Broker_Publish`); + +###JSON Configuration + +The JSON configuration for [.NET Core](https://github.com/dotnet/) Module will be similar to the configuration for Node and Java Module Host: + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ JSON +{ + "modules": [ + { + "name": "csharp_hello_world", + "loader": { + "name": "dotnetcore", + "entrypoint": { + "assembly.name": "mymoduleassembly", + "entry.type": "mycsharpmodule.classname" + } + }, + "args": "module configuration" + } + ] +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +1. `name` is the name of the module created ([.NET Core](https://github.com/dotnet/) Module) that will be stored by the gateway and used internally; + +2. `loader` is the configuration specifically for the [.NET Core](https://github.com/dotnet/) Loader. + + 2.1 `loader->assembly.name`: Name of the managed assembly that contains the module implementation; + + 2.2 `loader->entry.type`: Fully qualified name of the managed class that implements `IGatewayModule`; + +3. `args` The value of this property is used to supply configuration information specific to a given [.NET Core](https://github.com/dotnet/) module. The value is passed as a byte[] to .NET module and it shall be converted as a UTF-8 String; + +##Native methods description +### Module\_Create + +When the **.NET Core Module Host**’s `Module_Create` function is invoked by the +gateway process, it: + +- Creates a CLR instance by calling `coreclr_initialize; + +- Creates [.NET Core](https://github.com/dotnet/) Delegates for Create, Receive, Start and Destroy; + +- Calls Create Delegate, which will call the Create method on the user [.NET Core](https://github.com/dotnet/) Module (Module that implemented `IGatewayModule`); + +### Module\_Start + +When the **.NET Core Module Host**’s `Module_Start` function is invoked by the +gateway, it: + +- Call the `Start` Delegate; +- Managed implementation of Start delegate checks if [.NET Core](https://github.com/dotnet/) module has implemented the `Start` method; +- If defined, invokes the `Start` method implemented by the [.NET Core](https://github.com/dotnet/) module. + +### Module\_Receive + +When the **.NET Core Module Host**’s `Module_Receive` function is invoked by the +gateway process, it: + +- Serializes (by calling `Message_ToByteArray`) the message content and properties and invokes the `Receive` method implemented by the .NET module (`IGatewayInterface` below). The .NET module will deserialize this byte array into a Message object. +- Calls the `Receive` delegate; + +### Module\_Destroy + +When the **.NET Module Host**’s `Module_Destroy` function is invoked by the +gateway, it: + +- Calls the `Destroy` delegate (which is going to call `Destroy` method implemented by the [.NET Core](https://github.com/dotnet/) Module); +- Releases resources allocated; +- Calls the `coreclr_shutdown` method; + +.NET Wrappers and objects +------------------------- + +This is going to be a layer written in .NET that will wrap a method in our host that is responsible to publish a given message. +For [.NET Core](https://github.com/dotnet/) Modules the following wrappers will be provided: + +1. `Message` - Object that represents a message; + +2. `Broker` - Object that represents the broker, which passes messages between modules; + +3. `IGatewayModule` - interface that has to be implemented by the [.NET Core](https://github.com/dotnet/) Module; + +4. `nativeDotNetHostWrapper` - Uses DLLImport to marshal call to dotnetHost_PublishMessage. This will be transparent to the .NET User, it will be called by the Broker Class when the user calls Publish. + +The high level design of these objects and interfaces is documented below: + +### Message +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C# + + namespace Microsoft.Azure.IoT.Gateway + { + /// Object that represents a message passed between modules. + public class Message + { + public byte[] Content { set; get; }; + + public Dictionary Properties { set; get; }; + + public Message(); + + public Message(byte[] msgInByteArray); + + public Message(string content, Dictionary properties); + + public Message(Message message); + + public byte[] ToByteArray(); + } + } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +### Broker +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C# + + namespace Microsoft.Azure.IoT.Gateway + { + /// Object that represents the message broker, to which messsages will be published. + public class Broker + { + /// + /// Publish a message to the message broker. + /// + /// Object representing the message to be published to the broker. + /// + public void Publish(Message message); + } + } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +### IGatewayModule +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C# + + /// Interface to be implemented by the .NET Module + public interface IGatewayModule + { + /// + /// Creates a module using the specified configuration connecting to the specified message broker. + /// + /// The broker to which this module will connect. + /// A byte[] with user-defined configuration for this module. This parameter shall be enconded to a UTF-8 String. + /// + void Create(Broker broker, byte[] configuration); + + /// + /// Disposes of the resources allocated by/for this module. + /// + /// + void Destroy(); + + /// + /// The module's callback function that is called upon message receipt. + /// + /// The message being sent to the module. + /// + void Receive(Message received_message); + } + + /// Optional Start Interface to be implemented by the .NET Module + public interface IGatewayModuleStart + { + + /// + /// Informs module the gateway is ready to send and receive messages. + /// + /// + void Start(); + + } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +Flow Diagram +------------ + +Following is the flow diagram of a lifecycle of the [.NET Core](https://github.com/dotnet/) module: +![](images/flow_chart.png) + + + diff --git a/bindings/dotnetcore/devdoc/images/flow_chart.png b/bindings/dotnetcore/devdoc/images/flow_chart.png new file mode 100644 index 00000000..c8f1be62 Binary files /dev/null and b/bindings/dotnetcore/devdoc/images/flow_chart.png differ diff --git a/bindings/dotnetcore/devdoc/images/overall-design.png b/bindings/dotnetcore/devdoc/images/overall-design.png new file mode 100644 index 00000000..9a700d30 Binary files /dev/null and b/bindings/dotnetcore/devdoc/images/overall-design.png differ diff --git a/bindings/dotnetcore/devdoc/resources/dotnet-core-biding-hld.vsdx b/bindings/dotnetcore/devdoc/resources/dotnet-core-biding-hld.vsdx new file mode 100644 index 00000000..fcabf927 Binary files /dev/null and b/bindings/dotnetcore/devdoc/resources/dotnet-core-biding-hld.vsdx differ diff --git a/bindings/java/CMakeLists.txt b/bindings/java/CMakeLists.txt index 0c2b6fee..df24e1f2 100644 --- a/bindings/java/CMakeLists.txt +++ b/bindings/java/CMakeLists.txt @@ -89,7 +89,7 @@ linkSharedUtil(java_module_host_static) add_binding_to_solution(java_module_host) add_binding_to_solution(java_module_host_static) -if(NOT ${skip_unittests}) +if(${run_unittests}) add_subdirectory(tests) endif() diff --git a/bindings/nodejs/CMakeLists.txt b/bindings/nodejs/CMakeLists.txt index 74f2b042..96c49842 100644 --- a/bindings/nodejs/CMakeLists.txt +++ b/bindings/nodejs/CMakeLists.txt @@ -132,7 +132,7 @@ target_include_directories(nodejs_binding_static PUBLIC $ENV{NODE_INCLUDE}) add_binding_to_solution(nodejs_binding) add_binding_to_solution(nodejs_binding_static) -if(NOT ${skip_unittests}) +if(${run_unittests}) add_subdirectory(tests) endif() diff --git a/bindings/nodejs/src/nodejs.cpp b/bindings/nodejs/src/nodejs.cpp index ce2def6a..779e4a5c 100644 --- a/bindings/nodejs/src/nodejs.cpp +++ b/bindings/nodejs/src/nodejs.cpp @@ -467,9 +467,9 @@ static unsigned char* copy_contents( if (copied != *psize) { LogError("CopyContents failed"); + free((void*)result); result = NULL; *psize = 0; - free((void*)result); } } } diff --git a/bindings/nodejs/tests/nodejs_int/CMakeLists.txt b/bindings/nodejs/tests/nodejs_int/CMakeLists.txt index a1152ed2..12287f86 100644 --- a/bindings/nodejs/tests/nodejs_int/CMakeLists.txt +++ b/bindings/nodejs/tests/nodejs_int/CMakeLists.txt @@ -37,6 +37,11 @@ target_link_libraries(${theseTestsName}_exe ${LIBS}) target_include_directories(nodejs_binding_static PUBLIC $ENV{NODE_INCLUDE}) install_broker(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) copy_node_dll(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_gateway_dll(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) + +set_target_properties(${theseTestsName}_exe PROPERTIES + BUILD_WITH_INSTALL_RPATH TRUE +) if(WIN32) target_include_directories( diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index d9745275..b76bbcf1 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -77,10 +77,12 @@ set(gateway_h_sources ./inc/module_access.h ./inc/experimental/event_system.h ./inc/gateway.h + ./inc/gateway_export.h ./inc/gateway_version.h ./inc/module_loader.h ./inc/dynamic_library.h ./src/gateway_internal.h + ../deps/parson/parson.h ) # Add the module loaders @@ -140,31 +142,44 @@ endif() include_directories(./inc) -add_library(gateway +add_library(gateway SHARED + ${gateway_c_sources} + ${gateway_h_sources} +) + +add_library(gateway_static STATIC ${gateway_c_sources} ${gateway_h_sources} ) if(WIN32) target_link_libraries(gateway parson nanomsg aziotsharedutil ${dynamic_loader_library}) + target_link_libraries(gateway_static parson nanomsg aziotsharedutil ${dynamic_loader_library}) else() target_link_libraries(gateway parson nanomsg aziotsharedutil ${dynamic_loader_library}) target_link_libraries(gateway ${NN_REQUIRED_LIBRARIES}) target_link_libraries(gateway m) + + target_link_libraries(gateway_static parson nanomsg aziotsharedutil ${dynamic_loader_library}) + + target_link_libraries(gateway_static ${NN_REQUIRED_LIBRARIES}) + target_link_libraries(gateway_static m) endif() if(WIN32) target_link_libraries(gateway rpcrt4.lib) + target_link_libraries(gateway_static rpcrt4.lib) else() find_package(PkgConfig REQUIRED) pkg_search_module(UIDLINUX REQUIRED uuid) target_link_libraries(gateway uuid) + target_link_libraries(gateway_static uuid) endif() #this adds the tests to the build process -if(NOT ${skip_unittests}) +if(${run_unittests}) add_subdirectory(tests) endif() @@ -197,7 +212,7 @@ else() set(AIG_INCLUDE_DIRS ${AIG_HEADER_INSTALL_PREFIX}) endif() -install(TARGETS gateway EXPORT gatewayTargets +install(TARGETS gateway gateway_static EXPORT gatewayTargets LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR} RUNTIME DESTINATION ${LIB_INSTALL_DIR}/../bin diff --git a/core/azure_iot_gateway_sdkConfig.cmake b/core/azure_iot_gateway_sdkConfig.cmake index 60e7649e..94ee3fc3 100644 --- a/core/azure_iot_gateway_sdkConfig.cmake +++ b/core/azure_iot_gateway_sdkConfig.cmake @@ -36,6 +36,23 @@ else() link_directories("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") endif() +# install required gateway DLLs to current project +if (WIN32) + file( + INSTALL + "${azure_iot_gateway_sdk_DIR}/../bin/gateway.dll" + DESTINATION + "${CMAKE_CURRENT_BINARY_DIR}" + ) + + file( + INSTALL + "${azure_c_shared_utility_DIR}/../bin/aziotsharedutil.dll" + DESTINATION + "${CMAKE_CURRENT_BINARY_DIR}" + ) +endif() + link_directories("${CMAKE_CURRENT_LIST_DIR}/../lib") include("${CMAKE_CURRENT_LIST_DIR}/azure_iot_gateway_sdkTargets.cmake") \ No newline at end of file diff --git a/core/inc/broker.h b/core/inc/broker.h index 618038f7..799ff821 100644 --- a/core/inc/broker.h +++ b/core/inc/broker.h @@ -20,6 +20,7 @@ typedef struct BROKER_HANDLE_DATA_TAG* BROKER_HANDLE; #include "azure_c_shared_utility/macro_utils.h" #include "message.h" #include "module.h" +#include "gateway_export.h" #ifdef __cplusplus #include @@ -56,7 +57,7 @@ DEFINE_ENUM(BROKER_RESULT, BROKER_RESULT_VALUES); * * @return A valid #BROKER_HANDLE upon success, or @c NULL upon failure. */ -extern BROKER_HANDLE Broker_Create(void); +GATEWAY_EXPORT BROKER_HANDLE Broker_Create(void); /** @brief Increments the reference count of a message broker. * @@ -65,7 +66,7 @@ extern BROKER_HANDLE Broker_Create(void); * * @param broker The #BROKER_HANDLE to be cloned. */ -extern void Broker_IncRef(BROKER_HANDLE broker); +GATEWAY_EXPORT void Broker_IncRef(BROKER_HANDLE broker); /** @brief Decrements the reference count of a message broker. * @@ -75,7 +76,7 @@ extern void Broker_IncRef(BROKER_HANDLE broker); * * @param broker The #BROKER_HANDLE whose ref count will be decremented. */ -extern void Broker_DecRef(BROKER_HANDLE broker); +GATEWAY_EXPORT void Broker_DecRef(BROKER_HANDLE broker); /** @brief Publishes a message to the message broker. * @@ -93,7 +94,7 @@ extern void Broker_DecRef(BROKER_HANDLE broker); * * @return A #BROKER_RESULT describing the result of the function. */ -extern BROKER_RESULT Broker_Publish(BROKER_HANDLE broker, MODULE_HANDLE source, MESSAGE_HANDLE message); +GATEWAY_EXPORT BROKER_RESULT Broker_Publish(BROKER_HANDLE broker, MODULE_HANDLE source, MESSAGE_HANDLE message); /** @brief Adds a module to the message broker. * @@ -108,7 +109,7 @@ extern BROKER_RESULT Broker_Publish(BROKER_HANDLE broker, MODULE_HANDLE source, * * @return A #BROKER_RESULT describing the result of the function. */ -extern BROKER_RESULT Broker_AddModule(BROKER_HANDLE broker, const MODULE* module); +GATEWAY_EXPORT BROKER_RESULT Broker_AddModule(BROKER_HANDLE broker, const MODULE* module); /** @brief Removes a module from the message broker. * @@ -117,7 +118,7 @@ extern BROKER_RESULT Broker_AddModule(BROKER_HANDLE broker, const MODULE* module * * @return A #BROKER_RESULT describing the result of the function. */ -extern BROKER_RESULT Broker_RemoveModule(BROKER_HANDLE broker, const MODULE* module); +GATEWAY_EXPORT BROKER_RESULT Broker_RemoveModule(BROKER_HANDLE broker, const MODULE* module); /** @brief Adds a route to the message broker. * @@ -132,7 +133,7 @@ extern BROKER_RESULT Broker_RemoveModule(BROKER_HANDLE broker, const MODULE* mod * * @return A #BROKER_RESULT describing the result of the function. */ -extern BROKER_RESULT Broker_AddLink(BROKER_HANDLE broker, const BROKER_LINK_DATA* link); +GATEWAY_EXPORT BROKER_RESULT Broker_AddLink(BROKER_HANDLE broker, const BROKER_LINK_DATA* link); /** @brief Removes a route from the message broker. * @@ -141,13 +142,13 @@ extern BROKER_RESULT Broker_AddLink(BROKER_HANDLE broker, const BROKER_LINK_DATA * * @return A #BROKER_RESULT describing the result of the function. */ -extern BROKER_RESULT Broker_RemoveLink(BROKER_HANDLE broker, const BROKER_LINK_DATA* link); +GATEWAY_EXPORT BROKER_RESULT Broker_RemoveLink(BROKER_HANDLE broker, const BROKER_LINK_DATA* link); /** @brief Disposes of resources allocated by a message broker. * * @param broker The #BROKER_HANDLE to be destroyed. */ -extern void Broker_Destroy(BROKER_HANDLE broker); +GATEWAY_EXPORT void Broker_Destroy(BROKER_HANDLE broker); #ifdef __cplusplus } diff --git a/core/inc/experimental/event_system.h b/core/inc/experimental/event_system.h index 39cca52a..01429d64 100644 --- a/core/inc/experimental/event_system.h +++ b/core/inc/experimental/event_system.h @@ -9,6 +9,7 @@ #define EVENT_SYSTEM_H #include "gateway.h" +#include "gateway_export.h" #ifdef __cplusplus extern "C" @@ -72,10 +73,10 @@ typedef void* GATEWAY_EVENT_CTX; */ typedef void(*GATEWAY_CALLBACK)(GATEWAY_HANDLE gateway, GATEWAY_EVENT event_type, GATEWAY_EVENT_CTX context, void* user_param); -extern EVENTSYSTEM_HANDLE EventSystem_Init(void); -extern void EventSystem_AddEventCallback(EVENTSYSTEM_HANDLE event_system, GATEWAY_EVENT event_type, GATEWAY_CALLBACK callback, void* user_param); -extern void EventSystem_ReportEvent(EVENTSYSTEM_HANDLE event_system, GATEWAY_HANDLE gw, GATEWAY_EVENT event_type); -extern void EventSystem_Destroy(EVENTSYSTEM_HANDLE event_system); +EVENTSYSTEM_HANDLE EventSystem_Init(void); +void EventSystem_AddEventCallback(EVENTSYSTEM_HANDLE event_system, GATEWAY_EVENT event_type, GATEWAY_CALLBACK callback, void* user_param); +void EventSystem_ReportEvent(EVENTSYSTEM_HANDLE event_system, GATEWAY_HANDLE gw, GATEWAY_EVENT event_type); +void EventSystem_Destroy(EVENTSYSTEM_HANDLE event_system); /** @brief Registers a function to be called on a callback thread when_all * #GATEWAY_EVENT happens @@ -89,7 +90,7 @@ extern void EventSystem_Destroy(EVENTSYSTEM_HANDLE event_system); * @param user_param User defined parameter that will be later provided * to the called callback */ -extern void Gateway_AddEventCallback(GATEWAY_HANDLE gw, GATEWAY_EVENT event_type, GATEWAY_CALLBACK callback, void* user_param); +void Gateway_AddEventCallback(GATEWAY_HANDLE gw, GATEWAY_EVENT event_type, GATEWAY_CALLBACK callback, void* user_param); /** @brief Returns a snapshot copy of information about running modules. * @@ -103,14 +104,14 @@ extern void Gateway_AddEventCallback(GATEWAY_HANDLE gw, GATEWAY_EVENT event_type * @return A #VECTOR_HANDLE of pointers to #GATEWAY_MODULE_INFO on success. * NULL on failure. */ -extern VECTOR_HANDLE Gateway_GetModuleList(GATEWAY_HANDLE gw); +VECTOR_HANDLE Gateway_GetModuleList(GATEWAY_HANDLE gw); /** @brief Destroys the list returned by @c Gateway_GetModuleList * * @param module_list A vector handle as returned from * @c Gateway_GetModuleList */ -extern void Gateway_DestroyModuleList(VECTOR_HANDLE module_list); +void Gateway_DestroyModuleList(VECTOR_HANDLE module_list); #ifdef __cplusplus } diff --git a/core/inc/gateway.h b/core/inc/gateway.h index 45f80f38..822d8264 100644 --- a/core/inc/gateway.h +++ b/core/inc/gateway.h @@ -15,6 +15,7 @@ #include "azure_c_shared_utility/vector.h" #include "module.h" #include "module_loader.h" +#include "gateway_export.h" #ifdef __cplusplus extern "C" @@ -143,7 +144,7 @@ typedef struct GATEWAY_PROPERTIES_DATA_TAG * @return A non-NULL #GATEWAY_HANDLE that can be used to manage the * gateway or @c NULL on failure. */ -extern GATEWAY_HANDLE Gateway_CreateFromJson(const char* file_path); +GATEWAY_EXPORT GATEWAY_HANDLE Gateway_CreateFromJson(const char* file_path); /** @brief Creates a new gateway using the provided #GATEWAY_PROPERTIES. * @@ -153,7 +154,7 @@ extern GATEWAY_HANDLE Gateway_CreateFromJson(const char* file_path); * @return A non-NULL #GATEWAY_HANDLE that can be used to manage the * gateway or @c NULL on failure. */ -extern GATEWAY_HANDLE Gateway_Create(const GATEWAY_PROPERTIES* properties); +GATEWAY_EXPORT GATEWAY_HANDLE Gateway_Create(const GATEWAY_PROPERTIES* properties); /** @brief Tell the Gateway it's ready to start. * @@ -161,13 +162,13 @@ extern GATEWAY_HANDLE Gateway_Create(const GATEWAY_PROPERTIES* properties); * * @return A #GATEWAY_START_RESULT to report the result of the start */ -extern GATEWAY_START_RESULT Gateway_Start(GATEWAY_HANDLE gw); +GATEWAY_EXPORT GATEWAY_START_RESULT Gateway_Start(GATEWAY_HANDLE gw); /** @brief Destroys the gateway and disposes of all associated data. * * @param gw #GATEWAY_HANDLE to be destroyed. */ -extern void Gateway_Destroy(GATEWAY_HANDLE gw); +GATEWAY_EXPORT void Gateway_Destroy(GATEWAY_HANDLE gw); /** @brief Creates a new module based on the GATEWAY_MODULES_ENTRY*. * @@ -178,7 +179,7 @@ extern void Gateway_Destroy(GATEWAY_HANDLE gw); * @return A non-NULL #MODULE_HANDLE to the newly created and added * Module, or @c NULL on failure. */ -extern MODULE_HANDLE Gateway_AddModule(GATEWAY_HANDLE gw, const GATEWAY_MODULES_ENTRY* entry); +GATEWAY_EXPORT MODULE_HANDLE Gateway_AddModule(GATEWAY_HANDLE gw, const GATEWAY_MODULES_ENTRY* entry); /** @brief Tells a module that the gateway is ready for it to start. * @@ -186,7 +187,7 @@ extern MODULE_HANDLE Gateway_AddModule(GATEWAY_HANDLE gw, const GATEWAY_MODULES_ * Module. * @param module Pointer to a #MODULE_HANDLE that needs to be removed. */ -extern void Gateway_StartModule(GATEWAY_HANDLE gw, MODULE_HANDLE module); +GATEWAY_EXPORT void Gateway_StartModule(GATEWAY_HANDLE gw, MODULE_HANDLE module); /** @brief Removes the provided module from the gateway and all links that @@ -196,7 +197,7 @@ extern void Gateway_StartModule(GATEWAY_HANDLE gw, MODULE_HANDLE module); * Module. * @param module Pointer to a #MODULE_HANDLE that needs to be removed. */ -extern void Gateway_RemoveModule(GATEWAY_HANDLE gw, MODULE_HANDLE module); +GATEWAY_EXPORT void Gateway_RemoveModule(GATEWAY_HANDLE gw, MODULE_HANDLE module); /** @brief Removes module by its unique name * @@ -207,7 +208,7 @@ extern void Gateway_RemoveModule(GATEWAY_HANDLE gw, MODULE_HANDLE module); * * @return 0 on success and a non-zero value when an error occurs. */ -extern int Gateway_RemoveModuleByName(GATEWAY_HANDLE gw, const char *module_name); +GATEWAY_EXPORT int Gateway_RemoveModuleByName(GATEWAY_HANDLE gw, const char *module_name); /** @brief Adds a link to a gateway message broker. * @@ -218,7 +219,7 @@ extern int Gateway_RemoveModuleByName(GATEWAY_HANDLE gw, const char *module_name * * @return A GATEWAY_ADD_LINK_RESULT with the operation result. */ -extern GATEWAY_ADD_LINK_RESULT Gateway_AddLink(GATEWAY_HANDLE gw, const GATEWAY_LINK_ENTRY* entryLink); +GATEWAY_EXPORT GATEWAY_ADD_LINK_RESULT Gateway_AddLink(GATEWAY_HANDLE gw, const GATEWAY_LINK_ENTRY* entryLink); /** @brief Remove a link from a gateway message broker. * @@ -227,7 +228,7 @@ extern GATEWAY_ADD_LINK_RESULT Gateway_AddLink(GATEWAY_HANDLE gw, const GATEWAY_ * * @param entryLink Pointer to a #GATEWAY_LINK_ENTRY to be removed. */ -extern void Gateway_RemoveLink(GATEWAY_HANDLE gw, const GATEWAY_LINK_ENTRY* entryLink); +GATEWAY_EXPORT void Gateway_RemoveLink(GATEWAY_HANDLE gw, const GATEWAY_LINK_ENTRY* entryLink); #ifdef __cplusplus } diff --git a/core/inc/gateway_export.h b/core/inc/gateway_export.h new file mode 100644 index 00000000..2be543a6 --- /dev/null +++ b/core/inc/gateway_export.h @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** @file gateway_export.h + * @brief Defines the appropriate function export. + * + * @details Architecture dependent function declarations. + */ + +#ifndef GATEWAY_EXPORT_H +#define GATEWAY_EXPORT_H + +#ifdef _WIN32 +#define GATEWAY_EXPORT __declspec(dllexport) +#else +#define GATEWAY_EXPORT extern +#endif // _WIN32 + +#endif // GATEWAY_EXPORT_H diff --git a/core/inc/message.h b/core/inc/message.h index e305a2c0..9ec12768 100644 --- a/core/inc/message.h +++ b/core/inc/message.h @@ -30,6 +30,7 @@ #include "azure_c_shared_utility/map.h" #include "azure_c_shared_utility/constmap.h" #include "azure_c_shared_utility/constbuffer.h" +#include "gateway_export.h" #ifdef __cplusplus #include @@ -98,7 +99,7 @@ typedef struct MESSAGE_BUFFER_CONFIG_TAG * @return A non-NULL #MESSAGE_HANDLE for the newly created message, or * NULL upon failure. */ -extern MESSAGE_HANDLE Message_Create(const MESSAGE_CONFIG* cfg); +GATEWAY_EXPORT MESSAGE_HANDLE Message_Create(const MESSAGE_CONFIG* cfg); /** @brief Creates a new reference counted message from a byte array * containing the serialized form of a message. @@ -112,7 +113,7 @@ extern MESSAGE_HANDLE Message_Create(const MESSAGE_CONFIG* cfg); * @return A non-NULL #MESSAGE_HANDLE for the newly created message, or * NULL upon failure. */ -extern MESSAGE_HANDLE Message_CreateFromByteArray(const unsigned char* source, int32_t size); +GATEWAY_EXPORT MESSAGE_HANDLE Message_CreateFromByteArray(const unsigned char* source, int32_t size); /** @brief Creates a byte array representation of a MESSAGE_HANDLE. * @@ -129,7 +130,7 @@ extern MESSAGE_HANDLE Message_CreateFromByteArray(const unsigned char* source, i * size required for a full successful serialization. Returns a * negative value when an error occurs. */ -extern int32_t Message_ToByteArray(MESSAGE_HANDLE messageHandle, unsigned char* buf, int32_t size); +GATEWAY_EXPORT int32_t Message_ToByteArray(MESSAGE_HANDLE messageHandle, unsigned char* buf, int32_t size); /** @brief Creates a new message from a @c CONSTBUFFER source and * @c MAP_HANDLE. @@ -146,7 +147,7 @@ extern int32_t Message_ToByteArray(MESSAGE_HANDLE messageHandle, unsigned char* * @return A non-NULL #MESSAGE_HANDLE for the newly created message, or * @c NULL upon failure. */ -extern MESSAGE_HANDLE Message_CreateFromBuffer(const MESSAGE_BUFFER_CONFIG* cfg); +GATEWAY_EXPORT MESSAGE_HANDLE Message_CreateFromBuffer(const MESSAGE_BUFFER_CONFIG* cfg); /** @brief Creates a clone of the message. * @@ -158,7 +159,7 @@ extern MESSAGE_HANDLE Message_CreateFromBuffer(const MESSAGE_BUFFER_CONFIG* cfg) * @return A non-NULL #MESSAGE_HANDLE cloned from @c message, or @c NULL * upon failure. */ -extern MESSAGE_HANDLE Message_Clone(MESSAGE_HANDLE message); +GATEWAY_EXPORT MESSAGE_HANDLE Message_Clone(MESSAGE_HANDLE message); /** @brief Gets the properties of a message. * @@ -172,7 +173,7 @@ extern MESSAGE_HANDLE Message_Clone(MESSAGE_HANDLE message); * message, or @c NULL upon failure. * */ -extern CONSTMAP_HANDLE Message_GetProperties(MESSAGE_HANDLE message); +GATEWAY_EXPORT CONSTMAP_HANDLE Message_GetProperties(MESSAGE_HANDLE message); /** @brief Gets the content of a message. * @@ -184,7 +185,7 @@ extern CONSTMAP_HANDLE Message_GetProperties(MESSAGE_HANDLE message); * @return A non-NULL pointer to a @c CONSTBUFFER representing the content * of the message, or @c NULL upon failure. */ -extern const CONSTBUFFER* Message_GetContent(MESSAGE_HANDLE message); +GATEWAY_EXPORT const CONSTBUFFER* Message_GetContent(MESSAGE_HANDLE message); /** @brief Gets the @c CONSTBUFFER handle that may be used to access the * message content. @@ -197,13 +198,13 @@ extern const CONSTBUFFER* Message_GetContent(MESSAGE_HANDLE message); * @return A non-NULL @c CONSTBUFFER_HANDLE representing the message * content, or @c NULL upon failure. */ -extern CONSTBUFFER_HANDLE Message_GetContentHandle(MESSAGE_HANDLE message); +GATEWAY_EXPORT CONSTBUFFER_HANDLE Message_GetContentHandle(MESSAGE_HANDLE message); /** @brief Disposes of resources allocated by the message. * * @param message The #MESSAGE_HANDLE to be destroyed. */ -extern void Message_Destroy(MESSAGE_HANDLE message); +GATEWAY_EXPORT void Message_Destroy(MESSAGE_HANDLE message); #ifdef __cplusplus } diff --git a/core/inc/module_loaders/dotnet_loader.h b/core/inc/module_loaders/dotnet_loader.h index d10a5f78..0d0ecf8a 100644 --- a/core/inc/module_loaders/dotnet_loader.h +++ b/core/inc/module_loaders/dotnet_loader.h @@ -9,6 +9,7 @@ #include "module.h" #include "module_loader.h" +#include "gateway_export.h" #ifdef __cplusplus extern "C" @@ -31,7 +32,7 @@ typedef struct DOTNET_LOADER_ENTRYPOINT_TAG STRING_HANDLE dotnetModuleEntryClass; } DOTNET_LOADER_ENTRYPOINT; -MOCKABLE_FUNCTION(, const MODULE_LOADER*, DotnetLoader_Get); +MOCKABLE_FUNCTION(, GATEWAY_EXPORT const MODULE_LOADER*, DotnetLoader_Get); #ifdef __cplusplus } diff --git a/core/inc/module_loaders/dynamic_loader.h b/core/inc/module_loaders/dynamic_loader.h index 2a0490e2..a4d47fc6 100644 --- a/core/inc/module_loaders/dynamic_loader.h +++ b/core/inc/module_loaders/dynamic_loader.h @@ -17,6 +17,7 @@ #include "module.h" #include "module_loader.h" +#include "gateway_export.h" #ifdef __cplusplus extern "C" @@ -33,7 +34,7 @@ typedef struct DYNAMIC_LOADER_ENTRYPOINT_TAG } DYNAMIC_LOADER_ENTRYPOINT; /** @brief The API for the dynamically linked module loader. */ -MOCKABLE_FUNCTION(, const MODULE_LOADER*, DynamicLoader_Get); +MOCKABLE_FUNCTION(, GATEWAY_EXPORT const MODULE_LOADER*, DynamicLoader_Get); #ifdef __cplusplus } diff --git a/core/inc/module_loaders/java_loader.h b/core/inc/module_loaders/java_loader.h index a04dd42d..fcc11e91 100644 --- a/core/inc/module_loaders/java_loader.h +++ b/core/inc/module_loaders/java_loader.h @@ -11,6 +11,7 @@ #include "module_loader.h" #include "java_module_host.h" #include "gateway_version.h" +#include "gateway_export.h" #ifdef __cplusplus extern "C" @@ -74,7 +75,7 @@ typedef struct JAVA_LOADER_ENTRYPOINT_TAG STRING_HANDLE classPath; } JAVA_LOADER_ENTRYPOINT; -MOCKABLE_FUNCTION(, const MODULE_LOADER*, JavaLoader_Get); +MOCKABLE_FUNCTION(, GATEWAY_EXPORT const MODULE_LOADER*, JavaLoader_Get); #ifdef __cplusplus } diff --git a/core/inc/module_loaders/node_loader.h b/core/inc/module_loaders/node_loader.h index 5cc0034b..f9a6e549 100644 --- a/core/inc/module_loaders/node_loader.h +++ b/core/inc/module_loaders/node_loader.h @@ -9,6 +9,7 @@ #include "module.h" #include "module_loader.h" +#include "gateway_export.h" #ifdef __cplusplus extern "C" @@ -28,7 +29,7 @@ typedef struct NODE_LOADER_ENTRYPOINT_TAG STRING_HANDLE mainPath; } NODE_LOADER_ENTRYPOINT; -MOCKABLE_FUNCTION(, const MODULE_LOADER*, NodeLoader_Get); +MOCKABLE_FUNCTION(, GATEWAY_EXPORT const MODULE_LOADER*, NodeLoader_Get); #ifdef __cplusplus } diff --git a/core/tests/gateway_e2e/CMakeLists.txt b/core/tests/gateway_e2e/CMakeLists.txt index ebc7e5e0..a24db80d 100644 --- a/core/tests/gateway_e2e/CMakeLists.txt +++ b/core/tests/gateway_e2e/CMakeLists.txt @@ -26,7 +26,7 @@ set(${theseTestsName}_c_files ) include_directories(../../../samples/protocol_encapsulation/inc ${IOTHUB_CLIENT_INC_FOLDER} e2e_module/inc/) -include_directories(../../../deps/iot-sdk/c/testtools/iothub_test/inc) +include_directories(../../../deps/iot-sdk-c/testtools/iothub_test/inc) include_directories(../../../deps/c-utility/inc/azure_c_shared_utility) include_directories(../../../modules/common) include_directories(../../../modules/iothub/inc) @@ -36,12 +36,10 @@ include_directories(${IOTHUB_SERVICE_CLIENT_INC_FOLDER}) include_directories(${GW_INC}) build_test_artifacts(${theseTestsName} ON) -if(DEFINED ${dependency_install_prefix}) - set_target_properties( - ${theseTestsName}_exe PROPERTIES - BUILD_WITH_INSTALL_RPATH TRUE - ) -endif() +set_target_properties( + ${theseTestsName}_exe PROPERTIES + BUILD_WITH_INSTALL_RPATH TRUE +) if(WIN32) if(TARGET ${theseTestsName}_dll) @@ -61,6 +59,9 @@ if(WIN32) iothub_client_http_transport ) install_broker(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) + copy_gateway_dll(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) + copy_iothub_client_dll(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration)) + copy_iothub_service_dll(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration)) endif() else() if(TARGET ${theseTestsName}_exe) diff --git a/core/tests/gateway_e2e/dependencies.cmake b/core/tests/gateway_e2e/dependencies.cmake index 623a017d..46805baf 100644 --- a/core/tests/gateway_e2e/dependencies.cmake +++ b/core/tests/gateway_e2e/dependencies.cmake @@ -6,18 +6,18 @@ include("../../../gatewayFunctions.cmake") ############################################################################### ###########################Find/Install/Build uamqp############################ ############################################################################### -findAndInstall(uamqp ${PROJECT_SOURCE_DIR}/deps/uamqp ${PROJECT_SOURCE_DIR}/deps/uamqp -Duse_installed_dependencies=ON -Dskip_unittests=ON -G "${CMAKE_GENERATOR}") +findAndInstall(uamqp ${PROJECT_SOURCE_DIR}/deps/uamqp ${PROJECT_SOURCE_DIR}/deps/uamqp -Duse_installed_dependencies=ON -G "${CMAKE_GENERATOR}") ############################################################################### ###########################Find/Install/Build umqtt############################ ############################################################################### -findAndInstall(umqtt ${PROJECT_SOURCE_DIR}/deps/umqtt ${PROJECT_SOURCE_DIR}/deps/umqtt -Duse_installed_dependencies=ON -Dskip_unittests=ON -G "${CMAKE_GENERATOR}") +findAndInstall(umqtt ${PROJECT_SOURCE_DIR}/deps/umqtt ${PROJECT_SOURCE_DIR}/deps/umqtt -Duse_installed_dependencies=ON -G "${CMAKE_GENERATOR}") ############################################################################### #######################Find/Install/Build azure_iot_sdks####################### ############################################################################### #The azure_iot_sdks repo requires special treatment. Parson submodule must be initialized. -if(NOT EXISTS ${PROJECT_SOURCE_DIR}/deps/iot-sdk/c/parson/README.md) +if(NOT EXISTS ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c/parson/README.md) execute_process( COMMAND git submodule update --init ${PROJECT_SOURCE_DIR}/deps/iot-sdk WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -25,15 +25,15 @@ if(NOT EXISTS ${PROJECT_SOURCE_DIR}/deps/iot-sdk/c/parson/README.md) ) if(${res}) - message(FATAL_ERROR "Error pulling iot-sdk submodule: ${res}") + message(FATAL_ERROR "Error pulling iot-sdk-c submodule: ${res}") endif() execute_process( - COMMAND git submodule update --init c/parson - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/deps/iot-sdk + COMMAND git submodule update --init parson + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c RESULT_VARIABLE res ) if(${res}) message(FATAL_ERROR "Error pulling parson submodule: ${res}") endif() endif() -findAndInstall(azure_iot_sdks ${PROJECT_SOURCE_DIR}/deps/iot-sdk ${PROJECT_SOURCE_DIR}/deps/iot-sdk/c -Duse_installed_dependencies=ON -Drun_e2e_tests=ON -Duse_openssl=OFF -Dskip_unittests=ON -G "${CMAKE_GENERATOR}") +findAndInstall(azure_iot_sdks ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c -Duse_installed_dependencies=ON -Dbuild_as_dynamic=ON -Drun_e2e_tests=ON -Duse_openssl=OFF -G "${CMAKE_GENERATOR}") diff --git a/core/tests/gateway_e2e/e2e_module/CMakeLists.txt b/core/tests/gateway_e2e/e2e_module/CMakeLists.txt index 3982e7a9..3391bd3a 100644 --- a/core/tests/gateway_e2e/e2e_module/CMakeLists.txt +++ b/core/tests/gateway_e2e/e2e_module/CMakeLists.txt @@ -19,3 +19,4 @@ add_library(e2e_module MODULE ${e2e_module_sources} ${e2e_module_headers}) target_link_libraries(e2e_module gateway) linkSharedUtil(e2e_module) + diff --git a/dependencies-test.cmake b/dependencies-test.cmake index 08b5d892..6b16d4dc 100644 --- a/dependencies-test.cmake +++ b/dependencies-test.cmake @@ -16,4 +16,4 @@ findAndInstall(testrunnerswitcher ${PROJECT_SOURCE_DIR}/deps/testrunner ${PROJEC ############################################################################### ###########################Find/Install/Build umock############################ ############################################################################### -findAndInstall(umock_c ${PROJECT_SOURCE_DIR}/deps/umock-c ${PROJECT_SOURCE_DIR}/deps/umock-c -Duse_installed_dependencies=ON -Dskip_unittests=ON -G "${CMAKE_GENERATOR}") \ No newline at end of file +findAndInstall(umock_c ${PROJECT_SOURCE_DIR}/deps/umock-c ${PROJECT_SOURCE_DIR}/deps/umock-c -Duse_installed_dependencies=ON -G "${CMAKE_GENERATOR}") \ No newline at end of file diff --git a/dependencies.cmake b/dependencies.cmake index 27f4dc1c..7b85541e 100644 --- a/dependencies.cmake +++ b/dependencies.cmake @@ -10,7 +10,7 @@ include("gatewayFunctions.cmake") ############################################################################### ###################Find/Install/Build azure_c_shared_utility################### ############################################################################### -findAndInstall(azure_c_shared_utility ${PROJECT_SOURCE_DIR}/deps/c-utility ${PROJECT_SOURCE_DIR}/deps/c-utility -Duse_installed_dependencies=ON -G "${CMAKE_GENERATOR}") +findAndInstall(azure_c_shared_utility ${PROJECT_SOURCE_DIR}/deps/c-utility ${PROJECT_SOURCE_DIR}/deps/c-utility -Duse_installed_dependencies=ON -Drun_unittests=${run_unittests} -Dbuild_as_dynamic=ON -G "${CMAKE_GENERATOR}") set(SHARED_UTIL_INC_FOLDER ${AZURE_C_SHARED_UTILITY_INCLUDE_DIR} CACHE INTERNAL "this is what needs to be included if using sharedLib lib" FORCE) set(SHARED_UTIL_LIB_FOLDER ${AZURE_C_SHARED_LIBRARY_DIR} CACHE INTERNAL "this is what needs to be included if using sharedLib lib" FORCE) set(SHARED_UTIL_LIB aziotsharedutil CACHE INTERNAL "this is what needs to be included if using sharedLib lib" FORCE) @@ -55,6 +55,7 @@ else() #If earlier cmake if("${CMAKE_VERSION}" VERSION_GREATER 3.0.2) pkg_search_module(NANOMSG REQUIRED nanomsg) + set (NANOMSG_LIB_LOCATION "${NANOMSG_LIBDIR}/lib${NANOMSG_LIBRARIES}.so") else() if(DEFINED ${dependency_install_prefix}) set(NANOMSG_INCLUDEDIR "${dependency_install_prefix}/include") @@ -65,19 +66,32 @@ else() pkg_search_module(NANOMSG REQUIRED nanomsg) set(NANOMSG_LIBRARY_DIRS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") endif() + set (NANOMSG_LIB_LOCATION "${NANOMSG_LIBRARY_DIRS}/lib${NANOMSG_LIBRARIES}.so") + endif() - add_library(nanomsg STATIC IMPORTED) - set(NANOMSG_INCLUDES "${NANOMSG_INCLUDEDIR}" CACHE INTERNAL "") - message(STATUS "NANOMSG LIBRARIES: ${NANOMSG_LIBRARIES}") - message(STATUS "NANOMSG LDFLAGS: ${NANOMSG_LDFLAGS}") - message(STATUS "NANOMSG CFLAGS: ${NANOMSG_CFLAGS}") - set_target_properties(nanomsg PROPERTIES + if (NOT NANOMSG_LIBDIR STREQUAL "/usr/lib") + # There seems to be a problem in CMake if nanomsg is found in the system + # default location when cross compiling. If it's anywhere + # else, we can create a imported target for it. (Actually, this might + # fail for any cross compile where nanomsg points to a system directory, + # so this might need to be refined as we find edge cases) + add_library(nanomsg SHARED IMPORTED) + + set_target_properties(nanomsg PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${NANOMSG_INCLUDEDIR}" INTERFACE_LINK_LIBRARIES "${NANOMSG_LIBRARIES}" INTERFACE_COMPILE_OPTIONS "${NANOMSG_LDFLAGS}" - IMPORTED_LOCATION "${NANOMSG_LIBRARY_DIRS}/lib${NANOMSG_LIBRARIES}.so" + IMPORTED_LOCATION "${NANOMSG_LIB_LOCATION}" ) + message(STATUS "NANOMSG LIBRARIES: ${NANOMSG_LIBRARIES}") + message(STATUS "NANOMSG LDFLAGS: ${NANOMSG_LDFLAGS}") + message(STATUS "NANOMSG CFLAGS: ${NANOMSG_CFLAGS}") + message(STATUS "NANOMSG LOCATION: ${NANOMSG_LIB_LOCATION}") + endif() + set(NANOMSG_INCLUDES "${NANOMSG_INCLUDEDIR}" CACHE INTERNAL "") + + endif() ############################################################################### @@ -92,4 +106,4 @@ if(NOT EXISTS ${PROJECT_SOURCE_DIR}/deps/parson/parson.c) if(${res}) message(FATAL_ERROR "Error pulling parson submodule: ${res}") endif() -endif() \ No newline at end of file +endif() diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 753e3b5a..0f19693a 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -7,4 +7,4 @@ cmake_minimum_required(VERSION 2.8.11) set(run_valgrind OFF) add_subdirectory(./c-utility) -add_subdirectory(./iot-sdk/c) +add_subdirectory(./iot-sdk-c) diff --git a/deps/c-utility b/deps/c-utility index e8f4077b..4f1ae336 160000 --- a/deps/c-utility +++ b/deps/c-utility @@ -1 +1 @@ -Subproject commit e8f4077bdb7c8fbdfe2df7c9e90297e22a9c6708 +Subproject commit 4f1ae336aca29f766d109facc704dad1a15149a2 diff --git a/deps/ctest b/deps/ctest index c06affbd..c7dafa78 160000 --- a/deps/ctest +++ b/deps/ctest @@ -1 +1 @@ -Subproject commit c06affbd946f071e42cfd14bcebe4255a67d8df3 +Subproject commit c7dafa78ded94c4934fe038a6e53eef71d865a47 diff --git a/deps/iot-sdk b/deps/iot-sdk deleted file mode 160000 index 5b3a502b..00000000 --- a/deps/iot-sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5b3a502b9c0f15df138e9402d9a0505663ac795f diff --git a/deps/iot-sdk-c b/deps/iot-sdk-c new file mode 160000 index 00000000..2118d865 --- /dev/null +++ b/deps/iot-sdk-c @@ -0,0 +1 @@ +Subproject commit 2118d86528dc34b12cf70b1b359f1acc91fd9ee5 diff --git a/deps/uamqp b/deps/uamqp index 6f1288aa..6e6690fe 160000 --- a/deps/uamqp +++ b/deps/uamqp @@ -1 +1 @@ -Subproject commit 6f1288aaaf53c601c75e6ab084065b3e65ded1fe +Subproject commit 6e6690fe9362206f91bbd33eb4cbdbc7a5689ce3 diff --git a/deps/umock-c b/deps/umock-c index feeec3d1..8e7f281d 160000 --- a/deps/umock-c +++ b/deps/umock-c @@ -1 +1 @@ -Subproject commit feeec3d14a9f03014d15c7eadbad0201544f9a6f +Subproject commit 8e7f281d66d8cdbfc8d60fb0753d3c7a6c40b9d7 diff --git a/deps/umqtt b/deps/umqtt index 08d8e081..6c85ba9a 160000 --- a/deps/umqtt +++ b/deps/umqtt @@ -1 +1 @@ -Subproject commit 08d8e081aecb3c33d5ed20447c38dabe81f64e26 +Subproject commit 6c85ba9a56cf4def0107c290105090f082cadeab diff --git a/gatewayFunctions.cmake b/gatewayFunctions.cmake index 2df949ad..aea1fbf4 100644 --- a/gatewayFunctions.cmake +++ b/gatewayFunctions.cmake @@ -34,6 +34,9 @@ function(findAndInstallNonFindPkg libraryName submoduleRootDirectory cmakeRootDi if(DEFINED ${dependency_install_prefix}) set(CMD ${CMD} -DCMAKE_INSTALL_PREFIX=${dependency_install_prefix}) endif() + if(CMAKE_TOOLCHAIN_FILE) + set( CMD ${CMD} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() set(CMD ${CMD} ../) file(MAKE_DIRECTORY ${cmakeRootDirectory}/build) @@ -92,6 +95,9 @@ function(findAndInstall libraryName submoduleRootDirectory cmakeRootDirectory) if(DEFINED ${dependency_install_prefix}) set(CMD ${CMD} -DCMAKE_INSTALL_PREFIX=${dependency_install_prefix}) endif() + if(CMAKE_TOOLCHAIN_FILE) + set( CMD ${CMD} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() set(CMD ${CMD} ../) file(MAKE_DIRECTORY ${cmakeRootDirectory}/build) diff --git a/jenkins/linux_c.sh b/jenkins/linux_c.sh index 90565ced..93c245fe 100755 --- a/jenkins/linux_c.sh +++ b/jenkins/linux_c.sh @@ -6,6 +6,6 @@ build_root=$(cd "$(dirname "$0")/.." && pwd) cd $build_root # -- C -- -./tools/build.sh --enable-nodejs-binding --enable-java-binding "$@" #-x +./tools/build.sh --run-unittests --enable-nodejs-binding --enable-java-binding "$@" #-x [ $? -eq 0 ] || exit $? \ No newline at end of file diff --git a/jenkins/ubuntu1510_c.sh b/jenkins/ubuntu1510_c.sh index 90565ced..93c245fe 100755 --- a/jenkins/ubuntu1510_c.sh +++ b/jenkins/ubuntu1510_c.sh @@ -6,6 +6,6 @@ build_root=$(cd "$(dirname "$0")/.." && pwd) cd $build_root # -- C -- -./tools/build.sh --enable-nodejs-binding --enable-java-binding "$@" #-x +./tools/build.sh --run-unittests --enable-nodejs-binding --enable-java-binding "$@" #-x [ $? -eq 0 ] || exit $? \ No newline at end of file diff --git a/jenkins/windows_c.cmd b/jenkins/windows_c.cmd index 06717745..b02492c1 100644 --- a/jenkins/windows_c.cmd +++ b/jenkins/windows_c.cmd @@ -44,7 +44,7 @@ REM -- Build first dotnet binding for End2End Test. call build_dotnet.cmd %* if errorlevel 1 goto :reset-java -call build.cmd --run-e2e-tests --enable-nodejs-binding --enable-dotnet-binding --enable-java-binding %* +call build.cmd --run-unittests --run-e2e-tests --enable-nodejs-binding --enable-dotnet-binding --enable-java-binding %* if errorlevel 1 goto :reset-java cd %build-root% diff --git a/modules/azure_functions/CMakeLists.txt b/modules/azure_functions/CMakeLists.txt index 001cb688..8ad1abfe 100644 --- a/modules/azure_functions/CMakeLists.txt +++ b/modules/azure_functions/CMakeLists.txt @@ -32,6 +32,6 @@ if(install_executables) install(TARGETS azure_functions LIBRARY DESTINATION lib) endif() -if(NOT ${skip_unittests}) +if(${run_unittests}) add_subdirectory(tests) endif() \ No newline at end of file diff --git a/modules/ble/CMakeLists.txt b/modules/ble/CMakeLists.txt index 9e284e53..f6d40135 100644 --- a/modules/ble/CMakeLists.txt +++ b/modules/ble/CMakeLists.txt @@ -115,7 +115,7 @@ linkSharedUtil(ble_c2d_static) add_module_to_solution(ble) add_module_to_solution(ble_c2d) -if(NOT ${skip_unittests}) +if(${run_unittests}) add_subdirectory(tests) endif() diff --git a/modules/ble/tests/ble_ut/CMakeLists.txt b/modules/ble/tests/ble_ut/CMakeLists.txt index bef2798e..4d682233 100644 --- a/modules/ble/tests/ble_ut/CMakeLists.txt +++ b/modules/ble/tests/ble_ut/CMakeLists.txt @@ -79,5 +79,7 @@ if(WIN32) rpcrt4 ) install_broker(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) + copy_gateway_dll(${theseTestsName}_exe ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) + endif() endif() diff --git a/modules/dependencies.cmake b/modules/dependencies.cmake index c71749dd..b7aae45f 100644 --- a/modules/dependencies.cmake +++ b/modules/dependencies.cmake @@ -6,34 +6,34 @@ include("../gatewayFunctions.cmake") ############################################################################### ###########################Find/Install/Build uamqp############################ ############################################################################### -findAndInstall(uamqp ${PROJECT_SOURCE_DIR}/deps/uamqp ${PROJECT_SOURCE_DIR}/deps/uamqp -Duse_installed_dependencies=ON -Dskip_unittests=ON -G "${CMAKE_GENERATOR}") +findAndInstall(uamqp ${PROJECT_SOURCE_DIR}/deps/uamqp ${PROJECT_SOURCE_DIR}/deps/uamqp -Duse_installed_dependencies=ON -G "${CMAKE_GENERATOR}") ############################################################################### ###########################Find/Install/Build umqtt############################ ############################################################################### -findAndInstall(umqtt ${PROJECT_SOURCE_DIR}/deps/umqtt ${PROJECT_SOURCE_DIR}/deps/umqtt -Duse_installed_dependencies=ON -Dskip_unittests=ON -G "${CMAKE_GENERATOR}") +findAndInstall(umqtt ${PROJECT_SOURCE_DIR}/deps/umqtt ${PROJECT_SOURCE_DIR}/deps/umqtt -Duse_installed_dependencies=ON -G "${CMAKE_GENERATOR}") ############################################################################### #######################Find/Install/Build azure_iot_sdks####################### ############################################################################### #The azure_iot_sdks repo requires special treatment. Parson submodule must be initialized. -if(NOT EXISTS ${PROJECT_SOURCE_DIR}/deps/iot-sdk/c/parson/README.md) +if(NOT EXISTS ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c/parson/README.md) execute_process( - COMMAND git submodule update --init ${PROJECT_SOURCE_DIR}/deps/iot-sdk + COMMAND git submodule update --init ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE res ) if(${res}) - message(FATAL_ERROR "Error pulling iot-sdk submodule: ${res}") + message(FATAL_ERROR "Error pulling iot-sdk-c submodule: ${res}") endif() execute_process( - COMMAND git submodule update --init c/parson - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/deps/iot-sdk + COMMAND git submodule update --init parson + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c RESULT_VARIABLE res ) if(${res}) message(FATAL_ERROR "Error pulling parson submodule: ${res}") endif() endif() -findAndInstall(azure_iot_sdks ${PROJECT_SOURCE_DIR}/deps/iot-sdk ${PROJECT_SOURCE_DIR}/deps/iot-sdk/c -Duse_installed_dependencies=ON -Duse_openssl=OFF -Dskip_unittests=ON -G "${CMAKE_GENERATOR}") +findAndInstall(azure_iot_sdks ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c -Duse_installed_dependencies=ON -Duse_openssl=OFF -Dbuild_as_dynamic=ON -Drun_e2e_tests=ON -G "${CMAKE_GENERATOR}") diff --git a/modules/identitymap/CMakeLists.txt b/modules/identitymap/CMakeLists.txt index e28034c4..772d82eb 100644 --- a/modules/identitymap/CMakeLists.txt +++ b/modules/identitymap/CMakeLists.txt @@ -32,6 +32,6 @@ if(install_modules) install(TARGETS identity_map LIBRARY DESTINATION "${LIB_INSTALL_DIR}/modules") endif() -if(NOT ${skip_unittests}) +if(${run_unittests}) add_subdirectory(tests) endif() diff --git a/modules/iothub/CMakeLists.txt b/modules/iothub/CMakeLists.txt index 6a5aadbd..692e0f19 100644 --- a/modules/iothub/CMakeLists.txt +++ b/modules/iothub/CMakeLists.txt @@ -69,7 +69,7 @@ linkSharedUtil(iothub_static) add_module_to_solution(iothub) -if(NOT ${skip_unittests}) +if(${run_unittests}) add_subdirectory(tests) endif() diff --git a/modules/logger/CMakeLists.txt b/modules/logger/CMakeLists.txt index 128ecd03..7a85135d 100644 --- a/modules/logger/CMakeLists.txt +++ b/modules/logger/CMakeLists.txt @@ -36,7 +36,7 @@ linkSharedUtil(logger_static) add_module_to_solution(logger) -if(NOT ${skip_unittests}) +if(${run_unittests}) add_subdirectory(tests) endif() diff --git a/samples/azure_functions_sample/CMakeLists.txt b/samples/azure_functions_sample/CMakeLists.txt index 821c3283..c9aa33ee 100644 --- a/samples/azure_functions_sample/CMakeLists.txt +++ b/samples/azure_functions_sample/CMakeLists.txt @@ -34,5 +34,7 @@ add_dependencies(azure_functions_sample hello_world azure_functions) target_link_libraries(azure_functions_sample gateway) linkSharedUtil(azure_functions_sample) install_broker(azure_functions_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_gateway_dll(azure_functions_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_iothub_client_dll(azure_functions_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) add_sample_to_solution(azure_functions_sample) \ No newline at end of file diff --git a/samples/azure_functions_sample/README.md b/samples/azure_functions_sample/README.md index bb2ab589..f3993565 100644 --- a/samples/azure_functions_sample/README.md +++ b/samples/azure_functions_sample/README.md @@ -42,7 +42,7 @@ Running the sample ------------------ In order to run the sample you'll need to configure the Azure Functions module. -This configuration is provided as JSON. There is a sample JSON file +This configuration is provided as a JSON file, which must be encoded either as ASCII or UTF-8. There is a sample JSON file provided in the repo called `azure_functions_lin.json` for linux or `azure_functions_win.json` for windows. Edit this file and provice the 3 parameters `hostname`, `relativePath` and `key`(optional). diff --git a/samples/ble_gateway/CMakeLists.txt b/samples/ble_gateway/CMakeLists.txt index fcd60ba6..f060fc21 100644 --- a/samples/ble_gateway/CMakeLists.txt +++ b/samples/ble_gateway/CMakeLists.txt @@ -34,6 +34,8 @@ add_dependencies(ble_gateway ble ble_printer identity_map logger iothub) linkSharedUtil(ble_gateway) install_broker(ble_gateway ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_gateway_dll(ble_gateway ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) + add_sample_to_solution(ble_gateway) diff --git a/samples/ble_gateway/README.md b/samples/ble_gateway/README.md index 74e5063f..1cc81bbd 100644 --- a/samples/ble_gateway/README.md +++ b/samples/ble_gateway/README.md @@ -85,11 +85,12 @@ Running the sample ------------------ In order to bootstrap and run the sample, you'll need to configure each module -that participates in the gateway. This configuration is provided as JSON. All -5 participating modules will need to be configured. There is a sample JSON file -provided in the repo called `gateway_sample.json` which you can use as a -starting point for building your own configuration file. You should find the -file at the path `samples/ble_gateway/src` relative to the root of the repo. +that participates in the gateway. This configuration is provided as a JSON file, +which must be encoded either as ASCII or UTF-8. All 5 participating modules will need +to be configured. There is a sample JSON file provided in the repo called +`gateway_sample.json` which you can use as a starting point for building your +own configuration file. You should find the file at the path +`samples/ble_gateway/src` relative to the root of the repo. In order to run the sample you'll run the `ble_gateway` binary passing the path to the configuration JSON file. The following command assumes that you are diff --git a/samples/dotnet_binding_sample/CMakeLists.txt b/samples/dotnet_binding_sample/CMakeLists.txt index abe7ad53..5b42828f 100644 --- a/samples/dotnet_binding_sample/CMakeLists.txt +++ b/samples/dotnet_binding_sample/CMakeLists.txt @@ -24,6 +24,7 @@ add_dependencies(dotnet_binding_sample dotnet logger) target_link_libraries(dotnet_binding_sample gateway) linkSharedUtil(dotnet_binding_sample) install_broker(dotnet_binding_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_gateway_dll(dotnet_binding_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) install_binaries(dotnet_binding_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ${dotnet_managed_binding_dll} ) install_binaries(dotnet_binding_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ${dotnet_host_binding_dll} ) install_binaries(dotnet_binding_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ${dotnet_sensor_module_dll} ) diff --git a/samples/experimental/events_sample/CMakeLists.txt b/samples/experimental/events_sample/CMakeLists.txt index 3be07e5e..78cc16eb 100644 --- a/samples/experimental/events_sample/CMakeLists.txt +++ b/samples/experimental/events_sample/CMakeLists.txt @@ -14,11 +14,14 @@ include_directories(${IOTHUB_CLIENT_INC_FOLDER} ${GW_INC} ${GW_INC}/experimental add_executable(events_sample ${events_headers} ${events_sources}) -target_link_libraries(events_sample gateway) +#use static library because functions aren't public. +target_link_libraries(events_sample gateway_static) linkSharedUtil(events_sample) add_dependencies(events_sample hello_world) install_broker(events_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_gateway_dll(events_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_iothub_client_dll(events_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) # add events_sample to non-standard "Experimental" VS project folder for now #add_sample_to_solution(events_sample) diff --git a/samples/hello_world/CMakeLists.txt b/samples/hello_world/CMakeLists.txt index 4a492dea..42397bdc 100644 --- a/samples/hello_world/CMakeLists.txt +++ b/samples/hello_world/CMakeLists.txt @@ -31,5 +31,6 @@ add_dependencies(hello_world_sample hello_world logger) target_link_libraries(hello_world_sample gateway nanomsg) linkSharedUtil(hello_world_sample) install_broker(hello_world_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_gateway_dll(hello_world_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) add_sample_to_solution(hello_world_sample) \ No newline at end of file diff --git a/samples/hello_world/README.md b/samples/hello_world/README.md index 3aa6c61a..82180efc 100644 --- a/samples/hello_world/README.md +++ b/samples/hello_world/README.md @@ -119,7 +119,7 @@ Linux - build.sh produces its outputs in `azure-iot-gateway-sdk/build`. This is where the two module SOs and executable used in this sample are built. > Note: The logger module is built as `/modules/logger/logger.so`. The hello world module is built as `/modules/hello_world/hello_world.so`. The sample executable is built as `/samples/hello_world/hello_world_sample`. -- The hello_world_sample process takes the path to a JSON configuration file as an argument in the command line. An example JSON file has been provided as part of the repo at `azure-iot-gateway-sdk/samples/hello_world/src/hello_world_win.json' and is copied below. It will work as is unless you have modified the build script to place modules or sample executables in non-default locations. +- The hello_world_sample process takes the path to a JSON configuration file as an argument in the command line. The file must be encoded either as ASCII or UTF-8. An example JSON file has been provided as part of the repo at `azure-iot-gateway-sdk/samples/hello_world/src/hello_world_win.json' and is copied below. It will work as is unless you have modified the build script to place modules or sample executables in non-default locations. > Note: The module paths are relative to the current working directory from where the hello_world_sample executable is launched, not the directory where the executable is located. The sample JSON configuration file is defaults to writing 'log.txt' in your current working directory. ```json @@ -167,7 +167,7 @@ Windows - `build.cmd` produces a folder called `build` in the root repo folder. This is where the two module dlls and executable used in this sample are built. > Note: The logger module is built as `\modules\logger\Debug\logger.dll`. The hello world module is built as `\modules\hello_world\Debug\hello_world.dll`. The sample exe is built as `\samples\hello_world\Debug\hello_world_sample.exe`. -- The hello_world_sample process takes the path to a JSON configuration file as an argument in the command line. An example JSON file has been provided as part of the repo at `azure-iot-gateway-sdk\samples\hello_world\src\hello_world_win.json' and is copied below. It will work as is unless you have modified the build script to place modules or sample executables in non-default locations. +- The hello_world_sample process takes the path to a JSON configuration file as an argument in the command line. The file must be encoded either as ASCII or UTF-8. An example JSON file has been provided as part of the repo at `azure-iot-gateway-sdk\samples\hello_world\src\hello_world_win.json' and is copied below. It will work as is unless you have modified the build script to place modules or sample executables in non-default locations. > Note: The module paths are relative to the directory where the hello_world_sample.exe is located. The sample JSON configuration file is defaults to writing 'log.txt' in your current working directory. ```json @@ -245,7 +245,7 @@ Below is an example of typical output that is written to the log file when the H The gateway process needs to be written by the developer. This a program which creates internal infrastructure (e.g. the broker), loads the correct modules, and sets everything up to function correctly. The SDK provides the `Gateway_CreateFromJson` function which allows developers to bootstrap a gateway from a JSON file. -`Gateway_CreateFromJson` deals with creating internal infrastructure (e.g. the broker), loading modules, and setting everything up to function correctly. All the developer needs to do is provide this function with the path to a JSON file specifying what modules they want loaded and links to guide the broker to send messages to the correct module. +`Gateway_CreateFromJson` deals with creating internal infrastructure (e.g. the broker), loading modules, and setting everything up to function correctly. All the developer needs to do is provide this function with the path to a JSON file specifying what modules they want loaded and links to guide the broker to send messages to the correct module. The configuration file must be encoded either as ASCII or UTF-8. The code for the Hello World sample's gateway process is contained in [`samples/hello_world/main.c`](./src/main.c) A slightly abbreviated version of that code is copied below. This very short program just creates a gateway and then waits for the ENTER key to be pressed before it tears down the gateway. diff --git a/samples/java_sample/CMakeLists.txt b/samples/java_sample/CMakeLists.txt index 6ddf6089..98457dd8 100644 --- a/samples/java_sample/CMakeLists.txt +++ b/samples/java_sample/CMakeLists.txt @@ -33,6 +33,8 @@ target_link_libraries(java_sample gateway) add_dependencies(java_sample java_module_host logger) linkSharedUtil(java_sample) install_broker(java_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_gateway_dll(java_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_iothub_client_dll(java_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) add_sample_to_solution(java_sample) \ No newline at end of file diff --git a/samples/java_sample/README.md b/samples/java_sample/README.md index 87196896..994db768 100644 --- a/samples/java_sample/README.md +++ b/samples/java_sample/README.md @@ -59,28 +59,42 @@ Creating a Java module is easy: - **JSON Configuration** - A gateway is configured using a JSON configuration file. As a reference, you can see the JSON configuration file located [here](./src/java_sample_win.json). + A gateway is configured using a JSON configuration file. The file must be encoded either as ASCII or UTF-8. As a reference, you can see the JSON configuration file located [here](./src/java_sample_win.json). ```json { - "module name": "<>", - "module path": "<>", - "args": { - "class_path": "<>", - "library_path": "<>", - "class_name": "<>", - "args": <>, - "jvm_options": { - "version": <>, - "debug": [true | false], - "debug_port": <>, - "verbose": [true | false], - "additional_options": [ - "<>" - ] + "loaders": [ + { + "type": "java", + "name": "java", + "configuration":{ + "jvm.options":{ + "library.path": "<>", + "version": <>, + "debug": [true | false], + "debug_port": <>, + "verbose": [true | false], + "additional_options": [ + "<>" + ] + } + } + } - } - } + ], + "modules": [ + { + "name": "<>", + "loader":{ + "name": "java", + "entrypoint": { + "class.name": "<>", + "class.path": "<>" + } + }, + "args": <> + } + } ``` According to [Java documentation](https://docs.oracle.com/javase/tutorial/essential/environment/paths.html) one may also set the CLASSPATH environment @@ -92,16 +106,30 @@ Creating a Java module is easy: ```json { - "jvm_options": { - "version": 4, - "debug": false, - "debug_port": 9876, - "verbose": false, - "additional_options": null - } + ... + "jvm.options": { + "library.path": "<>", + "version": 5, + "debug": false, + "debug_port": 9876, + "verbose": false, + "additional_options": null + } + ... } ``` + **Note:** The default search locations are as follows: + + On Windows: + + %PROGRAMFILES%\azure_iot_gateway_sdk-{version}\lib\modules\java_module_host.dll + %PROGRAMFILES(x86)%\azure_iot_gateway_sdk-{version}\lib\modules\java_module_host.dll + + On Linux: + + /usr/local/lib/modules/java_module_host.so + **Note:** Since the JVM is only loaded once, the full classpath must be set and be the same across all module in a configuration. Similar to the "jvm_options" section, if the classpath differs across configuration, creation will fail. diff --git a/samples/java_sample/java_devbox_setup.md b/samples/java_sample/java_devbox_setup.md index 0080a4b4..9aeb8898 100644 --- a/samples/java_sample/java_devbox_setup.md +++ b/samples/java_sample/java_devbox_setup.md @@ -6,7 +6,6 @@ This document describes how to prepare your development environment to use the * - [Maven 3](#installmaven) - [Azure IoT Gateway SDK for Java](#installgw) - [Build from source](#installgwsource) - - [Include using Maven](#installgwmaven) - [Application Samples](#samplecode) @@ -112,29 +111,11 @@ Open a command prompt and use the following commands for the steps above: The compiled JAR file with all dependencies bundled in can then be found at: ``` -{IoT gateway SDK root}/bindings/java/gateway-java-binding/target/gateway-java-binding-{version}-with-deps.jar +{IoT gateway SDK root}/bindings/java/gateway-java-binding/target/gateway-java-binding-{version}.jar ``` When you're ready to build your own module in Java, include this JAR file in your project to get the interfaces and classes that you need. - -### Get the Java binding for the Azure IoT Gateway SDK from Maven (as a dependency) -_This is the recommended method of including the Azure IoT Gateway SDK in your project, however this method will only work if your project is a Maven project_ - -_For a guide on creating a maven project, see here: https://maven.apache.org/guides/getting-started/ _ - -- Navigate to http://search.maven.org, search for **com.microsoft.azure.gateway** and take note of the latest version number (or the version number of whichever version of the sdk you desire to use). - -In your main pom.xml file, add the Azure IoT Gateway SDK Java binding as a dependency using your desired version as follows: -``` - - com.microsoft.azure.gateway - gateway-java-binding - 1.0.0 - - -``` - ## Sample applications diff --git a/samples/java_sample/src/java_sample_lin.json b/samples/java_sample/src/java_sample_lin.json index 04b4e02a..06bee9ff 100644 --- a/samples/java_sample/src/java_sample_lin.json +++ b/samples/java_sample/src/java_sample_lin.json @@ -6,7 +6,8 @@ "configuration":{ "jvm.options":{ "library.path": "../../bindings/java" - } + }, + "binding.path": "../../bindings/java/libjava_module_host.so" } } diff --git a/samples/java_sample/src/java_sample_win.json b/samples/java_sample/src/java_sample_win.json index 01691702..96057e6b 100644 --- a/samples/java_sample/src/java_sample_win.json +++ b/samples/java_sample/src/java_sample_win.json @@ -6,7 +6,8 @@ "configuration":{ "jvm.options":{ "library.path": "..\\..\\bindings\\java\\Debug" - } + }, + "binding.path": "..\\..\\bindings\\java\\Debug\\java_module_host.dll" } } diff --git a/samples/nodejs_simple_sample/CMakeLists.txt b/samples/nodejs_simple_sample/CMakeLists.txt index 8dccea3b..13828d29 100644 --- a/samples/nodejs_simple_sample/CMakeLists.txt +++ b/samples/nodejs_simple_sample/CMakeLists.txt @@ -36,6 +36,7 @@ add_dependencies(nodejs_simple_sample nodejs_binding logger) linkSharedUtil(nodejs_simple_sample) install_broker(nodejs_simple_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) copy_node_dll(nodejs_simple_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_gateway_dll(nodejs_simple_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) add_sample_to_solution(nodejs_simple_sample) diff --git a/samples/nodejs_simple_sample/README.md b/samples/nodejs_simple_sample/README.md index 0eb0750d..e472aeaa 100644 --- a/samples/nodejs_simple_sample/README.md +++ b/samples/nodejs_simple_sample/README.md @@ -35,7 +35,7 @@ In order to run a gateway with a Node.js module do the following: - Edit file under <\>\samples\nodejs_simple_sample\src\gateway_sample.json - Copy the configuration values from the sample given below. - On folder <\>\build\samples\nodejs_simple_sample\Debug run the following command: -- nodejs_simple_sample ..\..\..\..\samples\nodejs_simple_sample\src\gateway_sample.json +- nodejs_simple_sample ..\..\..\..\samples\nodejs_simple_sample\src\gateway_sample_win.json ``` { @@ -118,18 +118,30 @@ On a terminal windows follow these steps: - Edit file under ~/azure-iot-gateway-sdk/samples/nodejs_simple_sample/src/gateway_sample.json - Copy the configuration values from the sample given below. - On folder ~/azure-iot-gateway-sdk/build/samples/nodejs_simple_sample run the following command: -- ./nodejs_simple_sample ../../../samples/nodejs_simple_sample/src/gateway_sample.json +- ./nodejs_simple_sample ../../../samples/nodejs_simple_sample/src/gateway_sample_lin.json Here is a sample of the gateway_sample.json file filled: ``` { +"loaders": [ + { + "type": "node", + "name": "node", + "configuration": { + "binding.path": "../../../build/bindings/nodejs/libnodejs_binding.so" + } + } + ], + "modules": [ { "name": "node_printer", "loader": { "name": "node", - "main.path": "./samples/nodejs_simple_sample/nodejs_modules/printer.js" - }, + "entrypoint": { + "main.path": "../../../samples/nodejs_simple_sample/nodejs_modules/printer.js" + } + }, "args": null }, { @@ -137,7 +149,7 @@ Here is a sample of the gateway_sample.json file filled: "loader": { "name": "node", "entrypoint": { - "main.path": "./samples/nodejs_simple_sample/nodejs_modules/sensor.js" + "main.path": "../../../samples/nodejs_simple_sample/nodejs_modules/sensor.js" } }, "args": null @@ -147,7 +159,7 @@ Here is a sample of the gateway_sample.json file filled: "loader": { "name": "node", "entrypoint": { - "main.path": "./samples/nodejs_simple_sample/nodejs_modules/iothub_writer.js" + "main.path": "../../../samples/nodejs_simple_sample/nodejs_modules/iothub_writer.js" } }, "args": { @@ -159,7 +171,7 @@ Here is a sample of the gateway_sample.json file filled: "loader": { "name": "native", "entrypoint": { - "module.path": "../../modules/logger/liblogger.so" + "module.path": "../../../build/modules/logger/liblogger.so" } }, "args": { @@ -182,4 +194,20 @@ Here is a sample of the gateway_sample.json file filled: } ] } -``` \ No newline at end of file +``` + +On successful run you should see **sample** output like this + +````` +Gateway is running. Press return to quit. +printer.receive - 47, 33 +printer.receive - 11, 12 +printer.receive - 39, 30 +printer.receive - 30, 21 +printer.receive - 12, 0 + +Gateway is quitting +printer.destroy +sensor.destroy +iothub_writer.destroy +````` diff --git a/samples/simulated_device_cloud_upload/CMakeLists.txt b/samples/simulated_device_cloud_upload/CMakeLists.txt index 76604e1c..0a7304fa 100644 --- a/samples/simulated_device_cloud_upload/CMakeLists.txt +++ b/samples/simulated_device_cloud_upload/CMakeLists.txt @@ -39,6 +39,8 @@ target_link_libraries(simulated_device_cloud_upload_sample gateway) linkSharedUtil(simulated_device_cloud_upload_sample) linkHttp(simulated_device_cloud_upload_sample) install_broker(simulated_device_cloud_upload_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_gateway_dll(simulated_device_cloud_upload_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) +copy_iothub_client_dll(simulated_device_cloud_upload_sample ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) add_sample_to_solution(simulated_device_cloud_upload_sample) diff --git a/samples/simulated_device_cloud_upload/README.md b/samples/simulated_device_cloud_upload/README.md index 8757495a..b671a0a1 100644 --- a/samples/simulated_device_cloud_upload/README.md +++ b/samples/simulated_device_cloud_upload/README.md @@ -84,7 +84,7 @@ match the ids of the two devices you added to your IoT hub, and that the `device - Run `$ ./samples/simulated_device_cloud_upload/simulated_device_cloud_upload_sample ` ->Note: The simulated device cloud upload process takes the path to a JSON configuration file as an argument in the command line. An example JSON file has been provided as part of the repo at `azure-iot-gateway-sdk/samples/simulated_device_cloud_upload/src/simulated_device_cloud_upload_lin.json'. +>Note: The simulated device cloud upload process takes the path to a JSON configuration file as an argument in the command line. The file must be encoded either as ASCII or UTF-8. An example JSON file has been provided as part of the repo at `azure-iot-gateway-sdk/samples/simulated_device_cloud_upload/src/simulated_device_cloud_upload_lin.json'. Windows @@ -110,5 +110,5 @@ match the ids of the two devices you added to your IoT hub, and that the `device - Run `.\simulated_device_cloud_upload_sample.exe ` ->Note: The simulated device cloud upload process takes the path to a JSON configuration file as an argument in the command line. An example JSON file has been provided as part of the repo at `azure-iot-gateway-sdk\samples\simulated_device_cloud_upload\src\simulated_device_cloud_upload_win.json'. +>Note: The simulated device cloud upload process takes the path to a JSON configuration file as an argument in the command line. The file must be encoded either as ASCII or UTF-8. An example JSON file has been provided as part of the repo at `azure-iot-gateway-sdk\samples\simulated_device_cloud_upload\src\simulated_device_cloud_upload_win.json'. diff --git a/samples/simulated_device_cloud_upload/src/azure-iot-field-gateway-sdk.bb b/samples/simulated_device_cloud_upload/src/azure-iot-field-gateway-sdk.bb index c0b3cb15..f4555458 100644 --- a/samples/simulated_device_cloud_upload/src/azure-iot-field-gateway-sdk.bb +++ b/samples/simulated_device_cloud_upload/src/azure-iot-field-gateway-sdk.bb @@ -2,13 +2,13 @@ DESCRIPTION = "" LICENSE = "MI" SRC_URI = "file:///home/<>/azure-iot-gateway-sdk" -LIC_FILES_CHKSUM = "file:///home/<>/azure-iot-gateway-sdk/deps/iot-sdk/LICENSE;md5=4283671594edec4c13aeb073c219237a" +LIC_FILES_CHKSUM = "file:///home/<>/azure-iot-gateway-sdk/deps/iot-sdk-c/LICENSE;md5=4283671594edec4c13aeb073c219237a" PROVIDES = "azure-iot-gateway-sdk" DEPENDS = "glib-2.0 curl" -EXTRA_OECMAKE = "-Dinstall_executables:BOOL=ON -Drun_as_a_service:BOOL=ON -Dskip_unittests:BOOL=ON" +EXTRA_OECMAKE = "-Dinstall_executables:BOOL=ON -Drun_as_a_service:BOOL=ON -Drun_unittests:BOOL=OFF" S = "${WORKDIR}/home/azure-iot-gateway-sdk" diff --git a/tools/Dockerfile b/tools/Dockerfile index 393758a2..306b9633 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -38,5 +38,5 @@ ENTRYPOINT rm -rf /gateway && \ git clone ${GATEWAY_REPO} /gateway && \ git -C /gateway checkout ${COMMIT_ID} && \ git -C /gateway submodule update --init && \ - /gateway/tools/build.sh -rv --enable-java-binding --enable-nodejs-binding && \ + /gateway/tools/build.sh --run-unittests -rv --enable-java-binding --enable-nodejs-binding && \ bash diff --git a/tools/build.cmd b/tools/build.cmd index 1bed4d0c..ed755975 100644 --- a/tools/build.cmd +++ b/tools/build.cmd @@ -22,7 +22,7 @@ rem ---------------------------------------------------------------------------- rem // default build options set build-config=Debug set build-platform=Win32 -set CMAKE_skip_unittests=OFF +set CMAKE_run_unittests=OFF set CMAKE_run_e2e_tests=OFF set CMAKE_enable_dotnet_binding=OFF set enable-java-binding=OFF @@ -34,7 +34,7 @@ set dependency_install_prefix="-Ddependency_install_prefix=%local-install%" if "%1" equ "" goto args-done if "%1" equ "--config" goto arg-build-config if "%1" equ "--platform" goto arg-build-platform -if "%1" equ "--skip-unittests" goto arg-skip-unittests +if "%1" equ "--run-unittests" goto arg-run-unittests if "%1" equ "--run-e2e-tests" goto arg-run-e2e-tests if "%1" equ "--enable-dotnet-binding" goto arg-enable-dotnet-binding if "%1" equ "--enable-java-binding" goto arg-enable-java-binding @@ -56,8 +56,8 @@ if "%1" equ "" call :usage && exit /b 1 set build-platform=%1 goto args-continue -:arg-skip-unittests -set CMAKE_skip_unittests=ON +:arg-run-unittests +set CMAKE_run_unittests=ON goto args-continue :arg-run-e2e-tests @@ -112,18 +112,18 @@ if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! pushd %cmake-root% if %build-platform% == x64 ( echo ***Running CMAKE for Win64*** - cmake %dependency_install_prefix% -Dskip_unittests:BOOL=%CMAKE_skip_unittests% -Drun_e2e_tests:BOOL=%CMAKE_run_e2e_tests% -Denable_dotnet_binding:BOOL=%CMAKE_enable_dotnet_binding% -Denable_java_binding:BOOL=%enable-java-binding% -Denable_nodejs_binding:BOOL=%enable_nodejs_binding% -Denable_ble_module:BOOL=%CMAKE_enable_ble_module% "%build-root%" -G "Visual Studio 14 Win64" + cmake %dependency_install_prefix% -Drun_unittests:BOOL=%CMAKE_run_unittests% -Drun_e2e_tests:BOOL=%CMAKE_run_e2e_tests% -Denable_dotnet_binding:BOOL=%CMAKE_enable_dotnet_binding% -Denable_java_binding:BOOL=%enable-java-binding% -Denable_nodejs_binding:BOOL=%enable_nodejs_binding% -Denable_ble_module:BOOL=%CMAKE_enable_ble_module% "%build-root%" -G "Visual Studio 14 Win64" if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! ) else ( echo ***Running CMAKE for Win32*** - cmake %dependency_install_prefix% -Dskip_unittests:BOOL=%CMAKE_skip_unittests% -Drun_e2e_tests:BOOL=%CMAKE_run_e2e_tests% -Denable_dotnet_binding:BOOL=%CMAKE_enable_dotnet_binding% -Denable_java_binding:BOOL=%enable-java-binding% -Denable_nodejs_binding:BOOL=%enable_nodejs_binding% -Denable_ble_module:BOOL=%CMAKE_enable_ble_module% "%build-root%" + cmake %dependency_install_prefix% -Drun_unittests:BOOL=%CMAKE_run_unittests% -Drun_e2e_tests:BOOL=%CMAKE_run_e2e_tests% -Denable_dotnet_binding:BOOL=%CMAKE_enable_dotnet_binding% -Denable_java_binding:BOOL=%enable-java-binding% -Denable_nodejs_binding:BOOL=%enable_nodejs_binding% -Denable_ble_module:BOOL=%CMAKE_enable_ble_module% "%build-root%" if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! ) msbuild /m /p:Configuration="%build-config%" /p:Platform="%build-platform%" azure_iot_gateway_sdk.sln if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! -if "%CMAKE_skip_unittests%"=="ON" if "%CMAKE_run_e2e_tests%"=="OFF" goto skip-tests +if "%CMAKE_run_unittests%"=="OFF" if "%CMAKE_run_e2e_tests%"=="OFF" goto skip-tests ctest -C "debug" -V if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL! @@ -141,7 +141,7 @@ echo build.cmd [options] echo options: echo --config value Build configuration (e.g. [Debug], Release) echo --platform value Build platform (e.g. [Win32], x64, ...) -echo --skip-unittests Do not build/run unit tests +echo --run-unittests Build/run unit tests echo --run-e2e-tests Build/run end-to-end tests echo --enable-dotnet-binding Build the .NET binding echo --enable-java-binding Build the Java binding diff --git a/tools/build.sh b/tools/build.sh index 9adcdc84..6ae0306e 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -8,7 +8,7 @@ build_clean= build_root=$(cd "$(dirname "$0")/.." && pwd) local_install=$build_root/install-deps log_dir=$build_root -skip_unittests=OFF +run_unittests=OFF run_e2e_tests=OFF run_valgrind=0 enable_java_binding=OFF @@ -28,7 +28,7 @@ usage () echo " Example: -cl -O1 -cl ..." echo " -rv, --run-valgrind Execute ctest with valgrind" echo " --toolchain-file Pass CMake a toolchain file for cross-compiling" - echo " --skip-unittests Do not build/run unit tests" + echo " --run-unittests Build/run unit tests" echo " --run-e2e-tests Build/run end-to-end tests" echo " --enable-java-binding Build the Java binding" echo " (JAVA_HOME must be defined in your environment)" @@ -63,7 +63,7 @@ process_args () case "$arg" in "-x" | "--xtrace" ) set -x;; "-c" | "--clean" ) build_clean=1;; - "--skip-unittests" ) skip_unittests=ON;; + "--run-unittests" ) run_unittests=ON;; "--run-e2e-tests" ) run_e2e_tests=ON;; "-cl" | "--compileoption" ) save_next_arg=1;; "-rv" | "--run-valgrind" ) run_valgrind=1;; @@ -124,7 +124,7 @@ cmake $toolchainfile \ $dependency_install_prefix \ -DcompileOption_C:STRING="$extracloptions" \ -DCMAKE_BUILD_TYPE=Debug \ - -Dskip_unittests:BOOL=$skip_unittests \ + -Drun_unittests:BOOL=$run_unittests \ -Drun_e2e_tests:BOOL=$run_e2e_tests \ -Denable_java_binding:BOOL=$enable_java_binding \ -Denable_nodejs_binding:BOOL=$enable_nodejs_binding \ @@ -135,7 +135,7 @@ cmake $toolchainfile \ make --jobs=$CORES -if [[ "$skip_unittests" == "OFF" || "$run_e2e_tests" == "ON" ]] +if [[ "$run_unittests" == "ON" || "$run_e2e_tests" == "ON" ]] then if [[ $run_valgrind == 1 ]] then diff --git a/tools/build_nodejs.cmd b/tools/build_nodejs.cmd index 4957e20b..4707cc86 100644 --- a/tools/build_nodejs.cmd +++ b/tools/build_nodejs.cmd @@ -21,7 +21,7 @@ mkdir %build-root% pushd %build-root% rem Clone Node.js -git clone -b shared-691 https://github.com/avranju/node.git +git clone -b shared-691 --depth 1 https://github.com/avranju/node.git pushd node rem Build Node.js diff --git a/tools/build_nodejs.sh b/tools/build_nodejs.sh index 0f5b093a..115c066f 100755 --- a/tools/build_nodejs.sh +++ b/tools/build_nodejs.sh @@ -13,7 +13,7 @@ mkdir -p $build_root # build Node.js pushd $build_root -git clone -b shared-691 https://github.com/avranju/node.git +git clone -b shared-691 --depth 1 https://github.com/avranju/node.git pushd node ./configure --shared make -j $(nproc) diff --git a/tools/inteledison_c.sh b/tools/inteledison_c.sh index a0931273..41a116c4 100755 --- a/tools/inteledison_c.sh +++ b/tools/inteledison_c.sh @@ -110,7 +110,7 @@ cmake_root="$build_root"/build rm -r -f "$cmake_root" mkdir -p "$cmake_root" pushd "$cmake_root" -cmake $dependency_install_prefix -DCMAKE_TOOLCHAIN_FILE=$FILE -DCMAKE_BUILD_TYPE=Debug -Drun_e2e_tests:BOOL=OFF -Dskip_unittests:BOOL=ON -Drun_valgrind:BOOL=OFF "$build_root" +cmake $dependency_install_prefix -DCMAKE_TOOLCHAIN_FILE=$FILE -DCMAKE_BUILD_TYPE=Debug -Drun_e2e_tests:BOOL=OFF -Drun_unittests:BOOL=OFF -Drun_valgrind:BOOL=OFF "$build_root" [ $? -eq 0 ] || exit $? make --jobs=$(nproc) diff --git a/tools/release/bump_version/inputs.js b/tools/release/bump_version/inputs.js index c94eccf0..180925c8 100644 --- a/tools/release/bump_version/inputs.js +++ b/tools/release/bump_version/inputs.js @@ -10,6 +10,14 @@ module.exports = [ return '$1' + '$2' + versions.gateway.core; } }, + { + "taskType": "regexReplaceTask", + "filePath": "CMakeLists.txt", + "search": "(set\\(GATEWAY\\_VERSION[\\s]+)(\\d+.\\d+.\\d+)([\\s]+.*)", + "replaceString": function(versions){ + return '$1' + versions.gateway.core + '$3'; + } + }, /////////////////////////////////////////////////// // Azure IoT Gateway SDK - DotNET binding /////////////////////////////////////////////////// diff --git a/tools/windriver_linux_c.sh b/tools/windriver_linux_c.sh index 7c2c70af..38efbd5d 100755 --- a/tools/windriver_linux_c.sh +++ b/tools/windriver_linux_c.sh @@ -107,7 +107,7 @@ cmake_root="$build_root"/build rm -r -f "$cmake_root" mkdir -p "$cmake_root" pushd "$cmake_root" -cmake -Ddependency_install_prefix=$local_install -DCMAKE_BUILD_TYPE=Debug -Dskip_unittests:BOOL=ON -Drun_e2e_tests:BOOL=OFF -Drun_valgrind:BOOL=OFF "$build_root" +cmake -Ddependency_install_prefix=$local_install -DCMAKE_BUILD_TYPE=Debug -Drun_unittests:BOOL=OFF -Drun_e2e_tests:BOOL=OFF -Drun_valgrind:BOOL=OFF "$build_root" [ $? -eq 0 ] || exit $? make --jobs=$(nproc)