From fb2006edf9b2b7338263abc629d59441b5da32d1 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 6 Jan 2020 13:14:20 -0800 Subject: [PATCH] [nethost] Adding a port for nethost (#8701) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adding a port for nethost * Fixing ref, removing unneeded include, and marking unsupported architectures for nethost * Fixing the expected sha512 for nethost * Setting nethost to fail on static and uwp * Removing an unecessary file(REMOVE_RECURSE) from nethost * update baseline * [nethost] Update to latest from dotnet/runtime * [vcpkg-baseline] Update baseline for nethost * [vcpkg-baseline] Update baseline for nethost Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> Co-authored-by: Robert Schumacher --- ports/nethost/0001-nethost-cmakelists.patch | 58 ++++++++++++++++++ ports/nethost/0002-settings-cmake.patch | 13 ++++ ports/nethost/CONTROL | 4 ++ ports/nethost/portfile.cmake | 68 +++++++++++++++++++++ ports/nethost/usage | 6 ++ scripts/ci.baseline.txt | 2 + 6 files changed, 151 insertions(+) create mode 100644 ports/nethost/0001-nethost-cmakelists.patch create mode 100644 ports/nethost/0002-settings-cmake.patch create mode 100644 ports/nethost/CONTROL create mode 100644 ports/nethost/portfile.cmake create mode 100644 ports/nethost/usage diff --git a/ports/nethost/0001-nethost-cmakelists.patch b/ports/nethost/0001-nethost-cmakelists.patch new file mode 100644 index 00000000000..93d49b95e16 --- /dev/null +++ b/ports/nethost/0001-nethost-cmakelists.patch @@ -0,0 +1,58 @@ +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($<$:/MT>) +- add_compile_options($<$:/MT>) +- add_compile_options($<$:/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 @@ + # 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) + project(nethost) + + set(DOTNET_PROJECT_NAME "nethost") + + # Include directories ++include(../../../settings.cmake) ++include(../../../functions.cmake) + include_directories(../fxr) + + # CMake does not recommend using globbing since it messes with the freshness checks +@@ -22,13 +24,18 @@ if(WIN32) + Exports.def) + endif() + ++if(BUILD_SHARED_LIBS) + include(../lib.cmake) ++else() + include(../lib_static.cmake) ++endif() + + 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) ++endif() diff --git a/ports/nethost/0002-settings-cmake.patch b/ports/nethost/0002-settings-cmake.patch new file mode 100644 index 00000000000..7143b942a9b --- /dev/null +++ b/ports/nethost/0002-settings-cmake.patch @@ -0,0 +1,13 @@ +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}/$/${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}) diff --git a/ports/nethost/CONTROL b/ports/nethost/CONTROL new file mode 100644 index 00000000000..f1e97e1d0c8 --- /dev/null +++ b/ports/nethost/CONTROL @@ -0,0 +1,4 @@ +Source: nethost +Version: 2019-12-21 +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 diff --git a/ports/nethost/portfile.cmake b/ports/nethost/portfile.cmake new file mode 100644 index 00000000000..3809d9872b3 --- /dev/null +++ b/ports/nethost/portfile.cmake @@ -0,0 +1,68 @@ +vcpkg_fail_port_install(ON_TARGET "uwp") + +set(COMMIT_HASH 188427d7e18102c45fc6d0e20c135e226f215992) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO dotnet/runtime + REF ${COMMIT_HASH} + SHA512 5a93c66c87e2113f733702d938efd39456c99fb74b383097b8d877df21536fcbcba901606aa70db6c8f1a16421ea8f06822c5b0ab1d882631b6daecbed8d03cc + HEAD_REF master + PATCHES + 0001-nethost-cmakelists.patch + 0002-settings-cmake.patch +) + +set(PRODUCT_VERSION "5.0.0") + +if(VCPKG_TARGET_IS_WINDOWS) + set(RID_PLAT "win") +elseif(VCPKG_TARGET_IS_OSX) + set(RID_PLAT "osx") +elseif(VCPKG_TARGET_IS_LINUX) + set(RID_PLAT "linux") +else() + message(FATAL_ERROR "Unsupported platform") +endif() + +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(RID_ARCH "x86") + set(ARCH_NAME "I386") +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(RID_ARCH "x64") + set(ARCH_NAME "AMD64") +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") + set(RID_ARCH "arm") + set(ARCH_NAME "ARM") +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + set(RID_ARCH "arm64") + set(ARCH_NAME "ARM64") +else() + message(FATAL_ERROR "Unsupported architecture") +endif() + +set(BASE_RID "${RID_PLAT}-${RID_ARCH}") + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/src/installer/corehost/cli/nethost + PREFER_NINJA + OPTIONS + "-DSKIP_VERSIONING=1" + "-DCLI_CMAKE_HOST_POLICY_VER:STRING=${PRODUCT_VERSION}" + "-DCLI_CMAKE_HOST_FXR_VER:STRING=${PRODUCT_VERSION}" + "-DCLI_CMAKE_HOST_VER:STRING=${PRODUCT_VERSION}" + "-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" +) + +vcpkg_install_cmake() + +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +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}) diff --git a/ports/nethost/usage b/ports/nethost/usage new file mode 100644 index 00000000000..6e6d860d1fb --- /dev/null +++ b/ports/nethost/usage @@ -0,0 +1,6 @@ +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}) diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 9aa7f493ac2..f2771183973 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -1097,6 +1097,8 @@ nanovg:x86-windows=ignore nativefiledialog:arm-uwp=fail nativefiledialog:x64-uwp=fail netcdf-cxx4:x64-linux=ignore +nethost:x64-uwp=fail +nethost:arm-uwp=fail networkdirect-sdk:arm64-windows=fail networkdirect-sdk:arm-uwp=fail networkdirect-sdk:x64-linux=fail