Skip to content

Commit

Permalink
Add 32-bit Windows and consume Pthreads from NuGet (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewk2 authored and rndi committed Oct 10, 2019
1 parent ef8ba13 commit 0e36bf2
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 29 deletions.
41 changes: 22 additions & 19 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
init:
# -ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# -ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

configuration:
- Release
- Debug
Expand All @@ -11,31 +11,34 @@ image:

platform:
- x64
- x86

build_script:
# build pthread
- git clone https://github.com/GerHobbelt/pthread-win32.git C:/pthread-src
- ps: "if ( $Env:APPVEYOR_BUILD_WORKER_IMAGE -eq 'Visual Studio 2013' ) { $VS_VERSION='2013' } else { $VS_VERSION='2015' }"
- ps: "msbuild C:/pthread-src/pthread.${VS_VERSION}.sln /p:Configuration=$Env:CONFIGURATION /p:Platform=x64"
- ps: mkdir C:/pthread-win32
- ps: mkdir C:/pthread-win32/include
- ps: mkdir C:/pthread-win32/lib
- ps: cp C:/pthread-src/*.h C:/pthread-win32/include
- ps: cp C:/pthread-src/bin/x64_MSVC${VS_VERSION}.${Env:CONFIGURATION}/pthread_lib.lib C:/pthread-win32/lib
# prep shared variables
- ps: if ( $Env:PLATFORM -eq 'x86' ) { $DEVENV_PLATFORM = 'Win32' } else { $DEVENV_PLATFORM = 'x64' }
- ps: if ( $Env:PLATFORM -eq 'x86' ) { $FOLDER_PLATFORM = 'win32' } else { $FOLDER_PLATFORM = 'win64' }
- ps: if ( $Env:APPVEYOR_BUILD_WORKER_IMAGE -eq 'Visual Studio 2013' ) { $VS_VERSION='2013' } else { $VS_VERSION='2015' }
- ps: $env:VS_VERSION = $VS_VERSION
# get pthreads
- ps: nuget install cinegy.pthreads-$FOLDER_PLATFORM-$VS_VERSION -version 2.9.1.24
# build SRT
- ps: if ( $VS_VERSION -eq "2013" ) { $CMAKE_GENERATOR = "Visual Studio 12 2013 Win64" } else { $CMAKE_GENERATOR = "Visual Studio 14 2015 Win64" }
- ps: if ( $VS_VERSION -eq "2013" ) { $ENABLE_UNITTESTS = "OFF" } else { $ENABLE_UNITTESTS = "ON" }
- ps: if ( $VS_VERSION -eq '2013' -and $Env:PLATFORM -eq 'x86' ) { $CMAKE_GENERATOR = 'Visual Studio 12 2013' }
- ps: if ( $VS_VERSION -eq '2013' -and $Env:PLATFORM -eq 'x64' ) { $CMAKE_GENERATOR = 'Visual Studio 12 2013 Win64' }
- ps: if ( $VS_VERSION -eq '2015' -and $Env:PLATFORM -eq 'x86' ) { $CMAKE_GENERATOR = 'Visual Studio 14 2015' }
- ps: if ( $VS_VERSION -eq '2015' -and $Env:PLATFORM -eq 'x64' ) { $CMAKE_GENERATOR = 'Visual Studio 14 2015 Win64' }
- ps: if ( $VS_VERSION -eq '2015' ) { $ENABLE_UNITTESTS = 'ON' } else { $ENABLE_UNITTESTS = 'OFF' }
- ps: cmake . -G"$CMAKE_GENERATOR" -DCMAKE_BUILD_TYPE=$Env:CONFIGURATION -DENABLE_UNITTESTS="$ENABLE_UNITTESTS"
- ps: msbuild SRT.sln /p:Configuration=$Env:CONFIGURATION /p:Platform=x64

- ps: Update-AppveyorBuild -Version "1.0.0-$Env:APPVEYOR_BUILD_NUMBER"
- ps: msbuild SRT.sln /p:Configuration=$Env:CONFIGURATION /p:Platform=$DEVENV_PLATFORM

test_script:
- ps: if ( $VS_VERSION -ne "2013" ) { ctest --extra-verbose -C $Env:CONFIGURATION }
- ps: if ( $VS_VERSION -eq '2015' ) { ctest --extra-verbose -C $Env:CONFIGURATION }

after_build:
- cmd: >-
scripts/gather-package.bat
7z a SRT-%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%-%APPVEYOR_BUILD_VERSION%.zip %APPVEYOR_BUILD_FOLDER%\package\*
appveyor PushArtifact SRT-%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%-%APPVEYOR_BUILD_VERSION%.zip
7z a SRT-%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%-Win%PLATFORM%-%VS_VERSION%-%APPVEYOR_BUILD_VERSION%.zip %APPVEYOR_BUILD_FOLDER%\package\*
appveyor PushArtifact SRT-%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%-Win%PLATFORM%-%VS_VERSION%-%APPVEYOR_BUILD_VERSION%.zip
on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
24 changes: 20 additions & 4 deletions CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ set (haicrypt_libspec VIRTUAL)
set (srtpack_libspec_common)
if (srt_libspec_shared)
list(APPEND srtpack_libspec_common ${TARGET_srt}_shared)

endif()
if (srt_libspec_static)
list(APPEND srtpack_libspec_common ${TARGET_srt}_static)
Expand Down Expand Up @@ -463,15 +464,29 @@ elseif (WIN32 AND NOT MINGW)
find_package(pthreads QUIET)

if (NOT PTHREAD_INCLUDE_DIR OR NOT PTHREAD_LIBRARY)
# find pthread
find_path(PTHREAD_INCLUDE_DIR pthread.h HINTS C:/pthread-win32/include)
#search package folders with GLOB to add as extra hint for headers
file(GLOB PTHREAD_PACKAGE_INCLUDE_HINT ./packages/cinegy.pthreads-win*/sources)
if (PTHREAD_PACKAGE_INCLUDE_HINT)
message(STATUS "PTHREAD_PACKAGE_INCLUDE_HINT value: ${PTHREAD_PACKAGE_INCLUDE_HINT}")
endif()

