-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[libusb] Add disable-udev feature #35328
Conversation
@microsoft-github-policy-service agree |
ports/libusb/vcpkg.json
Outdated
"features": { | ||
"disable-udev":{ | ||
"description": "Disable udev" | ||
} |
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.
Shouldn't this be defined as platform specific feature, as udev is only available on Unix?
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.
disable-udev
is not acceptable: "Features must be treated as additive functionality."
There can be an udev
feature, it can define what it supports
, and it can be in default-features
subject to platform
expressions.
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.
Great comments! I'll have these fixed and manually tested in the upcoming days. It's my first time contributing :)
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.
Changed disable-udev
to udev
feature and set this as a default feature for linux platform (and it supports only linux platform). I'm using this on linux, but was wondering if the platform expression should still be something like !windows
to support other non windows platforms, any opinions?
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.
I'm using this on linux, but was wondering if the platform expression should still be something like
!windows
to support other non windows platforms, any opinions?
It was limited to linux before, so you don't add a new limitation.
And actually it is easier now to test new platforms: You can ignore supports
at the command line, with --allow-unsupported
.
ports/libusb/portfile.cmake
Outdated
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | ||
FEATURES | ||
"disable-udev" DISABLE_UDEV | ||
) | ||
|
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.
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | |
FEATURES | |
"disable-udev" DISABLE_UDEV | |
) |
vcpkg_check_features
is for cmake options (via OUT_FEATURE_OPTIONS
).
There is a side effect on DISABLE_UDEV
etc. but IMO it shouldn't be used just for that.
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.
Fixed in latest commits
ports/libusb/portfile.cmake
Outdated
@@ -41,9 +46,15 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) | |||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libusb-1.0.pc" " -lusb-1.0" " -llibusb-1.0") | |||
endif() | |||
else() | |||
if(${DISABLE_UDEV}) |
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.
The usual pattern is:
if(${DISABLE_UDEV}) | |
if("feature-name" IN_LIST FEATURES) |
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.
Fixed in latest commits
@@ -8,7 +8,7 @@ select_library_configurations(LIBUSB) | |||
|
|||
set(LIBUSB_INCLUDE_DIRS "${LIBUSB_INCLUDE_DIR}") | |||
|
|||
if (@VCPKG_TARGET_IS_LINUX@) | |||
if (@VCPKG_TARGET_IS_LINUX@ AND NOT ${DISABLE_UDEV}) |
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.
Note that we use ${var}
for late-binding evaluation, and @var@
for early substitutions (configure_file(...@ONLY)
).
But maybe we restructure this section: Construct LIBUSB_LINK_LIBRARIES
in the portfile (subject to features), and replace the whole if
block with
list(APPEND LIBUSB_LIBRARIES @LIBUSB_LINK_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.
Section restructured and LIBUSB_LINK_LIBRARIES constructed in portfile in latest commits.
Please run:
to add the new version. |
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.
LGTM, but someone else must approve.
One more suggestion: append to MAKE_OPTIONS
, and formally initialize the lists.
ports/libusb/portfile.cmake
Outdated
if("udev" IN_LIST FEATURES) | ||
set(MAKE_OPTIONS "--enable-udev") | ||
list(APPEND LIBUSB_LINK_LIBRARIES udev) | ||
else() | ||
set(MAKE_OPTIONS "--disable-udev") | ||
endif() |
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.
if("udev" IN_LIST FEATURES) | |
set(MAKE_OPTIONS "--enable-udev") | |
list(APPEND LIBUSB_LINK_LIBRARIES udev) | |
else() | |
set(MAKE_OPTIONS "--disable-udev") | |
endif() | |
vcpkg_list(SET MAKE_OPTIONS) | |
vcpkg_list(SET LIBUSB_LINK_LIBRARIES) | |
if("udev" IN_LIST FEATURES) | |
vcpkg_list(APPEND MAKE_OPTIONS "--enable-udev") | |
vcpkg_list(APPEND LIBUSB_LINK_LIBRARIES udev) | |
else() | |
vcpkg_list(APPEND MAKE_OPTIONS "--disable-udev") | |
endif() |
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.
Implemented in latest commit
Noticed that this might help with the problem described here: #34343 |
./vcpkg x-add-version --all
and committing the result.Adds new feature for libusb port to allow building with --disable-udev flag. Default behavior still remains enabling udev (explicit --enable-udev flag is added in this case for clarity)