-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[nethost] Update nethost #25004
[nethost] Update nethost #25004
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have modified or added at least one portfile where deprecated functions are used.
If you feel able to do so, please consider migrating them to the new functions:
vcpkg_install_cmake
-> vcpkg_cmake_install
(from port vcpkg-cmake
)
vcpkg_build_cmake
-> vcpkg_cmake_build
(from port vcpkg-cmake
)
vcpkg_configure_cmake
-> vcpkg_cmake_configure
(Please remove the option PREFER_NINJA
) (from port vcpkg-cmake
)
vcpkg_fixup_cmake_targets
-> vcpkg_cmake_config_fixup
(from port vcpkg-cmake-config
)
In the ports that use the new function, you have to add the corresponding dependencies:
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
The following files are affected:
ports/nethost/portfile.cmake
You have modified or added at least one vcpkg.json where you should check the license
field.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nethost/vcpkg.json
Valid values for the license field can be found in the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that these functions are about to be deprecated, please use the new method.
#25004 (review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have modified or added at least one vcpkg.json where you should check the license
field.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nethost/vcpkg.json
Valid values for the license field can be found in the documentation
I have updated the deprecated functions, for example replacing |
@lanyizi New functions need dependencies, add dependencies in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have modified or added at least one vcpkg.json where you should check the license
field.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nethost/vcpkg.json
Valid values for the license field can be found in the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have modified or added at least one vcpkg.json where you should check the license
field.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nethost/vcpkg.json
Valid values for the license field can be found in the documentation
ports/nethost/usage
Outdated
find_package(unofficial-nethost CONFIG REQUIRED) | ||
target_link_libraries(main PRIVATE unofficial::nethost::nethost) # DLL | ||
target_link_libraries(main PRIVATE unofficial::nethost::libnethost) # Static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find_package(unofficial-nethost CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::nethost::nethost) # DLL
target_link_libraries(main PRIVATE unofficial::nethost::libnethost) # Static
Is it necessary to separate the linking of dynamic and static libraries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this usage is not available.
CMake Error at /Users/vcpkg/Frank/vcpkg/scripts/buildsystems/vcpkg.cmake:573 (_add_executable):
Target "test" links to target "unofficial::nethost::nethost" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
Call Stack (most recent call first):
CMakeLists.txt:5 (add_executable)
Example CMakeLists.txt:
1 cmake_minimum_required(VERSION 3.8)
2
3 project(test)
4
5 add_executable(test "test.cpp")
6
7 find_package(unofficial-nethost CONFIG REQUIRED)
8 target_link_libraries(test PRIVATE unofficial::nethost::nethost) # DLL
9 target_link_libraries(test PRIVATE unofficial::nethost::libnethost) # Static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unofficial::nethost::nethost
was meant to be used for non-static triplet
So if the current triplet is something like x86-windows-static
, then only unofficial::nethost::libnethost
is available.
This is also because upstream decided to name the two targets differently, they build the same source twice (both as static and shared library) at the same time:
https://github.com/dotnet/runtime/blob/70ae3df4a6f3c92fb6b315afc405edd10ff38579/src/native/corehost/nethost/CMakeLists.txt#L22
https://github.com/dotnet/runtime/blob/70ae3df4a6f3c92fb6b315afc405edd10ff38579/src/native/corehost/nethost/CMakeLists.txt#L23
If this appears too weird I can edit the patch file so both target have same name. Should I do that?
I found that for upstream they don't want nethost to export both dynamic and static libraries. https://github.com/dotnet/runtime/blob/55e2378d86841ec766ee21d5e504d7724c39b53b/src/native/corehost/nethost/nethost.h#L13. |
Don't invent a new option. Just leverage |
I feel |
Yes, this CMake anti-pattern is known from other ports. But vcpkg wants only one variant per triplet.
|
I feel this is easier to do for me ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have modified or added at least one vcpkg.json where you should check the license
field.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nethost/vcpkg.json
Valid values for the license field can be found in the documentation
Never mind the requests, did you test the usage locally? |
Yes, I tested it with both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I have reworked the patch to do a few additional things:
- Always install the name "unofficial::nethost::nethost", to avoid users needing to write an awful generator expression. If a static build is requested, it's just a link to the
libnethost
target - Embed the library linkage choice into the header
- I searched the source and found no uses of
CLI_CMAKE_PLATFORM_ARCH
, but I did seeCLR_CMAKE_TARGET_ARCH
, so I renamed that value.
Please run the following to merge those commits into this PR:
git fetch https://github.com/ras0219-msft/vcpkg dev/roschuma/nethost
git merge FETCH_HEAD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have modified or added at least one vcpkg.json where you should check the license
field.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nethost/vcpkg.json
Valid values for the license field can be found in the documentation
Thanks for the rework! I have merged the new commit into PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have modified or added at least one vcpkg.json where you should check the license
field.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nethost/vcpkg.json
Valid values for the license field can be found in the documentation
@ras0219-msft Hi! I noticed there was some build errors, for example now the static build didn't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have modified or added at least one vcpkg.json where you should check the license
field.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nethost/vcpkg.json
Valid values for the license field can be found in the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have modified or added at least one vcpkg.json where you should check the license
field.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nethost/vcpkg.json
Valid values for the license field can be found in the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
vcpkg 那边的依赖可能要等下面这个 PR 通过之后才能使用: microsoft/vcpkg#25004 或者可以暂时把 vcpkg 的 git 分支切换到我的 fork,然后就能直接安装依赖了(
Describe the pull request
What does your PR fix?
Addressed the issue with static library. The previous version was pushed long ago, back then
__declspec(dllimport)
was unconditionally enabled on thenethost.h
when compiling Windows platform, which hampers its use as static library: https://github.com/dotnet/runtime/blob/188427d7e18102c45fc6d0e20c135e226f215992/src/installer/corehost/cli/nethost/nethost.h#L12This PR updates the version of referenced .NET code base to .NET 6, which has a better support for static library: https://github.com/dotnet/runtime/blob/70ae3df4a6f3c92fb6b315afc405edd10ff38579/src/native/corehost/nethost/nethost.h#L15
This PR also adds imported targets, allowing users to
find_package()
and thentarget_link_library
directly, without having to manually set up include directories or compiler definitionsWhich triplets are supported/not supported? Have you updated the CI baseline?
Triplet and CI baseline should be same as before, although personally I couldn't test all platforms.
Does your PR follow the maintainer guide?
I guess yes
If you have added/updated a port: Have you run
./vcpkg x-add-version --all
and committed the result?Yes
If you are still working on the PR, open it as a Draft: https://github.blog/2019-02-14-introducing-draft-pull-requests/