summaryrefslogtreecommitdiff
path: root/contrib/vcpkg-ports/openssl/uwp
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2021-11-29 20:46:00 +0100
committerJörg Frings-Fürst <debian@jff.email>2021-11-29 20:46:00 +0100
commitf2b3dda12a731c2e0971cb7889728edaf23f6cb0 (patch)
treefdf8833416567ca3842f347b2126cdbb13c746bd /contrib/vcpkg-ports/openssl/uwp
parent4ee98f284a93c3b855092d35ac21371d9dcad65b (diff)
New upstream version 2.5.4upstream/2.5.4
Diffstat (limited to 'contrib/vcpkg-ports/openssl/uwp')
-rw-r--r--contrib/vcpkg-ports/openssl/uwp/EnableUWPSupport.patch170
-rw-r--r--contrib/vcpkg-ports/openssl/uwp/make-openssl.bat16
-rw-r--r--contrib/vcpkg-ports/openssl/uwp/portfile.cmake156
3 files changed, 342 insertions, 0 deletions
diff --git a/contrib/vcpkg-ports/openssl/uwp/EnableUWPSupport.patch b/contrib/vcpkg-ports/openssl/uwp/EnableUWPSupport.patch
new file mode 100644
index 0000000..fe78374
--- /dev/null
+++ b/contrib/vcpkg-ports/openssl/uwp/EnableUWPSupport.patch
@@ -0,0 +1,170 @@
+diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
+index 3c4299d264..99fcb1f713 100644
+--- a/Configurations/10-main.conf
++++ b/Configurations/10-main.conf
+@@ -1287,7 +1287,7 @@ my %targets = (
+ },
+ "VC-WIN64I" => {
+ inherit_from => [ "VC-WIN64-common", asm("ia64_asm"),
+- sub { $disabled{shared} ? () : "ia64_uplink" } ],
++ sub { $disabled{uplink} ? () : "ia64_uplink" } ],
+ AS => "ias",
+ ASFLAGS => "-d debug",
+ asoutflag => "-o ",
+@@ -1299,7 +1299,7 @@ my %targets = (
+ },
+ "VC-WIN64A" => {
+ inherit_from => [ "VC-WIN64-common", asm("x86_64_asm"),
+- sub { $disabled{shared} ? () : "x86_64_uplink" } ],
++ sub { $disabled{uplink} ? () : "x86_64_uplink" } ],
+ AS => sub { vc_win64a_info()->{AS} },
+ ASFLAGS => sub { vc_win64a_info()->{ASFLAGS} },
+ asoutflag => sub { vc_win64a_info()->{asoutflag} },
+@@ -1312,7 +1312,7 @@ my %targets = (
+ },
+ "VC-WIN32" => {
+ inherit_from => [ "VC-noCE-common", asm("x86_asm"),
+- sub { $disabled{shared} ? () : "uplink_common" } ],
++ sub { $disabled{uplink} ? () : "uplink_common" } ],
+ AS => sub { vc_win32_info()->{AS} },
+ ASFLAGS => sub { vc_win32_info()->{ASFLAGS} },
+ asoutflag => sub { vc_win32_info()->{asoutflag} },
+@@ -1374,7 +1374,7 @@ my %targets = (
+ #### MinGW
+ "mingw" => {
+ inherit_from => [ "BASE_unix", asm("x86_asm"),
+- sub { $disabled{shared} ? () : "x86_uplink" } ],
++ sub { $disabled{uplink} ? () : "x86_uplink" } ],
+ CC => "gcc",
+ CFLAGS => picker(default => "-Wall",
+ debug => "-g -O0",
+diff --git a/Configurations/50-win-onecore.conf b/Configurations/50-win-onecore.conf
+index d478f42b0f..e0fb70daca 100644
+--- a/Configurations/50-win-onecore.conf
++++ b/Configurations/50-win-onecore.conf
+@@ -1,3 +1,4 @@
++## -*- mode: perl; -*-
+ # Windows OneCore targets.
+ #
+ # OneCore is new API stability "contract" that transcends Desktop, IoT and
+@@ -10,6 +11,25 @@
+ # TODO: extend error handling to use ETW based eventing
+ # (Or rework whole error messaging)
+
++my $UWP_info = {};
++sub UWP_info {
++ unless (%$UWP_info) {
++ my $SDKver = `pwsh.exe -Command \"& {\$(Get-Item \\\"hklm:\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\\").GetValue(\\\"CurrentVersion\\\")}\"`;
++ $SDKver =~ s|\R$||;
++ my @SDKver_split = split(/\./, $SDKver);
++ # SDK version older than 10.0.17763 don't support our ASM builds
++ if ($SDKver_split[0] < 10
++ || ($SDKver_split[0] == 10
++ && $SDKver_split[1] == 0
++ && $SDKver_split[2] < 17763)) {
++ $UWP_info->{disable} = [ 'asm' ];
++ } else {
++ $UWP_info->{disable} = [ ];
++ }
++ }
++ return $UWP_info;
++}
++
+ my %targets = (
+ "VC-WIN32-ONECORE" => {
+ inherit_from => [ "VC-WIN32" ],
+@@ -61,4 +81,57 @@ my %targets = (
+ ex_libs => "onecore.lib",
+ multilib => "-arm64",
+ },
++
++ # Universal Windows Platform (UWP) App Support
++
++ # TODO
++ #
++ # The 'disable' attribute should have 'uplink'.
++ # however, these are checked in some 'inherit_from', which is processed
++ # very early, before the 'disable' attributes are seen.
++ # This is a problem that needs to be resolved in Configure first.
++ #
++ # But if you want to build library with Windows 10 Version 1809 SDK or
++ # earlier, the 'disable' attribute should also have 'asm'.
++
++ "VC-WIN32-UWP" => {
++ inherit_from => [ "VC-WIN32-ONECORE" ],
++ lflags => add("/APPCONTAINER"),
++ defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP",
++ "_WIN32_WINNT=0x0A00"),
++ dso_scheme => "",
++ disable => sub { [ 'ui-console', 'stdio', 'async', 'uplink',
++ @{ UWP_info()->{disable} } ] },
++ ex_libs => "WindowsApp.lib",
++ },
++ "VC-WIN64A-UWP" => {
++ inherit_from => [ "VC-WIN64A-ONECORE" ],
++ lflags => add("/APPCONTAINER"),
++ defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP",
++ "_WIN32_WINNT=0x0A00"),
++ dso_scheme => "",
++ disable => sub { [ 'ui-console', 'stdio', 'async', 'uplink',
++ @{ UWP_info()->{disable} } ] },
++ ex_libs => "WindowsApp.lib",
++ },
++ "VC-WIN32-ARM-UWP" => {
++ inherit_from => [ "VC-WIN32-ARM" ],
++ lflags => add("/APPCONTAINER"),
++ defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP",
++ "_WIN32_WINNT=0x0A00"),
++ dso_scheme => "",
++ disable => sub { [ 'ui-console', 'stdio', 'async', 'uplink',
++ @{ UWP_info()->{disable} } ] },
++ ex_libs => "WindowsApp.lib",
++ },
++ "VC-WIN64-ARM-UWP" => {
++ inherit_from => [ "VC-WIN64-ARM" ],
++ lflags => add("/APPCONTAINER"),
++ defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP",
++ "_WIN32_WINNT=0x0A00"),
++ dso_scheme => "",
++ disable => sub { [ 'ui-console', 'stdio', 'async', 'uplink',
++ @{ UWP_info()->{disable} } ] },
++ ex_libs => "WindowsApp.lib",
++ },
+ );
+diff --git a/Configure b/Configure
+index 5a699836f3..de45f1e299 100755
+--- a/Configure
++++ b/Configure
+@@ -407,6 +408,7 @@ my @disablables = (
+ "ubsan",
+ "ui-console",
+ "unit-test",
++ "uplink",
+ "whirlpool",
+ "weak-ssl-ciphers",
+ "zlib",
+@@ -491,8 +493,8 @@ my @disable_cascades = (
+
+ # Without position independent code, there can be no shared libraries or DSOs
+ "pic" => [ "shared" ],
+- "shared" => [ "dynamic-engine" ],
++ "shared" => [ "dynamic-engine", "uplink" ],
+ "dso" => [ "dynamic-engine" ],
+ "engine" => [ "afalgeng", "devcryptoeng" ],
+
+ # no-autoalginit is only useful when building non-shared
+diff --git a/INSTALL b/INSTALL
+index 2119cbae9e..ee54e8c215 100644
+--- a/INSTALL
++++ b/INSTALL
+@@ -560,6 +560,10 @@
+ likely to complement configuration command line with
+ suitable compiler-specific option.
+
++ no-uplink
++ Don't build support for UPLINK interface.
++
++
+ no-<prot>
+ Don't build support for negotiating the specified SSL/TLS
+ protocol (one of ssl, ssl3, tls, tls1, tls1_1, tls1_2,
diff --git a/contrib/vcpkg-ports/openssl/uwp/make-openssl.bat b/contrib/vcpkg-ports/openssl/uwp/make-openssl.bat
new file mode 100644
index 0000000..6f6166a
--- /dev/null
+++ b/contrib/vcpkg-ports/openssl/uwp/make-openssl.bat
@@ -0,0 +1,16 @@
+set build=%1
+
+perl Configure no-asm no-hw no-dso VC-WINUNIVERSAL -FS -FIWindows.h
+
+for /D %%f in ("%WindowsSdkDir%References\%WindowsSDKLibVersion%Windows.Foundation.FoundationContract\*") do set LibPath=%LibPath%;%%f\
+for /D %%f in ("%WindowsSdkDir%References\%WindowsSDKLibVersion%Windows.Foundation.UniversalApiContract\*") do set LibPath=%LibPath%;%%f\
+for /D %%f in ("%WindowsSdkDir%References\Windows.Foundation.FoundationContract\*") do set LibPath=%LibPath%;%%f\
+for /D %%f in ("%WindowsSdkDir%References\Windows.Foundation.UniversalApiContract\*") do set LibPath=%LibPath%;%%f\
+
+call ms\do_winuniversal.bat
+
+mkdir inc32\openssl
+
+jom -j %NUMBER_OF_PROCESSORS% -k -f ms\ntdll.mak
+REM due to a race condition in the build, we need to have a second single-threaded pass.
+nmake -f ms\ntdll.mak
diff --git a/contrib/vcpkg-ports/openssl/uwp/portfile.cmake b/contrib/vcpkg-ports/openssl/uwp/portfile.cmake
new file mode 100644
index 0000000..08a523c
--- /dev/null
+++ b/contrib/vcpkg-ports/openssl/uwp/portfile.cmake
@@ -0,0 +1,156 @@
+vcpkg_fail_port_install(MESSAGE "${PORT} is only for Windows Universal Platform" ON_TARGET "Linux" "OSX")
+
+vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
+
+vcpkg_find_acquire_program(JOM)
+get_filename_component(JOM_EXE_PATH ${JOM} DIRECTORY)
+vcpkg_add_to_path("${PERL_EXE_PATH}")
+
+vcpkg_extract_source_archive_ex(
+ OUT_SOURCE_PATH SOURCE_PATH
+ ARCHIVE ${ARCHIVE}
+ PATCHES
+ uwp/EnableUWPSupport.patch
+)
+
+vcpkg_find_acquire_program(NASM)
+get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY)
+vcpkg_add_to_path(PREPEND "${NASM_EXE_PATH}")
+
+set(CONFIGURE_COMMAND ${PERL} Configure
+ enable-static-engine
+ enable-capieng
+ no-unit-test
+ no-ssl2
+ no-asm
+ no-uplink
+ no-tests
+ -utf-8
+ shared
+)
+
+if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
+ set(OPENSSL_ARCH VC-WIN32-UWP)
+elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
+ set(OPENSSL_ARCH VC-WIN64A-UWP)
+elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
+ set(OPENSSL_ARCH VC-WIN32-ARM-UWP)
+elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
+ set(OPENSSL_ARCH VC-WIN64-ARM-UWP)
+else()
+ message(FATAL_ERROR "Unsupported target architecture: ${VCPKG_TARGET_ARCHITECTURE}")
+endif()
+
+set(OPENSSL_MAKEFILE "makefile")
+
+file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
+
+
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
+
+ # Copy openssl sources.
+ message(STATUS "Copying openssl release source files...")
+ file(GLOB OPENSSL_SOURCE_FILES "${SOURCE_PATH}/*")
+ foreach(SOURCE_FILE ${OPENSSL_SOURCE_FILES})
+ file(COPY ${SOURCE_FILE} DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
+ endforeach()
+ message(STATUS "Copying openssl release source files... done")
+ set(SOURCE_PATH_RELEASE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
+
+ set(OPENSSLDIR_RELEASE "${CURRENT_PACKAGES_DIR}")
+
+ message(STATUS "Configure ${TARGET_TRIPLET}-rel")
+ vcpkg_execute_required_process(
+ COMMAND ${CONFIGURE_COMMAND} ${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_RELEASE}" "--openssldir=${OPENSSLDIR_RELEASE}" -FS
+ WORKING_DIRECTORY "${SOURCE_PATH_RELEASE}"
+ LOGNAME configure-perl-${TARGET_TRIPLET}-${VCPKG_BUILD_TYPE}-rel
+ )
+ message(STATUS "Configure ${TARGET_TRIPLET}-rel done")
+
+ message(STATUS "Build ${TARGET_TRIPLET}-rel")
+ # Openssl's buildsystem has a race condition which will cause JOM to fail at some point.
+ # This is ok; we just do as much work as we can in parallel first, then follow up with a single-threaded build.
+ make_directory(${SOURCE_PATH_RELEASE}/inc32/openssl)
+ execute_process(
+ COMMAND "${JOM}" -k -j ${VCPKG_CONCURRENCY} -f "${OPENSSL_MAKEFILE}" build_libs
+ WORKING_DIRECTORY "${SOURCE_PATH_RELEASE}"
+ OUTPUT_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-rel-0-out.log"
+ ERROR_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-rel-0-err.log"
+ )
+ vcpkg_execute_required_process(
+ COMMAND nmake -f "${OPENSSL_MAKEFILE}" install_dev
+ WORKING_DIRECTORY "${SOURCE_PATH_RELEASE}"
+ LOGNAME build-${TARGET_TRIPLET}-rel-1)
+
+ message(STATUS "Build ${TARGET_TRIPLET}-rel done")
+endif()
+
+
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
+ # Copy openssl sources.
+ message(STATUS "Copying openssl debug source files...")
+ file(GLOB OPENSSL_SOURCE_FILES ${SOURCE_PATH}/*)
+ foreach(SOURCE_FILE ${OPENSSL_SOURCE_FILES})
+ file(COPY "${SOURCE_FILE}" DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
+ endforeach()
+ message(STATUS "Copying openssl debug source files... done")
+ set(SOURCE_PATH_DEBUG "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
+
+ set(OPENSSLDIR_DEBUG "${CURRENT_PACKAGES_DIR}/debug")
+
+ message(STATUS "Configure ${TARGET_TRIPLET}-dbg")
+ vcpkg_execute_required_process(
+ COMMAND ${CONFIGURE_COMMAND} debug-${OPENSSL_ARCH} "--prefix=${OPENSSLDIR_DEBUG}" "--openssldir=${OPENSSLDIR_DEBUG}" -FS
+ WORKING_DIRECTORY "${SOURCE_PATH_DEBUG}"
+ LOGNAME configure-perl-${TARGET_TRIPLET}-${VCPKG_BUILD_TYPE}-dbg
+ )
+ message(STATUS "Configure ${TARGET_TRIPLET}-dbg done")
+
+ message(STATUS "Build ${TARGET_TRIPLET}-dbg")
+ make_directory("${SOURCE_PATH_DEBUG}/inc32/openssl")
+ execute_process(
+ COMMAND "${JOM}" -k -j ${VCPKG_CONCURRENCY} -f "${OPENSSL_MAKEFILE}" build_libs
+ WORKING_DIRECTORY "${SOURCE_PATH_DEBUG}"
+ OUTPUT_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-dbg-0-out.log"
+ ERROR_FILE "${CURRENT_BUILDTREES_DIR}/build-${TARGET_TRIPLET}-dbg-0-err.log"
+ )
+ vcpkg_execute_required_process(
+ COMMAND nmake -f "${OPENSSL_MAKEFILE}" install_dev
+ WORKING_DIRECTORY "${SOURCE_PATH_DEBUG}"
+ LOGNAME build-${TARGET_TRIPLET}-dbg-1)
+
+ message(STATUS "Build ${TARGET_TRIPLET}-dbg done")
+endif()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/certs")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/private")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/engines-1_1")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/certs")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/engines-1_1")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/private")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+
+file(REMOVE
+ "${CURRENT_PACKAGES_DIR}/bin/openssl.exe"
+ "${CURRENT_PACKAGES_DIR}/debug/bin/openssl.exe"
+ "${CURRENT_PACKAGES_DIR}/debug/openssl.cnf"
+ "${CURRENT_PACKAGES_DIR}/openssl.cnf"
+ "${CURRENT_PACKAGES_DIR}/ct_log_list.cnf"
+ "${CURRENT_PACKAGES_DIR}/ct_log_list.cnf.dist"
+ "${CURRENT_PACKAGES_DIR}/openssl.cnf.dist"
+ "${CURRENT_PACKAGES_DIR}/debug/ct_log_list.cnf"
+ "${CURRENT_PACKAGES_DIR}/debug/ct_log_list.cnf.dist"
+ "${CURRENT_PACKAGES_DIR}/debug/openssl.cnf.dist"
+)
+
+file(READ "${CURRENT_PACKAGES_DIR}/include/openssl/dtls1.h" _contents)
+string(REPLACE "<winsock.h>" "<winsock2.h>" _contents "${_contents}")
+file(WRITE "${CURRENT_PACKAGES_DIR}/include/openssl/dtls1.h" "${_contents}")
+
+file(READ "${CURRENT_PACKAGES_DIR}/include/openssl/rand.h" _contents)
+string(REPLACE "# include <windows.h>" "#ifndef _WINSOCKAPI_\n#define _WINSOCKAPI_\n#endif\n# include <windows.h>" _contents "${_contents}")
+file(WRITE "${CURRENT_PACKAGES_DIR}/include/openssl/rand.h" "${_contents}")
+
+vcpkg_copy_pdbs()
+
+file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)