# find pthread header
find_path(PTHREAD_INCLUDE_DIR pthread.h HINTS C:/pthread-win32/include ${PTHREAD_PACKAGE_INCLUDE_HINT})

if (PTHREAD_INCLUDE_DIR)
message(STATUS "Pthread include dir: ${PTHREAD_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Failed to find pthread.h. Specify PTHREAD_INCLUDE_DIR.")
endif()

find_library(PTHREAD_LIBRARY NAMES pthread pthread_dll pthread_lib HINTS C:/pthread-win32/lib C:/pthread-win64/lib)

#search package folders with GLOB to add as extra hint for libs
file(GLOB PTHREAD_PACKAGE_LIB_HINT ./packages/cinegy.pthreads-win*/runtimes/win-*/native/release)
if (PTHREAD_PACKAGE_LIB_HINT)
message(STATUS "PTHREAD_PACKAGE_LIB_HINT value: ${PTHREAD_PACKAGE_LIB_HINT}")
endif()

#find pthread library
find_library(PTHREAD_LIBRARY NAMES pthread pthread_dll pthread_lib HINTS C:/pthread-win32/lib C:/pthread-win64/lib ${PTHREAD_PACKAGE_LIB_HINT})
if (PTHREAD_LIBRARY)
message(STATUS "Pthread library: ${PTHREAD_LIBRARY}")
else()
Expand Down Expand Up @@ -551,6 +566,7 @@ MafReadDir(srtcore filelist.maf

# Auto generated version file and add it to the HEADERS_srt list.
configure_file("srtcore/version.h.in" "version.h" @ONLY)

list(INSERT HEADERS_srt 0 "${CMAKE_CURRENT_BINARY_DIR}/version.h")
include_directories("${CMAKE_CURRENT_BINARY_DIR}")

Expand Down
11 changes: 11 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<configuration>
<config>
<add key="dependencyVersion" value="Highest" />
<add key="globalPackagesFolder" value="c:\packages" />
<add key="repositoryPath" value="packages" />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<!--<add key="Local Source" value="D:\Data\Dev\LocalNuget" />-->
</packageSources>
</configuration>
21 changes: 15 additions & 6 deletions scripts/gather-package.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
rem Create empty directories for package bundle
@echo off

IF "%PLATFORM%"=="x86" (
SET FOLDER_PLATFORM="32"
) ELSE IF "%PLATFORM%"=="x64" (
SET FOLDER_PLATFORM="64"
) ELSE (
echo "Platform %PLATFORM% is not supported"
exit 1
)

md %APPVEYOR_BUILD_FOLDER%\package
md %APPVEYOR_BUILD_FOLDER%\package\include
md %APPVEYOR_BUILD_FOLDER%\package\include\win
md %APPVEYOR_BUILD_FOLDER%\package\bin
md %APPVEYOR_BUILD_FOLDER%\package\lib
md %APPVEYOR_BUILD_FOLDER%\package\pthread-win32
md %APPVEYOR_BUILD_FOLDER%\package\openssl-win64
md %APPVEYOR_BUILD_FOLDER%\package\openssl-win%FOLDER_PLATFORM%

rem Gather SRT includes, binaries and libs
copy %APPVEYOR_BUILD_FOLDER%\version.h %APPVEYOR_BUILD_FOLDER%\package\include\
Expand All @@ -18,9 +26,10 @@ copy %APPVEYOR_BUILD_FOLDER%\common\win\*.h %APPVEYOR_BUILD_FOLDER%\package\incl
copy %APPVEYOR_BUILD_FOLDER%\%CONFIGURATION%\*.exe %APPVEYOR_BUILD_FOLDER%\package\bin\
copy %APPVEYOR_BUILD_FOLDER%\%CONFIGURATION%\*.dll %APPVEYOR_BUILD_FOLDER%\package\bin\
copy %APPVEYOR_BUILD_FOLDER%\%CONFIGURATION%\*.lib %APPVEYOR_BUILD_FOLDER%\package\lib\
copy %APPVEYOR_BUILD_FOLDER%\%CONFIGURATION%\*.lib %APPVEYOR_BUILD_FOLDER%\package\lib\
IF "%CONFIGURATION%"=="Debug" (
copy %APPVEYOR_BUILD_FOLDER%\%CONFIGURATION%\*.pdb %APPVEYOR_BUILD_FOLDER%\package\bin\
)

rem gather 3rd party elements
(robocopy c:\openssl-win64\ %APPVEYOR_BUILD_FOLDER%\package\openssl-win64 /s /e /np) ^& IF %ERRORLEVEL% GTR 1 exit %ERRORLEVEL%
(robocopy c:\pthread-win32\ %APPVEYOR_BUILD_FOLDER%\package\pthread-win32 /s /e /np) ^& IF %ERRORLEVEL% GTR 1 exit %ERRORLEVEL%
rem gather 3rd party openssl elements
(robocopy c:\openssl-win%FOLDER_PLATFORM%\ %APPVEYOR_BUILD_FOLDER%\package\openssl-win%FOLDER_PLATFORM% /s /e /np) ^& IF %ERRORLEVEL% GTR 1 exit %ERRORLEVEL%
exit 0

0 comments on commit 0e36bf2

Please sign in to comment.