Skip to content

Commit

Permalink
[msh3,msquic,vcpkg-ci-msh3] Update, add test port (#42788)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt authored Dec 30, 2024
1 parent 48afdad commit 78030b6
Show file tree
Hide file tree
Showing 17 changed files with 337 additions and 98 deletions.
76 changes: 56 additions & 20 deletions ports/msh3/dependencies_fix.patch
Original file line number Diff line number Diff line change
@@ -1,45 +1,56 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4bd7155..b7adecc 100644
index d8a81ab..edf5651 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,7 +72,7 @@ target_include_directories(msh3_headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
@@ -28,9 +28,6 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

if (WIN32)
- # Statically link the OS included part of the runtime.
- set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
- set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
set(QUIC_COMMON_DEFINES WIN32_LEAN_AND_MEAN SECURITY_WIN32)
# TODO - Get these to work on Linux
list(APPEND MSH3_COMMON_DEFINES VER_BUILD_ID=${MSH3_VER_BUILD_ID})
@@ -66,7 +63,8 @@ target_include_directories(msh3_headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
option(LSQPACK_TESTS "Build tests" OFF)
option(LSQPACK_BIN "Build binaries" OFF)
-add_subdirectory(ls-qpack)
+find_package(ls-qpack CONFIG REQUIRED)
+add_library(ls-qpack ALIAS ls-qpack::ls-qpack)

# Configure and build msquic dependency.
if (WIN32)
@@ -83,8 +83,9 @@ endif()
@@ -76,9 +74,11 @@ else()
endif()
set(QUIC_BUILD_SHARED ON CACHE BOOL "Builds MsQuic as a dynamic library")
set(QUIC_ENABLE_LOGGING ON CACHE BOOL "Enable MsQuic logging")
set(CMAKE_BUILD_TYPE "Release")
-set(CMAKE_BUILD_TYPE "Release")
-add_subdirectory(msquic)
-target_compile_features(inc INTERFACE cxx_std_20)
+find_package(msquic CONFIG REQUIRED)
+
+target_compile_features(msh3_headers INTERFACE cxx_std_20)
+# polyfill
+add_library(inc ALIAS msquic)
+add_library(platform ALIAS msquic)
+add_library(warnings ALIAS msquic)

# Build msh3 library (and cmd line tool).
add_subdirectory(lib)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index ab7fc24..c488486 100644
index 4d7aeb7..6da8e1a 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -7,10 +7,7 @@ else()
@@ -7,6 +7,8 @@ else()
set(SOURCES msh3.cpp)
endif()
add_library(msh3 SHARED ${SOURCES})
-target_link_libraries(msh3 PRIVATE inc warnings msquic ls-qpack msh3_headers)
-if (NOT BUILD_SHARED_LIBS)
- target_link_libraries(msh3 PRIVATE base_link)
-endif()
+target_link_libraries(msh3 PRIVATE msquic ls-qpack::ls-qpack msh3_headers)
if (MSH3_SERVER_SUPPORT)
target_link_libraries(msh3 PRIVATE platform) # For selfsign APIs
endif()
@@ -26,7 +23,11 @@ elseif (CX_PLATFORM STREQUAL "darwin")
+target_compile_features(msh3 PRIVATE cxx_std_20)
+target_include_directories(msh3 PUBLIC $<INSTALL_INTERFACE:include>)
target_link_libraries(msh3 PRIVATE inc warnings msquic ls-qpack msh3_headers)
if (NOT BUILD_SHARED_LIBS)
target_link_libraries(msh3 PRIVATE base_link)
@@ -24,12 +26,16 @@ elseif (CX_PLATFORM STREQUAL "darwin")
PROPERTIES LINK_FLAGS "-exported_symbols_list \"${CMAKE_CURRENT_SOURCE_DIR}/darwin/exports.txt\"")
endif()

Expand All @@ -50,15 +61,40 @@ index ab7fc24..c488486 100644
+ LIBRARY DESTINATION lib
+)
install(FILES ../msh3.h DESTINATION include)
configure_file(msh3-config.cmake.in ${CMAKE_BINARY_DIR}/msh3-config.cmake)
-configure_file(msh3-config.cmake.in ${CMAKE_BINARY_DIR}/msh3-config.cmake)
+configure_file(msh3-config.cmake.in ${CMAKE_BINARY_DIR}/msh3-config.cmake @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/msh3-config.cmake DESTINATION share/msh3)
install(EXPORT msh3 DESTINATION share/msh3)
-configure_file(libmsh3.pc.in ${CMAKE_BINARY_DIR}/libmsh3.pc)
-if(NOT WIN32)
+configure_file(libmsh3.pc.in ${CMAKE_BINARY_DIR}/libmsh3.pc @ONLY)
+if(1)
install(FILES ${CMAKE_BINARY_DIR}/libmsh3.pc DESTINATION lib/pkgconfig)
endif()
diff --git a/lib/libmsh3.pc.in b/lib/libmsh3.pc.in
index f156204..aad76ab 100644
--- a/lib/libmsh3.pc.in
+++ b/lib/libmsh3.pc.in
@@ -4,10 +4,10 @@
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
-includedir=${exec_prefix}/include
+includedir=${prefix}/include

Name: libmsh3
Description: Minimal HTTP/3 client on top of MsQuic
Version: 0.1.0
Libs: -L${libdir} -lmsh3
-Cflags: -I${includedir}/libmsh3
+Cflags: -I${includedir}
diff --git a/lib/msh3-config.cmake.in b/lib/msh3-config.cmake.in
index b4a54bf..a6a0fd2 100644
index b4a54bf..540d56d 100644
--- a/lib/msh3-config.cmake.in
+++ b/lib/msh3-config.cmake.in
@@ -1,4 +1,4 @@
include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@

-include(${SELF_DIR}/msh3.cmake)
+include(${CMAKE_INSTALL_PREFIX}/share/msh3/msh3.cmake)
+include("${CMAKE_CURRENT_LIST_DIR}/msh3.cmake")
10 changes: 4 additions & 6 deletions ports/msh3/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO nibanks/msh3
REF v${VERSION}
SHA512 e6ba4e8f4ce5cd3f586d61739148bf75dfddbe70f399b2e498e7d416c8d730a5f8c2c38f0eabe687049bb7525df44f5f511515ec578bc3832989f73961cdda72
SHA512 dedd8be43e44b4bebbf601d76b1f3b0135501330ed128ca710de942ef7d9142a21f1c1eb9efecf57881e72d93d68c7c2c085bc35d402eac5eabc57e77773be6b
HEAD_REF main
PATCHES
dependencies_fix.patch
width-exceeds-type.diff
)

