Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add 32-bit Windows and consume Pthreads from NuGet #614

Merged
merged 39 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a6b7acd
Win32bit (#2)
lewk2 Mar 14, 2019
a68b007
-CMakeLists now uses glob to for pthread via nuget
lewk2 Mar 18, 2019
ceebc73
-move away from packages.config to script
lewk2 Mar 18, 2019
55a7475
-fix nuget install step
lewk2 Mar 18, 2019
dcc0b53
-remove packages.config
lewk2 Mar 18, 2019
fb2d133
-stupid appveyor variable fix
lewk2 Mar 18, 2019
ad23fa7
-libeay32.dll is now marked as delay load for win32 builds
lewk2 Mar 20, 2019
2cb7c77
-fix appveyor detection for build number version setting
lewk2 Mar 21, 2019
cd9775c
-fix hangover from local testing with appveyor build number
lewk2 Mar 21, 2019
201dc70
-trying out idea to get build and project files into subdir
lewk2 Mar 26, 2019
c938c3e
-use semicolon to separate build commands on one line in powershell
lewk2 Mar 26, 2019
fc1a916
Revert "-use semicolon to separate build commands on one line in powe…
lewk2 Mar 26, 2019
3e65632
Revert "-trying out idea to get build and project files into subdir"
lewk2 Mar 26, 2019
330d372
-dramatically reduced .gitignore to just block VS Code and Nuget loca…
lewk2 Mar 26, 2019
78b7ba0
-attempt to fix travis build
lewk2 Sep 3, 2019
b0c36c9
-merge v1.3.4 from upstream
lewk2 Sep 3, 2019
51808a4
Merge branch 'Win_Build_Option' into Branch_v1.3.2
lewk2 Sep 3, 2019
1239a0b
-attempt to use SRT_VERSION var for Appveyor
lewk2 Sep 3, 2019
27e1e1e
-fix env var read in appveyor
lewk2 Sep 3, 2019
3bf4673
-more guessing about appveyor var usage
lewk2 Sep 3, 2019
42e87c2
-move to use Update-AppveyorBuild PS command
lewk2 Sep 3, 2019
f3edeae
-changing order of build step application
lewk2 Sep 3, 2019
261dc82
-give up being clever with appveyor build for now
lewk2 Sep 3, 2019
af2d62a
-add support for VS2013 back
lewk2 Sep 3, 2019
dd6efe1
-update readme to reference pthread nuget usage
lewk2 Sep 3, 2019
ba0d617
-vs2013 is v12
lewk2 Sep 3, 2019
015a520
-merge latest changes from master
lewishub Sep 9, 2019
0423b24
-loosen GLOB for pthreads for 2013/2015 packages
lewishub Sep 9, 2019
757733e
-found and fixed variable typo
lewishub Sep 9, 2019
77a5dd7
Merge branch 'master' into Branch_v1.3.2
lewishub Oct 8, 2019
3717df1
-removed excessive msg about not finding appveyor
lewishub Oct 8, 2019
0c4939c
-remove 'rem'd' lines from gather-package
lewishub Oct 8, 2019
12e3f4c
-remove dedicated win32 MAF
lewishub Oct 8, 2019
31259b1
-remove changes to readme to back to master
lewishub Oct 8, 2019
a08f28d
-remove DLL metadata resources
lewishub Oct 8, 2019
fe035a5
-hanging } symbol in cmakelist
lewishub Oct 8, 2019
333caed
-hanging build version metadata trimmed
lewishub Oct 8, 2019
de74d32
-extra newline to filelist.maf at end
lewishub Oct 8, 2019
86c3b81
Revert version number from appveyor
lewk2 Oct 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
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'))

version: 1.0.0.{build}

configuration:
- Release
- Debug

image:
- Visual Studio 2015
- Visual Studio 2013
lewk2 marked this conversation as resolved.
Show resolved Hide resolved

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' }
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
- ps: $env:VS_VERSION = $VS_VERSION
# get pthreads
- ps: nuget install cinegy.pthreads-$FOLDER_PLATFORM -version 2.9.1.17
# 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 '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' }
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
- 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.3.4-$Env:APPVEYOR_BUILD_NUMBER"
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
- 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'))
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ignore Visual Studio Code project elements
/.vs
rndi marked this conversation as resolved.
Show resolved Hide resolved

#ignore any downloaded nuget packages
/packages
39 changes: 36 additions & 3 deletions CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,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 @@ -454,14 +455,28 @@ if (PTHREAD_LIBRARY AND PTHREAD_INCLUDE_DIR)
message(STATUS "Pthread include dir: ${PTHREAD_INCLUDE_DIR}")
elseif (WIN32 AND NOT MINGW)
# find pthread
find_path(PTHREAD_INCLUDE_DIR pthread.h HINTS C:/pthread-win32/include)
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
file(GLOB PTHREAD_INCLUDE_HINT ./packages/cinegy.pthreads-win*/sources)
if (PTHREAD_INCLUDE_HINT)
message(STATUS "PTHREAD_INCLUDE_HINT value: ${PTHREAD_INCLUDE_HINT}")
else()
message(FATAL_ERROR "Failed to find PTHREAD_INCLUDE_HINT with GLOB against nuget package.")
endif()

