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

[mbedtls] update to 3.1.0 #20860

Closed
wants to merge 16 commits into from
167 changes: 65 additions & 102 deletions ports/mbedtls/enable-pthread.patch
Original file line number Diff line number Diff line change
@@ -1,102 +1,65 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8833246..f68ab02 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,7 @@ set(MBEDTLS_DIR ${CMAKE_CURRENT_SOURCE_DIR})

option(USE_PKCS11_HELPER_LIBRARY "Build mbed TLS with the pkcs11-helper library." OFF)
option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF)
+option(ENABLE_PTHREAD "Build mbed TLS with pthread" OFF)

option(ENABLE_PROGRAMS "Build mbed TLS programs." ON)

@@ -231,6 +232,8 @@ else()
set(LIB_INSTALL_DIR lib)
endif()

+include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
+
if(ENABLE_ZLIB_SUPPORT)
find_package(ZLIB)

@@ -239,6 +242,17 @@ if(ENABLE_ZLIB_SUPPORT)
endif(ZLIB_FOUND)
endif(ENABLE_ZLIB_SUPPORT)

+if(ENABLE_PTHREAD)
+ if(WIN32)
+ find_package(pthreads_windows REQUIRED)
+ include_directories(${PThreads4W_INCLUDE_DIR})
+ else()
+ set(CMAKE_THREAD_PREFER_PTHREAD ON)
+ find_package(Threads REQUIRED)
+ endif()
+ set(LINK_WITH_PTHREAD ON)
+endif()
+
add_subdirectory(include)

add_subdirectory(3rdparty)
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 62c0f62..7923202 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -1,10 +1,14 @@
option(INSTALL_MBEDTLS_HEADERS "Install mbed TLS headers." ON)

+configure_file(mbedtls/config_threading.h.in mbedtls/config_threading.h)
+
if(INSTALL_MBEDTLS_HEADERS)

