aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/nethost
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/nethost')
-rw-r--r--vcpkg/ports/nethost/0001-nethost-cmakelists.patch82
-rw-r--r--vcpkg/ports/nethost/portfile.cmake81
-rw-r--r--vcpkg/ports/nethost/usage4
-rw-r--r--vcpkg/ports/nethost/vcpkg.json18
4 files changed, 185 insertions, 0 deletions
diff --git a/vcpkg/ports/nethost/0001-nethost-cmakelists.patch b/vcpkg/ports/nethost/0001-nethost-cmakelists.patch
new file mode 100644
index 0000000..0d2947c
--- /dev/null
+++ b/vcpkg/ports/nethost/0001-nethost-cmakelists.patch
@@ -0,0 +1,82 @@
+diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt
+index 5ae3f76e8fe..9c0209ba9bc 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.
+
++cmake_minimum_required (VERSION 3.14.5)
+ project(nethost)
+
+ set(DOTNET_PROJECT_NAME "nethost")
+
+ # Include directories
++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
+@@ -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)
+
++if(NOT BUILD_SHARED_LIBS)
+ # Copy static lib PDB to the project output directory
+ if (WIN32)
+ set_target_properties(libnethost PROPERTIES
+@@ -32,12 +46,17 @@ 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
++)
+
++if(NOT BUILD_SHARED_LIBS)
+ if (MSVC)
+ # We ship libnethost.lib as a static library for external consumption, so
+ # LTCG must be disabled to ensure that non-MSVC toolchains can work with it.
+@@ -47,10 +66,10 @@ if (MSVC)
+ string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE})
+ string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO})
+ endif()
++endif()
+
+-# 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)
++install(EXPORT unofficial-nethost-config
++ DESTINATION share/unofficial-nethost
++ FILE unofficial-nethost-config.cmake
++ NAMESPACE unofficial::nethost::
++)
diff --git a/vcpkg/ports/nethost/portfile.cmake b/vcpkg/ports/nethost/portfile.cmake
new file mode 100644
index 0000000..a54bde1
--- /dev/null
+++ b/vcpkg/ports/nethost/portfile.cmake
@@ -0,0 +1,81 @@
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO dotnet/runtime
+ REF "v${VERSION}"
+ SHA512 b37918299f0e8723c41052b86479f91df76c54bcade97305aeef8034b8ebab7768dcac4517bdf6e6173102baf60764f23ce89ae681f1514049ee421a563f713e
+ HEAD_REF master
+ PATCHES
+ 0001-nethost-cmakelists.patch
+)
+
+file(MAKE_DIRECTORY "${SOURCE_PATH}/artifacts/obj")
+set(copy_version_files sh -c "${SOURCE_PATH}/eng/native/version/copy_version_files.sh")
+if(VCPKG_HOST_IS_WINDOWS)
+ set(copy_version_files cmd /C "eng\\native\\version\\copy_version_files.cmd")
+endif()
+vcpkg_execute_required_process(
+ COMMAND ${copy_version_files}
+ WORKING_DIRECTORY "${SOURCE_PATH}"
+ LOGNAME "copy_version_files-${TARGET_TRIPLET}"
+)
+
+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_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_PKG_RID:STRING=${BASE_RID}"
+ "-DCLI_CMAKE_FALLBACK_OS:STRING=${RID_PLAT}"
+ "-DCLI_CMAKE_COMMIT_HASH:STRING=v${VERSION}"
+ "-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_cmake_install()
+
+vcpkg_copy_pdbs()
+
+vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-nethost)
+
+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()
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.TXT")
+file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
diff --git a/vcpkg/ports/nethost/usage b/vcpkg/ports/nethost/usage
new file mode 100644
index 0000000..26a41d9
--- /dev/null
+++ b/vcpkg/ports/nethost/usage
@@ -0,0 +1,4 @@
+The package nethost can be used via CMake:
+
+ find_package(unofficial-nethost CONFIG REQUIRED)
+ target_link_libraries(main PRIVATE unofficial::nethost::nethost)
diff --git a/vcpkg/ports/nethost/vcpkg.json b/vcpkg/ports/nethost/vcpkg.json
new file mode 100644
index 0000000..b865bcd
--- /dev/null
+++ b/vcpkg/ports/nethost/vcpkg.json
@@ -0,0 +1,18 @@
+{
+ "name": "nethost",
+ "version": "8.0.3",
+ "description": "Provides a set of APIs that can be used to host .NET Core (dotnet)",
+ "homepage": "https://github.com/dotnet/runtime/tree/main/src/native/corehost/nethost",
+ "license": "MIT",
+ "supports": "(windows & !uwp), (linux, osx)",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ]
+}