vcpkg_find_acquire_program(PKGCONFIG)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
)

vcpkg_cmake_install()
Expand Down
5 changes: 2 additions & 3 deletions ports/msh3/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "msh3",
"version": "0.6.0",
"port-version": 1,
"version": "0.7.0",
"description": "Minimal HTTP/3 library",
"homepage": "https://github.com/nibanks/msh3",
"license": "MIT",
"supports": "!uwp",
"supports": "!(static & staticcrt)",
"dependencies": [
"ls-qpack",
"msquic",
Expand Down
32 changes: 32 additions & 0 deletions ports/msh3/width-exceeds-type.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/msh3.h b/msh3.h
index ebbdc20..c31b1b9 100644
--- a/msh3.h
+++ b/msh3.h
@@ -374,7 +374,11 @@ typedef struct MSH3_REQUEST_EVENT {
bool AppCloseInProgress : 1;
bool ConnectionShutdownByApp : 1;
bool ConnectionClosedRemotely : 1;
- bool RESERVED : 5;
+ bool RESERVED : 1;
+ bool RESERVED_2 : 1;
+ bool RESERVED_3 : 1;
+ bool RESERVED_4 : 1;
+ bool RESERVED_5 : 1;
uint64_t ConnectionErrorCode;
MSH3_STATUS ConnectionCloseStatus;
} SHUTDOWN_COMPLETE;
@@ -487,7 +491,13 @@ typedef struct MSH3_LISTENER_EVENT {
union {
struct {
bool AppCloseInProgress : 1;
- bool RESERVED : 7;
+ bool RESERVED : 1;
+ bool RESERVED_2 : 1;
+ bool RESERVED_3 : 1;
+ bool RESERVED_4 : 1;
+ bool RESERVED_5 : 1;
+ bool RESERVED_6 : 1;
+ bool RESERVED_7 : 1;
} SHUTDOWN_COMPLETE;
struct {
MSH3_CONNECTION* Connection;
13 changes: 0 additions & 13 deletions ports/msquic/all_headers.patch

This file was deleted.

56 changes: 56 additions & 0 deletions ports/msquic/exports-for-msh3.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/src/bin/darwin/exports.txt b/src/bin/darwin/exports.txt
index e90b06e..c221d2c 100644
--- a/src/bin/darwin/exports.txt
+++ b/src/bin/darwin/exports.txt
@@ -1,2 +1,6 @@
_MsQuicOpenVersion
_MsQuicClose
+_CxPlatGetSelfSignedCert
+_CxPlatFreeSelfSignedCert
+_CxPlatLogAssert
+_quic_bugcheck
diff --git a/src/bin/linux/exports.txt b/src/bin/linux/exports.txt
index e11806a..424c443 100644
--- a/src/bin/linux/exports.txt
+++ b/src/bin/linux/exports.txt
@@ -1,5 +1,9 @@
msquic
{
global: MsQuicOpenVersion; MsQuicClose;
+ CxPlatGetSelfSignedCert;
+ CxPlatFreeSelfSignedCert;
+ CxPlatLogAssert;
+ quic_bugcheck;
local: *;
};
diff --git a/src/bin/linux/init.c b/src/bin/linux/init.c
index 29bfa14..61bbc48 100644
--- a/src/bin/linux/init.c
+++ b/src/bin/linux/init.c
@@ -9,8 +9,15 @@ Abstract:

--*/

+#define QUIC_TEST_APIS 1
#include "quic_platform.h"

+void MsQuickChainLoadPlatformSymbolsNoOp()
+{
+ QUIC_CREDENTIAL_CONFIG* SelfSignedCertParams = (QUIC_CREDENTIAL_CONFIG*)CxPlatGetSelfSignedCert(CXPLAT_SELF_SIGN_CERT_USER, FALSE, NULL);
+ CxPlatFreeSelfSignedCert(SelfSignedCertParams);
+}
+
void
MsQuicLibraryLoad(
void
diff --git a/src/bin/winuser/msquic.def.in b/src/bin/winuser/msquic.def.in
index afaed5d..fa7d19a 100644
--- a/src/bin/winuser/msquic.def.in
+++ b/src/bin/winuser/msquic.def.in
@@ -3,3 +3,6 @@ LIBRARY @QUIC_LIBRARY_NAME@
EXPORTS
MsQuicOpenVersion
MsQuicClose
+ CxPlatGetSelfSignedCert
+ CxPlatFreeSelfSignedCert
+ CxPlatLogAssert
44 changes: 15 additions & 29 deletions ports/msquic/fix-install.patch
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt
index 2376823..d0592a3 100644
index 18048e3..4fcd161 100644
--- a/src/bin/CMakeLists.txt
+++ b/src/bin/CMakeLists.txt
@@ -253,14 +253,14 @@ endif()
@@ -11,6 +11,7 @@ endif()

if(BUILD_SHARED_LIBS)
target_include_directories(msquic PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../inc>
- $<INSTALL_INTERFACE:${include_dest}>)
+ $<INSTALL_INTERFACE:include>)
else()
target_include_directories(msquic_static INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../inc>
- $<INSTALL_INTERFACE:${include_dest}>)
+ $<INSTALL_INTERFACE:include>)
target_include_directories(msquic INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../inc>
- $<INSTALL_INTERFACE:${include_dest}>)
+ $<INSTALL_INTERFACE:include>)
add_library(msquic SHARED ${SOURCES})
+ target_include_directories(msquic PUBLIC $<INSTALL_INTERFACE:include>)
target_link_libraries(msquic PRIVATE core msquic_platform inc warnings logging base_link main_binary_link_args)
set_target_properties(msquic PROPERTIES OUTPUT_NAME ${QUIC_LIBRARY_NAME})
if (NOT WIN32)
@@ -261,7 +262,10 @@ if(WIN32)
endif()

set(PUBLIC_HEADERS
@@ -269,11 +269,10 @@ set(PUBLIC_HEADERS
../inc/msquic_posix.h
../inc/quic_sal_stub.h)

-if(BUILD_SHARED_LIBS)
- install(TARGETS msquic EXPORT msquic DESTINATION lib)
-else()
- install(FILES ${QUIC_STATIC_LIBRARY} DESTINATION lib)
-endif()
+install(TARGETS msquic EXPORT msquic
if(BUILD_SHARED_LIBS)
- install(TARGETS msquic msquic_platform inc logging_inc warnings main_binary_link_args ${OTHER_TARGETS} EXPORT msquic DESTINATION lib)
+ install(TARGETS msquic EXPORT msquic
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib)
install(FILES ${PUBLIC_HEADERS} DESTINATION include)

configure_file(msquic-config.cmake.in ${CMAKE_BINARY_DIR}/msquic-config.cmake)
else()
install(FILES ${QUIC_STATIC_LIBRARY} DESTINATION lib)
endif()
Loading

0 comments on commit 78030b6

Please sign in to comment.