Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tameraw committed Nov 17, 2016
2 parents 7da8858 + 7448850 commit 5b3a502
Show file tree
Hide file tree
Showing 17 changed files with 744 additions and 87 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -239,3 +239,5 @@ javawrapper/device/samples/file-upload-sample/target
javawrapper/device/samples/send-event-sample/target
javawrapper/device/test/target
javawrapper/device/samples/target
*.so
python/build_all/windows/pyenv.bat
11 changes: 9 additions & 2 deletions c/build_all/windows/build_client.cmd
Expand Up @@ -28,6 +28,7 @@ set CMAKE_use_wsio=OFF
set CMAKE_build_python=OFF
set CMAKE_build_javawrapper=OFF
set CMAKE_no_logging=OFF
set CMAKE_skip_unittests=OFF

:args-loop
if "%1" equ "" goto args-done
Expand All @@ -37,6 +38,7 @@ if "%1" equ "--use-websockets" goto arg-use-websockets
if "%1" equ "--buildpython" goto arg-build-python
if "%1" equ "--build-javawrapper" goto arg-build-javawrapper
if "%1" equ "--no-logging" goto arg-no-logging
if "%1" equ "--skip-unittests" goto arg-skip-unittests
call :usage && exit /b 1

:arg-build-config
Expand Down Expand Up @@ -72,6 +74,10 @@ goto args-continue
set CMAKE_no_logging=ON
goto args-continue

:arg-skip-unittests
set CMAKE_skip_unittests=ON
goto args-continue

:args-continue
shift
goto args-loop
Expand Down Expand Up @@ -99,11 +105,11 @@ pushd %USERPROFILE%\%cmake-output%

if %build-platform% == Win32 (
echo ***Running CMAKE for Win32***
cmake %build-root% -Duse_wsio:BOOL=%CMAKE_use_wsio% -Dbuild_python:STRING=%CMAKE_build_python% -Dbuild_javawrapper:BOOL=%CMAKE_build_javawrapper% -Dno_logging:BOOL=%CMAKE_no_logging%
cmake %build-root% -Dskip_unittests:BOOL=%CMAKE_skip_unittests% -Duse_wsio:BOOL=%CMAKE_use_wsio% -Dbuild_python:STRING=%CMAKE_build_python% -Dbuild_javawrapper:BOOL=%CMAKE_build_javawrapper% -Dno_logging:BOOL=%CMAKE_no_logging%
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
) else (
echo ***Running CMAKE for Win64***
cmake %build-root% -G "Visual Studio 14 Win64" -Dbuild_python:STRING=%CMAKE_build_python% -Dbuild_javawrapper:BOOL=%CMAKE_build_javawrapper% -Dno_logging:BOOL=%CMAKE_no_logging%
cmake %build-root% -G "Visual Studio 14 Win64" -Dskip_unittests:BOOL=%CMAKE_skip_unittests% -Duse_wsio:BOOL=%CMAKE_use_wsio% -Dbuild_python:STRING=%CMAKE_build_python% -Dbuild_javawrapper:BOOL=%CMAKE_build_javawrapper% -Dno_logging:BOOL=%CMAKE_no_logging%
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
)