find_path(PTHREAD_INCLUDE_DIR pthread.h HINTS ${PTHREAD_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)
file(GLOB PTHREAD_LIB_HINT ./packages/cinegy.pthreads-win*/runtimes/win-*/native/release)
if (PTHREAD_LIB_HINT)
message(STATUS "PTHREAD_LIB_HINT value: ${PTHREAD_LIB_HINT}")
else()
message(FATAL_ERROR "Failed to find PTHREAD_LIB_HINT with GLOB against nuget package.")
endif()

find_library(PTHREAD_LIBRARY NAMES pthread pthread_dll pthread_lib HINTS ${PTHREAD_LIB_HINT})
if (PTHREAD_LIBRARY)
message(STATUS "Pthread library: ${PTHREAD_LIBRARY}")
else()
Expand Down Expand Up @@ -539,7 +554,15 @@ MafReadDir(srtcore filelist.maf
)

# Auto generated version file and add it to the HEADERS_srt list.
if(DEFINED ENV{APPVEYOR_BUILD_NUMBER})
set(SRT_VERSION_BUILD ON)
set(APPVEYOR_BUILD_NUMBER_STRING $ENV{APPVEYOR_BUILD_NUMBER})
message(STATUS "AppVeyor build environment detected: Adding build number to version header")
else()
message(STATUS "AppVeyor build environment NOT detected: NOT adding build number to version header")
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
endif()
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 All @@ -550,6 +573,15 @@ if (ENABLE_SHARED)
foreach (tar srt_virtual haicrypt_virtual)
set_target_properties(${tar} PROPERTIES POSITION_INDEPENDENT_CODE 1)
endforeach()

#add resource files to shared library, to set DLL metadata on Windows DLLs
if (WIN32 AND NOT MINGW)
MafReadDir(srtcore filelist_win32_shared.maf
SOURCES SOURCES_srt_shared_win32
PRIVATE_HEADERS HEADERS_srt_shared_win32
)
message(STATUS "WINDOWS detected: Adding sources to SRT shared project: ${SOURCES_srt_shared_win32}")
endif()
endif()

# Manual handling of dependency on virtual library
Expand All @@ -559,7 +591,7 @@ endif()
set (VIRTUAL_srt $<TARGET_OBJECTS:srt_virtual> $<TARGET_OBJECTS:haicrypt_virtual>)

if (srt_libspec_shared)
add_library(${TARGET_srt}_shared SHARED ${OBJECT_LIB_SUPPORT} ${VIRTUAL_srt})
add_library(${TARGET_srt}_shared SHARED ${OBJECT_LIB_SUPPORT} ${VIRTUAL_srt} ${SOURCES_srt_shared_win32} ${HEADERS_srt_shared_win32})
# shared libraries need PIC
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
set_property(TARGET ${TARGET_srt}_shared PROPERTY OUTPUT_NAME ${TARGET_srt})
Expand All @@ -570,6 +602,7 @@ if (srt_libspec_shared)
endif()
if (MICROSOFT)
target_link_libraries(${TARGET_srt}_shared PRIVATE ws2_32.lib)
set_target_properties(${TARGET_srt}_shared PROPERTIES LINK_FLAGS "/DELAYLOAD:libeay32.dll")
elseif (MINGW)
target_link_libraries(${TARGET_srt}_shared PRIVATE wsock32.lib ws2_32.lib)
elseif (APPLE)
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>
rndi marked this conversation as resolved.
Show resolved Hide resolved
21 changes: 16 additions & 5 deletions scripts/gather-package.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
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
rem md %APPVEYOR_BUILD_FOLDER%\package\pthread-win%FOLDER_PLATFORM%
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
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 +27,11 @@ 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%
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
(robocopy c:\openssl-win%FOLDER_PLATFORM%\ %APPVEYOR_BUILD_FOLDER%\package\openssl-win%FOLDER_PLATFORM% /s /e /np) ^& IF %ERRORLEVEL% GTR 1 exit %ERRORLEVEL%
rem (robocopy c:\pthread-win%FOLDER_PLATFORM%\ %APPVEYOR_BUILD_FOLDER%\package\pthread-win%FOLDER_PLATFORM% /s /e /np) ^& IF %ERRORLEVEL% GTR 1 exit %ERRORLEVEL%
exit 0
7 changes: 7 additions & 0 deletions srtcore/filelist_win32_shared.maf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


SOURCES
srt_shared.rc

PRIVATE HEADERS
../version.h
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
Binary file added srtcore/srt_shared.rc
Binary file not shown.
1 change: 1 addition & 0 deletions srtcore/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ written by
#define SRT_VERSION_MAJOR @SRT_VERSION_MAJOR@
#define SRT_VERSION_MINOR @SRT_VERSION_MINOR@
#define SRT_VERSION_PATCH @SRT_VERSION_PATCH@
#cmakedefine SRT_VERSION_BUILD @APPVEYOR_BUILD_NUMBER_STRING@

#define SRT_VERSION_STRING "@SRT_VERSION@"
#define SRT_VERSION_VALUE \
Expand Down