[nethost] Update nethost (#25004)

* update nethost

* bump nethost version

* Add CMake exports in an unofficial- namespace
https://github.com/microsoft/vcpkg/blob/master/docs/maintainers/maintainer-guide.md#add-cmake-exports-in-an-unofficial--namespace

* fix port version and deprecated functions

* change nethost version date to version

* update usage

* add quotes to paths and export targets directly

* bump nethost version

* [nethost] Only build one flavor

* fix build error

* bump nethost version

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
This commit is contained in:
Lanyi 2022-06-03 00:20:55 +02:00 committed by GitHub
parent abb073fc56
commit 2aed520ed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 95 additions and 70 deletions

View File

@ -1,58 +1,73 @@
diff --git a/src/installer/corehost/cli/common.cmake b/src/installer/corehost/cli/common.cmake
index 63e7306..639c90e 100644
--- a/src/installer/corehost/cli/common.cmake
+++ b/src/installer/corehost/cli/common.cmake
@@ -5,9 +5,6 @@
project(${DOTNET_PROJECT_NAME})
if(WIN32)
- add_compile_options($<$<CONFIG:RelWithDebInfo>:/MT>)
- add_compile_options($<$<CONFIG:Release>:/MT>)
- add_compile_options($<$<CONFIG:Debug>:/MTd>)
else()
add_compile_options(-fvisibility=hidden)
endif()
diff --git a/src/installer/corehost/cli/nethost/CMakeLists.txt b/src/installer/corehost/cli/nethost/CMakeLists.txt
index 7473958..49c664f 100644
--- a/src/installer/corehost/cli/nethost/CMakeLists.txt
+++ b/src/installer/corehost/cli/nethost/CMakeLists.txt
@@ -2,12 +2,14 @@
diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt
index a9f44e720..0f24d4458 100644
--- a/src/native/corehost/nethost/CMakeLists.txt
+++ b/src/native/corehost/nethost/CMakeLists.txt
@@ -1,11 +1,14 @@
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.
# See the LICENSE file in the project root for more information.
-cmake_minimum_required (VERSION 2.6)
+cmake_minimum_required (VERSION 3.14)
+cmake_minimum_required (VERSION 3.14.5)
project(nethost)
set(DOTNET_PROJECT_NAME "nethost")
# Include directories
+include(../../../settings.cmake)
+include(../../../functions.cmake)
+include(../../../../eng/native/configurepaths.cmake)
+include("${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake")
include_directories(../fxr)
# CMake does not recommend using globbing since it messes with the freshness checks
@@ -22,13 +24,18 @@ if(WIN32)
@@ -19,12 +22,23 @@ if(CLR_CMAKE_TARGET_WIN32)
Exports.def)
endif()
+if(BUILD_SHARED_LIBS)
include(../lib.cmake)
+set(targets nethost)
+else()
+include(../hostmisc/hostmisc.cmake)
include(../lib_static.cmake)
+add_library(nethost INTERFACE)
+target_link_libraries(nethost INTERFACE libnethost)
+set(targets libnethost nethost)
+target_include_directories(libnethost INTERFACE $<INSTALL_INTERFACE:include>)
+endif()
+target_include_directories(nethost INTERFACE $<INSTALL_INTERFACE:include>)
add_definitions(-DFEATURE_LIBHOST=1)
add_definitions(-DNETHOST_EXPORT)
-install(FILES nethost.h DESTINATION corehost)
-install(TARGETS nethost DESTINATION corehost)
-install(TARGETS libnethost DESTINATION corehost)
-install_symbols(nethost corehost)
\ No newline at end of file
+install(FILES nethost.h ../coreclr_delegates.h ../hostfxr.h DESTINATION include)
+if(BUILD_SHARED_LIBS)
+install(TARGETS nethost)
+else()
+install(TARGETS libnethost)
+if(NOT BUILD_SHARED_LIBS)
# Copy static lib PDB to the project output directory
if (WIN32)
set_target_properties(libnethost PROPERTIES
@@ -32,15 +46,18 @@ if (WIN32)
COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}"
)
endif(WIN32)
+endif()
-install(FILES ../coreclr_delegates.h DESTINATION corehost)
-install(FILES ../hostfxr.h DESTINATION corehost)
-install(FILES nethost.h DESTINATION corehost)
-install_with_stripped_symbols(nethost TARGETS corehost)
+set(NETHOST_HEADERS nethost.h ../coreclr_delegates.h ../hostfxr.h)
+install(FILES ${NETHOST_HEADERS} DESTINATION include)
+install(TARGETS ${targets} EXPORT unofficial-nethost-config
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+ RUNTIME DESTINATION bin
+)
-# Only Windows creates a symbols file for static libs.
-if (WIN32)
- install_with_stripped_symbols(libnethost TARGETS corehost)
-else()
- install(TARGETS libnethost DESTINATION corehost)
-endif(WIN32)
\ No newline at end of file
+install(EXPORT unofficial-nethost-config
+ DESTINATION share/unofficial-nethost
+ FILE unofficial-nethost-config.cmake
+ NAMESPACE unofficial::nethost::
+)

