Skip to content

Commit

Permalink
Fix mbed build
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoltan Varga committed Jun 20, 2016
1 parent ac8defd commit 867fad9
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 127 deletions.
10 changes: 5 additions & 5 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ option(compileOption_C "passes a string to the command line of the C compiler" O
option(compileOption_CXX "passes a string to the command line of the C++ compiler" OFF)
option(build_python "builds the Python native iothub_client module" OFF)
option(build_javawrapper "builds the native iothub_client library for java C wrapper" OFF)
option(use_uploadtoblob "set use_uploadtoblob to ON if the functionality of upload to blob is to be included, OFF otherwise. It requires HTTP" ON)
option(dont_use_uploadtoblob "set dont_use_uploadtoblob to ON if the functionality of upload to blob is to be excluded, OFF otherwise. It requires HTTP" OFF)

#check for conflicting options
if(${use_uploadtoblob} AND NOT ${use_http})
message(FATAL_ERROR "option use_uploadtoblob set to ON requires option use_http set to ON")
if(NOT ${dont_use_uploadtoblob} AND NOT ${use_http})
message(FATAL_ERROR "option dont_use_uploadtoblob set to OFF requires option use_http set to ON")
endif()

if(${use_uploadtoblob})
add_definitions(-DUSE_UPLOADTOBLOB)
if(${dont_use_uploadtoblob})
add_definitions(-DDONT_USE_UPLOADTOBLOB)
endif()

#Use solution folders.
Expand Down
2 changes: 1 addition & 1 deletion c/build_all/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ process_args ()
fi
done

if [ $toolchainfile != " " ]
if [ "$toolchainfile" != " " ]
then
toolchainfile=$(readlink -f $toolchainfile)
toolchainfile="-DCMAKE_TOOLCHAIN_FILE=$toolchainfile"
Expand Down
2 changes: 1 addition & 1 deletion c/build_all/tirtos/azureiot.bld
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var Pkg = xdc.useModule('xdc.bld.PackageContents');
* Linux86 => -std=c99 for (at least sscanf() and strtof())
*/
var ccOpts = {
"ti.targets.arm.elf.M4" : " -ms -g --c99 -DTI_RTOS -DUSE_UPLOADTOBLOB",
"ti.targets.arm.elf.M4" : " -ms -g --c99 -DTI_RTOS",
};

var lnkOpts = {
Expand Down
4 changes: 2 additions & 2 deletions c/iothub_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set(iothub_client_ll_transport_c_files
../parson/parson.c
)

if(${use_uploadtoblob})
if(NOT ${dont_use_uploadtoblob})
set(iothub_client_ll_transport_c_files
${iothub_client_ll_transport_c_files}
./src/iothub_client_ll_uploadtoblob.c
Expand All @@ -31,7 +31,7 @@ set(iothub_client_ll_transport_h_files
../parson/parson.h
)

if(${use_uploadtoblob})
if(NOT ${dont_use_uploadtoblob})
set(iothub_client_ll_transport_h_files
${iothub_client_ll_transport_h_files}
./inc/iothub_client_ll_uploadtoblob.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(mbed_project_files
${CMAKE_CURRENT_SOURCE_DIR}/../../../../parson/parson.c
)

if(${USE_UPLOADTOBLOB})
if(NOT ${DONT_USE_UPLOADTOBLOB})
set(mbed_project_files
${mbed_project_files}
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/iothub_client_ll_uploadtoblob.c)
Expand Down
5 changes: 2 additions & 3 deletions c/iothub_client/build/mbed/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ call %build-root%\..\..\build\release\release_mbed_project.cmd %build-root%\..\s
if not %errorlevel%==0 exit /b %errorlevel%

if %skip_samples%==0 (
goto:eof
rem -----------------------------------------------------------------------------
rem -- build iothub client samples
rem -----------------------------------------------------------------------------
Expand All @@ -98,8 +97,8 @@ rem ----------------------------------------------------------------------------
rem -- build iothub longhaul tests
rem -----------------------------------------------------------------------------

call :compile longhaul_tests %build-root%\tests\longhaul_tests\mbed %longhaul_tests_download_bin_path%
if not %errorlevel%==0 exit /b %errorlevel%
rem call :compile longhaul_tests %build-root%\tests\longhaul_tests\mbed %longhaul_tests_download_bin_path%
rem if not %errorlevel%==0 exit /b %errorlevel%

goto:eof

Expand Down
2 changes: 1 addition & 1 deletion c/iothub_client/inc/iothub_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ extern "C"
*/
extern IOTHUB_CLIENT_RESULT IoTHubClient_SetOption(IOTHUB_CLIENT_HANDLE iotHubClientHandle, const char* optionName, const void* value);

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
/**
* @brief IoTHubClient_UploadToBlobAsync uploads data from memory to a file in Azure Blob Storage.
*
Expand Down
4 changes: 2 additions & 2 deletions c/iothub_client/inc/iothub_client_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ extern "C"
*/
extern IOTHUB_CLIENT_RESULT IoTHubClient_LL_SetOption(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, const char* optionName, const void* value);

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
/**
* @brief This API uploads to Azure Storage the content pointed to by @p source having the size @p size
* under the blob name devicename/@pdestinationFileName
Expand All @@ -339,7 +339,7 @@ extern "C"
*/
extern IOTHUB_CLIENT_RESULT IoTHubClient_LL_UploadToBlob(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, const char* destinationFileName, const unsigned char* source, size_t size);

#endif /*USE_UPLOADTOBLOB*/
#endif /*DONT_USE_UPLOADTOBLOB*/

#ifdef __cplusplus
}
Expand Down
6 changes: 3 additions & 3 deletions c/iothub_client/inc/iothub_client_ll_uploadtoblob.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* often not desired.
*/

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB

#ifndef IOTHUB_CLIENT_LL_UPLOADTOBLOB_H
#define IOTHUB_CLIENT_LL_UPLOADTOBLOB_H
Expand Down Expand Up @@ -48,5 +48,5 @@ typedef struct IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE_DATA* IOTHUB_CLIENT_LL_UPLOA
#endif /* IOTHUB_CLIENT_LL_UPLOADTOBLOB_H */

#else
#error "trying to #include iothub_client_ll_uploadtoblob.h in absence of #define USE_UPLOADTOBLOB"
#endif /*USE_UPLOADTOBLOB*/
#error "trying to #include iothub_client_ll_uploadtoblob.h in the presence of #define DONT_USE_UPLOADTOBLOB"
#endif /*DONT_USE_UPLOADTOBLOB*/
2 changes: 1 addition & 1 deletion c/iothub_client/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endfunction()
if(${use_http})
add_sample_directory(iothub_client_sample_http)
add_sample_directory(iothub_client_sample_http_shared)
if({${use_uploadtoblob})
if(NOT ${dont_use_uploadtoblob})
add_sample_directory(iothub_client_sample_upload_to_blob)
endif()
endif()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#ifndef USE_UPLOADTOBLOB
#error "trying to compile iothub_client_sample_upload_to_blob.c in absence of a #define USE_UPLOADTOBLOB"
#ifdef DONT_USE_UPLOADTOBLOB
#error "trying to compile iothub_client_sample_upload_to_blob.c while DONT_USE_UPLOADTOBLOB is #define'd"
#else

#include <stdio.h>
Expand Down Expand Up @@ -66,4 +66,4 @@ void iothub_client_sample_upload_to_blob_run(void)
platform_deinit();
}
}
#endif /*USE_UPLOADTOBLOB*/
#endif /*DONT_USE_UPLOADTOBLOB*/
36 changes: 18 additions & 18 deletions c/iothub_client/src/iothub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ typedef struct IOTHUB_CLIENT_INSTANCE_TAG
THREAD_HANDLE ThreadHandle;
LOCK_HANDLE LockHandle;
sig_atomic_t StopThread;
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
LIST_HANDLE savedDataToBeCleaned; /*list containing UPLOADTOBLOB_SAVED_DATA*/
#endif
} IOTHUB_CLIENT_INSTANCE;

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
typedef struct UPLOADTOBLOB_SAVED_DATA_TAG
{
unsigned char* source;
Expand All @@ -49,7 +49,7 @@ typedef struct UPLOADTOBLOB_SAVED_DATA_TAG
/*used by unittests only*/
const size_t IoTHubClient_ThreadTerminationOffset = offsetof(IOTHUB_CLIENT_INSTANCE, StopThread);

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
/*this function is called from _Destroy and from ScheduleWork_Thread to join finished blobUpload threads and free that memory*/
static void garbageCollectorImpl(IOTHUB_CLIENT_INSTANCE* iotHubClientInstance)
{
Expand Down Expand Up @@ -118,7 +118,7 @@ static int ScheduleWork_Thread(void* threadArgument)
/* Codes_SRS_IOTHUBCLIENT_01_039: [All calls to IoTHubClient_LL_DoWork shall be protected by the lock created in IotHubClient_Create.] */
IoTHubClient_LL_DoWork(iotHubClientInstance->IoTHubClientLLHandle);

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
garbageCollectorImpl(iotHubClientInstance);
#endif
(void)Unlock(iotHubClientInstance->LockHandle);
Expand Down Expand Up @@ -204,7 +204,7 @@ IOTHUB_CLIENT_HANDLE IoTHubClient_CreateFromConnectionString(const char* connect
}
else
{
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
/*Codes_SRS_IOTHUBCLIENT_02_059: [ IoTHubClient_CreateFromConnectionString shall create a LIST_HANDLE containing THREAD_HANDLE (created by future calls to IoTHubClient_UploadToBlobAsync). ]*/
if ((result->savedDataToBeCleaned = list_create()) == NULL)
{
Expand All @@ -222,7 +222,7 @@ IOTHUB_CLIENT_HANDLE IoTHubClient_CreateFromConnectionString(const char* connect
if (result->IoTHubClientLLHandle == NULL)
{
/* Codes_SRS_IOTHUBCLIENT_12_010: [If IoTHubClient_LL_CreateFromConnectionString fails then IoTHubClient_CreateFromConnectionString shall do clean - up and return NULL] */
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
list_destroy(result->savedDataToBeCleaned);
#endif
Lock_Deinit(result->LockHandle);
Expand Down Expand Up @@ -262,7 +262,7 @@ IOTHUB_CLIENT_HANDLE IoTHubClient_Create(const IOTHUB_CLIENT_CONFIG* config)
}
else
{
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
/*Codes_SRS_IOTHUBCLIENT_02_060: [ IoTHubClient_Create shall create a LIST_HANDLE containing THREAD_HANDLE (created by future calls to IoTHubClient_UploadToBlobAsync). ]*/
if ((result->savedDataToBeCleaned = list_create()) == NULL)
{
Expand All @@ -282,7 +282,7 @@ IOTHUB_CLIENT_HANDLE IoTHubClient_Create(const IOTHUB_CLIENT_CONFIG* config)
/* Codes_SRS_IOTHUBCLIENT_01_003: [If IoTHubClient_LL_Create fails, then IoTHubClient_Create shall return NULL.] */
/* Codes_SRS_IOTHUBCLIENT_01_031: [If IoTHubClient_Create fails, all resources allocated by it shall be freed.] */
Lock_Deinit(result->LockHandle);
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
list_destroy(result->savedDataToBeCleaned);
#endif
free(result);
Expand Down Expand Up @@ -322,7 +322,7 @@ IOTHUB_CLIENT_HANDLE IoTHubClient_CreateWithTransport(TRANSPORT_HANDLE transport
}
else
{
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
/*Codes_SRS_IOTHUBCLIENT_02_073: [ IoTHubClient_CreateWithTransport shall create a LIST_HANDLE that shall be used by IoTHubClient_UploadToBlobAsync. ]*/
if ((result->savedDataToBeCleaned = list_create()) == NULL)
{
Expand All @@ -343,7 +343,7 @@ IOTHUB_CLIENT_HANDLE IoTHubClient_CreateWithTransport(TRANSPORT_HANDLE transport
{
LogError("unable to IoTHubTransport_GetLock");
/*Codes_SRS_IOTHUBCLIENT_17_006: [ If IoTHubTransport_GetLock fails, then IoTHubClient_CreateWithTransport shall return NULL. ]*/
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
list_destroy(result->savedDataToBeCleaned);
#endif
free(result);
Expand All @@ -365,7 +365,7 @@ IOTHUB_CLIENT_HANDLE IoTHubClient_CreateWithTransport(TRANSPORT_HANDLE transport
{
LogError("unable to IoTHubTransport_GetLLTransport");
/*Codes_SRS_IOTHUBCLIENT_17_004: [ If IoTHubTransport_GetLLTransport fails, then IoTHubClient_CreateWithTransport shall return NULL. ]*/
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
list_destroy(result->savedDataToBeCleaned);
#endif
free(result);
Expand All @@ -376,7 +376,7 @@ IOTHUB_CLIENT_HANDLE IoTHubClient_CreateWithTransport(TRANSPORT_HANDLE transport
if (Lock(transportLock) != LOCK_OK)
{
LogError("unable to Lock");
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
list_destroy(result->savedDataToBeCleaned);
#endif
free(result);
Expand All @@ -391,7 +391,7 @@ IOTHUB_CLIENT_HANDLE IoTHubClient_CreateWithTransport(TRANSPORT_HANDLE transport
LogError("unable to IoTHubClient_LL_CreateWithTransport");
/*Codes_SRS_IOTHUBCLIENT_17_008: [ If IoTHubClient_LL_CreateWithTransport fails, then IoTHubClient_Create shall return NULL. ]*/
/*Codes_SRS_IOTHUBCLIENT_17_009: [ If IoTHubClient_LL_CreateWithTransport fails, all resources allocated by it shall be freed. ]*/
#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
list_destroy(result->savedDataToBeCleaned);
#endif
free(result);
Expand Down Expand Up @@ -429,7 +429,7 @@ void IoTHubClient_Destroy(IOTHUB_CLIENT_HANDLE iotHubClientHandle)
LogError("unable to Lock - - will still proceed to try to end the thread without locking");
}

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
/*Codes_SRS_IOTHUBCLIENT_02_069: [ IoTHubClient_Destroy shall free all data created by IoTHubClient_UploadToBlobAsync ]*/
/*wait for all uploading threads to finish*/
while (list_get_head_item(iotHubClientInstance->savedDataToBeCleaned) != NULL)
Expand All @@ -456,7 +456,7 @@ void IoTHubClient_Destroy(IOTHUB_CLIENT_HANDLE iotHubClientHandle)
/* Codes_SRS_IOTHUBCLIENT_01_006: [That includes destroying the IoTHubClient_LL instance by calling IoTHubClient_LL_Destroy.] */
IoTHubClient_LL_Destroy(iotHubClientInstance->IoTHubClientLLHandle);

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
if (iotHubClientInstance->savedDataToBeCleaned != NULL)
{
list_destroy(iotHubClientInstance->savedDataToBeCleaned);
Expand Down Expand Up @@ -697,7 +697,7 @@ IOTHUB_CLIENT_RESULT IoTHubClient_SetOption(IOTHUB_CLIENT_HANDLE iotHubClientHan
return result;
}

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
static int uploadingThread(void *data)
{
UPLOADTOBLOB_SAVED_DATA* savedData = (UPLOADTOBLOB_SAVED_DATA*)data;
Expand Down Expand Up @@ -743,7 +743,7 @@ static int uploadingThread(void *data)
}
#endif

#ifdef USE_UPLOADTOBLOB
#ifndef DONT_USE_UPLOADTOBLOB
IOTHUB_CLIENT_RESULT IoTHubClient_UploadToBlobAsync(IOTHUB_CLIENT_HANDLE iotHubClientHandle, const char* destinationFileName, const unsigned char* source, size_t size, IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK iotHubClientFileUploadCallback, void* context)
{
IOTHUB_CLIENT_RESULT result;
Expand Down Expand Up @@ -895,4 +895,4 @@ IOTHUB_CLIENT_RESULT IoTHubClient_UploadToBlobAsync(IOTHUB_CLIENT_HANDLE iotHubC
}
return result;
}
#endif /*USE_UPLOADTOBLOB*/
#endif /*DONT_USE_UPLOADTOBLOB*/
Loading

0 comments on commit 867fad9

Please sign in to comment.