Expand All @@ -130,4 +136,5 @@ echo --config ^<value^> [Debug] build configuration (e.g. Debug, Releas
echo --platform ^<value^> [Win32] build platform (e.g. Win32, x64, ...)
echo --buildpython ^<value^> [2.7] build python extension (e.g. 2.7, 3.4, ...)
echo --no-logging Disable logging
echo --use-websockets Enable websocket support for AMQP and MQTT
goto :eof
3 changes: 3 additions & 0 deletions c/configs/azure_iot_sdksFunctions.cmake
Expand Up @@ -16,6 +16,9 @@ function(linkUAMQP whatExecutableIsBuilding)

file(COPY $ENV{OpenSSLDir}/bin/libeay32.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug)
file(COPY $ENV{OpenSSLDir}/bin/ssleay32.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug)

file(COPY $ENV{OpenSSLDir}/bin/libeay32.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Release)
file(COPY $ENV{OpenSSLDir}/bin/ssleay32.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Release)
endif()
else()
target_link_libraries(${whatExecutableIsBuilding} uamqp aziotsharedutil ssl crypto)
Expand Down
Expand Up @@ -291,7 +291,7 @@ public void connectionLost(Throwable throwable)

// Codes_SRS_MQTTIOTHUBCONNECTION_15_018: [The maximum wait interval
// until a reconnect is attempted shall be 60 seconds.]
Thread.sleep(TransportUtils.generateSleepInterval(currentReconnectionAttempt) * 1000);
Thread.sleep(TransportUtils.generateSleepInterval(currentReconnectionAttempt));
} catch (InterruptedException exception)
{
// do nothing, reconnection attempts will continue
Expand Down
10 changes: 3 additions & 7 deletions jenkins/windows_python.cmd
Expand Up @@ -10,12 +10,8 @@ for %%i in ("%build-root%") do set build-root=%%~fi

REM -- Python --
cd %build-root%\python\build_all\windows
if "%1" equ "--use-cmake" (
echo Building client using cmake
call build_client.cmd %2 %3
) else (
echo Building client using Nuget packages
call build.cmd --run-ut
)
echo Building client using cmake
call build_client.cmd %2 %3

if errorlevel 1 exit /b 1
cd %build-root%
47 changes: 36 additions & 11 deletions python/build_all/windows/build_client.cmd
@@ -1,9 +1,19 @@
@REM Copyright (c) Microsoft. All rights reserved.
@REM Licensed under the MIT license. See LICENSE file in the project root for full license information.

@setlocal EnableExtensions EnableDelayedExpansion
@echo off

rem ensure python.exe exists
where /q python.exe
if errorlevel 1 goto :NeedPython

python python_version_check.py >pyenv.bat
if errorlevel 1 goto :NeedPython

call pyenv.bat

@setlocal EnableExtensions EnableDelayedExpansion

set build-root=%~dp0
rem // resolve to fully qualified path
for %%i in ("%build-root%") do set build-root=%%~fi
Expand All @@ -13,24 +23,16 @@ rem ----------------------------------------------------------------------------
rem -- check prerequisites
rem -----------------------------------------------------------------------------

rem ensure python.exe exists
where /q python.exe
if errorlevel 1 goto :NeedPython

rem -----------------------------------------------------------------------------
rem -- detect Python x86 or x64 version, select build target accordingly
rem -----------------------------------------------------------------------------

REM target may be set to 64 bit build if a Python x64 detected
set build-platform=Win32
set build-config=Release
set build-python=2.7
set wheel=0
set platname=win32
set use-websockets=OFF

python python_version_check.py >pyenv.bat
if errorlevel 1 goto :NeedPython
call pyenv.bat
@Echo Using Python found in: %PYTHON_PATH%, building Python %build-python% %build-platform% extension
goto :args-loop

Expand All @@ -43,6 +45,8 @@ exit /b 1
if "%1" equ "" goto args-done
if "%1" equ "--config" goto arg-build-config
if "%1" equ "--wheel" goto arg-build-wheel
if "%1" equ "--use-websockets" goto arg-use-websockets

call :usage && exit /b 1

:arg-build-config
Expand All @@ -55,6 +59,10 @@ goto args-continue
set wheel=1
goto args-continue

:arg-use-websockets
set use-websockets=ON
goto args-continue

:args-continue
shift
goto args-loop
Expand All @@ -67,7 +75,13 @@ set cmake-output=cmake_%build-platform%

REM -- C --
cd %build-root%..\..\..\c\build_all\windows
call build_client.cmd --platform %build-platform% --buildpython %build-python% --config %build-config%

if %use-websockets% == ON (
call build_client.cmd --platform %build-platform% --buildpython %build-python% --config %build-config% --use-websockets --skip-unittests
) else (
call build_client.cmd --platform %build-platform% --buildpython %build-python% --config %build-config% --skip-unittests
)

if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
cd %build-root%

Expand Down Expand Up @@ -110,3 +124,14 @@ if %wheel%==1 (
dir dist
echo Yet another Python wheel done
)
goto :eof

:usage
echo build_client.cmd [options]
echo options:
echo --config ^<value^> [Debug] build configuration (e.g. Debug, Release)
echo --platform ^<value^> [Win32] build platform (e.g. Win32, x64, ...)
echo --buildpython ^<value^> [2.7] build python extension (e.g. 2.7, 3.4, ...)
echo --no-logging Disable logging
echo --use-websockets Enable websocket support for AMQP and MQTT
goto :eof
2 changes: 2 additions & 0 deletions python/build_all/windows/python_version_check.py
Expand Up @@ -22,6 +22,8 @@ def __str__(self):
else:
if (plat[0] != "32bit"):
raise PlatformError("Require Windows CPython >= 2.7 or >= 3.4 32bit or 64bit version")
print ("SET build-platform=Win32")

print ("SET PYTHON_PATH=%s" % os.path.dirname(sys.executable))
print ("SET build-python=%s.%s" % (sys.version_info[0],sys.version_info[1]))
sys.exit(0)
Expand Down
4 changes: 4 additions & 0 deletions python/device/iothub_client_python/CMakeLists.txt
Expand Up @@ -75,5 +75,9 @@ if(${use_mqtt})
include_directories(${IOTHUB_CLIENT_MQTT_TRANSPORT_INC_FOLDER} ${MQTT_INC_FOLDER})
endif()

if(${use_wsio})
add_definitions(-DUSE_WEBSOCKETS)
endif()

add_subdirectory(src)
add_subdirectory(test)
47 changes: 35 additions & 12 deletions python/device/iothub_client_python/src/CMakeLists.txt
Expand Up @@ -7,9 +7,12 @@ set(iothub_client_python_c_files
./iothub_client_python.cpp
)


if(WIN32)
set(iothub_client_python_c_files ${iothub_client_python_c_files} ../windows/dllmain.c ../windows/iothub_client.def)
if(${use_wsio})
set(iothub_client_python_c_files ${iothub_client_python_c_files} ../windows/dllmain.c ../windows/iothub_client_ws.def)
else()
set(iothub_client_python_c_files ${iothub_client_python_c_files} ../windows/dllmain.c ../windows/iothub_client.def)
endif()
endif()

include_directories(.)
Expand All @@ -25,16 +28,36 @@ IF(WIN32)
SET_TARGET_PROPERTIES(iothub_client_python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32)

target_link_libraries(
iothub_client_python
iothub_client_mqtt_transport
iothub_client_http_transport
iothub_client_amqp_transport
iothub_client
uamqp
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
)
if(${use_wsio})
target_link_libraries(
iothub_client_python
iothub_client_http_transport
iothub_client_amqp_transport
iothub_client_amqp_ws_transport
iothub_client_mqtt_transport
iothub_client_mqtt_ws_transport
iothub_client
uamqp
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
)
else()
target_link_libraries(
iothub_client_python
iothub_client_http_transport
iothub_client_amqp_transport
iothub_client_mqtt_transport
iothub_client
uamqp
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
)
endif()

if(${use_wsio} AND WIN32)
file(COPY $ENV{OpenSSLDir}/bin/libeay32.dll DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../../samples)
file(COPY $ENV{OpenSSLDir}/bin/ssleay32.dll DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../../samples)
endif()

linkSharedUtil(iothub_client_python)
linkUAMQP(iothub_client_python)

0 comments on commit 5b3a502

Please sign in to comment.