Skip to content

Commit dd5d64c

Browse files
authored
Merge pull request #538 from metsma/openssl
Upgrade OpenSSL 3.0.9 and use vcpkg manifest
2 parents 133ed5f + 5d5acf3 commit dd5d64c

31 files changed

+805
-199
lines changed

.github/workflows/build.yml

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,24 +150,38 @@ jobs:
150150
MAKEFLAGS: ""
151151
VER_SUFFIX: .VS${{ matrix.toolset }}
152152
VERSION: 3.16.0.${{ github.run_number }}
153-
VCPKG_OVERLAY_TRIPLETS: ${{ github.workspace }}/patches/vcpkg-triplets
154-
VCPKG_OVERLAY_PORTS: ${{ github.workspace }}/patches/vcpkg-ports
155153
steps:
156154
- name: Checkout
157155
uses: actions/checkout@v3
158156
with:
159157
submodules: recursive
160-
- name: Prepare vcpkg
161-
uses: lukka/run-vcpkg@v7
158+
- uses: mad9000/actions-find-and-replace-string@3
159+
id: path
162160
with:
163-
vcpkgArguments: >-
164-
"xml-security-c:x86-windows-v${{ matrix.toolset }}"
165-
"xml-security-c:x64-windows-v${{ matrix.toolset }}"
166-
"zlib:x86-windows-v${{ matrix.toolset }}"
167-
"zlib:x64-windows-v${{ matrix.toolset }}"
168-
"boost-test:x86-windows-v${{ matrix.toolset }}"
169-
"boost-test:x64-windows-v${{ matrix.toolset }}"
170-
vcpkgGitCommitId: 9b9c2758ece1d8ac0de90589730bb5ccf45c0874
161+
source: ${{ github.workspace }}
162+
find: '\'
163+
replace: '/'
164+
replaceAll: true
165+
- name: Prepare vcpkg X64
166+
uses: lukka/run-vcpkg@v11
167+
with:
168+
vcpkgGitCommitId: 5787cfa699a75805ef41938ec66bc7492714d290
169+
vcpkgJsonGlob: ${{ steps.path.outputs.value }}/vcpkg.json
170+
runVcpkgInstall: true
171+
runVcpkgFormatString: "[`install`, `--recurse`, `--clean-after-build`, `--x-install-root`, `$[env.VCPKG_INSTALLED_DIR]`, `--triplet`, `$[env.VCPKG_DEFAULT_TRIPLET]`, `--x-feature`, `tests`]"
172+
env:
173+
VCPKG_DEFAULT_TRIPLET: x64-windows-v${{ matrix.toolset }}
174+
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed
175+
- name: Prepare vcpkg X86
176+
uses: lukka/run-vcpkg@v11
177+
with:
178+
vcpkgGitCommitId: 5787cfa699a75805ef41938ec66bc7492714d290
179+
vcpkgJsonGlob: ${{ steps.path.outputs.value }}/vcpkg.json
180+
runVcpkgInstall: true
181+
runVcpkgFormatString: "[`install`, `--recurse`, `--clean-after-build`, `--x-install-root`, `$[env.VCPKG_INSTALLED_DIR]`, `--triplet`, `$[env.VCPKG_DEFAULT_TRIPLET]`, `--x-feature`, `tests`]"
182+
env:
183+
VCPKG_DEFAULT_TRIPLET: x86-windows-v${{ matrix.toolset }}
184+
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed
171185
- name: Install dependencies
172186
run: choco install doxygen.install swig -y > $null
173187
- name: Build xsd
@@ -179,7 +193,8 @@ jobs:
179193
-toolset ${{ matrix.toolset }} `
180194
-vcvars "${{ matrix.vcvars }}" `
181195
-swig C:/ProgramData/chocolatey/bin/swig.exe `
182-
-doxygen "C:/Program files/doxygen/bin/doxygen.exe"
196+
-doxygen "C:/Program files/doxygen/bin/doxygen.exe" `
197+
-boost
183198
- name: Archive artifacts
184199
uses: actions/upload-artifact@v3
185200
with:

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
1. Install dependencies and necessary tools from
8686
* [Visual Studio Community 2017/2019/2022](https://www.visualstudio.com/downloads/)
8787
* [CMake](http://www.cmake.org)
88+
* [vcpkg](https://vcpkg.io/)
8889
* [Swig](http://swig.org/download.html) - Optional, for C# and Java bindings
8990
* [Doxygen](https://www.doxygen.nl/download.html) - Optional, for generationg documentation
9091
* [Wix toolset](http://wixtoolset.org/releases/) - Optional, for creating Windows installation packages
@@ -106,8 +107,9 @@
106107

107108
4. Configure
108109

109-
cmake -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake" `
110+
cmake -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake `
110111
-DVCPKG_TARGET_TRIPLET=x64-windows-v142 `
112+
-DVCPKG_MANIFEST_FEATURES=tests `
111113
-DXSD_INCLUDE_DIR=xsd/libxsd `
112114
-DXSD_EXECUTABLE=xsd/bin/xsd.exe `
113115
-B build -S .

build.ps1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ param(
33
[string]$libdigidocpp = $PSScriptRoot,
44
[string]$vcpkg = "vcpkg\vcpkg.exe",
55
[string]$vcpkg_dir = (split-path -parent $vcpkg),
6+
[string]$vcpkg_installed = $libdigidocpp,
67
[string]$buildver = "0",
78
[string]$msiversion = "3.16.0.$buildver",
89
[string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.msi",
@@ -16,7 +17,7 @@ param(
1617
[string]$light = "$env:WIX\bin\light.exe",
1718
[string]$swig = $null,
1819
[string]$doxygen = $null,
19-
[string]$boost = $null,
20+
[switch]$boost = $false,
2021
[string]$xsd = "$libdigidocpp\xsd",
2122
[string]$sign = $null,
2223
[string]$crosssign = $null,
@@ -33,7 +34,6 @@ if ($vcver) {
3334
$vcver = "-vcvars_ver=$vcver"
3435
}
3536

36-
$env:VCPKG_OVERLAY_TRIPLETS = "$libdigidocpp\patches\vcpkg-triplets"
3737
$cmakeext = @()
3838
$candleext = @()
3939
$lightext = @()
@@ -47,7 +47,7 @@ if($doxygen) {
4747
$lightext += "DocFilesFragment.wixobj"
4848
}
4949
if($boost) {
50-
$cmakeext += "-DBoost_INCLUDE_DIR=$boost"
50+
$cmakeext += "-DVCPKG_MANIFEST_FEATURES=tests"
5151
}
5252
if($source) {
5353
Remove-Item source -Force -Recurse
@@ -62,25 +62,27 @@ foreach($platform in @("x86", "x64")) {
6262
foreach($type in @("Debug", "RelWithDebInfo")) {
6363
$buildpath = $platform+$type
6464
Remove-Item $buildpath -Force -Recurse -ErrorAction Ignore
65-
& $vcvars $platform $vcver "&&" $cmake "-G$generator" `
65+
& $vcvars $platform $vcver "&&" $cmake -B $buildpath -S $libdigidocpp "-G$generator" `
6666
"-DCMAKE_BUILD_TYPE=$type" `
6767
"-DCMAKE_INSTALL_PREFIX=$platform" `
6868
"-DCMAKE_INSTALL_LIBDIR=bin" `
6969
"-DCMAKE_TOOLCHAIN_FILE=$vcpkg_dir/scripts/buildsystems/vcpkg.cmake" `
7070
"-DVCPKG_TARGET_TRIPLET=$platform-windows-v$toolset" `
71+
"-DVCPKG_INSTALLED_DIR=$vcpkg_installed\vcpkg_installed_$platform" `
7172
"-DXSD_INCLUDE_DIR=$xsd/libxsd" `
7273
"-DXSD_EXECUTABLE=$xsd/bin/xsd.exe" `
7374
"-DSIGNCERT=$sign" `
7475
"-DCROSSSIGNCERT=$crosssign" `
75-
$cmakeext -B $buildpath -S $libdigidocpp "&&" $cmake --build $buildpath --target check install
76+
$cmakeext "&&" $cmake --build $buildpath --target check install
7677
}
7778
}
7879

7980
if($doxygen) {
8081
& $heat dir x86/share/doc/libdigidocpp -nologo -cg Documentation -gg -scom -sreg -sfrag -srd -dr DocumentationFolder -var var.docLocation -out DocFilesFragment.wxs
8182
}
8283
& $heat dir x86/include -nologo -cg Headers -gg -scom -sreg -sfrag -srd -dr HeadersFolder -var var.headersLocation -out HeadersFragment.wxs
83-
& $vcvars x86 "&&" $candle -nologo "-dICON=$libdigidocpp/cmake/modules/ID.ico" "-dMSI_VERSION=$msiversion" "-dvcpkg=$vcpkg_dir" "-dvcpkg_suffix=windows-v$toolset" `
84+
& $vcvars x86 "&&" $candle -nologo "-dICON=$libdigidocpp/cmake/modules/ID.ico" "-dMSI_VERSION=$msiversion" `
85+
"-dvcpkg_x86=$vcpkg_installed\vcpkg_installed_x86\x86-windows-v$toolset" "-dvcpkg_x64=$vcpkg_installed\vcpkg_installed_x64\x64-windows-v$toolset" `
8486
"-dheadersLocation=x86/include" "-dlibdigidocpp=." $candleext $libdigidocpp\libdigidocpp.wxs HeadersFragment.wxs
8587
& $light -nologo -out $msi_name -ext WixUIExtension `
8688
"-dWixUIBannerBmp=$libdigidocpp/cmake/modules/banner.bmp" `

libdigidocpp.wxs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<?elseif $(env.VisualStudioVersion) = "16.0" ?>
55
<?define VCVER = "142" ?>
66
<?endif?>
7-
<?define VCPKG_X86 = "$(var.vcpkg)\installed\x86-$(var.vcpkg_suffix)\bin" ?>
8-
<?define VCPKG_X64 = "$(var.vcpkg)\installed\x64-$(var.vcpkg_suffix)\bin" ?>
9-
<?define VCPKG_X86D = "$(var.vcpkg)\installed\x86-$(var.vcpkg_suffix)\debug\bin" ?>
10-
<?define VCPKG_X64D = "$(var.vcpkg)\installed\x64-$(var.vcpkg_suffix)\debug\bin" ?>
7+
<?define VCPKG_X86 = "$(var.vcpkg_x86)\bin" ?>
8+
<?define VCPKG_X64 = "$(var.vcpkg_x64)\bin" ?>
9+
<?define VCPKG_X86D = "$(var.vcpkg_x86)\debug\bin" ?>
10+
<?define VCPKG_X64D = "$(var.vcpkg_x64)\debug\bin" ?>
1111

1212
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
1313
<Product Name="Libdigidocpp" UpgradeCode="{93985BBA-6B59-443B-80C8-BA987407F8B8}"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/Configure b/Configure
2+
index 5ac4b52..ad638e8 100755
3+
--- a/Configure
4+
+++ b/Configure
5+
@@ -401,6 +401,7 @@ my @dtls = qw(dtls1 dtls1_2);
6+
my @disablables = (
7+
"acvp-tests",
8+
"afalgeng",
9+
+ "apps",
10+
"aria",
11+
"asan",
12+
"asm",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
2+
index 110ba06..5b6b1c7 100644
3+
--- a/Configurations/unix-Makefile.tmpl
4+
+++ b/Configurations/unix-Makefile.tmpl
5+
@@ -611,7 +611,7 @@ install_sw: install_dev install_engines install_modules install_runtime
6+
7+
uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
8+
9+
-install_docs: install_man_docs install_html_docs
10+
+install_docs:
11+
12+
uninstall_docs: uninstall_man_docs uninstall_html_docs
13+
$(RM) -r $(DESTDIR)$(DOCDIR)
14+
diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl
15+
index d054431..b5c1c88 100644
16+
--- a/Configurations/windows-makefile.tmpl
17+
+++ b/Configurations/windows-makefile.tmpl
18+
@@ -487,7 +487,7 @@ install_sw: install_dev install_engines install_modules install_runtime
19+
20+
uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
21+
22+
-install_docs: install_html_docs
23+
+install_docs:
24+
25+
uninstall_docs: uninstall_html_docs
26+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function(install_pc_file name pc_data)
2+
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
3+
configure_file("${CMAKE_CURRENT_LIST_DIR}/openssl.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${name}.pc" @ONLY)
4+
endif()
5+
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
6+
configure_file("${CMAKE_CURRENT_LIST_DIR}/openssl.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${name}.pc" @ONLY)
7+
endif()
8+
endfunction()
9+
10+
install_pc_file(openssl [[
11+
Name: OpenSSL
12+
Description: Secure Sockets Layer and cryptography libraries and tools
13+
Requires: libssl libcrypto
14+
]])
15+
16+
install_pc_file(libssl [[
17+
Name: OpenSSL-libssl
18+
Description: Secure Sockets Layer and cryptography libraries
19+
Libs: -L"${libdir}" -llibssl
20+
Requires: libcrypto
21+
Cflags: -I"${includedir}"
22+
]])
23+
24+
install_pc_file(libcrypto [[
25+
Name: OpenSSL-libcrypto
26+
Description: OpenSSL cryptography library
27+
Libs: -L"${libdir}" -llibcrypto
28+
Libs.private: -lcrypt32 -lws2_32 -ladvapi32 -luser32
29+
Cflags: -I"${includedir}"
30+
]])
31+
32+
vcpkg_fixup_pkgconfig()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
prefix=${pcfiledir}/../..
2+
exec_prefix=${prefix}
3+
libdir=${exec_prefix}/lib
4+
includedir=${prefix}/include
5+
Version: @VERSION@
6+
@pc_data@
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
if(EXISTS "${CURRENT_INSTALLED_DIR}/share/libressl/copyright"
2+
OR EXISTS "${CURRENT_INSTALLED_DIR}/share/boringssl/copyright")
3+
message(FATAL_ERROR "Can't build openssl if libressl/boringssl is installed. Please remove libressl/boringssl, and try install openssl again if you need it.")
4+
endif()
5+
6+
if(VCPKG_TARGET_IS_EMSCRIPTEN)
7+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
8+
endif()
9+
10+
if (NOT "${VERSION}" MATCHES [[^([0-9]+)\.([0-9]+)\.([0-9]+)$]])
11+
message(FATAL_ERROR "Version regex did not match.")
12+
endif()
13+
set(OPENSSL_VERSION_MAJOR "${CMAKE_MATCH_1}")
14+
set(OPENSSL_VERSION_MINOR "${CMAKE_MATCH_2}")
15+
set(OPENSSL_VERSION_FIX "${CMAKE_MATCH_3}")
16+
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY)
17+
18+
vcpkg_from_github(
19+
OUT_SOURCE_PATH SOURCE_PATH
20+
REPO openssl/openssl
21+
REF "openssl-${VERSION}"
22+
SHA512 4762ce7faa0d7f43d0d4882700dcb10cd31bb025c52110fb2f1a8d3911f4ed92153db982935be6f38f45ae3f030f7edb4968e96dd5a41367ad7365c03c25edb1
23+
PATCHES
24+
disable-apps.patch
25+
disable-install-docs.patch
26+
script-prefix.patch
27+
windows/install-layout.patch
28+
windows/install-pdbs.patch
29+
unix/android-cc.patch
30+
unix/move-openssldir.patch
31+
unix/no-empty-dirs.patch
32+
unix/no-static-libs-for-shared.patch
33+
)
34+
35+
vcpkg_list(SET CONFIGURE_OPTIONS
36+
enable-static-engine
37+
enable-capieng
38+
no-ssl3
39+
no-weak-ssl-ciphers
40+
no-tests
41+
)
42+
43+
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
44+
vcpkg_list(APPEND CONFIGURE_OPTIONS shared)
45+
else()
46+
vcpkg_list(APPEND CONFIGURE_OPTIONS no-shared no-module)
47+
endif()
48+
49+
if(NOT "tools" IN_LIST FEATURES)
50+
vcpkg_list(APPEND CONFIGURE_OPTIONS no-apps)
51+
endif()
52+
53+
if(DEFINED OPENSSL_USE_NOPINSHARED)
54+
vcpkg_list(APPEND CONFIGURE_OPTIONS no-pinshared)
55+
endif()
56+
57+
if(OPENSSL_NO_AUTOLOAD_CONFIG)
58+
vcpkg_list(APPEND CONFIGURE_OPTIONS no-autoload-config)
59+
endif()
60+
61+
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
62+
include("${CMAKE_CURRENT_LIST_DIR}/windows/portfile.cmake")
63+
include("${CMAKE_CURRENT_LIST_DIR}/install-pc-files.cmake")
64+
else()
65+
include("${CMAKE_CURRENT_LIST_DIR}/unix/portfile.cmake")
66+
endif()
67+
68+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
69+
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/tools/c_rehash.in b/tools/c_rehash.in
2+
index 343cdc1..e48038e 100644
3+
--- a/tools/c_rehash.in
4+
+++ b/tools/c_rehash.in
5+
@@ -12,7 +12,7 @@
6+
# and add symbolic links to their hash values.
7+
8+
my $dir = {- quotify1($config{openssldir}) -};
9+
-my $prefix = {- quotify1($config{prefix}) -};
10+
+use FindBin;
11+
12+
my $errorcount = 0;
13+
my $openssl = $ENV{OPENSSL} || "openssl";
14+
@@ -61,7 +61,7 @@ if (defined(&Cwd::getcwd)) {
15+
16+
# DOS/Win32 or Unix delimiter? Prefix our installdir, then search.
17+
my $path_delim = ($pwd =~ /^[a-z]\:/i) ? ';' : ':';
18+
-$ENV{PATH} = "$prefix/bin" . ($ENV{PATH} ? $path_delim . $ENV{PATH} : "");
19+
+$ENV{PATH} = "$FindBin::Bin" . ($ENV{PATH} ? $path_delim . $ENV{PATH} : "");
20+
21+
if (! -x $openssl) {
22+
my $found = 0;

0 commit comments

Comments
 (0)