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

Set metadata in SRT DLL on Windows #639

Merged
merged 53 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
53 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
ac21344
-merge master to branch
lewishub Sep 10, 2019
51020d9
-merge in VS2013 build back
lewishub Sep 10, 2019
77a5dd7
Merge branch 'master' into Branch_v1.3.2
lewishub Oct 8, 2019
8b70a2c
Merge branch 'Branch_v1.3.2' into Win_Build_Option
lewishub Oct 8, 2019
462f71e
Merge remote-tracking branch 'remotes/origin/master' into Win_Build_O…
lewishub Oct 10, 2019
83a8784
-port small polish to metadata settings to branch
lewishub Oct 10, 2019
5460e4c
-ported a missed change for cygwin cmake fix
lewishub Oct 10, 2019
c8034e4
-remove accidental double block on cmakelist
lewishub Oct 10, 2019
6cb2630
-undone delete block that i didn't actually create
lewishub Oct 10, 2019
d9de9a0
Merge remote-tracking branch 'remotes/origin/master' into Win_Build_O…
Oct 22, 2019
c9898ac
-add script to set appveyor version to build
lewishub Oct 22, 2019
4e94fa2
-run version script after cmake
lewishub Oct 22, 2019
a1b0b62
Appveyorversion (#3)
lewk2 Oct 22, 2019
b7732b6
-set possibly questionable copyright to empty
lewishub Oct 22, 2019
0ccf1a1
-added extra MafReadFile tags (@maxlovic request)
Oct 23, 2019
55e9c1c
Repo Commit Metadata
lewk2 Oct 23, 2019
82241bd
-extra newlines at end for consistency
Oct 23, 2019
884139d
Merge branch 'Win_Build_Option' of https://github.com/Cinegy/srt into…
Oct 23, 2019
8ad2a5f
-more newlines for consistency
Oct 23, 2019
4117180
-removed accidental sub-module reference
lewishub Oct 24, 2019
5208f83
-change spaces for tags to match convention
Oct 24, 2019
c816426
-replace win32+not mingw with 'microsoft' macro
lewishub Oct 24, 2019
93299a0
-remove accidental googletest ref (again)
Nov 4, 2019
ef9ce39
Merge branch 'Win_Build_Option' of https://github.com/Cinegy/srt into…
Nov 4, 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
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ build_script:
- 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: Update-AppveyorBuild -Version "1.0.0-$Env:APPVEYOR_BUILD_NUMBER"
- ps: ./scripts/set-version-metadata.ps1
- ps: msbuild SRT.sln /p:Configuration=$Env:CONFIGURATION /p:Platform=$DEVENV_PLATFORM

test_script:
Expand Down
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,12 @@ 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")
endif()

configure_file("srtcore/version.h.in" "version.h" @ONLY)

list(INSERT HEADERS_srt 0 "${CMAKE_CURRENT_BINARY_DIR}/version.h")
Expand All @@ -577,6 +583,17 @@ 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)
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
MafReadDir(srtcore filelist.maf
SOURCES_WIN32_SHARED SOURCES_srt_shared_win32
PRIVATE_HEADERS_WIN32_SHARED HEADERS_srt_shared_win32
)

message(STATUS "WINDOWS detected: Adding sources to SRT shared project: ${SOURCES_srt_shared_win32}")
message(STATUS "WINDOWS detected: Adding private headers to SRT shared project: ${HEADERS_srt_shared_win32}")
endif()
endif()

# Manual handling of dependency on virtual library
Expand All @@ -586,7 +603,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 @@ -597,6 +614,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
2 changes: 2 additions & 0 deletions scripts/haiUtil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ MACRO(MafReadDir directory maffile)
PUBLIC_HEADERS # installable headers for include
PROTECTED_HEADERS # installable headers used by other headers
PRIVATE_HEADERS # non-installable headers
SOURCES_WIN32_SHARED # windows specific SOURCES
PRIVATE_HEADERS_WIN32_SHARED # windows specific PRIVATE_HEADERS
OPTIONS
)
cmake_parse_arguments(MAFREAD_VAR "" "${MAFREAD_TAGS}" "" ${ARGN})
Expand Down
47 changes: 47 additions & 0 deletions scripts/set-version-metadata.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Script for reading generated version values and updating metadata properties

#read major / minor version values from version.h (generated by cmake via version.h.in)
$majorVer=99
$minorVer=99
$patchVer=0
$buildNum=0

#define regular expressions to be used when checking for #define statements
$versionSniffingRegex = "(\s*#define\s+(\S+)\s+)(\d+)"

#read generated file, load values from this with regular expression
Get-Content ".\version.h" | Where-Object { $_ -match $versionSniffingRegex } | ForEach-Object {
switch ($Matches[2])
{
"SRT_VERSION_MAJOR" { $majorVer = $Matches[3] }
"SRT_VERSION_MINOR" { $minorVer = $Matches[3] }
"SRT_VERSION_PATCH" { $patchVer = $Matches[3] }
"SRT_VERSION_BUILD" { $buildNum = $Matches[3] }
}
}

$FileDescriptionBranchCommitValue = "SRT Local Build"

if($Env:APPVEYOR){
#make AppVeyor update with this new version number
Update-AppveyorBuild -Version "$majorVer.$minorVer.$patchVer.$buildNum"
$FileDescriptionBranchCommitValue = "$Env:APPVEYOR_REPO_NAME - $($Env:APPVEYOR_REPO_BRANCH) ($($Env:APPVEYOR_REPO_COMMIT.substring(0,8)))"
}

#find C++ resource files and update file description with branch / commit details
$FileDescriptionStringRegex = '(\bVALUE\s+\"FileDescription\"\s*\,\s*\")([^\"]*\\\")*[^\"]*(\")'

Get-ChildItem -Path "./srtcore/srt_shared.rc" | ForEach-Object {
$fileName = $_
Write-Host "Processing metadata changes for file: $fileName"

$FileLines = Get-Content -path $fileName

for($i=0;$i -lt $FileLines.Count;$i++)
{
$FileLines[$i] = $FileLines[$i] -Replace $FileDescriptionStringRegex, "`${1}$FileDescriptionBranchCommitValue`${3}"
}

[System.IO.File]::WriteAllLines($fileName.FullName, $FileLines)
}

6 changes: 6 additions & 0 deletions srtcore/filelist.maf
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ threadname.h
utilities.h
window.h

SOURCES_WIN32_SHARED
lewk2 marked this conversation as resolved.
Show resolved Hide resolved
srt_shared.rc

PRIVATE_HEADERS_WIN32_SHARED
../version.h

45 changes: 45 additions & 0 deletions srtcore/srt_shared.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Microsoft Visual C++ generated resource script.
//
#include "version.h"
#include "winres.h"

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
#ifdef SRT_VERSION_BUILD
FILEVERSION SRT_VERSION_MAJOR, SRT_VERSION_MINOR, SRT_VERSION_PATCH, SRT_VERSION_BUILD
#else
FILEVERSION SRT_VERSION_MAJOR, SRT_VERSION_MINOR, SRT_VERSION_PATCH
#endif
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "CompanyName", "SRT Alliance"
VALUE "FileDescription", "SRT Local Build"
VALUE "InternalName", "srt.dll"
VALUE "LegalCopyright", ""
VALUE "OriginalFilename", "srt.dll"
VALUE "ProductName", "SRT"
VALUE "ProductVersion", SRT_VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x809, 1200
END
END

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