file(GLOB headers "mbedtls/*.h")
file(GLOB psa_headers "psa/*.h")
-
+
+ set(headers ${headers} ${CMAKE_CURRENT_BINARY_DIR}/mbedtls/config_threading.h)
+
install(FILES ${headers}
DESTINATION include/mbedtls
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index 1e6e052..51c20da 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -24,6 +24,8 @@
* limitations under the License.
*/

+#include "mbedtls/config_threading.h"
+
#ifndef MBEDTLS_CONFIG_H
#define MBEDTLS_CONFIG_H

diff --git a/include/mbedtls/config_threading.h.in b/include/mbedtls/config_threading.h.in
new file mode 100644
index 0000000..9d5d42e
--- /dev/null
+++ b/include/mbedtls/config_threading.h.in
@@ -0,0 +1,6 @@
+#cmakedefine ENABLE_PTHREAD
+
+#ifdef ENABLE_PTHREAD
+#define MBEDTLS_THREADING_C
+#define MBEDTLS_THREADING_PTHREAD
+#endif
\ No newline at end of file
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index 33e2cfc..4b99331 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -137,7 +137,11 @@ if(ENABLE_ZLIB_SUPPORT)
endif(ENABLE_ZLIB_SUPPORT)

if(LINK_WITH_PTHREAD)
- set(libs ${libs} pthread)
+ if(WIN32)
+ set(libs ${libs} ${PThreads4W_LIBRARY})
+ else()
+ set(libs ${libs} pthread)
+ endif()
endif()

if(LINK_WITH_TRUSTED_STORAGE)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cf74af5..fbfdf4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,6 +43,7 @@ endif()
set(MBEDTLS_DIR ${CMAKE_CURRENT_SOURCE_DIR})

option(ENABLE_PROGRAMS "Build mbed TLS programs." ON)
+option(ENABLE_PTHREAD "Build mbed TLS with pthread" OFF)

option(UNSAFE_BUILD "Allow unsafe builds. These builds ARE NOT SECURE." OFF)
option(MBEDTLS_FATAL_WARNINGS "Compiler warnings treated as errors" ON)
@@ -222,6 +223,19 @@ else()
set(LIB_INSTALL_DIR lib)
endif()

+include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
+
+if(ENABLE_PTHREAD)
+ if(WIN32)
+ find_package(pthreads_windows REQUIRED)
+ include_directories(${PThreads4W_INCLUDE_DIR})
+ else()
+ set(CMAKE_THREAD_PREFER_PTHREAD ON)
+ find_package(Threads REQUIRED)
+ endif()
+ set(LINK_WITH_PTHREAD ON)
+endif()
+
add_subdirectory(include)

add_subdirectory(3rdparty)
diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h
index a60db7e..bb2cad5 100644
--- a/include/mbedtls/mbedtls_config.h
+++ b/include/mbedtls/mbedtls_config.h
@@ -24,6 +24,11 @@
* limitations under the License.
*/

+#ifdef ENABLE_PTHREAD
+#define MBEDTLS_THREADING_C
+#define MBEDTLS_THREADING_PTHREAD
+#endif
+
/**
* This is an optional version symbol that enables comatibility handling of
* config files.
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index 1cd5589..aa06678 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -130,7 +130,11 @@ if(HAIKU)
endif(HAIKU)

if(LINK_WITH_PTHREAD)
- set(libs ${libs} pthread)
+ if(WIN32)
+ set(libs ${libs} ${PThreads4W_LIBRARY})
+ else()
+ set(libs ${libs} pthread)
+ endif()
endif()

if(LINK_WITH_TRUSTED_STORAGE)
25 changes: 12 additions & 13 deletions ports/mbedtls/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set(VCPKG_LIBRARY_LINKAGE static)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ARMmbed/mbedtls
REF 523f0554b6cdc7ace5d360885c3f5bbcc73ec0e8 # mbedtls-2.24.0
SHA512 1ce78f34e8d87c2ce0454e0a08f4c6e5b3129d4b24cfa44162af21c2e8b5dc7feabf849e4fa547ce3781b5ce11aaf675cfed47412bae40091fbdd87bbcdbee07
REF 8df2f8e7b9c7bb9390ac74bb7bace27edca81a2b # mbedtls-3.0.0
SHA512 7cc1412664a8e8d35b8d0c578cd2d0fc2b4aee82e1f9583aaf167e4adf893b5fd0c8fd686db11900c13418789e99ee03fc91ea37ac3ef922c28d51f54fa196ad
HEAD_REF master
PATCHES
enable-pthread.patch
Expand All @@ -15,27 +15,26 @@ vcpkg_from_github(
vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
pthreads ENABLE_PTHREAD
pthreads ENABLE_PTHREAD
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DENABLE_TESTING=OFF
-DENABLE_PROGRAMS=OFF
-DMBEDTLS_FATAL_WARNINGS=FALSE
)

vcpkg_install_cmake()
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(CONFIG_PATH "CMake")

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

if (VCPKG_TARGET_IS_WINDOWS AND pthreads IN_LIST FEATURES)
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
endif ()

vcpkg_copy_pdbs()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
endif ()
13 changes: 11 additions & 2 deletions ports/mbedtls/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{
"name": "mbedtls",
"version-string": "2.24.0",
"port-version": 3,
"version": "3.0.0",
"description": "An open source, portable, easy to use, readable and flexible SSL library",
"homepage": "https://github.com/ARMmbed/mbedtls",
"supports": "!uwp",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"pthreads": {
"description": "Multi-threading support",
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4325,8 +4325,8 @@
"port-version": 0
},
"mbedtls": {
"baseline": "2.24.0",
"port-version": 3
"baseline": "3.0.0",
"port-version": 0
},
"mcpp": {
"baseline": "2.7.2.14",
Expand Down
5 changes: 5 additions & 0 deletions versions/m-/mbedtls.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "1253d35afb1cda738ecfaefd4d36dc3e692c7041",
"version": "3.0.0",
"port-version": 0
},
{
"git-tree": "a68475211755b3999de8cb2ec1d2fdfe9bb8ab10",
"version-string": "2.24.0",
Expand Down