View File

@ -1,13 +0,0 @@
diff --git a/src/installer/settings.cmake b/src/installer/settings.cmake
index 29d57b44..6ea63902 100644
--- a/src/installer/settings.cmake
+++ b/src/installer/settings.cmake
@@ -114,7 +114,7 @@ endfunction()
function(install_symbols targetName destination_path)
if(WIN32)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION ${destination_path})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${targetName}.pdb DESTINATION ${destination_path})
else()
strip_symbols(${targetName} strip_destination_file)
install(FILES ${strip_destination_file} DESTINATION ${destination_path})

View File

@ -1,17 +1,16 @@
set(COMMIT_HASH 188427d7e18102c45fc6d0e20c135e226f215992)
set(COMMIT_HASH v6.0.5)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO dotnet/runtime
REF ${COMMIT_HASH}
SHA512 5a93c66c87e2113f733702d938efd39456c99fb74b383097b8d877df21536fcbcba901606aa70db6c8f1a16421ea8f06822c5b0ab1d882631b6daecbed8d03cc
SHA512 ccf4865bd9ea63c525fc11b0008774052d51f9247427fc28a91e3836e8e8d157569565bdac17326fe44a446d98a3e4b74a55779d01bede596f2458f4ec86f3aa
HEAD_REF master
PATCHES
0001-nethost-cmakelists.patch
0002-settings-cmake.patch
)
set(PRODUCT_VERSION "5.0.0")
set(PRODUCT_VERSION "6.0.5")
if(VCPKG_TARGET_IS_WINDOWS)
set(RID_PLAT "win")
@ -41,9 +40,10 @@ endif()
set(BASE_RID "${RID_PLAT}-${RID_ARCH}")
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}/src/installer/corehost/cli/nethost
PREFER_NINJA
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/src/native/corehost/nethost/"
# vcpkg's /utf-8 is incompatible with dotnet's own /source-charset:utf-8
NO_CHARSET_FLAG
OPTIONS
"-DSKIP_VERSIONING=1"
"-DCLI_CMAKE_HOST_POLICY_VER:STRING=${PRODUCT_VERSION}"
@ -52,15 +52,26 @@ vcpkg_configure_cmake(
"-DCLI_CMAKE_COMMON_HOST_VER:STRING=${PRODUCT_VERSION}"
"-DCLI_CMAKE_PKG_RID:STRING=${BASE_RID}"
"-DCLI_CMAKE_COMMIT_HASH:STRING=${COMMIT_HASH}"
"-DCLI_CMAKE_PLATFORM_ARCH_${ARCH_NAME}=1"
"-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=10.0"
"-DCLR_CMAKE_TARGET_ARCH_${ARCH_NAME}=1"
"-DCLR_CMAKE_TARGET_ARCH=${RID_ARCH}"
"-DCLR_CMAKE_HOST_ARCH=${RID_ARCH}"
MAYBE_UNUSED_VARIABLES
SKIP_VERSIONING # only used on WIN32
)
vcpkg_install_cmake()
vcpkg_cmake_install()
vcpkg_copy_pdbs()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-nethost)
file(INSTALL ${SOURCE_PATH}/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/nethost.h" "#ifdef NETHOST_USE_AS_STATIC" "#if 1")
else()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/nethost.h" "#ifdef NETHOST_USE_AS_STATIC" "#if 0")
endif()
file(INSTALL "${SOURCE_PATH}/LICENSE.TXT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

View File

@ -1,6 +1,4 @@
The package nethost can be used via CMake:
find_path(NETHOST_INCLUDE_DIRS nethost.h)
find_library(NETHOST_LIBRARY NAMES libnethost nethost)
target_include_directories(main PRIVATE ${NETHOST_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${NETHOST_LIBRARY})
find_package(unofficial-nethost CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::nethost::nethost)

View File

@ -1,8 +1,17 @@
{
"name": "nethost",
"version-date": "2019-12-21",
"port-version": 2,
"version": "6.0.5",
"description": "Provides a set of APIs that can be used to host .NET Core (dotnet)",
"homepage": "https://github.com/dotnet/runtime/tree/master/src/installer/corehost/cli/nethost",
"supports": "!uwp"
"supports": "!uwp",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

View File

@ -4837,8 +4837,8 @@
"port-version": 3
},
"nethost": {
"baseline": "2019-12-21",
"port-version": 2
"baseline": "6.0.5",
"port-version": 0
},
"nettle": {
"baseline": "3.7.3",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "267a7f140709e65c5d692a7f3add885021764c25",
"version": "6.0.5",
"port-version": 0
},
{
"git-tree": "5b1a7d98ce2c1520bbb370dfc2fcb8c3d704c300",
"version-date": "2019-12-21",